Browse Source

Merge remote-tracking branch 'origin/smb' into smb

# Conflicts:
#	src/main/resources/data/update/smb0826.sql
liutao 1 month ago
parent
commit
bd6b4c0c7f

+ 0 - 70
src/main/java/com/sunxung/factoring/entity/financing/payment/PaymentApplyHis.java

@@ -94,36 +94,6 @@ public class PaymentApplyHis extends BaseEntity {
     @TableField(exist = false)
     private String taskId;
 
-    /**
-     * 是否为苏商资方
-     */
-    @TableField(exist = false)
-    private Boolean smbManagement;
-
-    /**
-     * 销售合同已签署文件
-     */
-    @TableField(exist = false)
-    private List<FileStorage> salesContractFileList;
-
-    /**
-     * 采购合同已签署文件
-     */
-    @TableField(exist = false)
-    private List<FileStorage> purchContractFileList;
-
-    /**
-     * 验收单已签署文件
-     */
-    @TableField(exist = false)
-    private List<FileStorage> acceptanceFileList;
-
-    /**
-     * 代偿承诺书
-     */
-    @TableField(exist = false)
-    private List<FileStorage> commitmentFileList;
-
     public Long getPaymentInfoId() {
         return paymentInfoId;
     }
@@ -235,44 +205,4 @@ public class PaymentApplyHis extends BaseEntity {
     public void setPaymentApplyId(Long paymentApplyId) {
         this.paymentApplyId = paymentApplyId;
     }
-
-    public Boolean getSmbManagement() {
-        return smbManagement;
-    }
-
-    public void setSmbManagement(Boolean smbManagement) {
-        this.smbManagement = smbManagement;
-    }
-
-    public List<FileStorage> getSalesContractFileList() {
-        return salesContractFileList;
-    }
-
-    public void setSalesContractFileList(List<FileStorage> salesContractFileList) {
-        this.salesContractFileList = salesContractFileList;
-    }
-
-    public List<FileStorage> getPurchContractFileList() {
-        return purchContractFileList;
-    }
-
-    public void setPurchContractFileList(List<FileStorage> purchContractFileList) {
-        this.purchContractFileList = purchContractFileList;
-    }
-
-    public List<FileStorage> getAcceptanceFileList() {
-        return acceptanceFileList;
-    }
-
-    public void setAcceptanceFileList(List<FileStorage> acceptanceFileList) {
-        this.acceptanceFileList = acceptanceFileList;
-    }
-
-    public List<FileStorage> getCommitmentFileList() {
-        return commitmentFileList;
-    }
-
-    public void setCommitmentFileList(List<FileStorage> commitmentFileList) {
-        this.commitmentFileList = commitmentFileList;
-    }
 }

+ 14 - 2
src/main/java/com/sunxung/factoring/service/financing/payment/IPaymentApplyService.java

@@ -6,6 +6,8 @@ import com.sunxung.factoring.entity.financing.payment.PaymentApply;
 import com.sunxung.factoring.entity.financing.payment.PaymentApproval;
 import com.sunxung.factoring.entity.financing.payment.PaymentCondition;
 import com.sunxung.factoring.entity.financing.sop.RefinancingRepaymentPlan;
+import com.sunxung.factoring.entity.financing.sop.RefinancingUseCreditReport;
+import com.sunxung.factoring.entity.smb.FinancingFromInvestorsNotice;
 import com.sunxung.factoring.entity.smb.FinancingLoanInfo;
 import com.sunxung.factoring.service.smbApi.dto.LoanCreditRiskMsgDto;
 
@@ -70,9 +72,19 @@ public interface IPaymentApplyService extends IService<PaymentApply> {
          *
          * @param financingBasicInfo
          * @param management
-         * @param payoutDate
+         * @param loanInfo
          */
-    void financingToSop(CFinancingBasicInfo financingBasicInfo, String management, String payoutDate);
+    void financingToSop(CFinancingBasicInfo financingBasicInfo, String management, FinancingLoanInfo loanInfo);
+
+
+    /**
+     * 构建再融资上报信息
+     *
+     * @param businessNo
+     * @param notice
+     * @param financingLoanInfo
+     */
+    RefinancingUseCreditReport createUseCreditReport(String businessNo, FinancingFromInvestorsNotice notice, FinancingLoanInfo financingLoanInfo);
 
     /**
      * 构建sop再融资计划

+ 1 - 136
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApplyHisServiceImpl.java

@@ -63,26 +63,6 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
     @Autowired
     private FileStorageService fileStorageService;
     @Autowired
-    private ISysAttachmentRefService sysAttachmentRefService;
-    @Autowired
-    private PurchContractService purchContractService;
-    @Autowired
-    private PurchContractBasicInfoService purchContractBasicInfoService;
-    @Autowired
-    private SalesContractService salesContractService;
-    @Autowired
-    private ICSalesContractBasicInfoService salesContractBasicInfoService;
-    @Autowired
-    private ICSalesSignConfirmationService salesSignConfirmationService;
-    @Autowired
-    private ICSalesSignConfirmationElectronicInfoService signConfirmationElectronicInfoService;
-    @Autowired
-    private FileService fileService;
-    @Autowired
-    private ICFinancingBasicInfoService financingBasicInfoService;
-    @Autowired
-    private ICFinancingGoodsInfoService financingGoodsInfoService;
-    @Autowired
     private IPaymentApplyService paymentApplyService;
 
     @Override
@@ -111,7 +91,7 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
 
         List<PaymentConditionHis> conditionHisList = paymentConditionHisService.list(new QueryWrapper<PaymentConditionHis>()
                 .eq("payment_apply_his_id", paymentApplyHis.getId()));
-        if (CollectionUtil.isNotEmpty(conditionHisList)){
+        if (CollectionUtil.isNotEmpty(conditionHisList)) {
             for (PaymentConditionHis conditionHis : conditionHisList) {
                 List<PaymentConditionFileRefHis> conditionFileRefs = paymentConditionFileRefHisService.list(new QueryWrapper<PaymentConditionFileRefHis>()
                         .eq("payment_condition_his_id", conditionHis.getId()));
@@ -126,121 +106,6 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
             }
         }
         paymentApplyHis.setConditionList(conditionHisList);
-
-        //判断如果是苏宁资方、需要拉取合同文件
-        Boolean smbManagement = false;
-        if (reviewFinancingInfo != null && ConstantUtil.JIANGSU_SUSHANG_BANK.equals(reviewFinancingInfo.getInstitutionName())) {
-            smbManagement = true;
-            //销售合同
-            List<FileStorage> salesContractFiles = getSalesContractFile(paymentInfo.getBusinessNo());
-            paymentApplyHis.setSalesContractFileList(salesContractFiles);
-            //采购合同
-            List<FileStorage> purchContractFiles = getPurchContractFiles(paymentInfo.getBusinessNo());
-            paymentApplyHis.setPurchContractFileList(purchContractFiles);
-            //验收单
-            List<FileStorage> acceptanceFiles = getAcceptanceFile(id);
-            paymentApplyHis.setAcceptanceFileList(acceptanceFiles);
-            //代偿承诺函
-            AttachmentDto attachmentDto = AttachmentDto.builder()
-                    .setEntityId(paymentApply.getId())
-                    .setChildEnum(FileModuleDict.ChildEnum.SU_SHANG_COMPENSATION_COMMITMENT_LETTER)
-                    .build();
-            List<FileStorage> commitmentFileList = sysAttachmentRefService.getFiles(attachmentDto);
-            paymentApplyHis.setCommitmentFileList(commitmentFileList);
-        }
-        paymentApplyHis.setSmbManagement(smbManagement);
         return paymentApplyHis;
     }
-
-    /**
-     * 填充销售合同文件
-     *
-     * @param businessNo
-     */
-    private List<FileStorage> getSalesContractFile(String businessNo) {
-        List<FileStorage> salesContractFileList = new ArrayList<>();
-        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(businessNo);
-        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService.getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
-
-        //已签署的文件
-        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
-                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContractManagement.getId()).one();
-        if (salesSignConfirmation != null) {
-            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
-                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
-            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
-                signElectronicInfos.forEach(signElectronicInfo -> {
-                    salesContractFileList.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
-                });
-            }
-        } else {
-            //没有的话拉取销售合同原件
-            //合同文件
-            List<FileStorageDO> fileStorageDOList = fileService.findByBusinessId(salesContractBasicInfo.getId(), FileModuleDict.ChildEnum.SALES_CONTRACT_FILE.getCode());
-            if (CollectionUtil.isNotEmpty(fileStorageDOList)) {
-                fileStorageDOList.forEach(fileStorageDO -> {
-                    FileStorage fileStorage = new FileStorage();
-                    fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
-                    fileStorage.setName(fileStorageDO.getOriginalName());
-                    fileStorage.setPath(fileStorageDO.getPath());
-                    fileStorage.setId(fileStorageDO.getId());
-                    fileStorage.setOriginalName(fileStorageDO.getOriginalName());
-                    salesContractFileList.add(fileStorage);
-                });
-            }
-        }
-        return salesContractFileList;
-    }
-
-    /**
-     * 填充采购合同附件
-     *
-     * @param businessNo
-     */
-    private List<FileStorage> getPurchContractFiles(String businessNo) {
-        //采购合同 文件
-        PurchContractManagement purchContractManagement = purchContractService
-                .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", businessNo)
-                );
-        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
-
-        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_FILE)
-                .setEntityId(purchContractBasicInfo.getId()).build());
-
-        return purchaseContract;
-    }
-
-    /**
-     * 填充验收单签署文件
-     *
-     * @param financingBasicInfoId
-     * @return
-     */
-    private List<FileStorage> getAcceptanceFile(Long financingBasicInfoId) {
-        List<FileStorage> acceptanceFiles = new ArrayList<>();
-        CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(financingBasicInfoId);
-        if (financingBasicInfo != null) {
-            List<CFinancingGoodsInfo> financingGoodsInfoList = financingGoodsInfoService.list(new QueryWrapper<CFinancingGoodsInfo>()
-                    .select("DISTINCT acceptance_basic_info_id AS cAcceptanceBasicInfoId")
-                    .eq("c_financing_basic_info_id", financingBasicInfo.getId()));
-            if (CollectionUtil.isNotEmpty(financingGoodsInfoList)) {
-                for (CFinancingGoodsInfo goodsInfo : financingGoodsInfoList) {
-                    if (goodsInfo.getcAcceptanceBasicInfoId() != null) {
-                        //获取已签署文件
-                        AttachmentDto attachmentDto = AttachmentDto.builder()
-                                .setEntityId(goodsInfo.getcAcceptanceBasicInfoId())
-                                .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN)
-                                .build();
-                        List<FileStorage> files = sysAttachmentRefService.getFiles(attachmentDto);
-                        if (CollectionUtil.isNotEmpty(files)) {
-                            acceptanceFiles.addAll(files);
-                        }
-                    }
-                }
-            }
-        }
-        return acceptanceFiles;
-    }
 }

