From fec6c1c27cc4333f1f3b39bd09bd3f4cc201772b Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期日, 10 五月 2026 11:31:22 +0800
Subject: [PATCH] fix: 开票台账创建日期相同未保证排序

---
 src/main/resources/mapper/production/ProductOrderMapper.xml |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductOrderMapper.xml b/src/main/resources/mapper/production/ProductOrderMapper.xml
index 6b993bf..f8d10e0 100644
--- a/src/main/resources/mapper/production/ProductOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductOrderMapper.xml
@@ -110,4 +110,14 @@
         WHERE create_time &gt;= #{startDate} AND create_time &lt;= #{endDate}
           AND complete_quantity &lt; quantity
     </select>
+
+    <update id="addCompleteQtyIfNotExceed">
+        update product_order
+        set
+            complete_quantity = complete_quantity + #{delta},
+            start_time = ifnull(start_time, now()),
+            end_time = case when (complete_quantity + #{delta}) = quantity then now() else end_time end
+        where id = #{id}
+          and (complete_quantity + #{delta}) <![CDATA[ <= ]]> quantity
+    </update>
 </mapper>

--
Gitblit v1.9.3