Explorar el Código

Merge branch 'smb' of http://192.168.0.200:3000/liuj/factoring-trade-backend into smb

wanglang hace 1 mes
padre
commit
2f7eb88cae

+ 14 - 0
src/main/java/com/sunxung/factoring/entity/financing/payment/PaymentApproval.java

@@ -98,6 +98,12 @@ public class PaymentApproval extends BaseEntity {
     @TableField(exist = false)
     private List<FileStorage> commitmentFileList;
 
+    /**
+     * 代偿承诺书附件Id
+     */
+    @TableField(exist = false)
+    private List<Long> commitmentFileIds;
+
     public Long getPaymentApplyId() {
         return paymentApplyId;
     }
@@ -201,4 +207,12 @@ public class PaymentApproval extends BaseEntity {
     public void setCommitmentFileList(List<FileStorage> commitmentFileList) {
         this.commitmentFileList = commitmentFileList;
     }
+
+    public List<Long> getCommitmentFileIds() {
+        return commitmentFileIds;
+    }
+
+    public void setCommitmentFileIds(List<Long> commitmentFileIds) {
+        this.commitmentFileIds = commitmentFileIds;
+    }
 }

+ 28 - 0
src/main/java/com/sunxung/factoring/entity/smb/FinancingLoanInfo.java

@@ -43,6 +43,12 @@ public class FinancingLoanInfo extends BaseEntity {
     @TableField("customer_type")
     private Integer customerType;
 
+    /**
+     * 用户唯一标识
+     */
+    @TableField("open_id")
+    private String openId;
+
     /**
      * 供应商企业信息Id
      */
@@ -55,6 +61,12 @@ public class FinancingLoanInfo extends BaseEntity {
     @TableField(exist = false)
     private String supplierName;
 
+    /**
+     * 供应商统一社会信用代码
+     */
+    @TableField(exist = false)
+    private String socialCreditCode;
+
     /**
      * 资方ID
      */
@@ -348,6 +360,22 @@ public class FinancingLoanInfo extends BaseEntity {
         this.supplierName = supplierName;
     }
 
+    public String getSocialCreditCode() {
+        return socialCreditCode;
+    }
+
+    public void setSocialCreditCode(String socialCreditCode) {
+        this.socialCreditCode = socialCreditCode;
+    }
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
     @Override
     public String toString() {
         return "FinancingLoanInfo{" +

+ 12 - 0
src/main/java/com/sunxung/factoring/job/impl/SmbTaskJob.java

@@ -1,6 +1,7 @@
 package com.sunxung.factoring.job.impl;
 
 import com.sunxung.factoring.service.smb.IFinancingFromInvestorsService;
+import com.sunxung.factoring.service.smb.IFinancingLoanInfoService;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +23,8 @@ public class SmbTaskJob {
     @Autowired
     private IFinancingFromInvestorsService financingFromInvestorsService;
 
+    @Autowired
+    private IFinancingLoanInfoService financingLoanInfoService;
 
     @Scheduled(cron = "0 0/30 * * * ?")
     public void process() {
@@ -30,4 +33,13 @@ public class SmbTaskJob {
         log.info("苏商定时任务任务执行结束...");
     }
 
+    /**
+     * 苏商提款状态查询接口(每小时执行一次)
+     */
+    @Scheduled(cron = "0 0 */1 * * ?")
+    public void withdrawStatusProcess() {
+        log.info("苏商提款状态查询定时任务执行开始...");
+        financingLoanInfoService.withdrawStatusQuery();
+        log.info("苏商提款状态查询定时任务执行结束...");
+    }
 }

+ 113 - 7
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApplyServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.deepoove.poi.XWPFTemplate;
 import com.snb.fsos.bean.LoanApply;
+import com.snb.fsos.bean.SMBFileUpload;
 import com.sunxung.factoring.component.enums.FinancingCurrentStageEnum;
 import com.sunxung.factoring.component.exception.BusinessException;
 import com.sunxung.factoring.component.exception.ValidatorException;
@@ -24,7 +25,10 @@ import com.sunxung.factoring.entity.financing.apply.CFinancingAccountsReceivable
 import com.sunxung.factoring.entity.financing.apply.CFinancingApplicantInfo;
 import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
 import com.sunxung.factoring.entity.financing.apply.CFinancingGoodsInfo;
-import com.sunxung.factoring.entity.financing.contract.*;
+import com.sunxung.factoring.entity.financing.contract.ContractFinancingInfo;
+import com.sunxung.factoring.entity.financing.contract.ContractInfo;
+import com.sunxung.factoring.entity.financing.contract.ContractLoanConditionSetting;
+import com.sunxung.factoring.entity.financing.contract.ContractMasterContract;
 import com.sunxung.factoring.entity.financing.contractTemplate.ContractTemplate;
 import com.sunxung.factoring.entity.financing.payment.*;
 import com.sunxung.factoring.entity.financing.review.*;
@@ -715,7 +719,10 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
                 ReviewFinancingInfo reviewFinancingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
                         .eq("review_quota_disburse_id", paymentInfo.getQuotaDisburseId()));
                 if (reviewFinancingInfo != null && ConstantUtil.JIANGSU_SUSHANG_BANK.equals(reviewFinancingInfo.getInstitutionName())) {
-                    LoanApplyResp loanApplyResp = withdrawApplyBySmb(financingBasicInfo, reviewFinancingInfo);
+                    //文件上传、获取苏商上传文件集合
+                    List<LoanCreditRiskMsgDto.FileInfo> fileInfoList = getFileInfoList(paymentApproval, receivablesRegisterInfo, paymentInfo, financingBasicInfo);
+
+                    LoanApplyResp loanApplyResp = withdrawApplyBySmb(financingBasicInfo, reviewFinancingInfo, fileInfoList);
                     //保存资方放款信息
                     saveFinancingLoanInfo(financingBasicInfo, reviewFinancingInfo, loanApplyResp);
                     if ("02".equals(loanApplyResp.getStatus())) {
@@ -734,6 +741,104 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         }
     }
 
+    /**
+     * 获取上传苏商的文件信息
+     *
+     * @param paymentApproval
+     * @param receivablesRegisterInfo
+     * @param paymentInfo
+     * @param financingBasicInfo
+     * @return
+     */
+    private List<LoanCreditRiskMsgDto.FileInfo> getFileInfoList(PaymentApproval paymentApproval, ReceivablesRegisterInfo receivablesRegisterInfo, PaymentInfo paymentInfo, CFinancingBasicInfo financingBasicInfo) {
+        List<LoanCreditRiskMsgDto.FileInfo> fileList = new ArrayList<>();
+
+        //上传应收账款合同
+        List<FileStorage> salesContractFile = getSalesContractFile(paymentInfo.getBusinessNo());
+        if (CollectionUtil.isNotEmpty(salesContractFile)) {
+            for (FileStorage fileStorage : salesContractFile) {
+                String fileSdossId = fileUploadBySmb(fileStorage, "811");
+
+                LoanCreditRiskMsgDto.FileInfo fileInfo = new LoanCreditRiskMsgDto.FileInfo();
+                fileInfo.setFileType("811");
+                fileInfo.setFileSdossId(fileSdossId);
+                fileList.add(fileInfo);
+            }
+        }
+        List<FileStorage> purchContractFiles = getPurchContractFiles(paymentInfo.getBusinessNo());
+        if (CollectionUtil.isNotEmpty(purchContractFiles)) {
+            for (FileStorage fileStorage : purchContractFiles) {
+                String fileSdossId = fileUploadBySmb(fileStorage, "811");
+
+                LoanCreditRiskMsgDto.FileInfo fileInfo = new LoanCreditRiskMsgDto.FileInfo();
+                fileInfo.setFileType("811");
+                fileInfo.setFileSdossId(fileSdossId);
+                fileList.add(fileInfo);
+            }
+        }
+        //上传应收账款产值单
+        List<FileStorage> acceptanceFile = getAcceptanceFile(financingBasicInfo.getId());
+        for (FileStorage fileStorage : acceptanceFile) {
+            String fileSdossId = fileUploadBySmb(fileStorage, "812");
+
+            LoanCreditRiskMsgDto.FileInfo fileInfo = new LoanCreditRiskMsgDto.FileInfo();
+            fileInfo.setFileType("812");
+            fileInfo.setFileSdossId(fileSdossId);
+            fileList.add(fileInfo);
+        }
+        //上传中登网登记凭证
+        if (CollectionUtil.isNotEmpty(receivablesRegisterInfo.getReceivablesFileIds())) {
+            for (Long fileId : receivablesRegisterInfo.getReceivablesFileIds()) {
+                FileStorage fileStorage = fileStorageService.get(fileId);
+
+                String fileSdossId = fileUploadBySmb(fileStorage, "813");
+                LoanCreditRiskMsgDto.FileInfo fileInfo = new LoanCreditRiskMsgDto.FileInfo();
+                fileInfo.setFileType("813");
+                fileInfo.setFileSdossId(fileSdossId);
+                fileList.add(fileInfo);
+            }
+        }
+        //上传回购承诺函
+        List<Long> commitmentFileIds = paymentApproval.getCommitmentFileIds();
+        if (CollectionUtil.isNotEmpty(commitmentFileIds)) {
+            for (Long fileId : commitmentFileIds) {
+                FileStorage fileStorage = fileStorageService.get(fileId);
+
+                String fileSdossId = fileUploadBySmb(fileStorage, "814");
+                LoanCreditRiskMsgDto.FileInfo fileInfo = new LoanCreditRiskMsgDto.FileInfo();
+                fileInfo.setFileType("814");
+                fileInfo.setFileSdossId(fileSdossId);
+                fileList.add(fileInfo);
+            }
+        }
+        return fileList;
+    }
+
+    /**
+     * 苏商银行-文件上传
+     *
+     * @param fileStorage
+     * @param fileType
+     * @return
+     */
+    private String fileUploadBySmb(FileStorage fileStorage, String fileType) {
+        List<SMBFileUpload> upload = new ArrayList<>();
+        SMBFileUpload smbFileUpload = new SMBFileUpload();
+        smbFileUpload.setFileName(fileStorage.getOriginalName());
+        smbFileUpload.setFileType(fileType);
+        smbFileUpload.setFilePath(fileStorage.getAbsolutePath());
+        upload.add(smbFileUpload);
+        Map<String, String> map;
+        try {
+            map = smbApiService.fileStreamUpload(upload);
+            String fileSdossId = map.get(fileStorage.getOriginalName());
+            return fileSdossId;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BusinessException(CodeUtil.FAIL, "上传苏商文件出错,请稍后重试!");
+        }
+    }
+
     @Override
     public List<PaymentCondition> findConditions(Long applyId) {
         return paymentConditionService.lambdaQuery().eq(PaymentCondition::getPaymentApplyId, applyId).list();
@@ -944,7 +1049,7 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
      * @param reviewFinancingInfo
      * @return
      */
-    private LoanApplyResp withdrawApplyBySmb(CFinancingBasicInfo financingBasicInfo, ReviewFinancingInfo reviewFinancingInfo) {
+    private LoanApplyResp withdrawApplyBySmb(CFinancingBasicInfo financingBasicInfo, ReviewFinancingInfo reviewFinancingInfo, List<LoanCreditRiskMsgDto.FileInfo> fileInfoList) {
         FinancingFromInvestorsNotice notice = reviewQuotaDisburseService.getFinancingFromInvestorsNotice(financingBasicInfo.getId());
         FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistoryService.getById(notice.getFinancingFromInvestorsHistoryId());
         FinancingFromInvestors financingFromInvestors = financingFromInvestorsService.getById(financingFromInvestorsHistory.getFinancingFromInvestorsId());
@@ -959,15 +1064,15 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         //还款方式
         loanApplyReq.setRepayMethod("2");
         //期限
-        loanApplyReq.setTerm(reviewFinancingInfo.getFinancingPeriod().toString());
+        loanApplyReq.setTerm("12");
         //期限单位
-        loanApplyReq.setTermUnit("D");
+        loanApplyReq.setTermUnit("M");
         //还款账户
         loanApplyReq.setRepayAcctno(financingFromInvestors.getRepaymentAccount());
         //还款账户名
         loanApplyReq.setRepayAcctName(financingFromInvestors.getRepaymentAccountName());
-        //还款账户账号类型
-        loanApplyReq.setRepayAccType(financingFromInvestors.getRepaymentAccountType());
+        //还款账户账号类型-默认为内部户
+        loanApplyReq.setRepayAccType("5");
         //支付方式
         loanApplyReq.setPayWay("0");
         //收款卡标识
@@ -1027,6 +1132,7 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
             throw new ValidatorException(CodeUtil.FAIL, "核心企业或核心企业的统一社会信用代码不存在");
         }
         loanCreditRiskMsg.setContractor(coreEnterprise.getCorporateName());
+        loanCreditRiskMsg.setFileList(fileInfoList);
         //获取openId
         String openId = financingFromInvestors.getOpenId();
         return smbApiService.loanApply(loanApplyReq, loanCreditRiskMsg, openId);

+ 6 - 1
src/main/java/com/sunxung/factoring/service/smb/IFinancingLoanInfoService.java

@@ -1,8 +1,8 @@
 package com.sunxung.factoring.service.smb;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.sunxung.factoring.entity.GridPage;
 import com.sunxung.factoring.entity.smb.FinancingLoanInfo;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.sunxung.factoring.entity.smb.vo.FinancingLoanInfoSearch;
 
 /**
@@ -30,4 +30,9 @@ public interface IFinancingLoanInfoService extends IService<FinancingLoanInfo> {
      * @return
      */
     FinancingLoanInfo getDetail(Long id);
+
+    /**
+     * 提款状态查询
+     */
+    void withdrawStatusQuery();
 }

+ 36 - 0
src/main/java/com/sunxung/factoring/service/smb/impl/FinancingLoanInfoServiceImpl.java

@@ -1,5 +1,7 @@
 package com.sunxung.factoring.service.smb.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
@@ -10,8 +12,11 @@ import com.sunxung.factoring.entity.smb.vo.FinancingLoanInfoSearch;
 import com.sunxung.factoring.mapper.smb.FinancingLoanInfoMapper;
 import com.sunxung.factoring.service.entprise.IEnterpriseService;
 import com.sunxung.factoring.service.smb.IFinancingLoanInfoService;
+import com.sunxung.factoring.service.smbApi.api.SMBApiService;
+import com.sunxung.factoring.service.smbApi.resp.LoanApplyStatusResp;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -28,6 +33,8 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
 
     @Autowired
     private IEnterpriseService enterpriseService;
+    @Autowired
+    private SMBApiService smbApiService;
 
     @Override
     public GridPage<FinancingLoanInfo> findBySearch(FinancingLoanInfoSearch search) {
@@ -44,8 +51,37 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
             Enterprise enterprise = enterpriseService.getById(financingLoanInfo.getcEnterpriseId());
             if (enterprise != null) {
                 financingLoanInfo.setSupplierName(enterprise.getCorporateName());
+                financingLoanInfo.setSocialCreditCode(enterprise.getSocialCreditCode());
             }
         }
         return financingLoanInfo;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void withdrawStatusQuery() {
+        //查询所有放款状态为处理中的放款信息
+        List<FinancingLoanInfo> loanInfoList = list(new QueryWrapper<FinancingLoanInfo>().eq("payout_status", "01"));
+        if (CollectionUtil.isNotEmpty(loanInfoList)) {
+            for (FinancingLoanInfo loanInfo : loanInfoList) {
+                LoanApplyStatusResp loanApplyStatusResp = smbApiService.loanApplyStatusQuery(loanInfo.getOpenId(), loanInfo.getPayoutNo());
+                if (loanApplyStatusResp != null) {
+                    //借据编号
+                    loanInfo.setDueBillNo(loanApplyStatusResp.getDuebillNo());
+                    //到期日期
+                    loanInfo.setMaturityDate(loanApplyStatusResp.getMaturity());
+                    //提款申请日期
+                    loanInfo.setLoanApplyDate(loanApplyStatusResp.getLoanApplyTime());
+                    //放款日期
+                    loanInfo.setPayoutDate(loanApplyStatusResp.getPayoutDate());
+                    //放款状态
+                    loanInfo.setPayoutStatus(loanApplyStatusResp.getStatus());
+                    //放款金额
+                    loanInfo.setLoanAmount(loanApplyStatusResp.getBusiAmt());
+                    updateById(loanInfo);
+                }
+            }
+        }
+
+    }
 }

+ 2 - 1
src/main/java/com/sunxung/factoring/service/smbApi/api/impl/SMBApiServiceImpl.java

@@ -219,7 +219,8 @@ public class SMBApiServiceImpl implements SMBApiService {
         loanApplyStatusQuery.setProductCode(smbConfiguration.getProductCode());
         loanApplyStatusQuery.setSysCode(smbConfiguration.getSysCode());
         loanApplyStatusQuery.setPlatformCode(smbConfiguration.getPlatformCode());
-        loanApplyStatusQuery.setBizNo(bizNo);
+        loanApplyStatusQuery.setPayoutNo(bizNo);
+      //  loanApplyStatusQuery.setBizNo(bizNo);
         SnbRequestBean snbRequestBean = new SnbRequestBean();
         snbRequestBean.setPayLoadBean(loanApplyStatusQuery);
         snbRequestBean.setOpenId(openId);

+ 3 - 2
src/main/java/com/sunxung/factoring/web/smb/FinancingLoanInfoController.java

@@ -1,6 +1,7 @@
 package com.sunxung.factoring.web.smb;
 
 import com.sunxung.factoring.entity.GridPage;
+import com.sunxung.factoring.entity.ResponseJson;
 import com.sunxung.factoring.entity.smb.FinancingFromInvestors;
 import com.sunxung.factoring.entity.smb.FinancingLoanInfo;
 import com.sunxung.factoring.entity.smb.vo.FinancingFromInvestorsSearchVo;
@@ -36,7 +37,7 @@ public class FinancingLoanInfoController {
      * @return
      */
     @GetMapping("/detail")
-    public FinancingLoanInfo getDetail(Long id){
-        return financingLoanInfoService.getDetail(id);
+    public ResponseJson<FinancingLoanInfo> getDetail(Long id){
+        return new ResponseJson<>(financingLoanInfoService.getDetail(id));
     }
 }

+ 1 - 0
src/main/resources/data/update/smb0826.sql

@@ -30,6 +30,7 @@ CREATE TABLE `financing_loan_info` (
         `quota_disburse_batch` int(11) DEFAULT NULL COMMENT '额度支用批次',
         `customer_type` tinyint(1) DEFAULT NULL COMMENT '客户类型',
         `c_enterprise_id` bigint(20) DEFAULT NULL COMMENT '供应商企业信息Id',
+        `open_id` varchar(100) DEFAULT '' COMMENT '用户唯一标识',
         `financing_management_id` bigint(20) DEFAULT NULL  COMMENT '资方ID',
         `financing_institution_name` varchar(200) DEFAULT NULL COMMENT '资方名称',
         `loan_amount` varchar(50) DEFAULT NULL COMMENT '放款金额',

+ 1 - 0
src/main/resources/mapper/smb/FinancingLoanInfoMapper.xml

@@ -15,6 +15,7 @@
         <result column="customer_type" property="customerType" />
         <result column="c_enterprise_id" property="cEnterpriseId" />
         <result column="corporate_name" property="supplierName" />
+        <result column="open_id" property="openId" />
         <result column="financing_management_id" property="financingManagementId" />
         <result column="financing_institution_name" property="financingInstitutionName" />
         <result column="loan_amount" property="loanAmount" />