From 47b42159fbe69fb2b4dbc13c75dd45abd00a55ae Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 13 二月 2026 11:10:34 +0800
Subject: [PATCH] fix: 查询日期缺少时分秒

---
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 2a1b94a..671fcf5 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -8,23 +8,23 @@
         SELECT
         T1.*,
         CASE
-        WHEN t2.qualitity > T1.quantity THEN 1
+        WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >= IFNULL(T1.quantity, 0) THEN 1
         ELSE 0
         END as has_sufficient_stock
         FROM
         sales_ledger_product T1
         LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id
         <where>
-            1=1
-            <if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' ">
+            <if test="salesLedgerProduct.salesLedgerId != null">
                 AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
             </if>
-            <if test="salesLedgerProduct.type != null and salesLedgerProduct.type != '' ">
+            <if test="salesLedgerProduct.type != null">
                 AND T1.type = #{salesLedgerProduct.type}
             </if>
         </where>
         ORDER BY T1.register_date DESC
     </select>
+
     <select id="selectSalesLedgerProductByMainId" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
         select slp.*
         from quality_inspect qi
@@ -97,7 +97,7 @@
                 AND slp.product_category like concat('%',#{req.productCategory},'%')
             </if>
             <if test="req.status != null and req.status ">
-                AND slp.pending_invoice_total &gt; 0
+                AND slp.pending_tickets_total &gt; 0
             </if>
         </where>
         order by slp.register_date desc
@@ -196,11 +196,15 @@
     </select>
 
     <select id="selectProductCountByTypeAndDate" resultType="int">
-        SELECT COUNT(*)
+        SELECT IFNULL(COUNT(*), 0)
         FROM sales_ledger_product
         WHERE type = #{type}
-        AND register_date &gt;= #{startDate}
-        AND register_date &lt;= #{endDate}
+        <if test="startDate != null">
+            AND register_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null">
+            AND register_date &lt;= #{endDate}
+        </if>
     </select>
 
     <select id="selectRawMaterialExpense" resultType="java.math.BigDecimal">

--
Gitblit v1.9.3