From 1de63420c2360a89e9e14d33c86d49aa3b0297f0 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期二, 10 十二月 2024 15:44:40 +0800
Subject: [PATCH] 579-已经上面的订单状态统计不准确

---
 src/main/resources/mapper/payment/OrderMapper.xml |   65 +++++++++++++++++++++++++++++---
 1 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/src/main/resources/mapper/payment/OrderMapper.xml b/src/main/resources/mapper/payment/OrderMapper.xml
index 6bd3e15..66cd365 100644
--- a/src/main/resources/mapper/payment/OrderMapper.xml
+++ b/src/main/resources/mapper/payment/OrderMapper.xml
@@ -7,6 +7,7 @@
         where status_backend = 'SEND' and partner_id is not null
     </update>
 
+
     <select id="getPartnerOrderReceive" resultType="com.mzl.flower.entity.payment.Order">
         select * from t_order t where status_backend = 'SEND' and partner_id is not null
     </select>
@@ -14,6 +15,7 @@
     <select id="getOrderStatusCount" resultType="com.mzl.flower.dto.response.payment.OrderStatusCountDTO">
         SELECT q.status_backend value, count(1) orderCount
         FROM t_order q
+        left join t_user u on q.create_by = u.id
         WHERE q.deleted = 0
         <if test="condition.orderNo != null and condition.orderNo != ''">
             AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
@@ -51,7 +53,7 @@
             AND q.payment_time &gt;= #{condition.createStartDate}
         </if>
         <if test="condition.createEndDate != null">
-            AND q.payment_time &lt;= #{condition.createEndDate}
+            AND q.payment_time &lt; #{condition.createEndDate}
         </if>
         <if test="condition.partnerId != null">
             AND q.partner_id = #{condition.partnerId}
@@ -63,9 +65,10 @@
             AND exists(
                 select 1 from t_order_item oi
                 where oi.order_id = q.id
-                and oi.status = 'reduce'
+                and (oi.status = 'reduce' or oi.status = 'abnormal')
             )
             and q.transfer_id is null
+            and q.status in ('COLLECTION', 'SEND')
         </if>
         <if test="condition.billId != null and condition.billId != ''">
             AND q.bill_id = #{condition.billId}
@@ -76,6 +79,22 @@
                 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>
         GROUP BY q.status_backend
     </select>
@@ -92,6 +111,15 @@
         WHERE q.deleted = 0
         <if test="condition.orderNo != null and condition.orderNo != ''">
             AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
+        </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>
         <if test="condition.customerAddress != null and condition.customerAddress != ''">
             AND q.customer_address LIKE concat('%', #{condition.customerAddress},'%')
@@ -131,7 +159,7 @@
             AND q.payment_time  &gt;= #{condition.createStartDate}
         </if>
         <if test="condition.createEndDate != null">
-            AND q.payment_time &lt;= #{condition.createEndDate}
+            AND q.payment_time &lt; #{condition.createEndDate}
         </if>
         <if test="condition.partnerId != null">
             AND q.partner_id = #{condition.partnerId}
@@ -160,6 +188,9 @@
         </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>
 
         ORDER BY q.create_time desc, q.payment_time desc
@@ -193,7 +224,7 @@
             AND q.payment_time &gt;= #{condition.createStartDate}
         </if>
         <if test="condition.createEndDate != null">
-            AND q.payment_time &lt;= #{condition.createEndDate}
+            AND q.payment_time &lt; #{condition.createEndDate}
         </if>
 <!--        <if test="condition.createStartDate != null">-->
 <!--            AND q.create_time &gt;= #{condition.createStartDate}-->
@@ -331,7 +362,7 @@
             AND q.payment_time &gt;= #{condition.startDate}
         </if>
         <if test="condition.endDate != null">
-            AND q.payment_time &lt;= #{condition.endDate}
+            AND q.payment_time &lt; #{condition.endDate}
         </if>
         <if test="condition.createStartDate != null">
             AND q.create_time &gt;= #{condition.createStartDate}
@@ -373,8 +404,8 @@
     <select id="getOrderSaleAmount" resultType="java.math.BigDecimal">
         SELECT sum(o.payment_amount)
         FROM t_order o
-        WHERE o.payment_time is not null
-        and o.refund_time is null
+        WHERE o.deleted=0
+        and o.status_backend not in ('PENDING','CANCEL','REFUND')
         <if test="startTime != null">
             and o.create_time &gt; #{startTime}
         </if>
@@ -382,4 +413,24 @@
             and o.create_time &lt;= #{endTime}
         </if>
     </select>
+
+<!--    获取所有的订单数据,以及时间数据-->
+    <select id="selectAllDateList" resultType="com.mzl.flower.entity.payment.Order">
+        SELECT t.id,t.payment_time,
+               CASE
+                   WHEN t.payment_time > DATE(t.payment_time) + INTERVAL 17 HOUR THEN DATE(t.payment_time) + INTERVAL 1 DAY
+                   ELSE DATE(t.payment_time)
+                   END AS payment_date,
+               t.create_time,
+               CASE
+                   WHEN t.create_time > DATE(t.create_time) + INTERVAL 17 HOUR THEN DATE(t.create_time) + INTERVAL 1 DAY
+                   ELSE DATE(t.create_time)
+                   END AS create_date
+        FROM t_order t
+        order by t.create_time desc
+    </select>
+
+    <update id="updatePaymentCreateDate">
+        update t_order  set payment_date_sta=#{order.paymentDate}, create_date_sta=#{order.createDate} where id=#{order.id}
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3