From 6bbed1ea6b36af4eb0b234bec9d6e42d56f0cd00 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 30 九月 2026 16:12:49 +0800
Subject: [PATCH] feat:合同新增关联单位 开票可根据甲方或关联单位选择开票单位 收款去掉强制确认 收款只关联合同甲方或关联单位
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java | 60 ++++++++++++++++++++++++++++--------------------------------
1 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
index 7443d48..7579123 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
@@ -58,6 +58,9 @@
@Value("${dept.smjzt}")
private String smjzt;
+ @Value("${dept.smjhw}")
+ private String smjhw;
+
@Value("${dept.sgb}")
private String sgb;
@@ -111,7 +114,8 @@
addDTO.getSubjectMatterList().stream().forEach(outSubjectMatterAddDTO -> {
OutBound outBound = BeanUtil.copyProperties(outSubjectMatterAddDTO, OutBound.class);
if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) ||
- StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)) {
+ StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)||
+ StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) {
outBound.setBatchNumber(generateSMJContractCKNo());
}
if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", sgb)) {
@@ -337,18 +341,6 @@
// beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
// scheduleMapper.updateById(beforeSchedule);
// }
- //鏇存柊灞ョ害
- ContractPaymentScheduleProcess contractPaymentScheduleProcess = new ContractPaymentScheduleProcess();
- contractPaymentScheduleProcess.setContractId(schedule.getContractId());
- contractPaymentScheduleProcess.setContractName(schedule.getContractName());
- contractPaymentScheduleProcess.setScheduleId(schedule.getId());
- contractPaymentScheduleProcess.setScheduleName(schedule.getStageName());
- contractPaymentScheduleProcess.setProcessDate(addDTO.getOutBoundTime());
- ContractPaymentScheduleProcess lastProcess = scheduleProcessMapper.selectOne(Wrappers.<ContractPaymentScheduleProcess>lambdaQuery().eq(ContractPaymentScheduleProcess::getContractId, schedule.getContractId())
- .eq(ContractPaymentScheduleProcess::getScheduleId, schedule.getId()).last("limit 1"));
- if (ObjUtil.isNull(lastProcess)) {
- scheduleProcessMapper.insert(contractPaymentScheduleProcess);
- }
}
//鏌ヨ鏄惁鏈夊悗缁樁娈�
@@ -473,54 +465,58 @@
public R addContractOut(OutBoundAddDTO addDTO) {
//鏍¢獙鍙傛暟
R<Contract> r = vailParam(addDTO);
- if (!r.isOk()){
+ if (!r.isOk()) {
return r;
}
Contract contract = r.getData();
+ String batchNumber = genBatchNumber();
//鍑哄簱
- handleOutBound(contract,addDTO);
+ handleOutBound(batchNumber,contract, addDTO);
+
//淇濆瓨璧勯噾鏄庣粏
- BigDecimal outBoundAmount = savePaymentConfirm(contract,addDTO);
+ BigDecimal outBoundAmount = savePaymentConfirm(contract, addDTO);
//鏇存柊鍚堝悓鐘舵�佸強闃舵
contract.setOutBoundAmout(outBoundAmount);
updateContractSchedule(contract);
- return R.ok();
+ return R.ok(batchNumber);
}
private void updateContractSchedule(Contract contract) {
List<ContractSubjectMatter> unComOutList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery()
.eq(ContractSubjectMatter::getContractId, contract.getId())
.ne(ContractSubjectMatter::getDeliveryStatus, 2));
- if (CollUtil.isEmpty(unComOutList)){
+ if (CollUtil.isEmpty(unComOutList)) {
contract.setNextScheduleName("璐у埌绛炬敹");
}
contract.setBillingStatus("2");
contractMapper.updateById(contract);
}
- private BigDecimal savePaymentConfirm(Contract contract,OutBoundAddDTO addDTO) {
+ private BigDecimal savePaymentConfirm(Contract contract, OutBoundAddDTO addDTO) {
//鏌ヨ鍚堝悓鏄惁鏈夊嚭搴撻樁娈�
ContractPaymentSchedule schedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId())
- .eq(ContractPaymentSchedule::getStageName, "鍙戣揣鍓�").gt(ContractPaymentSchedule::getPaymentRatio,0).last("limit 1"));
- if (ObjUtil.isNull(schedule.getEffectiveDate())&&ObjUtil.isNull(schedule.getEffectiveEndDate())){
+ .eq(ContractPaymentSchedule::getStageName, "鍙戣揣鍓�").last("limit 1"));
+ if (ObjUtil.isNull(schedule.getEffectiveDate()) && ObjUtil.isNull(schedule.getEffectiveEndDate())) {
schedule.setEffectiveDate(addDTO.getOutBoundTime());
- schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(),schedule.getAgreedDays()));
+ schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
scheduleMapper.updateById(schedule);
}
+ //灞ョ害鍑犵巼
+ processService.saveScheduleProcess(addDTO.getOutBoundTime(),schedule);
- BigDecimal outAmount = new BigDecimal("0");
//璁$畻鍑哄簱浠锋牸
+ BigDecimal outAmount = new BigDecimal("0");
for (OutSubjectMatterAddDTO outSubjectMatterAddDTO : addDTO.getSubjectMatterList()) {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
.eq(ContractSubjectMatter::getContractId, contract.getId())
.eq(ContractSubjectMatter::getMaterialCode, outSubjectMatterAddDTO.getSubjectMatterCode())
- .eq(StrUtil.isNotBlank(outSubjectMatterAddDTO.getLineNo()),ContractSubjectMatter::getLineNo, outSubjectMatterAddDTO.getLineNo())
+ .eq(StrUtil.isNotBlank(outSubjectMatterAddDTO.getLineNo()), ContractSubjectMatter::getLineNo, outSubjectMatterAddDTO.getLineNo())
.last("limit 1"));
outAmount = outAmount.add(outSubjectMatterAddDTO.getOutBoundNum().multiply(subjectMatter.getUnitPrice()));
}
//瀛樺湪鍙戣揣鍓嶆敹娆鹃樁娈�
- if (ObjUtil.isNotNull(schedule)) {
+ if (schedule.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) {
//鏂板褰撳墠闃舵搴旀敹
PaymentConfirm currentConfim = new PaymentConfirm();
currentConfim.setBusinessType(schedule.getStageName() + "搴旀敹");
@@ -533,7 +529,7 @@
currentConfim.setScheduleName(schedule.getStageName());
currentConfim.setConfirmTime(addDTO.getOutBoundTime());
//鎸夊嚭搴撴瘮渚嬭绠楀簲鏀�
- currentConfim.setTransationAmount(schedule.getPlannedAmount().multiply(outAmount.divide(contract.getAmount(),2,RoundingMode.HALF_UP)));
+ currentConfim.setTransationAmount(schedule.getPlannedAmount().multiply(outAmount.divide(contract.getAmount(), 2, RoundingMode.HALF_UP)));
currentConfim.setReceivableAmount(currentConfim.getTransationAmount());
PaymentConfirm lastConfirm = paymentConfirmMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId())
.orderByDesc(PaymentConfirm::getCreateTime).last("limit 1"));
@@ -547,12 +543,12 @@
currentConfim.setTotalAmount(currentConfim.getTransationAmount().multiply(new BigDecimal("-1")));
paymentConfirmMapper.insert(currentConfim);
//鍘嗗彶璧勯噾浣欓
- processService.handleBeforeRemain(currentConfim,contract);
+ processService.handleBeforeRemain(currentConfim, contract);
}
return outAmount;
}
- private void handleOutBound(Contract contract, OutBoundAddDTO addDTO) {
+ private void handleOutBound(String batchNumber,Contract contract, OutBoundAddDTO addDTO) {
addDTO.getSubjectMatterList().stream().forEach(outSubjectMatterAddDTO -> {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
.eq(ContractSubjectMatter::getContractId, contract.getId())
@@ -580,8 +576,7 @@
subjectMatter.setActualDeliveryDate(addDTO.getOutBoundTime());
contractSubjectMatterMapper.updateById(subjectMatter);
//淇濆瓨erp鍑哄簱
- String batchNumber = genBatchNumber();
- Long outBoundId = saveErpOutBound(contract,addDTO,outSubjectMatterAddDTO,batchNumber);
+ Long outBoundId = saveErpOutBound(contract, addDTO, outSubjectMatterAddDTO, batchNumber);
//淇濆瓨鍚堝悓鍑哄簱璁板綍
saveContractOutBound(contract, addDTO, subjectMatter, outBoundId);
});
@@ -589,7 +584,8 @@
private String genBatchNumber() {
if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) ||
- StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)) {
+ StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)||
+ StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) {
return generateSMJContractCKNo();
}
if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", sgb)) {
@@ -607,7 +603,7 @@
return "";
}
- private Long saveErpOutBound(Contract contract, OutBoundAddDTO addDTO,OutSubjectMatterAddDTO outSubjectMatterAddDTO,String batchNumber) {
+ private Long saveErpOutBound(Contract contract, OutBoundAddDTO addDTO, OutSubjectMatterAddDTO outSubjectMatterAddDTO, String batchNumber) {
OutBound outBound = new OutBound();
outBound.setBatchNumber(batchNumber);
outBound.setOutBoundNum(outSubjectMatterAddDTO.getOutBoundNum());
--
Gitblit v1.9.1