|
|
@@ -162,28 +162,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
|
GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, payRequest.getSkuId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
if (groups == null) {
|
|
|
- //新增车次
|
|
|
- groups = new GroupsTrips();
|
|
|
- groups.setSkuId(sku.getId());
|
|
|
- groups.setNum(sku.getNum());
|
|
|
- groups.setAvailableNum(sku.getNum());
|
|
|
- groups.setStatus(GroupsTrips.Status.waiting);
|
|
|
- groups.setRemark("等待设置账号");
|
|
|
- groupsMapper.insert(groups);
|
|
|
- relation = new GroupsRelation();
|
|
|
- relation.setGroupsId(groups.getId());
|
|
|
- relation.setNum(1);
|
|
|
- relation.setStatus(GroupsRelation.Status.locking);
|
|
|
- relation.setGroupsId(groups.getId());
|
|
|
- groupsRelationMapper.insert(relation);
|
|
|
-
|
|
|
- for (int i = 2; i <= groups.getNum(); i++) {
|
|
|
- GroupsRelation groupsRelation = new GroupsRelation();
|
|
|
- groupsRelation.setGroupsId(groups.getId());
|
|
|
- groupsRelation.setNum(i);
|
|
|
- groupsRelation.setStatus(GroupsRelation.Status.none);
|
|
|
- groupsRelationMapper.insert(groupsRelation);
|
|
|
- }
|
|
|
+ relation = createNewGroupsTrips(sku, true);
|
|
|
isNew = true;
|
|
|
} else {
|
|
|
//寻找快满编车队进行占座
|
|
|
@@ -368,6 +347,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
|
}
|
|
|
this.updateById(order);
|
|
|
+ //无车队,新增车队
|
|
|
+ checkNoGroupsTripsAndSendMsg(sku, order);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -607,6 +588,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(orderDon));
|
|
|
}
|
|
|
this.updateById(orderDon);
|
|
|
+ //无车队,新增车队
|
|
|
+ checkNoGroupsTripsAndSendMsg(sku, orderDon);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1065,4 +1048,55 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验是否还有多余的车位
|
|
|
+ */
|
|
|
+ private void checkNoGroupsTripsAndSendMsg(GoodsDonSku sku, OrderDon order) {
|
|
|
+ GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, sku.getId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
+ if (groups == null) {
|
|
|
+ createNewGroupsTrips(sku, false);
|
|
|
+ //新增空车队发送模板消息
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ try {
|
|
|
+ List<CustomerService> customerServices = customerServiceMapper.selectList(null);
|
|
|
+ for (CustomerService customerService : customerServices) {
|
|
|
+ log.info("发送客服{}空车位通知消息", customerService.getNickName());
|
|
|
+ emptySendMsgNotify(order, customerService.getOpenId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发送{}空车位模板消息至客服失败:{}", order.getGoodsId(), e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增空车队
|
|
|
+ */
|
|
|
+ private GroupsRelation createNewGroupsTrips(GoodsDonSku sku,Boolean isNeedRelationId) {
|
|
|
+ //新增车次
|
|
|
+ GroupsTrips groups = new GroupsTrips();
|
|
|
+ groups.setSkuId(sku.getId());
|
|
|
+ groups.setNum(sku.getNum());
|
|
|
+ groups.setAvailableNum(sku.getNum());
|
|
|
+ groups.setStatus(GroupsTrips.Status.waiting);
|
|
|
+ groups.setRemark("等待设置账号");
|
|
|
+ groupsMapper.insert(groups);
|
|
|
+ GroupsRelation relation = new GroupsRelation();
|
|
|
+ relation.setGroupsId(groups.getId());
|
|
|
+ relation.setNum(1);
|
|
|
+ relation.setStatus(isNeedRelationId ? GroupsRelation.Status.locking : GroupsRelation.Status.none);
|
|
|
+ relation.setGroupsId(groups.getId());
|
|
|
+ groupsRelationMapper.insert(relation);
|
|
|
+
|
|
|
+ for (int i = 2; i <= groups.getNum(); i++) {
|
|
|
+ GroupsRelation groupsRelation = new GroupsRelation();
|
|
|
+ groupsRelation.setGroupsId(groups.getId());
|
|
|
+ groupsRelation.setNum(i);
|
|
|
+ groupsRelation.setStatus(GroupsRelation.Status.none);
|
|
|
+ groupsRelationMapper.insert(groupsRelation);
|
|
|
+ }
|
|
|
+ return relation;
|
|
|
+ }
|
|
|
}
|