|
|
@@ -52,14 +52,17 @@ import com.cyksj.model.views.CouponNewUserView;
|
|
|
import com.cyksj.model.views.CouponUserView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.coupon.CouponFontService;
|
|
|
+import com.cyksj.service.exchange.ExchangeCodeService;
|
|
|
import com.cyksj.service.mange.stock.GoodsDonStockService;
|
|
|
import com.cyksj.service.market.task.TaskService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
+import com.cyksj.service.template.TemplateCommonService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
import com.cyksj.task.JobManager;
|
|
|
import com.cyksj.task.OrderCustomerHandleScheduler;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -159,6 +162,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final CustomerServiceRenewOrderRecordMapper customerServiceRenewOrderRecordMapper;
|
|
|
|
|
|
+ private final ExchangeCodeService exchangeCodeService;
|
|
|
+
|
|
|
+ private final TemplateCommonService templateCommonService;
|
|
|
+
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@Override
|
|
|
public OrderDon submit(OrderPayRequest payRequest) throws Exception {
|
|
|
@@ -168,67 +175,77 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//记录优惠券使用状态
|
|
|
couponUser = couponStatusRecord(payRequest.getCouponExCode(), payRequest.getCouponId(), payRequest.getUserId());
|
|
|
}
|
|
|
- User user = userMapper.selectById(payRequest.getUserId());
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(payRequest.getSkuId());
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
Boolean isNew = false;
|
|
|
if (goodsDon == null || !goodsDon.getStatus()) {
|
|
|
throw new BusinessRuntimeException("商品已下架");
|
|
|
}
|
|
|
- String payOpenId = user.getOpenId();
|
|
|
-
|
|
|
+ Boolean isNoLogin = payRequest.getIsNoLogin();
|
|
|
+ User user;
|
|
|
+ String payOpenId = null;
|
|
|
Long relationId = 0L;
|
|
|
|
|
|
- if (goodsDon.getType() == 1) {
|
|
|
- GroupsRelation relation = null;
|
|
|
- //锁定座位
|
|
|
- if (payRequest.getRelationId() != null && payRequest.getRelationId() > 0) {
|
|
|
- relation = groupsRelationMapper.selectById(payRequest.getRelationId());
|
|
|
- if (relation == null) {
|
|
|
- throw new BusinessRuntimeException(GROUP_INDEX_NOT_FIND.getCode(), GROUP_INDEX_NOT_FIND.getMsg());
|
|
|
- }
|
|
|
- if (relation.getUserId() != null && relation.getUserId() > 0L) {
|
|
|
- throw new BusinessRuntimeException(GROUP_INDEX_ALREADY_BE_USER.getCode(), GROUP_INDEX_ALREADY_BE_USER.getMsg());
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- //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) {
|
|
|
- relation = createNewGroupsTrips(sku, true);
|
|
|
- isNew = true;
|
|
|
- } else {
|
|
|
- //寻找快满编车队进行占座
|
|
|
- relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
- .eq(GroupsRelation::getGroupsId, groups.getId())
|
|
|
- .eq(GroupsRelation::getStatus, "none")
|
|
|
- .eq(GroupsRelation::getUserId, 0)
|
|
|
- .orderByAsc(GroupsRelation::getNum)
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
+ if (isNoLogin != null && isNoLogin) {
|
|
|
+ user = new User();
|
|
|
+ user.setId(0l);
|
|
|
+ } else {
|
|
|
+ user = userMapper.selectById(payRequest.getUserId());
|
|
|
+ payOpenId = user.getOpenId();
|
|
|
+ if (goodsDon.getType() == 1) {
|
|
|
+ GroupsRelation relation = null;
|
|
|
+ //锁定座位
|
|
|
+ if (payRequest.getRelationId() != null && payRequest.getRelationId() > 0) {
|
|
|
+ relation = groupsRelationMapper.selectById(payRequest.getRelationId());
|
|
|
if (relation == null) {
|
|
|
throw new BusinessRuntimeException(GROUP_INDEX_NOT_FIND.getCode(), GROUP_INDEX_NOT_FIND.getMsg());
|
|
|
}
|
|
|
+ if (relation.getUserId() != null && relation.getUserId() > 0L) {
|
|
|
+ throw new BusinessRuntimeException(GROUP_INDEX_ALREADY_BE_USER.getCode(), GROUP_INDEX_ALREADY_BE_USER.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //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) {
|
|
|
+ relation = createNewGroupsTrips(sku, true);
|
|
|
+ isNew = true;
|
|
|
+ } else {
|
|
|
+ //寻找快满编车队进行占座
|
|
|
+ relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getGroupsId, groups.getId())
|
|
|
+ .eq(GroupsRelation::getStatus, "none")
|
|
|
+ .eq(GroupsRelation::getUserId, 0)
|
|
|
+ .orderByAsc(GroupsRelation::getNum)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (relation == null) {
|
|
|
+ throw new BusinessRuntimeException(GROUP_INDEX_NOT_FIND.getCode(), GROUP_INDEX_NOT_FIND.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //锁定座位
|
|
|
- setRelation(relation.getId(), payRequest.getUserId(), goodsDon.getId());
|
|
|
- relation.setUserId(user.getId());
|
|
|
- relation.setStatus(GroupsRelation.Status.locking);
|
|
|
- groupsRelationMapper.updateById(relation);
|
|
|
- relationId = relation.getId();
|
|
|
- }else {
|
|
|
+ //锁定座位
|
|
|
+ setRelation(relation.getId(), user.getId(), goodsDon.getId());
|
|
|
+ relation.setUserId(user.getId());
|
|
|
+ relation.setStatus(GroupsRelation.Status.locking);
|
|
|
+ groupsRelationMapper.updateById(relation);
|
|
|
+ relationId = relation.getId();
|
|
|
+ }else {
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/* 生成订单 */
|
|
|
String donNo = SEQUENCE.nextId().toString();
|
|
|
OrderDon orderDon = new OrderDon();
|
|
|
+ if (isNoLogin != null && isNoLogin) {
|
|
|
+ orderDon.setIsNoLogin(true);
|
|
|
+ }
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
|
if (sku.getPrice() != null && payRequest.getDonMoney().compareTo(sku.getPrice()) < 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("车位所付金额错误");
|
|
|
+ throw BusinessRuntimeException.getInstance("支付金额错误");
|
|
|
}
|
|
|
orderDon.setMoney(payRequest.getDonMoney());
|
|
|
orderDon.setRealMoney(payRequest.getDonMoney());
|
|
|
@@ -261,14 +278,16 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
|
orderDon.setUserId(user.getId());
|
|
|
orderDon.setType(OrderDon.Type.getType(payRequest.getType()));
|
|
|
- //虚拟商品订单,是否是分销订单
|
|
|
- if (goodsDon.getType() == 1) {
|
|
|
- UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, user.getId()).last("limit 1"));
|
|
|
- if (userDistributeShared != null) {
|
|
|
- orderDon.setIsDistribute(true);
|
|
|
- UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, userDistributeShared.getSharedId()));
|
|
|
- if (userDistribute != null) {
|
|
|
- orderDon.setIsFixedDistribute(true);
|
|
|
+ if (isNoLogin == null || !isNoLogin) {
|
|
|
+ //虚拟商品订单,是否是分销订单
|
|
|
+ if (goodsDon.getType() == 1) {
|
|
|
+ UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, user.getId()).last("limit 1"));
|
|
|
+ if (userDistributeShared != null) {
|
|
|
+ orderDon.setIsDistribute(true);
|
|
|
+ UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, userDistributeShared.getSharedId()));
|
|
|
+ if (userDistribute != null) {
|
|
|
+ orderDon.setIsFixedDistribute(true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -320,6 +339,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (shopConfig != null) {
|
|
|
shopId = shopConfig.getAppId();
|
|
|
}
|
|
|
+ orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
orderDon.setShopId(shopId);
|
|
|
this.updateById(orderDon);
|
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
|
@@ -396,9 +416,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (null == order) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在.");
|
|
|
}
|
|
|
+ String appId = map.get("mch_id");
|
|
|
|
|
|
// 校验签名
|
|
|
- boolean f = weChatService.checkSignWithMd5(map, shopConfigMapper.getByAppId(Optional.ofNullable(order.getShopId()).orElse(ShopConfig.WX_DEFAULT_APP_ID)).getSecret());
|
|
|
+ boolean f = weChatService.checkSignWithMd5(map, shopConfigMapper.getByAppId(appId).getSecret());
|
|
|
if (!f) {
|
|
|
log.error("回调数据:{}", map);
|
|
|
throw BusinessRuntimeException.getInstance("支付成功回调, 校验签名失败.");
|
|
|
@@ -419,53 +440,39 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
order.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
|
|
|
order.setPayTime(DateUtil.parse(map.get("time_end"), "yyyyMMddHHmmss"));
|
|
|
+ order.setShopId(appId);
|
|
|
|
|
|
+ if (order.getIsNoLogin()) {
|
|
|
+ order.setExCode(exchangeCodeService.getExCode(order.getGoodsId(), order.getSkuId(), 1));
|
|
|
+ }
|
|
|
if (StringUtils.isBlank(order.getOpenId())) {
|
|
|
order.setOpenId(map.get("openid"));
|
|
|
}
|
|
|
- updateCarParkAndSendMsg(goodsDon, sku, order);
|
|
|
order.setType(OrderDon.Type.WeChat);
|
|
|
- if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
|
|
|
- TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
|
+ if (order.getIsNoLogin()) {
|
|
|
+ order.setStatus(OrderDon.Status.hasPayment);
|
|
|
+ }
|
|
|
+ if (!order.getIsNoLogin()) {
|
|
|
+ updateCarParkAndSendMsg(goodsDon, sku, order);
|
|
|
+ if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
|
|
|
+ TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
|
+ }
|
|
|
+ if (goodsDon.getType() == 1) {
|
|
|
+ //无车队,新增车队
|
|
|
+ checkNoGroupsTripsAndSendMsg(sku, order);
|
|
|
+ }
|
|
|
+ //完成任务
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
+ .eq(TaskType::getName, TaskTypeEnum.yh_order.getDesc()).last("limit 1"));
|
|
|
+ taskService.completeTask(taskType, order.getUserId());
|
|
|
+ });
|
|
|
+ //客服续费订单
|
|
|
+ handleServiceRenewOrder(order);
|
|
|
}
|
|
|
this.updateById(order);
|
|
|
- if (goodsDon.getType() == 1) {
|
|
|
- //无车队,新增车队
|
|
|
- checkNoGroupsTripsAndSendMsg(sku, order);
|
|
|
- }
|
|
|
- //客服续费订单
|
|
|
- handleServiceRenewOrder(order);
|
|
|
- //完成任务
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
- .eq(TaskType::getName, TaskTypeEnum.yh_order.getDesc()).last("limit 1"));
|
|
|
- taskService.completeTask(taskType, order.getUserId());
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void newOderSendMsgByType(OrderDon order, GoodsDon goodsDon, GoodsDonSku sku, User user, String toPeople) throws Exception {
|
|
|
- TemplateEnum templateEnum = null;
|
|
|
- if (EnvCommonService.active.equals(envCommonService.getEnv())) {
|
|
|
- templateEnum = TemplateEnum.NEW_ORDER_ENV_TEMPLATE;
|
|
|
- }else {
|
|
|
- templateEnum = TemplateEnum.NEW_ORDER_PRD_TEMPLATE;
|
|
|
- }
|
|
|
- WxMpTemplateMessage templateMessage = new WxMpTemplateMessage()
|
|
|
- .setToUser(toPeople)
|
|
|
- .setTemplateId(templateEnum.getTemplateId())
|
|
|
- //TODO
|
|
|
- .setUrl(" ");
|
|
|
- WxMpTemplateMessage.TemplateData data = templateMessage.getData();
|
|
|
- data.setFirst(new WxMpTemplateData("新订单通知!"));
|
|
|
- data.setKeyword1(new WxMpTemplateData(order.getOrderNo()));
|
|
|
- data.setKeyword2(new WxMpTemplateData(String.format("%s,%s", goodsDon.getTitle(), sku.getSpecVal())));
|
|
|
- data.setKeyword3(new WxMpTemplateData(user.getNickname()));
|
|
|
- data.setKeyword4(new WxMpTemplateData(order.getMoney().divide(BigDecimal.valueOf(100)).toString()));
|
|
|
- data.setKeyword5(new WxMpTemplateData(DateUtil.format(order.getCreatedTime(), "yyyy-MM-dd HH:mm:ss")));
|
|
|
- data.setRemark(new WxMpTemplateData("点击查看详情"));
|
|
|
- weChatService.sendTemplateMessage(weChatService.getAccessToken(), Jsons.toJson(templateMessage));
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<RealGoodsInterestUser> selectNoPaymentRealGoods() {
|
|
|
@@ -530,7 +537,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
private void emptySendMsgNotify(OrderDon orderDon, String toPeople) throws Exception {
|
|
|
TemplateEnum templateEnum = null;
|
|
|
if (EnvCommonService.active.equals(envCommonService.getEnv())) {
|
|
|
- templateEnum = TemplateEnum.EMPTY_ENV_TEMPLATE;
|
|
|
+ return;
|
|
|
} else {
|
|
|
templateEnum = TemplateEnum.EMPTY_PRD_TEMPLATE;
|
|
|
}
|
|
|
@@ -647,13 +654,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OrderDonView getDetail(Long orderId, long userId) {
|
|
|
-
|
|
|
- OrderDonView detail = beanSearcher.searchFirst(OrderDonView.class, MapUtils.builder()
|
|
|
- .field(OrderDonView::getUserId, userId)
|
|
|
+ public OrderDonView getDetail(Long orderId, Long userId) {
|
|
|
+ MapBuilder builder = MapUtils.builder()
|
|
|
.field(OrderDonView::getId, orderId)
|
|
|
- .orderBy(OrderDonView::getId).desc()
|
|
|
- .build());
|
|
|
+ .orderBy(OrderDonView::getId).desc();
|
|
|
+ if (userId != null) {
|
|
|
+ builder.field(OrderDonView::getUserId, userId);
|
|
|
+ }
|
|
|
+ OrderDonView detail = beanSearcher.searchFirst(OrderDonView.class, builder.build());
|
|
|
|
|
|
detail.setTransport(transportMapper.selectOne(Wrappers.lambdaQuery(OrderDonTransport.class).eq(OrderDonTransport::getOrderId, detail.getId()).last(" limit 1")));
|
|
|
detail.setWaybill(waybillMapper.selectOne(Wrappers.lambdaQuery(OrderDonWaybill.class).eq(OrderDonWaybill::getOrderId, detail.getId()).last(" limit 1")));
|
|
|
@@ -668,13 +676,15 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
@Override
|
|
|
public AliPayParams aliPay(Long orderId, String productCode) throws Exception {
|
|
|
OrderDon orderDon = getById(orderId);
|
|
|
- String appId = null;
|
|
|
+ String appId = ShopConfig.ZFB_DEFAULT_APP_ID;
|
|
|
+
|
|
|
if (orderDon.getPopularizeId() != null) {
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByChannelPopularizeId(orderDon.getPopularizeId(),"zfb");
|
|
|
if (shopConfig != null) {
|
|
|
appId = shopConfig.getAppId();
|
|
|
}
|
|
|
}
|
|
|
+ orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
orderDon.setShopId(appId);
|
|
|
this.updateById(orderDon);
|
|
|
return commonAliPay(orderId, productCode, appId);
|
|
|
@@ -694,7 +704,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getPopularizeId() == null) {
|
|
|
orderDon.setShopId(null);
|
|
|
}
|
|
|
- boolean signVerified = AlipaySignature.rsaCheckV1(params,shopConfigMapper.getByAppId((Optional.ofNullable(orderDon.getShopId()).orElse(ShopConfig.ZFB_DEFAULT_APP_ID))).getPublicKey(), BaseZfbConfig.charset, BaseZfbConfig.signType);
|
|
|
+ String appId = params.get("app_id");
|
|
|
+ boolean signVerified = AlipaySignature.rsaCheckV1(params,shopConfigMapper.getByAppId(appId).getPublicKey(), BaseZfbConfig.charset, BaseZfbConfig.signType);
|
|
|
if (!signVerified) {
|
|
|
log.error("支付宝回调校验签名错误,自定义入参:{}", params.get("body"));
|
|
|
throw BusinessRuntimeException.getInstance("支付宝回调校验签名错误");
|
|
|
@@ -706,6 +717,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());
|
|
|
return;
|
|
|
}
|
|
|
+ if (orderDon.getIsNoLogin()) {
|
|
|
+ orderDon.setExCode(exchangeCodeService.getExCode(orderDon.getGoodsId(), orderDon.getSkuId(), 1));
|
|
|
+ }
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
Date payTime = DateTime.now();
|
|
|
@@ -716,25 +730,31 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setTransactionId(transactionId);
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
orderDon.setPayTime(payTime);
|
|
|
- //修改车位状态并发送模板消息
|
|
|
- updateCarParkAndSendMsg(goodsDon, sku, orderDon);
|
|
|
+ orderDon.setShopId(appId);
|
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
- if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0 && orderDon.getIsDistribute()) {
|
|
|
- TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(orderDon));
|
|
|
+ if (orderDon.getIsNoLogin()) {
|
|
|
+ orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
+ }
|
|
|
+ if (!orderDon.getIsNoLogin()) {
|
|
|
+ //修改车位状态并发送模板消息
|
|
|
+ updateCarParkAndSendMsg(goodsDon, sku, orderDon);
|
|
|
+ if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0 && orderDon.getIsDistribute()) {
|
|
|
+ TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(orderDon));
|
|
|
+ }
|
|
|
+ if (goodsDon.getType() == 1) {
|
|
|
+ //无车队,新增车队
|
|
|
+ checkNoGroupsTripsAndSendMsg(sku, orderDon);
|
|
|
+ }
|
|
|
+ //完成任务
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
+ .eq(TaskType::getName, TaskTypeEnum.yh_order.getDesc()).last("limit 1"));
|
|
|
+ taskService.completeTask(taskType, orderDon.getUserId());
|
|
|
+ });
|
|
|
+ //客服续费订单
|
|
|
+ handleServiceRenewOrder(orderDon);
|
|
|
}
|
|
|
this.updateById(orderDon);
|
|
|
- if (goodsDon.getType() == 1) {
|
|
|
- //无车队,新增车队
|
|
|
- checkNoGroupsTripsAndSendMsg(sku, orderDon);
|
|
|
- }
|
|
|
- //客服续费订单
|
|
|
- handleServiceRenewOrder(orderDon);
|
|
|
- //完成任务
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
- .eq(TaskType::getName, TaskTypeEnum.yh_order.getDesc()).last("limit 1"));
|
|
|
- taskService.completeTask(taskType, orderDon.getUserId());
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -886,7 +906,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
Integer num = orderDon.getNum();
|
|
|
DateTime now = DateTime.now();
|
|
|
GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
- Date expiryTime = relation.getExpiryTime();
|
|
|
Boolean isFlag = true;
|
|
|
if (orderDon.getOrderType() == 2) {
|
|
|
//是否有其他付款订单是否过期
|
|
|
@@ -905,6 +924,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
if (relation != null) {
|
|
|
+ Date expiryTime = relation.getExpiryTime();
|
|
|
if (isFlag) {
|
|
|
relation.setUserId(0l);
|
|
|
relation.setStatus(GroupsRelation.Status.none);
|
|
|
@@ -933,7 +953,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* 校验订单是否符合退款操作
|
|
|
* @param orderDon
|
|
|
*/
|
|
|
- private void checkOrderRefund(OrderDon orderDon,GoodsDon goodsDon, GoodsDonSku sku) {
|
|
|
+ private void checkOrderRefund(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) {
|
|
|
if (orderDon == null) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
}
|
|
|
@@ -1055,8 +1075,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
public void setRelation(Long relationId, Long userId, Long goodsId) {
|
|
|
- int noPayCount = count(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, goodsId).eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
-
|
|
|
+ int noPayCount = count(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, goodsId).eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
if (noPayCount > 0) {
|
|
|
throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
}
|
|
|
@@ -1210,21 +1229,23 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
//新订单产生 发送模板消息给用户、客服
|
|
|
User user = userMapper.selectById(order.getUserId());
|
|
|
- THREAD_POOL_TASK_EXECUTOR.execute(() -> {
|
|
|
- try {
|
|
|
- //发送至用户消息
|
|
|
- newOderSendMsgByType(order, goodsDon, sku, user, user.getOpenId());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("向用户发送新订单{}通知消息失败:{}", order.getOrderNo(), e);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (user != null) {
|
|
|
+ THREAD_POOL_TASK_EXECUTOR.execute(() -> {
|
|
|
+ try {
|
|
|
+ //发送至用户消息
|
|
|
+ templateCommonService.newOderSendMsgByType(order, goodsDon, sku, user, user.getOpenId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("向用户发送新订单{}通知消息失败:{}", order.getOrderNo(), e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
THREAD_POOL_TASK_EXECUTOR.execute(() -> {
|
|
|
try {
|
|
|
//发送至客服消息
|
|
|
List<CustomerService> customerServices = customerServiceMapper.selectList(null);
|
|
|
for (CustomerService customerService : customerServices) {
|
|
|
log.info("向客服{}发送新订单消息通知..", customerService.getNickName());
|
|
|
- newOderSendMsgByType(order, goodsDon, sku, user, customerService.getOpenId());
|
|
|
+ templateCommonService.newOderSendMsgByType(order, goodsDon, sku, user, customerService.getOpenId());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("向客服发送新订单{}通知消息失败:{}", order.getOrderNo(), e);
|