From f727a93931f801bbcd3b5eb0275169cf55a87d5e Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期日, 22 九月 2024 22:40:56 +0800
Subject: [PATCH] 1.优惠券-使用条件-根据满减还是无门槛控制 2.商品限购-根据payment_time来控制

---
 src/main/resources/mapper/payment/DeliveryOrderMapper.xml |   53 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
index 93e2eaf..243e5d8 100644
--- a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
+++ b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
@@ -101,8 +101,12 @@
         <if test="condition.orderNo != null and condition.orderNo != ''">
             AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
         </if>
-        <if test="condition.status != null and condition.status != ''">
-            AND q.status = #{condition.status}
+
+        <if test="condition.statusList != null and condition.statusList.size > 0">
+            AND q.status in
+            <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
+                #{status}
+            </foreach>
         </if>
 
         <if test="condition.supplierId != null">
@@ -151,8 +155,12 @@
         <if test="condition.orderNo != null and condition.orderNo != ''">
             AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
         </if>
-        <if test="condition.status != null and condition.status != ''">
-            AND q.status = #{condition.status}
+
+        <if test="condition.statusList != null and condition.statusList.size > 0">
+            AND q.status in
+            <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
+                #{status}
+            </foreach>
         </if>
 
         <if test="condition.warehouseId != null">
@@ -180,6 +188,22 @@
     </select>
 
     <select id="statisticStationList" resultType="com.mzl.flower.dto.response.flower.StationStatisticDTO">
+        select tt.*
+            , (select count(distinct s.id)
+                from t_supplier_info s
+                join t_delivery_order q on s.id = q.supplier_id
+                WHERE q.deleted = 0
+                and q.status in ('CHECKED')
+                AND s.station_id = tt.stationId
+            ) checkedSupplierCount
+            , (select count(distinct s.id)
+                from t_supplier_info s
+                join t_delivery_order q on s.id = q.supplier_id
+                WHERE q.deleted = 0
+                and q.status in ('PENDING', 'ARRIVED')
+                AND s.station_id = tt.stationId
+            ) uncheckedSupplierCount
+        from (
             SELECT
                 s.station_id AS stationId,
                 st.`name`,
@@ -210,10 +234,15 @@
             <if test="endDate != null">
                 AND o.create_time &lt;= #{endDate}
             </if>
-            GROUP BY
-            s.station_id,
-            st.`name`;
 
+            <if test="statusList != null and statusList.size > 0">
+                AND o.status in
+                <foreach collection="statusList" item="status" open="(" separator="," close=")">
+                    #{status}
+                </foreach>
+            </if>
+            GROUP BY s.station_id, st.`name`
+        ) tt
     </select>
 
     <update id="setDeliveryOrderPending">
@@ -228,9 +257,13 @@
         SELECT q.*
         FROM t_delivery_order q
         WHERE q.deleted = 0
-        and q.status in ('PENDING', 'ARRIVED', 'CHECKED')
+        AND q.status in ('PENDING', 'ARRIVED')
         AND q.supplier_id = #{supplierId}
-        AND q.create_time &gt; #{startDate}
-        AND q.create_time &lt;= #{endDate}
+        <if test="startDate != null">
+            AND q.create_time &gt; #{startDate}
+        </if>
+        <if test="endDate != null">
+            AND q.create_time &lt;= #{endDate}
+        </if>
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3