+ 11 - 13
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApplyServiceImpl.java

@@ -742,10 +742,10 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
                     String bizNo = createBizNo();
                     LoanApplyResp loanApplyResp = withdrawApplyBySmb(financingBasicInfo, reviewFinancingInfo, fileInfoList, bizNo);
                     //保存资方放款信息
-                    saveFinancingLoanInfo(financingBasicInfo, reviewFinancingInfo, loanApplyResp, bizNo);
+                    FinancingLoanInfo loanInfo = saveFinancingLoanInfo(financingBasicInfo, reviewFinancingInfo, loanApplyResp, bizNo);
                     if ("02".equals(loanApplyResp.getStatus())) {
                         //成功,向sop推送融资信息
-                        financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanApplyResp.getPayoutDate());
+                        financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo);
                     }
                 } else {
                     //向sop推送融资信息
@@ -899,10 +899,10 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
      *
      * @param financingBasicInfo 融资信息
      * @param management         资方名称
-     * @param payoutDate         放款日期
+     * @param loanInfo           放款信息
      */
     @Override
-    public void financingToSop(CFinancingBasicInfo financingBasicInfo, String management, String payoutDate) {
+    public void financingToSop(CFinancingBasicInfo financingBasicInfo, String management, FinancingLoanInfo loanInfo) {
         //查询sop对应的业务编号
         String getBusinessNoByTradeUrl = getBusinessNoByTrade + "?businessNumber=" + financingBasicInfo.getBusinessNumber();
         ResponseEntity<String> responseEntity = restTemplate.getForEntity(getBusinessNoByTradeUrl, String.class);
@@ -943,7 +943,7 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         List<ReviewIncomeExpenditurePlan> planList;
         if (ConstantUtil.JIANGSU_SUSHANG_BANK.equals(management)) {
             //如果是苏宁资方,重新调用还款计划试算接口获取最新的收支计划
-            Date loanDate = DateUtil.getGeneralDateYMD(payoutDate);
+            Date loanDate = DateUtil.getGeneralDateYMD(loanInfo.getPayoutDate());
             reviewFinancingInfo.setStartingDate(loanDate);
             ReviewFinancingInfoApi reviewFinancingInfoApi = autoFinancingInfoApi(reviewFinancingInfo);
             quotaDisburseReport.setReviewFinancingInfo(reviewFinancingInfoApi);
@@ -1000,12 +1000,9 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         if (ConstantUtil.JIANGSU_SUSHANG_BANK.equals(management)) {
             //如果资方是苏商银行、支用上报完成后、还需要再融资上报
             FinancingFromInvestorsNotice notice = reviewQuotaDisburseService.getFinancingFromInvestorsNotice(financingBasicInfo.getId());
-            //查询借据编号
-            FinancingLoanInfo financingLoanInfo = financingLoanInfoService.lambdaQuery().eq(FinancingLoanInfo::getcFinancingBasicInfoId, financingBasicInfo.getId())
-                    .eq(FinancingLoanInfo::getPayoutStatus, "02").one();
-            if (financingLoanInfo != null && financingLoanInfo.getDueBillNo() != null) {
+            if (loanInfo != null && loanInfo.getDueBillNo() != null) {
                 //构建再融资上报
-                RefinancingUseCreditReport useCreditReport = createUseCreditReport(businessNo, notice, financingLoanInfo);
+                RefinancingUseCreditReport useCreditReport = createUseCreditReport(businessNo, notice, loanInfo);
 
                 //再融资上报
                 ResponseEntity<String> refinancingResponseEntity = restTemplate.postForEntity(refinancingUseCreditReportUrl, useCreditReport, String.class);
@@ -1024,7 +1021,7 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
      * @param notice
      * @param financingLoanInfo
      */
-    private RefinancingUseCreditReport createUseCreditReport(String businessNo, FinancingFromInvestorsNotice notice, FinancingLoanInfo financingLoanInfo) {
+    public RefinancingUseCreditReport createUseCreditReport(String businessNo, FinancingFromInvestorsNotice notice, FinancingLoanInfo financingLoanInfo) {
         RefinancingUseCreditReport useCreditReport = new RefinancingUseCreditReport();
         //业务编号
         useCreditReport.setBusinessNo(businessNo);
@@ -1250,8 +1247,8 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
      * @param loanApplyResp
      * @param bizNo
      */
-    private void saveFinancingLoanInfo(CFinancingBasicInfo financingBasicInfo, ReviewFinancingInfo reviewFinancingInfo,
-                                       LoanApplyResp loanApplyResp, String bizNo) {
+    private FinancingLoanInfo saveFinancingLoanInfo(CFinancingBasicInfo financingBasicInfo, ReviewFinancingInfo reviewFinancingInfo,
+                                                    LoanApplyResp loanApplyResp, String bizNo) {
 
         FinancingLoanInfo loanInfo = new FinancingLoanInfo();
         loanInfo.setcFinancingBasicInfoId(financingBasicInfo.getId());
@@ -1299,6 +1296,7 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         loanInfo.setRepayAcctType(financingFromInvestors.getRepaymentAccountType());
         loanInfo.setBizNo(bizNo);
         financingLoanInfoService.save(loanInfo);
+        return loanInfo;
     }
 
     /**

+ 176 - 0
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApprovalServiceImpl.java

@@ -4,15 +4,41 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.component.util.ConstantUtil;
+import com.sunxung.factoring.dict.impl.FileModuleDict;
+import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
+import com.sunxung.factoring.entity.financing.apply.CFinancingGoodsInfo;
 import com.sunxung.factoring.entity.financing.payment.*;
+import com.sunxung.factoring.entity.financing.review.ReviewFinancingInfo;
+import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractBasicInfo;
+import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractManagement;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesContract;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesContractBasicInfo;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesSignConfirmation;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesSignConfirmationElectronicInfo;
 import com.sunxung.factoring.entity.sys.FileStorage;
+import com.sunxung.factoring.entity.sys.FileStorageDO;
 import com.sunxung.factoring.mapper.financing.payment.PaymentApprovalMapper;
+import com.sunxung.factoring.service.financing.apply.ICFinancingBasicInfoService;
+import com.sunxung.factoring.service.financing.apply.ICFinancingGoodsInfoService;
 import com.sunxung.factoring.service.financing.payment.*;
+import com.sunxung.factoring.service.financing.review.ReviewFinancingInfoService;
+import com.sunxung.factoring.service.purchcontractmanagement.PurchContractBasicInfoService;
+import com.sunxung.factoring.service.purchcontractmanagement.PurchContractService;
+import com.sunxung.factoring.service.salescontractmanagement.ICSalesContractBasicInfoService;
+import com.sunxung.factoring.service.salescontractmanagement.ICSalesSignConfirmationElectronicInfoService;
+import com.sunxung.factoring.service.salescontractmanagement.ICSalesSignConfirmationService;
+import com.sunxung.factoring.service.salescontractmanagement.SalesContractService;
+import com.sunxung.factoring.service.sys.FileService;
 import com.sunxung.factoring.service.sys.FileStorageService;
+import com.sunxung.factoring.service.sys.ISysAttachmentRefService;
+import com.sunxung.factoring.service.sys.dto.AttachmentDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -38,6 +64,32 @@ public class PaymentApprovalServiceImpl extends ServiceImpl<PaymentApprovalMappe
     private IReceivablesRegisterInfoService receivablesRegisterInfoService;
     @Autowired
     private IReceivablesRegisterFileService receivablesRegisterFileService;
+    @Autowired
+    private IPaymentApplyService paymentApplyService;
+    @Autowired
+    private IPaymentInfoService paymentInfoService;
+    @Autowired
+    private ReviewFinancingInfoService reviewFinancingInfoService;
+    @Autowired
+    private ISysAttachmentRefService sysAttachmentRefService;
+    @Autowired
+    private PurchContractService purchContractService;
+    @Autowired
+    private PurchContractBasicInfoService purchContractBasicInfoService;
+    @Autowired
+    private SalesContractService salesContractService;
+    @Autowired
+    private ICSalesContractBasicInfoService salesContractBasicInfoService;
+    @Autowired
+    private ICSalesSignConfirmationService salesSignConfirmationService;
+    @Autowired
+    private ICSalesSignConfirmationElectronicInfoService signConfirmationElectronicInfoService;
+    @Autowired
+    private FileService fileService;
+    @Autowired
+    private ICFinancingBasicInfoService financingBasicInfoService;
+    @Autowired
+    private ICFinancingGoodsInfoService financingGoodsInfoService;
 
     @Override
     public PaymentApproval getView(Long id) {
@@ -45,6 +97,14 @@ public class PaymentApprovalServiceImpl extends ServiceImpl<PaymentApprovalMappe
         if (paymentApproval == null) {
             throw new BusinessException(CodeUtil.FAIL, "获取不到对应的付款审批信息");
         }
+        PaymentApply paymentApply = paymentApplyService.getById(paymentApproval.getPaymentApplyId());
+        if (paymentApply == null) {
+            throw new ValidatorException(CodeUtil.FAIL, "查询不到对应的付款申请信息!");
+        }
+        PaymentInfo paymentInfo = paymentInfoService.getById(paymentApply.getPaymentInfoId());
+        if (paymentInfo == null) {
+            throw new ValidatorException(CodeUtil.FAIL, "查询不到对应的付款信息!");
+        }
 
         //应收账款登记信息
         ReceivablesRegisterInfo receivablesRegisterInfo = receivablesRegisterInfoService.getOne(new QueryWrapper<ReceivablesRegisterInfo>()
@@ -96,6 +156,122 @@ public class PaymentApprovalServiceImpl extends ServiceImpl<PaymentApprovalMappe
         }
         paymentApproval.setPaymentConditionList(paymentConditionList);
 
+        ReviewFinancingInfo reviewFinancingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
+                .eq("review_quota_disburse_id", paymentInfo.getQuotaDisburseId()));
+        //判断如果是苏宁资方、需要拉取合同文件
+        Boolean smbManagement = false;
+        if (reviewFinancingInfo != null && ConstantUtil.JIANGSU_SUSHANG_BANK.equals(reviewFinancingInfo.getInstitutionName())) {
+            smbManagement = true;
+            //销售合同
+            List<FileStorage> salesContractFiles = getSalesContractFile(paymentInfo.getBusinessNo());
+            paymentApproval.setSalesContractFileList(salesContractFiles);
+            //采购合同
+            List<FileStorage> purchContractFiles = getPurchContractFiles(paymentInfo.getBusinessNo());
+            paymentApproval.setPurchContractFileList(purchContractFiles);
+            //验收单
+            List<FileStorage> acceptanceFiles = getAcceptanceFile(paymentInfo.getFinancingBasicInfoId());
+            paymentApproval.setAcceptanceFileList(acceptanceFiles);
+            //代偿承诺函
+            AttachmentDto attachmentDto = AttachmentDto.builder()
+                    .setEntityId(paymentApply.getId())
+                    .setChildEnum(FileModuleDict.ChildEnum.SU_SHANG_COMPENSATION_COMMITMENT_LETTER)
+                    .build();
+            List<FileStorage> commitmentFileList = sysAttachmentRefService.getFiles(attachmentDto);
+            paymentApproval.setCommitmentFileList(commitmentFileList);
+        }
+        paymentApproval.setSmbManagement(smbManagement);
         return paymentApproval;
     }
+
+    /**
+     * 填充销售合同文件
+     *
+     * @param businessNo
+     */
+    private List<FileStorage> getSalesContractFile(String businessNo) {
+        List<FileStorage> salesContractFileList = new ArrayList<>();
+        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(businessNo);
+        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService.getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
+
+        //已签署的文件
+        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContractManagement.getId()).one();
+        if (salesSignConfirmation != null) {
+            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
+                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
+            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
+                signElectronicInfos.forEach(signElectronicInfo -> {
+                    salesContractFileList.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
+                });
+            }
+        } else {
+            //没有的话拉取销售合同原件
+            //合同文件
+            List<FileStorageDO> fileStorageDOList = fileService.findByBusinessId(salesContractBasicInfo.getId(), FileModuleDict.ChildEnum.SALES_CONTRACT_FILE.getCode());
+            if (CollectionUtil.isNotEmpty(fileStorageDOList)) {
+                fileStorageDOList.forEach(fileStorageDO -> {
+                    FileStorage fileStorage = new FileStorage();
+                    fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
+                    fileStorage.setName(fileStorageDO.getOriginalName());
+                    fileStorage.setPath(fileStorageDO.getPath());
+                    fileStorage.setId(fileStorageDO.getId());
+                    fileStorage.setOriginalName(fileStorageDO.getOriginalName());
+                    salesContractFileList.add(fileStorage);
+                });
+            }
+        }
+        return salesContractFileList;
+    }
+
+    /**
+     * 填充采购合同附件
+     *
+     * @param businessNo
+     */
+    private List<FileStorage> getPurchContractFiles(String businessNo) {
+        //采购合同 文件
+        PurchContractManagement purchContractManagement = purchContractService
+                .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", businessNo)
+                );
+        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
+
+        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_FILE)
+                .setEntityId(purchContractBasicInfo.getId()).build());
+
+        return purchaseContract;
+    }
+
+    /**
+     * 填充验收单签署文件
+     *
+     * @param financingBasicInfoId
+     * @return
+     */
+    private List<FileStorage> getAcceptanceFile(Long financingBasicInfoId) {
+        List<FileStorage> acceptanceFiles = new ArrayList<>();
+        CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(financingBasicInfoId);
+        if (financingBasicInfo != null) {
+            List<CFinancingGoodsInfo> financingGoodsInfoList = financingGoodsInfoService.list(new QueryWrapper<CFinancingGoodsInfo>()
+                    .select("DISTINCT acceptance_basic_info_id AS cAcceptanceBasicInfoId")
+                    .eq("c_financing_basic_info_id", financingBasicInfo.getId()));
+            if (CollectionUtil.isNotEmpty(financingGoodsInfoList)) {
+                for (CFinancingGoodsInfo goodsInfo : financingGoodsInfoList) {
+                    if (goodsInfo.getcAcceptanceBasicInfoId() != null) {
+                        //获取已签署文件
+                        AttachmentDto attachmentDto = AttachmentDto.builder()
+                                .setEntityId(goodsInfo.getcAcceptanceBasicInfoId())
+                                .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN)
+                                .build();
+                        List<FileStorage> files = sysAttachmentRefService.getFiles(attachmentDto);
+                        if (CollectionUtil.isNotEmpty(files)) {
+                            acceptanceFiles.addAll(files);
+                        }
+                    }
+                }
+            }
+        }
+        return acceptanceFiles;
+    }
 }

+ 7 - 0
src/main/java/com/sunxung/factoring/service/smb/IFinancingLoanInfoService.java

@@ -49,4 +49,11 @@ public interface IFinancingLoanInfoService extends IService<FinancingLoanInfo> {
      * @param id
      */
     void loanApplyAgain(Long id);
+
+    /**
+     * 重新发起再融资支用上报
+     *
+     * @param id
+     */
+    void refinancingReport(Long id);
 }

+ 49 - 4
src/main/java/com/sunxung/factoring/service/smb/impl/FinancingLoanInfoServiceImpl.java

@@ -1,6 +1,8 @@
 package com.sunxung.factoring.service.smb.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
@@ -13,6 +15,7 @@ import com.sunxung.factoring.component.util.ConstantConversionUtil;
 import com.sunxung.factoring.component.util.ConstantUtil;
 import com.sunxung.factoring.component.util.ThreadLocalUtil;
 import com.sunxung.factoring.entity.GridPage;
+import com.sunxung.factoring.entity.ResponseJson;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.financing.apply.CFinancingAccountsReceivableInfo;
 import com.sunxung.factoring.entity.financing.apply.CFinancingApplicantInfo;
@@ -20,6 +23,7 @@ import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
 import com.sunxung.factoring.entity.financing.review.ReviewFinancingInfo;
 import com.sunxung.factoring.entity.financing.review.ReviewMasterContract;
 import com.sunxung.factoring.entity.financing.review.ReviewQuotaDisburse;
+import com.sunxung.factoring.entity.financing.sop.RefinancingUseCreditReport;
 import com.sunxung.factoring.entity.smb.FinancingFromInvestors;
 import com.sunxung.factoring.entity.smb.FinancingFromInvestorsHistory;
 import com.sunxung.factoring.entity.smb.FinancingFromInvestorsNotice;
@@ -49,8 +53,12 @@ import com.sunxung.factoring.service.sys.RoleService;
 import com.sunxung.factoring.service.sys.UserService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
@@ -96,6 +104,12 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
     private RoleService roleService;
     @Autowired
     private PermissionService permissionService;
+    @Autowired
+    private RestTemplate restTemplate;
+    @Value("${sop.getBusinessNoByTrade}")
+    private String getBusinessNoByTrade;
+    @Value("${sop.refinancingUseCreditReportUrl}")
+    private String refinancingUseCreditReportUrl;
 
     @Override
     public GridPage<FinancingLoanInfo> findBySearch(FinancingLoanInfoSearch search) {
@@ -198,7 +212,7 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
                 if (loanInfo.getcFinancingBasicInfoId() != null) {
                     CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(loanInfo.getcFinancingBasicInfoId());
                     if (financingBasicInfo != null) {
-                        paymentApplyService.financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo.getPayoutDate());
+                        paymentApplyService.financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo);
                     }
                 }
             }
@@ -321,10 +335,40 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
             String openId = financingFromInvestors.getOpenId();
             LoanApplyResp loanApplyResp = smbApiService.loanApply(loanApplyReq, loanCreditRiskMsg, openId);
             if (loanApplyResp != null) {
-                saveFinancingLoanInfo(financingBasicInfo, loanApplyResp, bizNo);
+                FinancingLoanInfo info = saveFinancingLoanInfo(financingBasicInfo, loanApplyResp, bizNo);
                 if ("02".equals(loanApplyResp.getStatus())) {
                     //成功,向sop推送融资信息
-                    paymentApplyService.financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanApplyResp.getPayoutDate());
+                    paymentApplyService.financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, info);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void refinancingReport(Long id) {
+        FinancingLoanInfo financingLoanInfo = getById(id);
+
+        CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(financingLoanInfo.getcFinancingBasicInfoId());
+        FinancingFromInvestorsNotice notice = reviewQuotaDisburseService.getFinancingFromInvestorsNotice(financingLoanInfo.getcFinancingBasicInfoId());
+        if (financingLoanInfo != null && financingLoanInfo.getDueBillNo() != null && notice != null) {
+            //查询sop对应的业务编号
+            String getBusinessNoByTradeUrl = getBusinessNoByTrade + "?businessNumber=" + financingBasicInfo.getBusinessNumber();
+            ResponseEntity<String> responseEntity = restTemplate.getForEntity(getBusinessNoByTradeUrl, String.class);
+            ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
+            if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
+                throw new BusinessException(CodeUtil.FAIL, "查询sop对应的业务编号失败:" + responseJson.getMsg());
+            }
+            JSONObject jsonObject = (JSONObject) responseJson.getData();
+            String businessNo = jsonObject.getStr("businessNo");
+
+            if (financingLoanInfo != null && financingLoanInfo.getDueBillNo() != null) {
+                //构建再融资上报
+                RefinancingUseCreditReport useCreditReport = paymentApplyService.createUseCreditReport(businessNo, notice, financingLoanInfo);
+                //再融资上报
+                ResponseEntity<String> refinancingResponseEntity = restTemplate.postForEntity(refinancingUseCreditReportUrl, useCreditReport, String.class);
+                ResponseJson refinancingResponseJson = JSONUtil.toBean(refinancingResponseEntity.getBody(), ResponseJson.class);
+                if (refinancingResponseEntity.getStatusCode().value() != HttpStatus.OK.value() || !refinancingResponseJson.isSuccess()) {
+                    throw new BusinessException(CodeUtil.FAIL, "再融资支用上报失败:" + refinancingResponseJson.getMsg());
                 }
             }
         }
@@ -337,7 +381,7 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
      * @param loanApplyResp
      * @param bizNo
      */
-    private void saveFinancingLoanInfo(CFinancingBasicInfo financingBasicInfo, LoanApplyResp loanApplyResp, String bizNo) {
+    private FinancingLoanInfo saveFinancingLoanInfo(CFinancingBasicInfo financingBasicInfo, LoanApplyResp loanApplyResp, String bizNo) {
         FinancingLoanInfo loanInfo = new FinancingLoanInfo();
         loanInfo.setcFinancingBasicInfoId(financingBasicInfo.getId());
         ReviewQuotaDisburse reviewQuotaDisburse = reviewQuotaDisburseService.getOne(new QueryWrapper<ReviewQuotaDisburse>()
@@ -388,5 +432,6 @@ public class FinancingLoanInfoServiceImpl extends ServiceImpl<FinancingLoanInfoM
         loanInfo.setRepayAcctType(financingFromInvestors.getRepaymentAccountType());
         loanInfo.setBizNo(bizNo);
         this.save(loanInfo);
+        return loanInfo;
     }
 }

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

@@ -49,7 +49,7 @@ public class SMBNoticeInit {
                             if (loanInfo.getcFinancingBasicInfoId() != null) {
                                 CFinancingBasicInfo financingBasicInfo = getFinancingBasicInfoService().getById(loanInfo.getcFinancingBasicInfoId());
                                 if (financingBasicInfo != null) {
-                                    getPaymentApplyService().financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo.getPayoutDate());
+                                    getPaymentApplyService().financingToSop(financingBasicInfo, ConstantUtil.JIANGSU_SUSHANG_BANK, loanInfo);
                                 }
                             }
                         }

+ 10 - 0
src/main/java/com/sunxung/factoring/web/smb/FinancingLoanInfoController.java

@@ -63,4 +63,14 @@ public class FinancingLoanInfoController {
         return new ResponseJson<>("放款申请成功");
     }
 
+    /**
+     * 重新发起再融资支用上报
+     * @param
+     * @return
+     */
+    @GetMapping("/refinancingReport")
+    public ResponseJson refinancingReport(Long id){
+        financingLoanInfoService.refinancingReport(id);
+        return new ResponseJson<>("再融资支用上报成功");
+    }
 }

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

