Forráskód Böngészése

苏商提款接口重试

liuj 1 napja%!(EXTRA string=óta)
szülő
commit
c570b7750a

+ 169 - 1
src/main/java/com/sunxung/factoring/job/impl/SmbTaskJob.java

@@ -1,7 +1,28 @@
 package com.sunxung.factoring.job.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.snb.fsos.bean.LoanApply;
+import com.sunxung.factoring.component.exception.BusinessException;
+import com.sunxung.factoring.component.exception.ValidatorException;
+import com.sunxung.factoring.component.util.CodeUtil;
+import com.sunxung.factoring.entity.entprise.Enterprise;
+import com.sunxung.factoring.entity.financing.apply.CFinancingAccountsReceivableInfo;
+import com.sunxung.factoring.entity.financing.apply.CFinancingApplicantInfo;
+import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
+import com.sunxung.factoring.entity.smb.FinancingFromInvestors;
+import com.sunxung.factoring.entity.smb.FinancingFromInvestorsHistory;
+import com.sunxung.factoring.entity.smb.FinancingFromInvestorsNotice;
+import com.sunxung.factoring.service.entprise.IEnterpriseService;
+import com.sunxung.factoring.service.financing.apply.ICFinancingAccountsReceivableInfoService;
+import com.sunxung.factoring.service.financing.apply.ICFinancingApplicantInfoService;
+import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
+import com.sunxung.factoring.service.financing.review.ReviewQuotaDisburseService;
+import com.sunxung.factoring.service.smb.IFinancingFromInvestorsHistoryService;
 import com.sunxung.factoring.service.smb.IFinancingFromInvestorsService;
 import com.sunxung.factoring.service.smb.IFinancingLoanInfoService;
+import com.sunxung.factoring.service.smbApi.api.SMBApiService;
+import com.sunxung.factoring.service.smbApi.dto.LoanCreditRiskMsgDto;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,9 +30,13 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
- * @notice 苏商定时任务
  * @author liutao
+ * @notice 苏商定时任务
  * @date 2024-09-14
  */
 @Component
