From 6847fa93b9ecaec32da3763cb1da844bea1681dd Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 25 六月 2026 14:38:06 +0800
Subject: [PATCH] fix: 1.发货车牌号展示多个 2.销售客户往来合同金额改成退货后金额

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java |   25 ++++++++++++++++++-------
 src/main/resources/mapper/basic/CustomerMapper.xml                            |    2 +-
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index b8042d8..92c44c3 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -98,16 +98,27 @@
         List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct);
         if(!CollectionUtils.isEmpty(salesLedgerProducts)){
             salesLedgerProducts.forEach(item -> {
-                // 鍙戣揣淇℃伅
-                ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+                // 鍙戣揣淇℃伅锛堝彇鏈�鏂颁竴鏉★級
+                ShippingInfo latestShippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
                         .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
                         .orderByDesc(ShippingInfo::getCreateTime)
                         .last("limit 1"));
-                if(shippingInfo != null){
-                    item.setShippingDate(shippingInfo.getShippingDate());
-                    item.setShippingCarNumber(shippingInfo.getShippingCarNumber());
-                    item.setExpressCompany(shippingInfo.getExpressCompany());
-                    item.setExpressNumber(shippingInfo.getExpressNumber());
+                if(latestShippingInfo != null){
+                    item.setShippingDate(latestShippingInfo.getShippingDate());
+                    item.setExpressCompany(latestShippingInfo.getExpressCompany());
+                    item.setExpressNumber(latestShippingInfo.getExpressNumber());
+                }
+                // 杞︾墝鍙凤細鍙栨墍鏈夊彂璐ц褰曠殑杞︾墝鍙凤紝閫楀彿鎷兼帴
+                List<ShippingInfo> allShippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
+                        .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
+                        .orderByAsc(ShippingInfo::getCreateTime));
+                if(!CollectionUtils.isEmpty(allShippingInfos)){
+                    String carNumbers = allShippingInfos.stream()
+                            .map(ShippingInfo::getShippingCarNumber)
+                            .filter(carNo -> carNo != null && !carNo.trim().isEmpty())
+                            .distinct()
+                            .collect(Collectors.joining(","));
+                    item.setShippingCarNumber(carNumbers);
                 }
             });
         }
diff --git a/src/main/resources/mapper/basic/CustomerMapper.xml b/src/main/resources/mapper/basic/CustomerMapper.xml
index f001387..442173e 100644
--- a/src/main/resources/mapper/basic/CustomerMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerMapper.xml
@@ -167,7 +167,7 @@
         select sl.id salesLedgerId,
                sl.sales_contract_no,
                sl.execution_date,
-               sl.contract_amount,
+               sl.contract_amount - IFNULL(T3.returnAmount, 0) AS contract_amount,
                IFNULL(T1.receiptPaymentAmount, 0) AS receiptPaymentAmount,
                IFNULL(T2.outboundAmount, 0) - IFNULL(T3.returnAmount, 0) AS receiptableAmount
         from sales_ledger sl

--
Gitblit v1.9.3