From 70a56e3ba7596074f11d6b8f406aae0b61ab0152 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 06 一月 2026 18:03:14 +0800
Subject: [PATCH] yys  修改附件问题

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 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..e408631 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -82,6 +82,7 @@
     private final InvoiceLedgerMapper invoiceLedgerMapper;
 
     private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+    private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
 
     @Autowired
     private SysDeptMapper sysDeptMapper;
@@ -361,6 +362,15 @@
         LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>()
                 .in(SalesLedgerScheduling::getSalesLedgerId, idList);
         salesLedgerSchedulingMapper.delete(in);
+        LambdaQueryWrapper<InvoiceRegistrationProduct> InvoiceRegistrationProductWrapper = new LambdaQueryWrapper<>();
+        InvoiceRegistrationProductWrapper.in(InvoiceRegistrationProduct::getSalesLedgerId, idList);
+        List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(InvoiceRegistrationProductWrapper);
+        if (!CollectionUtils.isEmpty(invoiceRegistrationProducts)) {
+            List<Integer> InvoiceRegistrationProductIds = invoiceRegistrationProducts.stream().map(InvoiceRegistrationProduct::getId).collect(Collectors.toList());
+            LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
+            invoiceLedgerQuery.in(InvoiceLedger::getInvoiceRegistrationProductId, InvoiceRegistrationProductIds);
+            invoiceLedgerMapper.delete(invoiceLedgerQuery);
+        }
         // 2. 鍐嶅垹闄や富琛ㄦ暟鎹�
         return salesLedgerMapper.deleteBatchIds(idList);
     }
@@ -399,17 +409,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. 澶勭悊瀛愯〃鏁版嵁

--
Gitblit v1.9.3