Browse Source

在支付订单同步的定时器中加入查询富友订单的程序

Yangzw 8 tháng trước cách đây
mục cha
commit
77e580e345

+ 19 - 14
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/order/PayOrderServiceImpl.java

@@ -485,6 +485,21 @@ public class PayOrderServiceImpl implements PayOrderService {
      */
     private boolean syncOrder(PayOrderExtensionDO orderExtension) {
         try {
+            // 如果是对接富友的支付单,则查询富友的订单状态
+            if (channelService.getChannelById(orderExtension.getChannelId())) {
+                PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId());
+
+                // 查询状态,修改支付订单状态
+                PayOrderDO payOrder = fuYouPayOrderService.getPayOrderByStatus(orderExtension, order);
+
+                // 支付单状态发生变化才更新
+                if (payOrder != null && !payOrder.getStatus().equals(order.getStatus()) && payOrder.getStatus().equals(PayOrderStatusEnum.SUCCESS.getStatus())) {
+                    // 修改订单状态
+                    tradeOrderProducer.sendTradeOrderMessage(order.getId());
+                }
+                return true;
+            }
+
             // 1.1 查询支付订单信息
             PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
             if (payClient == null) {
@@ -545,26 +560,16 @@ public class PayOrderServiceImpl implements PayOrderService {
                     continue;
                 }
 
+                if (channelService.getChannelById(orderExtension.getChannelId())) {
+                    return false;
+                }
+
                 // 情况一:校验数据库中的 orderExtension 是不是已支付
                 if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) {
                     log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]",
                             order.getId(), orderExtension.getId());
                     return false;
                 }
-
-                // 如果是对接富友的支付单,则查询富友的订单状态
-                if (channelService.getChannelById(orderExtension.getChannelId())) {
-                    // 查询状态,修改支付订单状态
-                    PayOrderDO payOrder = fuYouPayOrderService.getPayOrderByStatus(orderExtension, order);
-
-                    // 支付单状态发生变化才更新
-                    if (payOrder != null && !payOrder.getStatus().equals(order.getStatus()) && payOrder.getStatus().equals(PayOrderStatusEnum.SUCCESS.getStatus())) {
-                        // 修改订单状态
-                        tradeOrderProducer.sendTradeOrderMessage(order.getId());
-                    }
-                    return false;
-                }
-
                 // 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款
                 PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
                 if (payClient == null) {

+ 5 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/refund/PayRefundServiceImpl.java

@@ -300,6 +300,11 @@ public class PayRefundServiceImpl implements PayRefundService {
      */
     private boolean syncRefund(PayRefundDO refund) {
         try {
+
+            if (channelService.getChannelById(refund.getChannelId())) {
+                return false;
+            }
+
             // 1.1 查询退款订单信息
             PayClient payClient = channelService.getPayClient(refund.getChannelId());
             if (payClient == null) {