From ae3dd677f3bbbc26d7c41aebc0e6048e2d20593c Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期六, 21 十二月 2024 14:58:43 +0800
Subject: [PATCH] 1.花材统计报表:增加父类名称
---
src/main/resources/mapper/payment/OrderMapper.xml | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 221 insertions(+), 7 deletions(-)
diff --git a/src/main/resources/mapper/payment/OrderMapper.xml b/src/main/resources/mapper/payment/OrderMapper.xml
index ebaac79..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}
@@ -164,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
@@ -197,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}-->
@@ -335,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}
@@ -356,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}
@@ -402,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