瀏覽代碼

苏商提款回调通知接口开发

liuj 1 天之前
父節點
當前提交
4ecca67790

+ 96 - 0
src/main/java/com/sunxung/factoring/start/impl/SMBNoticeInit.java

@@ -0,0 +1,96 @@
+package com.sunxung.factoring.start.impl;
+
+import com.sunxung.factoring.component.util.ConstantUtil;
+import com.sunxung.factoring.component.util.SpringUtil;
+import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
+import com.sunxung.factoring.entity.smb.FinancingLoanInfo;
+import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
+import com.sunxung.factoring.service.financing.payment.IPaymentApplyService;
+import com.sunxung.factoring.service.smb.IFinancingLoanInfoService;
+import com.sunxung.factoring.service.smbApi.dto.SMBNotifyRespDto;
+import com.sunxung.factoring.service.smbApi.dto.WithdrawNotifyPayloadDto;
+import com.sunxung.factoring.service.smbApi.spi.SMBSpiRegister;
+
+import java.util.function.Function;
+
+/**
+ * 苏商注册提款结果通知回调函数初始化
+ */
+public class SMBNoticeInit {
+
+    public void run() {
+        Function<WithdrawNotifyPayloadDto, SMBNotifyRespDto> withdrawNotifyHandler = withdrawNotifyPayloadDto -> {
+            if (withdrawNotifyPayloadDto.getPayoutNo() != null) {
+                FinancingLoanInfo loanInfo = getFinancingLoanInfoService().lambdaQuery().eq(FinancingLoanInfo::getPayoutNo, withdrawNotifyPayloadDto.getPayoutNo()).one();
+                if (loanInfo != null) {
+                    //借据编号
+                    loanInfo.setDueBillNo(withdrawNotifyPayloadDto.getDuebillNo());
+                    //到期日期
+                    loanInfo.setMaturityDate(withdrawNotifyPayloadDto.getMaturity());
+                    //提款申请日期
+                    loanInfo.setLoanApplyDate(withdrawNotifyPayloadDto.getLoanApplyTime());
+                    //放款日期
+                    loanInfo.setPayoutDate(withdrawNotifyPayloadDto.getPayoutDate());
+                    //放款状态
+                    loanInfo.setPayoutStatus(withdrawNotifyPayloadDto.getStatus());
+                    //放款金额
+                    loanInfo.setLoanAmount(withdrawNotifyPayloadDto.getBusiAmt());
+                    if ("03".equals(withdrawNotifyPayloadDto.getStatus())) {
+                        //如果提款失败,添加失败原因
+                        loanInfo.setFailMsg(withdrawNotifyPayloadDto.getRemark());
+                    }
+                    getFinancingLoanInfoService().updateById(loanInfo);
+                    if ("02".equals(withdrawNotifyPayloadDto.getStatus())) {
+                        //如果提款成功后、需要向sop推送融资信息
+                        if (loanInfo.getcFinancingBasicInfoId() != null) {
+                            CFinancingBasicInfo financingBasicInfo = getFinancingBasicInfoService().getById(loanInfo.getcFinancingBasicInfoId());
+                            if (financingBasicInfo != null) {
+                                getPaymentApplyService().financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo.getPayoutDate());
+                            }
+                        }
+                    }
+                }
+            }
+            SMBNotifyRespDto respDto = new SMBNotifyRespDto();
+            respDto.setRespResult(true);
+            return respDto;
+        };
+        getSMBSpiRegister().registerWithdrawNotifyHandler(withdrawNotifyHandler);
+    }
+
+    private static SMBSpiRegister smbSpiRegister;
+
+    private static SMBSpiRegister getSMBSpiRegister() {
+        if (smbSpiRegister == null) {
+            smbSpiRegister = SpringUtil.getBeanByType(SMBSpiRegister.class);
+        }
+        return smbSpiRegister;
+    }
+
+    private static IFinancingLoanInfoService financingLoanInfoService;
+
+    private static IFinancingLoanInfoService getFinancingLoanInfoService() {
+        if (financingLoanInfoService == null) {
+            financingLoanInfoService = SpringUtil.getBeanByType(IFinancingLoanInfoService.class);
+        }
+        return financingLoanInfoService;
+    }
+
+    private static ICFinancingBasicInfoService financingBasicInfoService;
+
+    private static ICFinancingBasicInfoService getFinancingBasicInfoService() {
+        if (financingBasicInfoService == null) {
+            financingBasicInfoService = SpringUtil.getBeanByType(ICFinancingBasicInfoService.class);
+        }
+        return financingBasicInfoService;
+    }
+
+    private static IPaymentApplyService paymentApplyService;
+
+    private static IPaymentApplyService getPaymentApplyService() {
+        if (paymentApplyService == null) {
+            paymentApplyService = SpringUtil.getBeanByType(IPaymentApplyService.class);
+        }
+        return paymentApplyService;
+    }
+}

+ 23 - 87
src/main/java/com/sunxung/factoring/start/impl/StartLoadImpl.java

@@ -1,25 +1,12 @@
 package com.sunxung.factoring.start.impl;
 
-import com.sunxung.factoring.component.util.ConstantUtil;
-import com.sunxung.factoring.component.util.MockAdminThreadLocalUtil;
-import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
-import com.sunxung.factoring.entity.smb.FinancingLoanInfo;
 import com.sunxung.factoring.entity.sys.SqlVersion;
