|
|
@@ -1935,7 +1935,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (sku.getNum() > 1 && Constant.AI_goodsIds.contains(sku.getGoodsId())) {
|
|
|
DateTime tenExpiry = DateUtil.offsetDay(DateUtil.beginOfDay(DateTime.now()), 10);
|
|
|
//不塞存在该用户的车队
|
|
|
- Long groupsId = groupsRelationMapper.getOutSideGroupsTripsRelationByGoodsId(sku.getId(), tenExpiry, 5, userId);
|
|
|
+ Long groupsId = groupsRelationMapper.getOutSideGroupsTripsRelationByGoodsId(sku.getId(), tenExpiry, 5, userId, sku.getNum());
|
|
|
if (groupsId != null) {
|
|
|
relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
.eq(GroupsRelation::getGroupsId, groupsId)
|
|
|
@@ -1943,15 +1943,17 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.eq(GroupsRelation::getStatus, GroupsRelation.Status.outside)
|
|
|
.last("limit 1"));
|
|
|
if (relation == null) {
|
|
|
- if (redisService.setNx(RedisService.key.GROUPS_TRIPS_OUTSIDE_RELATION.getName() + groupsId, groupsId, RedisService.key.GROUPS_TRIPS_OUTSIDE_RELATION.getTimeout())) {
|
|
|
- relation = new GroupsRelation();
|
|
|
- relation.setStatus(GroupsRelation.Status.outside);
|
|
|
- relation.setUserId(userId);
|
|
|
- relation.setGroupsId(groupsId);
|
|
|
- GroupsRelation maxNumRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).orderByDesc(GroupsRelation::getNum).last("limit 1"));
|
|
|
- relation.setNum(maxNumRelation.getNum() + 1);
|
|
|
+ relation = new GroupsRelation();
|
|
|
+ relation.setStatus(GroupsRelation.Status.outside);
|
|
|
+ relation.setUserId(userId);
|
|
|
+ relation.setGroupsId(groupsId);
|
|
|
+ GroupsRelation maxNumRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).orderByDesc(GroupsRelation::getNum).last("limit 1"));
|
|
|
+ Integer nextNum = maxNumRelation.getNum() + 1;
|
|
|
+ if (redisService.setNx(RedisService.key.GROUPS_TRIPS_OUTSIDE_RELATION.getNameFormat(groupsId, nextNum), nextNum, RedisService.key.GROUPS_TRIPS_OUTSIDE_RELATION.getTimeout())) {
|
|
|
+ relation.setNum(nextNum);
|
|
|
groupsRelationMapper.insert(relation);
|
|
|
- redisService.del(RedisService.key.GROUPS_TRIPS_OUTSIDE_RELATION.getName() + groupsId);
|
|
|
+ } else {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统繁忙,请重试...");
|
|
|
}
|
|
|
}
|
|
|
groups = groupsMapper.selectById(groupsId);
|