Просмотр исходного кода

fix:【mall 商城】门店自提时,缺少上传订单物流信息到微信小程序

YunaiV месяцев назад: 10
Родитель
Сommit
b5d5fa8ea4

+ 34 - 17
yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java

@@ -42,6 +42,40 @@ public class TradeStatusSyncToWxaOrderHandler implements TradeOrderHandler {
         if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) {
             return;
         }
+
+        // 上传订单物流信息到微信小程序
+        uploadWxaOrderShippingInfo(order);
+    }
+
+    @Override
+    public void afterReceiveOrder(TradeOrderDO order) {
+        // 注意:只有微信小程序支付的订单,才需要同步
+        if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) {
+            return;
+        }
+        PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId());
+        SocialWxaOrderNotifyConfirmReceiveReqDTO reqDTO = new SocialWxaOrderNotifyConfirmReceiveReqDTO()
+                .setTransactionId(payOrder.getChannelOrderNo())
+                .setReceivedTime(order.getReceiveTime());
+        try {
+            socialClientApi.notifyWxaOrderConfirmReceive(UserTypeEnum.MEMBER.getValue(), reqDTO);
+        } catch (Exception ex) {
+            log.error("[afterReceiveOrder][订单({}) 通知订单收货到微信小程序失败]", order, ex);
+        }
+
+        // 如果是门店自提订单,上传订单物流信息到微信小程序
+        // 原因是,门店自提订单没有 “afterDeliveryOrder” 阶段。可见 https://t.zsxq.com/KWD3u 反馈
+        if (DeliveryTypeEnum.PICK_UP.getType().equals(order.getDeliveryType())) {
+            uploadWxaOrderShippingInfo(order);
+        }
+    }
+
+    /**
+     * 上传订单物流信息到微信小程序
+     *
+     * @param order 订单
+     */
+    private void uploadWxaOrderShippingInfo(TradeOrderDO order) {
         PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId());
         SocialWxaOrderUploadShippingInfoReqDTO reqDTO = new SocialWxaOrderUploadShippingInfoReqDTO()
                 .setTransactionId(payOrder.getChannelOrderNo())
@@ -64,23 +98,6 @@ public class TradeStatusSyncToWxaOrderHandler implements TradeOrderHandler {
         }
     }
 
-    @Override
-    public void afterReceiveOrder(TradeOrderDO order) {
-        // 注意:只有微信小程序支付的订单,才需要同步
-        if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) {
-            return;
-        }
-        PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId());
-        SocialWxaOrderNotifyConfirmReceiveReqDTO reqDTO = new SocialWxaOrderNotifyConfirmReceiveReqDTO()
-                .setTransactionId(payOrder.getChannelOrderNo())
-                .setReceivedTime(order.getReceiveTime());
-        try {
-            socialClientApi.notifyWxaOrderConfirmReceive(UserTypeEnum.MEMBER.getValue(), reqDTO);
-        } catch (Exception ex) {
-            log.error("[afterReceiveOrder][订单({}) 通知订单收货到微信小程序失败]", order, ex);
-        }
-    }
-
     // TODO @芋艿:【设置路径】 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AD%E3%80%81%E6%B6%88%E6%81%AF%E8%B7%B3%E8%BD%AC%E8%B7%AF%E5%BE%84%E8%AE%BE%E7%BD%AE%E6%8E%A5%E5%8F%A3
 
 }