From 061977e873182b0c7249d02fe0253a291fa4e69d Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 12 六月 2026 09:46:31 +0800
Subject: [PATCH] fix(customer): 修复客户数据查询中的空值问题并优化生产订单状态管理

---
 src/main/resources/mapper/basic/CustomerMapper.xml |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/basic/CustomerMapper.xml b/src/main/resources/mapper/basic/CustomerMapper.xml
index 8117c66..237f8cd 100644
--- a/src/main/resources/mapper/basic/CustomerMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerMapper.xml
@@ -113,12 +113,12 @@
                T1.contractAmounts,
                IFNULL(T2.receiptPaymentAmount, 0) AS receiptPaymentAmount,
                IFNULL(T3.outboundAmount, 0) - IFNULL(T4.returnAmount, 0) AS receiptableAmount
-        from (select customer_id, sum(contract_amount) as contractAmounts from sales_ledger group by customer_id) T1
+        from (select customer_id, sum(contract_amount) as contractAmounts from sales_ledger where customer_id is not null group by customer_id) T1
         left join (select customer_id, sum(collection_amount) as receiptPaymentAmount from account_sales_collection group by customer_id) T2 on T1.customer_id = T2.customer_id
         left join (
             SELECT
                 sl.customer_id,
-                sum(sor.stock_out_num * slp.tax_inclusive_unit_price) as outboundAmount
+                sum(sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1)) as outboundAmount
             FROM stock_out_record sor
             LEFT join shipping_info s on sor.record_id = s.id
             LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
@@ -169,7 +169,7 @@
         left join (
             SELECT
                 sl.id,
-                sum(sor.stock_out_num * slp.tax_inclusive_unit_price) as outboundAmount
+                sum(sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1)) as outboundAmount
             FROM stock_out_record sor
                      left join shipping_info s on sor.record_id = s.id
                      LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id

--
Gitblit v1.9.3