|
@@ -5,22 +5,40 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.sunxung.factoring.component.exception.ValidatorException;
|
|
import com.sunxung.factoring.component.exception.ValidatorException;
|
|
import com.sunxung.factoring.component.util.CodeUtil;
|
|
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.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.FileStorage;
|
|
|
|
+import com.sunxung.factoring.entity.sys.FileStorageDO;
|
|
import com.sunxung.factoring.mapper.financing.payment.PaymentApplyHisMapper;
|
|
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.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.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.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -44,6 +62,28 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
|
|
private ReviewFinancingInfoService reviewFinancingInfoService;
|
|
private ReviewFinancingInfoService reviewFinancingInfoService;
|
|
@Autowired
|
|
@Autowired
|
|
private FileStorageService fileStorageService;
|
|
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
|
|
@Override
|
|
public PaymentApplyHis getView(Long id) {
|
|
public PaymentApplyHis getView(Long id) {
|
|
@@ -56,7 +96,10 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
|
|
if (paymentInfo == null) {
|
|
if (paymentInfo == null) {
|
|
throw new ValidatorException(CodeUtil.FAIL, "查询不到对应的付款信息!");
|
|
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>()
|
|
ReviewFinancingInfo reviewFinancingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
|
|
.eq("review_quota_disburse_id", paymentInfo.getQuotaDisburseId()));
|
|
.eq("review_quota_disburse_id", paymentInfo.getQuotaDisburseId()));
|
|
if (reviewFinancingInfo != null) {
|
|
if (reviewFinancingInfo != null) {
|
|
@@ -83,6 +126,121 @@ public class PaymentApplyHisServiceImpl extends ServiceImpl<PaymentApplyHisMappe
|
|
}
|
|
}
|
|
}
|
|
}
|
|
paymentApplyHis.setConditionList(conditionHisList);
|
|
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;
|
|
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;
|
|
|
|
+ }
|
|
}
|
|
}
|