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/account/sales/AccountInvoiceApplicationMapper.xml |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
index 99b16d2..8ed7530 100644
--- a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
@@ -36,7 +36,7 @@
         p.product_name,
         pm.model as specification_model,
         slp.tax_rate,
-        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
+        sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1) as outboundAmount,
         s.shipping_no,
         sl.sales_contract_no
         FROM stock_out_record sor
@@ -64,10 +64,12 @@
     <select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
         SELECT COUNT(*) > 0
         FROM account_invoice_application
-        WHERE
-        <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
-            FIND_IN_SET(#{id}, stock_out_record_ids)
+        WHERE status != 2
+        AND (
+        <foreach collection="stockOutRecordIds" item="id" separator=" OR ">
+            FIND_IN_SET(#{id}, stock_out_record_ids) > 0
         </foreach>
+        )
     </select>
 
 </mapper>

--
Gitblit v1.9.3