From f1763a56d1b7b22470db393646657db24219c4c3 Mon Sep 17 00:00:00 2001
From: zhang_nuo <zhang_12370@163.com>
Date: 星期六, 19 九月 2026 22:00:21 +0800
Subject: [PATCH] fix: 修复财务单据存在性校验空列表导致的SQL语法错误

---
 src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml |   12 ++++++++----
 src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml       |    9 +++++----
 src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml    |   12 ++++++++----
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml b/src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml
index 8b23627..c9cbbb0 100644
--- a/src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml
+++ b/src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml
@@ -89,10 +89,14 @@
     <select id="existsByStockInRecordId" resultType="java.lang.Boolean">
          SELECT COUNT(*) > 0
         FROM account_payment_application
-        WHERE  status != 2
-        <foreach collection="stockInRecordIds" item="id" open="(" separator=" OR " close=")">
-            FIND_IN_SET(#{id}, stock_in_record_ids)
-        </foreach>
+        WHERE status != 2
+        <if test="stockInRecordIds != null and stockInRecordIds.size() > 0">
+            AND (
+            <foreach collection="stockInRecordIds" item="id" separator=" OR ">
+                FIND_IN_SET(#{id}, stock_in_record_ids)
+            </foreach>
+            )
+        </if>
     </select>
 
 </mapper>
diff --git a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
index 842e94c..511c076 100644
--- a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
@@ -64,10 +64,14 @@
     <select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
         SELECT COUNT(*) > 0
         FROM account_invoice_application
-        WHERE status!=2
-        <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
-            FIND_IN_SET(#{id}, stock_out_record_ids)
-        </foreach>
+        WHERE status != 2
+        <if test="stockOutRecordIds != null and stockOutRecordIds.size() > 0">
+            AND (
+            <foreach collection="stockOutRecordIds" item="id" separator=" OR ">
+                FIND_IN_SET(#{id}, stock_out_record_ids)
+            </foreach>
+            )
+        </if>
     </select>
 
 </mapper>
diff --git a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
index 4ad55d4..c107d13 100644
--- a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
@@ -50,10 +50,11 @@
     <select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
         SELECT COUNT(*) > 0
         FROM account_sales_collection
-        WHERE
-        <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
-            FIND_IN_SET(#{id}, stock_out_record_ids)
-        </foreach>
+        <where>
+            <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
+                FIND_IN_SET(#{id}, stock_out_record_ids)
+            </foreach>
+        </where>
     </select>
     <select id="getOutboundBatchesByCustomer"
             resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">

--
Gitblit v1.9.3