|
|
@@ -268,7 +268,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds) {
|
|
|
+ public GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds, String ip) {
|
|
|
Long skuId = sku.getId();
|
|
|
Integer days = sku.getDays();
|
|
|
Integer months = sku.getMonths();
|
|
|
@@ -285,7 +285,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
maxNum += extraNum;
|
|
|
DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
|
|
|
- Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime, maxNum);
|
|
|
+ Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime, maxNum, ip);
|
|
|
if (groupsId == null) {
|
|
|
log.info("暂无相似过期时间车队");
|
|
|
return null;
|
|
|
@@ -346,7 +346,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku) {
|
|
|
+ public GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku, String ip) {
|
|
|
GroupsRelation relation = null;
|
|
|
Integer maxNum = sku.getNum();
|
|
|
if (payRelationId != null && payRelationId > 0) {
|
|
|
@@ -397,23 +397,14 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
if (groups == null) {
|
|
|
//寻找差不多过期时间规格的车位
|
|
|
- relation = getSimilarExpiredGroupRelation(sku,null);
|
|
|
+ relation = getSimilarExpiredGroupRelation(sku, null, ip);
|
|
|
if (relation == null) {
|
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
|
- groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
- .eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
- .gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
- .apply(String.format("(available_parking_num = 0 or available_parking_num > (select count(*) from groups_relation gr where gr.groups_id = groups_trips.id and gr.user_id != 0 and gr.num <= %s))", maxNum))
|
|
|
- .eq(GroupsTrips::getStatus, GroupsTrips.Status.validity)
|
|
|
- .orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
+ groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.validity, maxNum, ip);
|
|
|
+
|
|
|
if (groups == null) {
|
|
|
//待发车
|
|
|
- groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
- .eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
- .gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
- .eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting)
|
|
|
- .apply(String.format("(available_parking_num = 0 or available_parking_num > (select count(*) from groups_relation gr where gr.groups_id = groups_trips.id and gr.user_id != 0 and gr.num <= %s))", maxNum))
|
|
|
- .orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
+ groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.waiting, maxNum, ip);
|
|
|
}
|
|
|
//新增空车队
|
|
|
if (groups == null) {
|