From 67647a9bdb5ca2c0acf5c5f635ec28d2e4d6c9db Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 08 十月 2026 13:58:51 +0800
Subject: [PATCH] fix:countTodayByCreateTime方法加上null值判断

---
 src/main/resources/mapper/sales/SalesLedgerMapper.xml |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/sales/SalesLedgerMapper.xml b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
index c145e0a..0fc627f 100644
--- a/src/main/resources/mapper/sales/SalesLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -88,6 +88,30 @@
             <if test="salesLedgerDto.projectName != null and salesLedgerDto.projectName != '' ">
                 AND T1.project_name LIKE CONCAT('%',#{salesLedgerDto.projectName},'%')
             </if>
+            <if test="salesLedgerDto.shippingStatus != null and salesLedgerDto.shippingStatus != '' ">
+                AND T1.id IN (
+                SELECT slp.sales_ledger_id
+                FROM sales_ledger_product slp
+                LEFT JOIN (
+                SELECT si.sales_ledger_product_id, IFNULL(SUM(spd.quantity), 0) AS shipped_quantity
+                FROM shipping_info si
+                LEFT JOIN shipping_product_detail spd ON si.id = spd.shipping_info_id
+                WHERE si.status != '瀹℃牳鎷掔粷'
+                GROUP BY si.sales_ledger_product_id
+                ) ship ON ship.sales_ledger_product_id = slp.id
+                WHERE slp.type = 1
+                GROUP BY slp.sales_ledger_id
+                HAVING
+                <choose>
+                    <when test="'宸插彂璐�'.equals(salesLedgerDto.shippingStatus)">
+                        SUM(CASE WHEN IFNULL(slp.quantity, 0) - IFNULL(ship.shipped_quantity, 0) &gt; 0 THEN 1 ELSE 0 END) = 0
+                    </when>
+                    <otherwise>
+                        SUM(CASE WHEN IFNULL(slp.quantity, 0) - IFNULL(ship.shipped_quantity, 0) &gt; 0 THEN 1 ELSE 0 END) &gt; 0
+                    </otherwise>
+                </choose>
+                )
+            </if>
             <if test="salesLedgerDto.entryDateStart != null and salesLedgerDto.entryDateStart != '' ">
                 AND T1.entry_date &gt;= DATE_FORMAT(#{salesLedgerDto.entryDateStart},'%Y-%m-%d')
             </if>
@@ -95,7 +119,7 @@
                 AND T1.entry_date &lt;= DATE_FORMAT(#{salesLedgerDto.entryDateEnd},'%Y-%m-%d')
             </if>
         </where>
-        order by T1.entry_date desc
+        order by T1.entry_date desc, T1.sales_contract_no desc
     </select>
 
     <select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
@@ -110,17 +134,22 @@
         FROM sales_ledger
         GROUP BY customer_name
     </select>
+
     <select id="listSalesLedgerAndShipped" resultType="com.ruoyi.sales.dto.SalesLedgerDto">
         select distinct sl.id as 'disId', sl.* from
         sales_ledger sl
         left join sales_ledger_product slp on sl.id = slp.sales_ledger_id
         left join shipping_info si on slp.id = si.sales_ledger_product_id
-        where si.status = '宸插彂璐�'
+        where si.status in ('瀹℃牳閫氳繃', '宸插彂璐�')
+        <if test="ew.customerId != null and ew.customerId != '' ">
+            and sl.customer_id = #{ew.customerId}
+        </if>
         <if test="ew.customerName != null and ew.customerName != '' ">
-            and sl.customer_name like concat('%',#{ew.customerName},'%')
+            and sl.customer_name like concat('%', #{ew.customerName}, '%')
         </if>
         order by sl.execution_date desc
     </select>
+
     <select id="selectPurchaseReportVoPage" resultType="com.ruoyi.purchase.vo.PurchaseReportVo">
         select sl.sales_contract_no customerContractNo,
                c.customer_name,

--
Gitblit v1.9.3