@@ -79,7 +79,9 @@ VALUES ( (select t.id from t_permission t where t.ename = 'CapitalLoanMoney'), '
 INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`, `user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
 VALUES ( (select t.id from t_permission t where t.ename = 'CapitalLoanMoney'), 'button', '重新发起 ', 'loanApplyAgain', 2, '资方融资管理', null, NULL, NULL, NULL, now(), now());
 INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`, `user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
-VALUES ( (select t.id from t_permission t where t.ename = 'CapitalLoanMoney'), 'button', '数据全员可见 ', 'viewAllFinancingLoanInfo', 3, '资方融资管理', null, NULL, NULL, NULL, now(), now());
+VALUES ( (select t.id from t_permission t where t.ename = 'CapitalLoanMoney'), 'button', '数据全员可见 ', 'viewAllFinancingLoanInfo', 4, '资方融资管理', null, NULL, NULL, NULL, now(), now());
+INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`, `user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
+VALUES ( (select t.id from t_permission t where t.ename = 'CapitalLoanMoney'), 'button', '重新发起再融资上报 ', 'reRefinancingReport', 3, '资方融资管理', null, NULL, NULL, NULL, now(), now());
 
 INSERT INTO `t_dictionary` ( `name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
 VALUES ('苏商银行主合同文件', 1349, 'sushangFirstContrat', NULL, 3, '2024-02-07 14:54:49', '2024-02-07 14:54:49');