From eeb3b46afe7da500bce62daad35ded0886df3b88 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 09 一月 2025 18:31:12 +0800
Subject: [PATCH] Merge branch 'master-v4' of http://47.96.225.205:8888/r/flowerbackend-v2 into master-v4

---
 src/main/resources/mapper/payment/OrderMapper.xml |  195 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 191 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/payment/OrderMapper.xml b/src/main/resources/mapper/payment/OrderMapper.xml
index 66cd365..2a87af2 100644
--- a/src/main/resources/mapper/payment/OrderMapper.xml
+++ b/src/main/resources/mapper/payment/OrderMapper.xml
@@ -68,7 +68,7 @@
                 and (oi.status = 'reduce' or oi.status = 'abnormal')
             )
             and q.transfer_id is null
-            and q.status in ('COLLECTION', 'SEND')
+            and q.status in ('COLLECTION', 'SEND','RECEIVE')
         </if>
         <if test="condition.billId != null and condition.billId != ''">
             AND q.bill_id = #{condition.billId}
@@ -174,7 +174,7 @@
                 and (oi.status = 'reduce' or oi.status = 'abnormal')
             )
             and q.transfer_id is null
-            and q.status in ('COLLECTION', 'SEND')
+            and q.status in ('COLLECTION', 'SEND','RECEIVE')
         </if>
         <if test="condition.billId != null and condition.billId != ''">
             AND q.bill_id = #{condition.billId}
@@ -191,6 +191,33 @@
         </if>
         <if test="condition.createName != null and condition.createName != ''">
             AND u.nick_name LIKE concat('%', #{condition.createName},'%')
+        </if>
+
+        <if test="condition.abnormalOrderStatus != null and condition.abnormalOrderStatus != '' and condition.abnormalOrderStatus == 'UN_PROCESSED'">
+            AND q.id in (
+                select oi.order_id
+                from t_order_item oi
+                left join t_order o
+                on oi.order_id=o.id
+                where oi.status in ('abnormal','reduce','lack','back')
+                and  o.transfer_id is null
+                and o.status in ('COLLECTION','SEND','RECEIVE')
+            )
+        </if>
+
+        <if test="condition.abnormalOrderStatus != null and condition.abnormalOrderStatus != '' and condition.abnormalOrderStatus == 'PROCESSED'">
+            AND q.id in (
+                select order_id from t_order_item oi where oi.status in ('abnormal','reduce','lack','back')
+            )
+            and q.id not in(
+                select oi.order_id
+                from t_order_item oi
+                left join t_order o
+                on oi.order_id=o.id
+                where oi.status in ('abnormal','reduce','lack','back')
+                and  o.transfer_id is null
+                and o.status in ('COLLECTION','SEND','RECEIVE')
+            )
         </if>
 
         ORDER BY q.create_time desc, q.payment_time desc
@@ -321,7 +348,7 @@
     </select>
 
     <select id="selectOrderExportList" resultType="com.mzl.flower.dto.response.payment.OrderListExportDTO">
-        SELECT q.order_no,q.create_time,q.customer,q.customer_tel,q.total_amount,q.status_backend,q.partner_name,q.warehouse_location_code,q.remarks,
+        SELECT q.order_no,q.create_time,q.customer,q.customer_tel,q.total_amount,q.status_backend,q.partner_name,q.warehouse_location_code,q.remarks,q.logistics_company_code,
                u.nick_name createName ,
                code.label as statusBackendStr,
                code2.label as specialNeedsStr,
@@ -383,7 +410,7 @@
             and (oi.status = 'reduce' or oi.status = 'abnormal')
             )
             and q.transfer_id is null
-            and q.status in ('COLLECTION', 'SEND')
+            and q.status in ('COLLECTION', 'SEND','RECEIVE')
         </if>
         <if test="condition.billId != null and condition.billId != ''">
             AND q.bill_id = #{condition.billId}
@@ -429,6 +456,166 @@
         FROM t_order t
         order by t.create_time desc
     </select>
