From b5d5fa8ea4167468f84e37b0926166f3d2799def Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 10:56:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90mall=20=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E3=80=91=E9=97=A8=E5=BA=97=E8=87=AA=E6=8F=90=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E4=B8=8A=E4=BC=A0=E8=AE=A2=E5=8D=95=E7=89=A9?= =?UTF-8?q?=E6=B5=81=E4=BF=A1=E6=81=AF=E5=88=B0=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeStatusSyncToWxaOrderHandler.java | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java b/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java index 8bd1a802ea..5d436727ae 100644 --- a/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java +++ b/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 }