Browse Source

feat: 已支付 但是没有银行流水号数据修复

xdd 1 month ago
parent
commit
c752d6785c

+ 17 - 0
fs-admin/src/test/java/com/fs/store/controller/FsStorePaymentControllerTest.java

@@ -55,6 +55,23 @@ public class FsStorePaymentControllerTest {
         fsStorePaymentService.paymentSync();
     }
 
+    /**
+     * 已支付 但是没有银行流水号数据修复
+     */
+    @Test
+    public void updatePaymentsBankInfo(){
+        String[] payCodeList = new String[]{
+                "1899282845931667456"
+        };
+
+        for (String payCode : payCodeList) {
+            FsStorePayment fsStorePayment = fsStorePaymentService.selectFsStorePaymentByCode(payCode);
+            if(fsStorePayment != null){
+                fsStorePaymentService.updateYbBankSerial(fsStorePayment);
+            }
+        }
+    }
+
     @Autowired
     private MiniProgramSubTask miniProgramSubTask;
     @Test

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStorePaymentService.java

@@ -110,4 +110,6 @@ public interface IFsStorePaymentService
 
     boolean queryTzbk(FsStorePayment fsStorePayment);
     boolean queryYb(FsStorePayment fsStorePayment);
+
+    boolean updateYbBankSerial(FsStorePayment fsStorePayment);
 }

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

@@ -1,7 +1,6 @@
 package com.fs.store.service.impl;
 
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -414,4 +413,39 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         }
         return false;
     }
+
+    @Override
+    public boolean updateYbBankSerial(FsStorePayment fsStorePayment) {
+        // 查询易宝
+
+        OrderQueryRequest orderQueryRequest = new OrderQueryRequest();
+        orderQueryRequest.setAccount(account);
+        orderQueryRequest.setUpOrderId(fsStorePayment.getTradeNo());
+        orderQueryRequest.setIsNeedUpInfo("1");
+
+        String sign = PayUtil.sign(orderQueryRequest.toSignMap());
+        orderQueryRequest.setSign(sign);
+
+        OrderQueryResponse orderQueryResponse = orderQueryService.queryOrder(orderQueryRequest);
+        if(ObjectUtil.equal(orderQueryResponse.getStatus(),100)){
+
+            // 支付成功
+            if("0".equals(orderQueryResponse.getState())){
+                // 如果查询支付成功 更新订单状态
+                cn.hutool.json.JSONObject upInfo = orderQueryResponse.getUpInfo();
+                String bankTrxId = upInfo.getStr("bankTrxId");
+                String bankOrderId = upInfo.getStr("bankOrderId");
+                fsStorePayment.setBankTransactionId(bankTrxId);
+                fsStorePayment.setBankSerialNo(bankOrderId);
+                this.updateFsStorePayment(fsStorePayment);
+                return true;
+                // 1失败 2已撤销
+            } else if("1".equals(orderQueryResponse.getState()) || "2".equals(orderQueryResponse.getState())){
+                fsStorePayment.setStatus(-2);
+                this.updateFsStorePayment(fsStorePayment);
+                return false;
+            }
+        }
+        return false;
+    }
 }