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 |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 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 8b4f6ff..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>()

--
Gitblit v1.9.3