From c83b580b0f51a2cdf16f2b1537aa3cb113ef112f Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期五, 20 十二月 2024 17:56:10 +0800
Subject: [PATCH] add: 花材销售统计商品分类
---
src/main/resources/mapper/payment/OrderMapper.xml | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 226 insertions(+), 9 deletions(-)
diff --git a/src/main/resources/mapper/payment/OrderMapper.xml b/src/main/resources/mapper/payment/OrderMapper.xml
index 4f847ac..08965d0 100644
--- a/src/main/resources/mapper/payment/OrderMapper.xml
+++ b/src/main/resources/mapper/payment/OrderMapper.xml
@@ -15,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},'%')
@@ -52,7 +53,7 @@
AND q.payment_time >= #{condition.createStartDate}
</if>
<if test="condition.createEndDate != null">
- AND q.payment_time <= #{condition.createEndDate}
+ AND q.payment_time < #{condition.createEndDate}
</if>
<if test="condition.partnerId != null">
AND q.partner_id = #{condition.partnerId}
@@ -64,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','RECEIVE')
</if>
<if test="condition.billId != null and condition.billId != ''">
AND q.bill_id = #{condition.billId}
@@ -77,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>
@@ -93,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},'%')
@@ -132,7 +159,7 @@
AND q.payment_time >= #{condition.createStartDate}
</if>
<if test="condition.createEndDate != null">
- AND q.payment_time <= #{condition.createEndDate}
+ AND q.payment_time < #{condition.createEndDate}
</if>
<if test="condition.partnerId != null">
AND q.partner_id = #{condition.partnerId}
@@ -147,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}
@@ -161,6 +188,36 @@
</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.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
@@ -194,7 +251,7 @@
AND q.payment_time >= #{condition.createStartDate}
</if>
<if test="condition.createEndDate != null">
- AND q.payment_time <= #{condition.createEndDate}
+ AND q.payment_time < #{condition.createEndDate}
</if>
<!-- <if test="condition.createStartDate != null">-->
<!-- AND q.create_time >= #{condition.createStartDate}-->
@@ -332,7 +389,7 @@
AND q.payment_time >= #{condition.startDate}
</if>
<if test="condition.endDate != null">
- AND q.payment_time <= #{condition.endDate}
+ AND q.payment_time < #{condition.endDate}
</if>
<if test="condition.createStartDate != null">
AND q.create_time >= #{condition.createStartDate}
@@ -353,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}
@@ -374,8 +431,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 > #{startTime}
</if>
@@ -399,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 >= #{condition.startDate}-->
+ <!-- </if>-->
+ <!-- <if test="condition.endDate != null">-->
+ <!-- AND q.payment_time <= #{condition.endDate}-->
+ <!-- </if>-->
+ <!-- <if test="condition.createStartDate != null">-->
+ <!-- AND q.create_time >= #{condition.createStartDate}-->
+ <!-- </if>-->
+ <!-- <if test="condition.createEndDate != null">-->
+ <!-- AND q.create_time <= #{condition.createEndDate}-->
+ <!-- </if>-->
+ <if test="condition.createStartDate != null">
+ AND q.payment_time >= #{condition.createStartDate}
+ </if>
+ <if test="condition.createEndDate != null">
+ AND q.payment_time < #{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