|
|
@@ -231,15 +231,24 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GroupsRelation getSimilarExpiredGroupRelation(Long skuId, Integer days, Integer months, List<Long> errorsRelationIds) {
|
|
|
+ public GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds) {
|
|
|
+ Long skuId = sku.getId();
|
|
|
+ Integer days = sku.getDays();
|
|
|
+ Integer months = sku.getMonths();
|
|
|
+ Integer maxNum = sku.getNum();
|
|
|
DateTime expiryTime = null;
|
|
|
if (days != null && days > 0) {
|
|
|
expiryTime = DateUtil.offsetDay(DateTime.now(), days);
|
|
|
} else {
|
|
|
expiryTime = DateUtil.offsetMonth(DateTime.now(), months);
|
|
|
}
|
|
|
+ Integer extraNum = 5;
|
|
|
+ if (sku.getId() == 178l) {
|
|
|
+ extraNum = 2;
|
|
|
+ }
|
|
|
+ maxNum += extraNum;
|
|
|
DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
|
|
|
- Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime);
|
|
|
+ Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime, maxNum);
|
|
|
if (groupsId == null) {
|
|
|
log.info("暂无相似过期时间车队");
|
|
|
return null;
|
|
|
@@ -315,14 +324,16 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
GroupsTrips groups = null;
|
|
|
//ChatGpt Plus、Midjourney非独立规格 上车先获取硬塞座位 硬塞5个座位
|
|
|
//主账号过期时间25天以外
|
|
|
+ Integer maxNum = sku.getNum();
|
|
|
if (sku.getNum() > 1 && Constant.AI_goodsIds.contains(sku.getGoodsId())) {
|
|
|
Integer extraNum = 5;
|
|
|
if (sku.getId() == 178l) {
|
|
|
extraNum = 2;
|
|
|
}
|
|
|
+ maxNum += extraNum;
|
|
|
DateTime time = DateUtil.offsetDay(DateUtil.beginOfDay(DateTime.now()), 25);
|
|
|
//不塞存在该用户的车队
|
|
|
- Long groupsId = groupsRelationMapper.getOutSideGroupsTripsRelationByGoodsId(sku.getId(), time, extraNum, userId, sku.getNum());
|
|
|
+ Long groupsId = groupsRelationMapper.getOutSideGroupsTripsRelationByGoodsId(sku.getId(), time, extraNum, userId, sku.getNum(), maxNum);
|
|
|
if (groupsId != null) {
|
|
|
relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
.eq(GroupsRelation::getGroupsId, groupsId)
|
|
|
@@ -348,13 +359,13 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
if (groups == null) {
|
|
|
//寻找差不多过期时间规格的车位
|
|
|
- relation = getSimilarExpiredGroupRelation(sku.getId(), sku.getDays(), sku.getMonths(), null);
|
|
|
+ relation = getSimilarExpiredGroupRelation(sku,null);
|
|
|
if (relation == null) {
|
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
|
groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
- .apply("(available_parking_num = 0 or available_parking_num > (select count(*) from groups_relation gr where gr.groups_id = groups_trips.id and user_id != 0))")
|
|
|
+ .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));
|
|
|
if (groups == null) {
|
|
|
@@ -363,7 +374,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting)
|
|
|
- .apply("(available_parking_num = 0 or available_parking_num > (select count(*) from groups_relation gr where gr.groups_id = groups_trips.id and user_id != 0))")
|
|
|
+ .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));
|
|
|
}
|
|
|
//新增空车队
|