|
@@ -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;
|
|
|
+ }
|
|
|
}
|