From 47806d9e390ee00e1d29ad1da8c1aa908882a758 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 11 八月 2026 14:43:59 +0800
Subject: [PATCH] 用河南鹤壁代码覆盖山西长治

---
 src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml |   77 +++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 46 deletions(-)

diff --git a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
index 6a35890..4ad55d4 100644
--- a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
@@ -45,7 +45,7 @@
                 AND A.collection_date BETWEEN #{req.startDate} AND #{req.endDate}
             </if>
         </where>
-        order by A.id desc
+
     </select>
     <select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
         SELECT COUNT(*) > 0
@@ -58,51 +58,36 @@
     <select id="getOutboundBatchesByCustomer"
             resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
         SELECT
-            id,
-            outbound_batches,
-            customer_name,
-            shipping_date,
-            product_name,
-            specification_model,
-            tax_rate,
-            outbound_amount,
-            shipping_no,
-            sales_contract_no,
-            amount_received
-        FROM
-            (
-                SELECT
-                    sor.id,
-                    sor.outbound_batches,
-                    sl.customer_name,
-                    sor.create_time AS shipping_date,
-                    p.product_name,
-                    pm.model AS specification_model,
-                    slp.tax_rate,
-                    sor.stock_out_num * slp.tax_inclusive_unit_price AS outbound_amount,
-                    s.shipping_no,
-                    sl.sales_contract_no,
-                    COALESCE ( SUM( acsc.collection_amount ), 0 ) AS amount_received
-                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
-                        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id
-                        AND slp.type = 1
-                        LEFT JOIN product_model pm ON slp.product_model_id = pm.id
-                        LEFT JOIN product p ON pm.product_id = p.id
-                        LEFT JOIN account_sales_collection acsc ON acsc.stock_out_record_ids = sor.id
-                WHERE
-                    sor.record_type = '13'
-                  AND sor.approval_status = 1
-                  AND sl.customer_id = #{customerId}
-                GROUP BY
-                    sor.outbound_batches
-                ORDER BY
-                    sor.id
-            ) tempA
-        WHERE
-            amount_received &lt; outbound_amount
+        sor.id,
+        sor.outbound_batches,
+        sl.customer_name,
+        sor.create_time as shippingDate,
+        p.product_name,
+        pm.model as specification_model,
+        slp.tax_rate,
+        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
+        s.shipping_no,
+        sl.sales_contract_no
+        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
+        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
+        left join product_model pm on slp.product_model_id = pm.id
+        left join product p on pm.product_id = p.id
+        WHERE sor.record_type='13' and sor.approval_status=1
+        and sl.customer_id=#{customerId}
+
+        and sor.id NOT IN (
+        SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.stock_out_record_ids, ',', n.n), ',', -1)
+        FROM account_sales_collection a
+        CROSS JOIN (
+            SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
+            SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
+        ) n
+        WHERE n.n &lt;= CHAR_LENGTH(a.stock_out_record_ids) - CHAR_LENGTH(REPLACE(a.stock_out_record_ids, ',', '')) + 1
+        )
+
+        order by sor.id DESC
     </select>
     <select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
          SELECT DATE_FORMAT(collection_date, #{dateFormat}) AS dateStr,

--
Gitblit v1.9.3