Browse Source

FEAT: yb 补偿机制,定时反查支付接口

xdd 6 ngày trước cách đây
mục cha
commit
d1d256eb61

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/mapper/FsStorePaymentMapper.java

@@ -379,7 +379,7 @@ public interface FsStorePaymentMapper
     /**
      * 一个小时状态还没有变化
      */
-    @Select("select * from fs_store_payment where pay_mode='hf' and status=0 and trade_no is not null and remark is not null AND create_time < DATE_SUB(NOW(), INTERVAL 10 MINUTE)")
+    @Select("select * from fs_store_payment where pay_mode='yb' and status=0 and trade_no is not null and remark is not null AND create_time < DATE_SUB(NOW(), INTERVAL 10 MINUTE)")
     List<FsStorePayment> queryPendingDelayState();
 
     @Select("select count(1) from fs_store_payment where order_id=${orderId} limit 1")

+ 33 - 1
fs-service-system/src/main/java/com/fs/store/service/impl/FsStorePaymentServiceImpl.java

@@ -22,11 +22,15 @@ import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.dto.*;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
 import com.fs.huifuPay.service.HuiFuService;
+import com.fs.pay.pay.domain.OrderResult;
+import com.fs.pay.pay.dto.OrderQueryDTO;
+import com.fs.pay.pay.service.PayService;
 import com.fs.pay.pay.util.PayUtil;
 import com.fs.store.domain.*;
 import com.fs.store.service.IFsStoreOrderService;
 import com.fs.store.service.channel.PaymentHandler;
 import com.fs.store.service.channel.PaymentHandlerHolder;
+import com.fs.store.service.channel.YbPaymentHandler;
 import com.fs.store.service.channel.param.PayProcessContext;
 import com.fs.system.config.SnowflakeUtils;
 import com.fs.tzBank.TzBankService;
@@ -316,12 +320,39 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         return fsStorePaymentMapper.selectFsStorePaymentByTradeNo(tradeNo);
     }
 
+    @Autowired
+    private PayService payService;
+
+
     @Override
     public void paymentSync() {
         List<FsStorePayment> fsStorePayments = fsStorePaymentMapper.queryPendingDelayState();
         for (FsStorePayment fsStorePayment : fsStorePayments) {
             try{
-                queryHf(fsStorePayment);
+                String json = configService.selectConfigByKey("store.pay");
+                FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
+                OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
+                orderQueryDTO.setAccount(fsPayConfig.getYbAccount());
+                orderQueryDTO.setUpOrderId(fsStorePayment.getTradeNo());
+                OrderResult orderResult = payService.getOrder(orderQueryDTO);
+
+                    if ("0".equals(orderResult.getState())) {
+                        String[] order = orderResult.getLowOrderId().split("-");
+                        if (orderResult.getStatus().equals("100")) {
+                            switch (order[0]) {
+                                case "store":
+                                    orderService.payConfirm(1, null, order[1], orderResult.getUpOrderId(), orderResult.getBankTrxId(), orderResult.getBankOrderId());
+                                    break;
+                                case "store_remain":
+                                    orderService.payRemainConfirm(order[1], orderResult.getUpOrderId(), orderResult.getBankTrxId(), orderResult.getBankOrderId());
+                                    break;
+                                case "payment":
+                                    this.payConfirm(order[1], orderResult.getUpOrderId(), orderResult.getBankTrxId(), orderResult.getBankOrderId());
+                                    break;
+                            }
+                        }
+                    }
+
             }catch (Exception e){
                 logger.error("同步支付状态异常,订单号: {}",fsStorePayment.getOrderId(),e);
             }
@@ -430,6 +461,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         String sign = PayUtil.sign(orderQueryRequest.toSignMap());
         orderQueryRequest.setSign(sign);
 
+
         OrderQueryResponse orderQueryResponse = orderQueryService.queryOrder(orderQueryRequest);
         if(ObjectUtil.equal(orderQueryResponse.getStatus(),100)){
             Long orderId = fsStorePayment.getOrderId();