+    <select id="getAbnormalOrderStatusCount"
+            resultType="com.mzl.flower.dto.response.payment.OrderStatusCountDTO">
+        SELECT 'UN_PROCESSED' as value, count(1) orderCount
+        FROM t_order q
+        left join t_user u on q.create_by = u.id
+        WHERE q.deleted = 0
+        <include refid="getAbnormalOrderStatusCount_condition"></include>
+
+        AND q.id in (
+            select oi.order_id
+            from t_order_item oi
+            left join t_order o
+            on oi.order_id=o.id
+            where oi.status in ('abnormal','reduce','lack','back')
+            and  o.transfer_id is null
+            and o.status in ('COLLECTION','SEND','RECEIVE')
+        )
+
+        union
+
+        SELECT 'PROCESSED' as value, count(1) orderCount
+        FROM t_order q
+        left join t_user u on q.create_by = u.id
+        WHERE q.deleted = 0
+        <include refid="getAbnormalOrderStatusCount_condition"></include>
+        AND q.id in (
+            select order_id from t_order_item oi where oi.status in ('abnormal','reduce','lack','back')
+        )
+        and q.id not in(
+            select oi.order_id
+            from t_order_item oi
+            left join t_order o
+            on oi.order_id=o.id
+            where oi.status in ('abnormal','reduce','lack','back')
+            and  o.transfer_id is null
+            and o.status in ('COLLECTION','SEND','RECEIVE')
+        )
+
+    </select>
+
+    <select id="getAbnormalOrderStatusCount2"
+            resultType="com.mzl.flower.dto.response.payment.OrderStatusCountDTO">
+        SELECT 'UN_PROCESSED' as value, count(1) orderCount
+        FROM t_order q
+        left join t_user u on q.create_by = u.id
+        WHERE q.deleted = 0
+        <include refid="getAbnormalOrderStatusCount_condition"></include>
+
+        AND exists(
+        select 1 from t_order_item oi
+        where oi.order_id = q.id
+        and oi.status in ('abnormal','reduce','lack','back')
+        )
+        and q.transfer_id is null
+        and q.status in ('COLLECTION', 'SEND','RECEIVE')
+
+        union
+
+        SELECT 'PROCESSED' as value, count(1) orderCount
+        FROM t_order q
+        left join t_user u on q.create_by = u.id
+        WHERE q.deleted = 0
+        <include refid="getAbnormalOrderStatusCount_condition"></include>
+        AND  exists(
+        select 1 from t_order_item oi
+        where oi.order_id = q.id
+        and oi.status in ('abnormal','reduce','lack','back')
+        )
+        AND not exists(
+        select 1 from t_order_item oi
+        where oi.order_id = q.id
+        and oi.status in ('abnormal','reduce','lack','back')
+        and q.transfer_id is null
+        and q.status in ('COLLECTION', 'SEND','RECEIVE')
+        )
+
+    </select>
+    
+    <sql id="getAbnormalOrderStatusCount_condition">
+        <if test="condition.orderNo != null and condition.orderNo != ''">
+            AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
+        </if>
+        <if test="condition.customerAddress != null and condition.customerAddress != ''">
+            AND q.customer_address LIKE concat('%', #{condition.customerAddress},'%')
+        </if>
+        <if test="condition.customer != null and condition.customer != ''">
+            AND (q.customer LIKE concat('%', #{condition.customer},'%')
+            or q.customer_tel LIKE concat('%', #{condition.customer},'%')
+            )
+        </if>
+        <if test="condition.createBy != null and condition.createBy != ''">
+            AND q.create_by = #{condition.createBy}
+        </if>
+        <if test="condition.status != null and condition.status != ''">
+            AND q.status = #{condition.status}
+        </if>
+        <if test="condition.statusBackend != null and condition.statusBackend != ''">
+            AND q.status_backend = #{condition.statusBackend}
+        </if>
+        <!--        <if test="condition.startDate != null">-->
+        <!--            AND q.payment_time &gt;= #{condition.startDate}-->
+        <!--        </if>-->
+        <!--        <if test="condition.endDate != null">-->
+        <!--            AND q.payment_time &lt;= #{condition.endDate}-->
+        <!--        </if>-->
+        <!--        <if test="condition.createStartDate != null">-->
+        <!--            AND q.create_time &gt;= #{condition.createStartDate}-->
+        <!--        </if>-->
+        <!--        <if test="condition.createEndDate != null">-->
+        <!--            AND q.create_time &lt;= #{condition.createEndDate}-->
+        <!--        </if>-->
+        <if test="condition.createStartDate != null">
+            AND q.payment_time &gt;= #{condition.createStartDate}
+        </if>
+        <if test="condition.createEndDate != null">
+            AND q.payment_time &lt; #{condition.createEndDate}
+        </if>
+        <if test="condition.partnerId != null">
+            AND q.partner_id = #{condition.partnerId}
+        </if>
+        <if test="condition.partnerName != null and condition.partnerName != ''">
+            AND q.partner_name LIKE concat('%', #{condition.partnerName},'%')
+        </if>
+<!--        <if test="condition.levelDown != null and condition.levelDown != ''">-->
+<!--            AND exists(-->
+<!--            select 1 from t_order_item oi-->
+<!--            where oi.order_id = q.id-->
+<!--            and (oi.status = 'reduce' or oi.status = 'abnormal')-->
+<!--            )-->
+<!--            and q.transfer_id is null-->
+<!--            and q.status in ('COLLECTION', 'SEND','RECEIVE')-->
+<!--        </if>-->
+        <if test="condition.billId != null and condition.billId != ''">
+            AND q.bill_id = #{condition.billId}
+        </if>
+        <if test="condition.flowerName != null and condition.flowerName != ''">
+            AND exists(
+            select 1 from t_order_item oi
+            where oi.order_id = q.id
+            and oi.flower_name LIKE concat('%', #{condition.flowerName},'%')
+            )
+        </if>
+
+        <if test="condition.warehouseLocationCode != null and condition.warehouseLocationCode != ''">
+            AND q.warehouse_location_code LIKE concat('%', #{condition.warehouseLocationCode},'%')
+        </if>
+        <if test="condition.createName != null and condition.createName != ''">
+            AND u.nick_name LIKE concat('%', #{condition.createName},'%')
+        </if>
+        <if test="condition.province != null and condition.province != ''">
+            AND q.customer_province LIKE concat('%', #{condition.province},'%')
+        </if>
+        <if test="condition.city != null and condition.city != ''">
+            AND q.customer_city LIKE concat('%', #{condition.city},'%')
+        </if>
+        <if test="condition.region != null and condition.region != ''">
+            AND q.customer_region LIKE concat('%', #{condition.region},'%')
+        </if>
+    </sql>
+    
 
     <update id="updatePaymentCreateDate">
         update t_order  set payment_date_sta=#{order.paymentDate}, create_date_sta=#{order.createDate} where id=#{order.id}

--
Gitblit v1.9.3