|
|
@@ -559,9 +559,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.error("回调数据:{}", map);
|
|
|
throw BusinessRuntimeException.getInstance("支付成功回调, 校验签名失败.");
|
|
|
}
|
|
|
-
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(order.getSkuId());
|
|
|
- GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
+ GoodsDonSku sku = null;
|
|
|
+ if (order.getSkuId() != null) {
|
|
|
+ sku = goodsDonSkuMapper.selectById(order.getSkuId());
|
|
|
+ }
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectById(order.getGoodsId());
|
|
|
|
|
|
String transactionId = map.get("transaction_id");
|
|
|
|
|
|
@@ -572,7 +574,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
// 更改订单状态
|
|
|
order.setTransactionId(transactionId);
|
|
|
- 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);
|
|
|
@@ -584,74 +585,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
order.setOpenId(map.get("openid"));
|
|
|
}
|
|
|
order.setType(OrderDon.Type.WeChat);
|
|
|
- if (order.getIsNoLogin()) {
|
|
|
- order.setStatus(OrderDon.Status.hasPayment);
|
|
|
- }
|
|
|
-
|
|
|
- boolean isSuccess = update(Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
- .set(OrderDon::getStatus, order.getStatus())
|
|
|
- .in(OrderDon::getStatus, List.of(OrderDon.Status.noPayment, OrderDon.Status.close))
|
|
|
- .eq(OrderDon::getId, order.getId()));
|
|
|
- if (!isSuccess) {
|
|
|
- log.info("微信回调商家订单号:{}订单状态已修改", order.getOrderNo());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!order.getIsNoLogin()) {
|
|
|
- //更新座位信息
|
|
|
- updateGroupsTicket(order, goodsDon, sku);
|
|
|
- if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
|
|
|
- TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
|
|
|
- }
|
|
|
- //店铺分销 存在
|
|
|
- if (order.getYhsId() != null && order.getYhsId() > 0) {
|
|
|
- TASK_POOL.execute(() -> yhShopDistributeService.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);
|
|
|
- }
|
|
|
- //购买Midjourney课程 赠送Midjourney车票
|
|
|
- if (goodsId != null && goodsId.equals(27l)) {
|
|
|
- order.setStatus(OrderDon.Status.complete);
|
|
|
- TASK_POOL.execute(() -> sendMidjourneyTicketIfCourse(order.getUserId()));
|
|
|
- }
|
|
|
- this.updateById(order);
|
|
|
- //配置了特定奖池,增加抽奖机会
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- try {
|
|
|
- marketFrontService.addSpecificChanceNum(order.getUserId(), order.getId(), order.getGoodsId(), order.getSkuId());
|
|
|
- if (goodsDon.getType() == 2) {
|
|
|
- equipmentDistributeService.addDistributeBenefitsChance(order.getUserId(), order.getId());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("wx增加抽奖机会错误,orderId:{},error:{}", order.getId(), e);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- try {
|
|
|
- orderDonPostService.postData((order.getId()));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("回传错误 {}", StringUtil.getErrorText(e));
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- //虚拟物品购买推送电报消息
|
|
|
- if(goodsDon.getType() == 1){
|
|
|
- TASK_POOL.execute(()->{
|
|
|
- sendTelegramMsg(order, goodsDon);
|
|
|
- });
|
|
|
- }
|
|
|
+ unifiedHandlerOrderNotify(order, goodsDon, sku);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -937,84 +872,22 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getIsNoLogin()) {
|
|
|
orderDon.setExCode(exchangeCodeService.getExCode(goodsId, orderDon.getSkuId(), 1));
|
|
|
}
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
- GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
+ GoodsDonSku sku = null;
|
|
|
+ if (orderDon.getSkuId() != null) {
|
|
|
+ sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
+ }
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
Date payTime = DateTime.now();
|
|
|
if (StringUtils.isNotBlank(payTimeStr)) {
|
|
|
payTime = DateUtil.parse(payTimeStr, "yyyy-MM-dd HH:mm:ss");
|
|
|
}
|
|
|
// 更改订单状态
|
|
|
orderDon.setTransactionId(transactionId);
|
|
|
- orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
orderDon.setPayTime(payTime);
|
|
|
orderDon.setShopId(appId);
|
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
- if (orderDon.getIsNoLogin()) {
|
|
|
- orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
- }
|
|
|
- boolean isSuccess = update(Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
- .set(OrderDon::getStatus, orderDon.getStatus())
|
|
|
- .in(OrderDon::getStatus, List.of(OrderDon.Status.noPayment, OrderDon.Status.close))
|
|
|
- .eq(OrderDon::getId, orderDon.getId()));
|
|
|
- if (!isSuccess) {
|
|
|
- log.info("支付宝回调商家订单号:{}订单状态已修改", orderDon.getOrderNo());
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!orderDon.getIsNoLogin()) {
|
|
|
- //更新座位信息
|
|
|
- updateGroupsTicket(orderDon, goodsDon, sku);
|
|
|
- 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);
|
|
|
- }
|
|
|
- //购买Midjourney课程 赠送Midjourney车票
|
|
|
- if (goodsId != null && goodsId.equals(27l)) {
|
|
|
- orderDon.setStatus(OrderDon.Status.complete);
|
|
|
- TASK_POOL.execute(() -> sendMidjourneyTicketIfCourse(orderDon.getUserId()));
|
|
|
- }
|
|
|
- this.updateById(orderDon);
|
|
|
- //配置了特定奖池,增加抽奖机会
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- try {
|
|
|
- marketFrontService.addSpecificChanceNum(orderDon.getUserId(), orderDon.getId(), orderDon.getGoodsId(), orderDon.getSkuId());
|
|
|
- if (goodsDon.getType() == 2) {
|
|
|
- equipmentDistributeService.addDistributeBenefitsChance(orderDon.getUserId(), orderDon.getId());
|
|
|
- }
|
|
|
- //若该订单使用了规定推广者的兑换码 增加上下级关系
|
|
|
- if (StrUtil.isNotBlank(orderDon.getCouponExCode())) {
|
|
|
- addDistributeCouponCode(orderDon.getUserId(), orderDon.getCouponExCode());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("zfb增加抽奖机会错误,orderId:{},error:{}", orderDon.getId(), e);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
- try {
|
|
|
- orderDonPostService.postData((orderDon.getId()));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("回传错误 {}", StringUtil.getErrorText(e));
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- //虚拟物品购买推送电报消息
|
|
|
- if(goodsDon.getType() == 1){
|
|
|
- TASK_POOL.execute(()->{
|
|
|
- sendTelegramMsg(orderDon, goodsDon);
|
|
|
- });
|
|
|
- }
|
|
|
+ unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
}
|
|
|
|
|
|
private void sendOrderPhoneMsg(Long userId) {
|
|
|
@@ -1817,7 +1690,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* 查询第三放接口订单是否已支付
|
|
|
*/
|
|
|
public OrderDon.Status isHasPaid(OrderDon orderDon) {
|
|
|
- OrderDon.Status noPayment = OrderDon.Status.noPayment;
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
if (orderDon.getType() == OrderDon.Type.WeChat) {
|
|
|
try {
|
|
|
@@ -1827,7 +1699,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if ("SUCCESS".equals(orderStatus)) {
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
orderDon.setTransactionId(reMap.get("transaction_id"));
|
|
|
- return updateNoPayment(noPayment, orderDon, goodsDon);
|
|
|
+ return updateNoPayment(orderDon, goodsDon);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -1841,7 +1713,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if ("TRADE_SUCCESS".equals(tradeStatus)) {
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
orderDon.setTransactionId(zfbOrderDetail.getTradeNo());
|
|
|
- return updateNoPayment(noPayment, orderDon, goodsDon);
|
|
|
+ return updateNoPayment(orderDon, goodsDon);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -1851,21 +1723,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return orderDon.getStatus();
|
|
|
}
|
|
|
|
|
|
- private OrderDon.Status updateNoPayment(OrderDon.Status noPayment, OrderDon orderDon, GoodsDon goodsDon) {
|
|
|
- boolean isSuccess = update(Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
- .set(OrderDon::getStatus, orderDon.getStatus())
|
|
|
- .set(OrderDon::getTransactionId, orderDon.getTransactionId())
|
|
|
- .eq(OrderDon::getStatus, noPayment)
|
|
|
- .eq(OrderDon::getId, orderDon.getId()));
|
|
|
- if (isSuccess) {
|
|
|
- //更新车位情况
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
- //更新座位信息
|
|
|
- updateGroupsTicket(orderDon, goodsDon, sku);
|
|
|
- updateById(orderDon);
|
|
|
- return orderDon.getStatus();
|
|
|
+ private OrderDon.Status updateNoPayment(OrderDon orderDon, GoodsDon goodsDon) {
|
|
|
+ GoodsDonSku sku = null;
|
|
|
+ if (orderDon.getSkuId() != null) {
|
|
|
+ sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
}
|
|
|
- return noPayment;
|
|
|
+ unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
+ return orderDon.getStatus();
|
|
|
}
|
|
|
|
|
|
public void checkIsSameUser(Long relationUserId, Long userId, String openId, String loginPhone) {
|
|
|
@@ -2160,13 +2024,19 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getIsNoLogin()) {
|
|
|
orderDon.setExCode(exchangeCodeService.getExCode(goodsId, orderDon.getSkuId(), 1));
|
|
|
}
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
- GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
- orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
-
|
|
|
- if (orderDon.getIsNoLogin()) {
|
|
|
- orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
+ GoodsDonSku sku = null;
|
|
|
+ if (orderDon.getSkuId() != null) {
|
|
|
+ sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
}
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
+ unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统一订单信息回调
|
|
|
+ */
|
|
|
+ public void unifiedHandlerOrderNotify(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) {
|
|
|
+ orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
boolean isSuccess = update(Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
.set(OrderDon::getStatus, orderDon.getStatus())
|
|
|
.in(OrderDon::getStatus, List.of(OrderDon.Status.noPayment, OrderDon.Status.close))
|
|
|
@@ -2175,34 +2045,43 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("支付宝回调商家订单号:{}订单状态已修改", orderDon.getOrderNo());
|
|
|
return;
|
|
|
}
|
|
|
- if (!orderDon.getIsNoLogin()) {
|
|
|
+
|
|
|
+ if (orderDon.getIsNoLogin()) {
|
|
|
+ orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
+ }
|
|
|
+ Long goodsId = goodsDon.getId();
|
|
|
+ if (!orderDon.getIsNoLogin() && sku != null) {
|
|
|
//更新座位信息
|
|
|
updateGroupsTicket(orderDon, goodsDon, sku);
|
|
|
- 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);
|
|
|
}
|
|
|
- //购买Midjourney课程 赠送Midjourney车票
|
|
|
- if (goodsId != null && goodsId.equals(27l)) {
|
|
|
- orderDon.setStatus(OrderDon.Status.complete);
|
|
|
- TASK_POOL.execute(() -> sendMidjourneyTicketIfCourse(orderDon.getUserId()));
|
|
|
- }
|
|
|
this.updateById(orderDon);
|
|
|
- //配置了特定奖池,增加抽奖机会
|
|
|
- TASK_POOL.execute(() -> {
|
|
|
+
|
|
|
+ TASK_POOL.execute(()->{
|
|
|
try {
|
|
|
+ //发放积分
|
|
|
+ if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0 && orderDon.getIsDistribute()) {
|
|
|
+ TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(orderDon));
|
|
|
+ }
|
|
|
+ //店铺分销 存在
|
|
|
+ if (orderDon.getYhsId() != null && orderDon.getYhsId() > 0) {
|
|
|
+ TASK_POOL.execute(() -> yhShopDistributeService.distributeWaitingSendPointsRecord(orderDon));
|
|
|
+ }
|
|
|
+ //完成任务
|
|
|
+ TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
+ .eq(TaskType::getName, TaskTypeEnum.yh_order.getDesc()).last("limit 1"));
|
|
|
+ taskService.completeTask(taskType, orderDon.getUserId());
|
|
|
+ //购买Midjourney课程 赠送Midjourney车票
|
|
|
+ if (goodsId != null && goodsId.equals(27l)) {
|
|
|
+ orderDon.setStatus(OrderDon.Status.complete);
|
|
|
+ TASK_POOL.execute(() -> sendMidjourneyTicketIfCourse(orderDon.getUserId()));
|
|
|
+ }
|
|
|
+ //配置了特定奖池,增加抽奖机会
|
|
|
marketFrontService.addSpecificChanceNum(orderDon.getUserId(), orderDon.getId(), orderDon.getGoodsId(), orderDon.getSkuId());
|
|
|
if (goodsDon.getType() == 2) {
|
|
|
equipmentDistributeService.addDistributeBenefitsChance(orderDon.getUserId(), orderDon.getId());
|
|
|
@@ -2212,9 +2091,24 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
addDistributeCouponCode(orderDon.getUserId(), orderDon.getCouponExCode());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("zfb增加抽奖机会错误,orderId:{},error:{}", orderDon.getId(), e);
|
|
|
+ log.error("回调修改订单信息错误,orderId:{},error:{}", orderDon.getId(), StringUtil.getErrorText(e));
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ TASK_POOL.execute(()->{
|
|
|
+ try {
|
|
|
+ orderDonPostService.postData((orderDon.getId()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("回传错误 {}",StringUtil.getErrorText(e));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //虚拟物品购买推送电报消息
|
|
|
+ if(goodsDon.getType() == 1){
|
|
|
+ TASK_POOL.execute(()->{
|
|
|
+ sendTelegramMsg(orderDon, goodsDon);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|