ソースを参照

付款审核历史页修改

liuj 1 ヶ月 前
コミット
bb448ad713

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

@@ -3,6 +3,7 @@ package com.sunxung.factoring.entity.financing.payment;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.sunxung.factoring.entity.BaseEntity;
+import com.sunxung.factoring.entity.sys.FileStorage;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -93,6 +94,36 @@ 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;
     }
@@ -204,4 +235,44 @@ 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;
+    }
 }

+ 167 - 9
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApplyHisServiceImpl.java

@@ -5,22 +5,40 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.CodeUtil;
-import com.sunxung.factoring.entity.financing.payment.PaymentApplyHis;
-import com.sunxung.factoring.entity.financing.payment.PaymentConditionFileRefHis;
-import com.sunxung.factoring.entity.financing.payment.PaymentConditionHis;
-import com.sunxung.factoring.entity.financing.payment.PaymentInfo;
+import com.sunxung.factoring.component.util.ConstantUtil;
+import com.sunxung.factoring.component.util.ElectronicSignatureUtil;
+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.PaymentApplyHisMapper;
-import com.sunxung.factoring.service.financing.payment.IPaymentApplyHisService;
-import com.sunxung.factoring.service.financing.payment.IPaymentConditionFileRefHisService;
-import com.sunxung.factoring.service.financing.payment.IPaymentConditionHisService;
-import com.sunxung.factoring.service.financing.payment.IPaymentInfoService;
+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.io.File;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
@@ -44,6 +62,28 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
     private ReviewFinancingInfoService reviewFinancingInfoService;
     @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
     public PaymentApplyHis getView(Long id) {
@@ -56,7 +96,10 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
         if (paymentInfo == null) {
             throw new ValidatorException(CodeUtil.FAIL, "查询不到对应的付款信息!");
         }
-
+        PaymentApply paymentApply = paymentApplyService.getOne(new QueryWrapper<PaymentApply>().eq("payment_info_id", paymentInfo.getId()));
+        if (paymentApply == null) {
+            throw new ValidatorException(CodeUtil.FAIL, "查询不到对应的付款申请信息!");
+        }
         ReviewFinancingInfo reviewFinancingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
                 .eq("review_quota_disburse_id", paymentInfo.getQuotaDisburseId()));
         if (reviewFinancingInfo != null) {
@@ -83,6 +126,121 @@ 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;
+    }
 }