@@ -26,6 +51,21 @@ public class SmbTaskJob {
     @Autowired
     private IFinancingLoanInfoService financingLoanInfoService;
 
+    @Autowired
+    private ReviewQuotaDisburseService reviewQuotaDisburseService;
+    @Autowired
+    private IFinancingFromInvestorsHistoryService financingFromInvestorsHistoryService;
+    @Autowired
+    private ICFinancingBasicInfoService financingBasicInfoService;
+    @Autowired
+    private ICFinancingApplicantInfoService financingApplicantInfoService;
+    @Autowired
+    private ICFinancingAccountsReceivableInfoService financingAccountsReceivableInfoService;
+    @Autowired
+    private IEnterpriseService enterpriseService;
+    @Autowired
+    private SMBApiService smbApiService;
+
     @Scheduled(cron = "0 0/30 * * * ?")
     public void process() {
         log.info("苏商定时任务任务执行开始...");
@@ -42,4 +82,132 @@ public class SmbTaskJob {
         financingLoanInfoService.withdrawStatusQuery();
         log.info("苏商提款状态查询定时任务执行结束...");
     }
+
+    /**
+     * 苏商提款状态查询接口(每小时执行一次)
+     */
+    @Scheduled(cron = "0 0 */1 * * ?")
+    public void withdrawApplyProcess() {
+
+        CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(63L);
+        FinancingFromInvestorsNotice notice = reviewQuotaDisburseService.getFinancingFromInvestorsNotice(financingBasicInfo.getId());
+        FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistoryService.getById(notice.getFinancingFromInvestorsHistoryId());
+        FinancingFromInvestors financingFromInvestors = financingFromInvestorsService.getById(financingFromInvestorsHistory.getFinancingFromInvestorsId());
+        if (notice == null) {
+            throw new BusinessException(CodeUtil.FAIL, "获取不到对应的资方融资回调信息");
+        }
+        LoanApply loanApplyReq = new LoanApply();
+        //额度编号
+        loanApplyReq.setProductLimitNo(notice.getLimitNumber());
+        //放款金额
+        loanApplyReq.setBusiAmt("3000.00");
+        //还款方式
+        loanApplyReq.setRepayMethod("2");
+        //期限
+        loanApplyReq.setTerm("12");
+        //期限单位
+        loanApplyReq.setTermUnit("M");
+        //还款账户
+        loanApplyReq.setRepayAcctno(financingFromInvestors.getRepaymentAccount());
+        //还款账户名
+        loanApplyReq.setRepayAcctName(financingFromInvestors.getRepaymentAccountName());
+        //还款账户账号类型-默认为内部户
+        loanApplyReq.setRepayAccType("5");
+        //支付方式
+        loanApplyReq.setPayWay("0");
+        //收款卡标识
+        CFinancingApplicantInfo financingApplicantInfo = financingApplicantInfoService.lambdaQuery()
+                .eq(CFinancingApplicantInfo::getFinancingBasicInfoId, financingBasicInfo.getId()).one();
+        if (financingApplicantInfo == null || financingApplicantInfo.getSmb() == null) {
+            throw new BusinessException(CodeUtil.FAIL, "获取不到对应的融资申请-申请人信息");
+        }
+        if (financingApplicantInfo.getSmb()) {
+            loanApplyReq.setPayeeInnerCardFlag("0");
+        } else {
+            loanApplyReq.setPayeeInnerCardFlag("1");
+        }
+        //收款账户
+        loanApplyReq.setPayeeAcctThNbr(financingApplicantInfo.getApplicantDesignatedAccount());
+        //收款账户名
+        loanApplyReq.setPayeeAcctThName(financingApplicantInfo.getApplicantDesignatedAccountName());
+
+        LoanCreditRiskMsgDto loanCreditRiskMsg = new LoanCreditRiskMsgDto();
+        //精准扶贫类型代码
+        loanCreditRiskMsg.setPovertyAlleviationFlag("Z");
+        //涉农贷款类型代码
+        loanCreditRiskMsg.setAgricultureType("00");
+        //地方政府融资平台标志
+        loanCreditRiskMsg.setGovernmentFlag("0");
+        //贷款发放地区代码
+        String[] strArray = financingFromInvestors.getRegisteredAddress().split(",");
+        if (strArray.length == 3) {
+            loanCreditRiskMsg.setLoanAreaAddress(strArray[2]);
+        }
+        //创业担保贷款
+        loanCreditRiskMsg.setUndertakingGuarantee("00");
+        //普惠型小微企业法人贷款
+        loanCreditRiskMsg.setLoanType("06");
+        //绿色贷款类型
+        loanCreditRiskMsg.setGreenLoanFlag("00");
+        //行业类型代码
+        loanCreditRiskMsg.setIndustryFlag(financingFromInvestors.getIndustryTypeThree());
+        //担保方式
+        loanCreditRiskMsg.setGuaranteeFlag("3");
+        //贷款方式
+        loanCreditRiskMsg.setPurpose("03");
+        //应收账款金额
+        List<CFinancingAccountsReceivableInfo> informationList = financingAccountsReceivableInfoService.list(new QueryWrapper<CFinancingAccountsReceivableInfo>()
+                .eq("c_financing_basic_info_id", financingBasicInfo.getId()));
+        BigDecimal accountsReceivableAmount = BigDecimal.ZERO;
+        if (CollectionUtil.isNotEmpty(informationList)) {
+            accountsReceivableAmount = informationList.stream().filter(accountsReceivable -> accountsReceivable.getAccountsReceivableAmount() != null)
+                    .map(CFinancingAccountsReceivableInfo::getAccountsReceivableAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+        }
+        loanCreditRiskMsg.setReceivables(accountsReceivableAmount.toString());
+        //应收账款编号
+        loanCreditRiskMsg.setReceivablesNumber(financingBasicInfo.getPurchContractNumber());
+        //核心企业名称
+        Enterprise coreEnterprise = enterpriseService.getById(financingBasicInfo.getCoreEnterpriseId());
+        if (coreEnterprise == null || coreEnterprise.getSocialCreditCode() == null) {
+            throw new ValidatorException(CodeUtil.FAIL, "核心企业或核心企业的统一社会信用代码不存在");
+        }
+        loanCreditRiskMsg.setContractor(coreEnterprise.getCorporateName());
+
+        List<LoanCreditRiskMsgDto.FileInfo> fileList = new ArrayList<>();
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo1 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo1.setFileType("811");
+        fileInfo1.setFileSdossId("a272a720e74840048a8775cf40a6ca6f.pdf");
+        fileList.add(fileInfo1);
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo2 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo2.setFileType("811");
+        fileInfo2.setFileSdossId("ea91c8c9d16b40a7aa3a4a23cffea127.pdf");
+        fileList.add(fileInfo2);
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo3 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo3.setFileType("811");
+        fileInfo3.setFileSdossId("7170a4bf595e49e3aa34555e4f3c0557.pdf");
+        fileList.add(fileInfo3);
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo4 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo4.setFileType("812");
+        fileInfo4.setFileSdossId("81a1234b99e14e009ece60bfc2d92b4a.pdf");
+        fileList.add(fileInfo4);
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo5 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo5.setFileType("813");
+        fileInfo5.setFileSdossId("622fd4bb33dc472bac8a3f7d88c3922e.docx");
+        fileList.add(fileInfo5);
+
+        LoanCreditRiskMsgDto.FileInfo fileInfo6 = new LoanCreditRiskMsgDto.FileInfo();
+        fileInfo6.setFileType("814");
+        fileInfo6.setFileSdossId("b3b2ed4c245a4608aabd3cc8566fce87.pdf");
+        fileList.add(fileInfo6);
+
+        loanCreditRiskMsg.setFileList(fileList);
+        //获取openId
+        String openId = financingFromInvestors.getOpenId();
+        smbApiService.loanApply(loanApplyReq, loanCreditRiskMsg, openId);
+    }
 }