From c58c05fa307754061c9264758eff668105f89625 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 09 三月 2026 14:14:41 +0800
Subject: [PATCH] yys 商机管理优化
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 0cbe9d1..49b7a7d 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -83,6 +83,10 @@
private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+ private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+
+ private final InvoiceRegistrationMapper invoiceRegistrationMapper;
+
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -124,7 +128,8 @@
// 3.鏌ヨ涓婁紶鏂囦欢
LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
- salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId());
+ salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId())
+ .eq(CommonFile::getType, FileNameType.SALE.getValue());
List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
// 4. 杞崲 DTO
@@ -347,6 +352,13 @@
if (CollectionUtils.isEmpty(idList)) {
return 0;
}
+ // 鍒ゆ柇鏄惁鏈夊紑绁ㄨ褰�
+ LambdaQueryWrapper<InvoiceRegistrationProduct> invoiceLedgerQuery = new LambdaQueryWrapper<>();
+ invoiceLedgerQuery.in(InvoiceRegistrationProduct::getSalesLedgerId, idList);
+ List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(invoiceLedgerQuery);
+ if (CollectionUtils.isNotEmpty(invoiceRegistrationProducts)) {
+ throw new BaseException("鏈夊紑绁ㄨ褰曪紝涓嶅彲鍒犻櫎");
+ }
// 鐢熶骇璁㈠崟鏈夊緟鎺掍骇鏁版嵁锛屽彴璐︿笉鍙垹闄�
LambdaQueryWrapper<SalesLedgerScheduling> salesLedgerSchedulingLambdaQueryWrapper = new LambdaQueryWrapper<SalesLedgerScheduling>()
.in(SalesLedgerScheduling::getSalesLedgerId, idList);
@@ -355,7 +367,8 @@
}
// 1. 鍏堝垹闄ゅ瓙琛ㄦ暟鎹�
LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
- productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList);
+ productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList)
+ .eq(SalesLedgerProduct::getType,1);
salesLedgerProductMapper.delete(productWrapper);
// 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>()
@@ -399,17 +412,19 @@
} else {
salesLedgerMapper.updateById(salesLedger);
SalesLedger salesLedgerDB = salesLedgerMapper.selectById(salesLedger.getId());
- AccountIncome accountIncomeDB = accountIncomeService.getByInvoiceNumber(salesLedger.getSalesContractNo());
- if (ObjectUtils.isEmpty(accountIncomeDB)) {
- throw new BaseException("鏀跺叆绠$悊鏃犺閿�鍞悎鍚岀殑鏀跺叆璁板綍");
+ List<AccountIncome> accountIncomeDBs = accountIncomeService.getByInvoiceNumberList(salesLedger.getSalesContractNo());
+ if (!CollectionUtils.isEmpty(accountIncomeDBs)) {
+ accountIncomeDBs.forEach(accountIncomeDB ->{
+ accountIncomeDB.setCustomerName(salesLedgerDB.getCustomerName());
+ accountIncomeDB.setIncomeMoney(salesLedgerDB.getContractAmount());
+ accountIncomeDB.setIncomeDescribed("閿�鍞悎鍚岋細" + salesLedgerDB.getSalesContractNo());
+ accountIncomeDB.setInvoiceNumber(salesLedgerDB.getSalesContractNo());
+ accountIncomeDB.setInputTime(new Date());
+ accountIncomeDB.setInputUser(salesLedgerDB.getEntryPerson());
+ accountIncomeService.updateById(accountIncomeDB);
+ });
}
- accountIncomeDB.setCustomerName(salesLedgerDB.getCustomerName());
- accountIncomeDB.setIncomeMoney(salesLedgerDB.getContractAmount());
- accountIncomeDB.setIncomeDescribed("閿�鍞悎鍚岋細" + salesLedgerDB.getSalesContractNo());
- accountIncomeDB.setInvoiceNumber(salesLedgerDB.getSalesContractNo());
- accountIncomeDB.setInputTime(new Date());
- accountIncomeDB.setInputUser(salesLedgerDB.getEntryPerson());
- accountIncomeService.updateById(accountIncomeDB);
+
}
// 4. 澶勭悊瀛愯〃鏁版嵁
@@ -478,13 +493,6 @@
Path formalFilePath = formalDirPath.resolve(formalFilename);
try {
- // 鎵ц鏂囦欢杩佺Щ锛堜娇鐢ㄥ師瀛愭搷浣滅‘淇濆畨鍏ㄦ�э級
-// Files.move(
-// Paths.get(tempFile.getTempPath()),
-// formalFilePath,
-// StandardCopyOption.REPLACE_EXISTING,
-// StandardCopyOption.ATOMIC_MOVE
-// );
// 鍘熷瓙绉诲姩澶辫触锛屼娇鐢ㄥ鍒�+鍒犻櫎
Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
--
Gitblit v1.9.3