-import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
-import com.sunxung.factoring.service.financing.payment.IPaymentApplyService;
-import com.sunxung.factoring.service.smb.IFinancingLoanInfoService;
-import com.sunxung.factoring.service.smbApi.dto.SMBNotifyRespDto;
-import com.sunxung.factoring.service.smbApi.dto.WithdrawNotifyPayloadDto;
-import com.sunxung.factoring.service.smbApi.spi.SMBSpiRegister;
 import com.sunxung.factoring.start.StartLoad;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.util.function.Function;
-
 /**
  * 系统启动环境加载实现
  */
@@ -28,15 +15,6 @@ public class StartLoadImpl implements StartLoad {
 
     private static Logger log = LogManager.getLogger(StartLoadImpl.class);
 
-    @Autowired
-    private SMBSpiRegister smbSpiRegister;
-    @Autowired
-    private IFinancingLoanInfoService financingLoanInfoService;
-    @Autowired
-    private ICFinancingBasicInfoService financingBasicInfoService;
-    @Autowired
-    private IPaymentApplyService paymentApplyService;
-
     /**
      * 是否初始化
      */
@@ -61,71 +39,29 @@ public class StartLoadImpl implements StartLoad {
      * @throws Exception
      */
     private void init() throws Exception {
-        long startTime = System.currentTimeMillis();
-        log.error("开始初始化");
-        log.error("开始初始化数据库");
-        MockAdminThreadLocalUtil.mock();
-        log.error("开始初始化字典项");
-        new DictionaryInit().run();
-        log.error("开始初始化权限");
-        new PermissionInit().run();
-        log.error("开始初始化组织机构");
-        new OrgInit().run();
-        log.error("开始初始化行政区划");
-        log.error("开始初始化角色");
-        new RoleInit().run();
-        log.error("开始初始化用户");
-        new UserInit().run();
-        log.error("开始初始化工作日");
-        new WorkingDayInit().run();
-        log.error("开始初始化脚本升级最大版本号");
-        addSqlVersion();
-        smbNoticeInit();
-        log.error("成功初始化,耗时:" + (System.currentTimeMillis() - startTime) / 1000.0 + "秒");
-        MockAdminThreadLocalUtil.destroy();
-    }
-
-    /**
-     * 苏商注册提款结果通知回调函数初始化
-     */
-    private void smbNoticeInit() {
-        Function<WithdrawNotifyPayloadDto, SMBNotifyRespDto> withdrawNotifyHandler = withdrawNotifyPayloadDto -> {
-            if (withdrawNotifyPayloadDto.getPayoutNo() != null) {
-                FinancingLoanInfo loanInfo = financingLoanInfoService.lambdaQuery().eq(FinancingLoanInfo::getPayoutNo, withdrawNotifyPayloadDto.getPayoutNo()).one();
-                if (loanInfo != null) {
-                    //借据编号
-                    loanInfo.setDueBillNo(withdrawNotifyPayloadDto.getDuebillNo());
-                    //到期日期
-                    loanInfo.setMaturityDate(withdrawNotifyPayloadDto.getMaturity());
-                    //提款申请日期
-                    loanInfo.setLoanApplyDate(withdrawNotifyPayloadDto.getLoanApplyTime());
-                    //放款日期
-                    loanInfo.setPayoutDate(withdrawNotifyPayloadDto.getPayoutDate());
-                    //放款状态
-                    loanInfo.setPayoutStatus(withdrawNotifyPayloadDto.getStatus());
-                    //放款金额
-                    loanInfo.setLoanAmount(withdrawNotifyPayloadDto.getBusiAmt());
-                    if ("03".equals(withdrawNotifyPayloadDto.getStatus())) {
-                        //如果提款失败,添加失败原因
-                        loanInfo.setFailMsg(withdrawNotifyPayloadDto.getRemark());
-                    }
-                    financingLoanInfoService.updateById(loanInfo);
-                    if ("02".equals(withdrawNotifyPayloadDto.getStatus())) {
-                        //如果提款成功后、需要向sop推送融资信息
-                        if (loanInfo.getcFinancingBasicInfoId() != null) {
-                            CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(loanInfo.getcFinancingBasicInfoId());
-                            if (financingBasicInfo != null) {
-                                paymentApplyService.financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo.getPayoutDate());
-                            }
-                        }
-                    }
-                }
-            }
-            SMBNotifyRespDto respDto = new SMBNotifyRespDto();
-            respDto.setRespResult(true);
-            return respDto;
-        };
-        smbSpiRegister.registerWithdrawNotifyHandler(withdrawNotifyHandler);
+//        long startTime = System.currentTimeMillis();
+//        log.error("开始初始化");
+//        log.error("开始初始化数据库");
+//        MockAdminThreadLocalUtil.mock();
+//        log.error("开始初始化字典项");
+//        new DictionaryInit().run();
+//        log.error("开始初始化权限");
+//        new PermissionInit().run();
+//        log.error("开始初始化组织机构");
+//        new OrgInit().run();
+//        log.error("开始初始化行政区划");
+//        log.error("开始初始化角色");
+//        new RoleInit().run();
+//        log.error("开始初始化用户");
+//        new UserInit().run();
+//        log.error("开始初始化工作日");
+//        new WorkingDayInit().run();
+//        log.error("开始初始化脚本升级最大版本号");
+//        addSqlVersion();
+//        log.error("成功初始化,耗时:" + (System.currentTimeMillis() - startTime) / 1000.0 + "秒");
+//        MockAdminThreadLocalUtil.destroy();
+        log.error("开始初始化苏商注册提款结果通知回调函数");
+        new SMBNoticeInit().run();
     }
 
     /**

+ 1 - 1
src/main/resources/application-dev.yml

@@ -1,7 +1,7 @@
 #数据库启动方式
 data:
   #是否初始化
-  init: false
+  init: true
   #脚本升级版本号
   upgradeVersion: 1