From 9bb9952db0b22034b4aea1f486df827d77a03031 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 17 十月 2024 14:41:35 +0800
Subject: [PATCH] add:销售合计统计运费+打包费;售后扣平台款字段,增加增加统计售后“打包运费(散户)”字段
---
src/main/resources/mapper/report/OrderReportMapper.xml | 39 +++++++++++++++++++++++----------------
1 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml
index aa1e51b..64045e7 100644
--- a/src/main/resources/mapper/report/OrderReportMapper.xml
+++ b/src/main/resources/mapper/report/OrderReportMapper.xml
@@ -5,6 +5,7 @@
<select id="getOrderDateReport" resultType="com.mzl.flower.dto.response.report.OrderReportResultVO">
select
sum(order_total) as order_total,
+ sum(total_amount) as total_amount,
sum(order_supplier_price_amount) as order_supplier_price_amount,
sum(order_markup_one_amount) as order_markup_one_amount,
sum(order_markup_two_amount) as order_markup_two_amount,
@@ -16,7 +17,7 @@
sum(order_replace_fee) as order_replace_fee,
sum(order_fee_supplier) as order_fee_supplier,
sum(order_fee_partner) as order_fee_partner,
- sum(order_fee_platform) as order_fee_platform,
+ sum(order_fee_platform) + sum(order_fee_packing_transport) as order_fee_platform,
sum(order_fee_platform_pack) as order_fee_platform_pack,
sum(order_fee_platform_check) as order_fee_platform_check,
sum(order_fee_platform_transport) as order_fee_platform_transport,
@@ -229,7 +230,7 @@
IFNULL(sum(order_lack_num),0) as order_lack_num,
IFNULL(sum(order_num)-sum(order_lack_num),0) as real_sale_num
from (
- select t2.payment_date,t2.id,t2.order_no,t2.create_by,ci.partner_id,p.name as partner_name,r2.* from (
+ select t2.payment_date,t2.id,t2.order_no,t2.create_by,t2.partner_id,p.name as partner_name,r2.* from (
SELECT t.*,
CASE
WHEN t.payment_time > DATE(t.payment_time) + INTERVAL 17 HOUR THEN DATE(t.payment_time) + INTERVAL 1 DAY
@@ -242,10 +243,8 @@
)t2
left join ( <include refid="baseSqlWithDate"></include> ) r2
on t2.id = r2.order_id
- left join t_customer_info ci
- on t2.create_by=ci.user_id
left join t_partner_info p
- on ci.partner_id=p.id
+ on t2.partner_id=p.id
)t3
where t3.partner_id is not null
<if test="dto.paymentDateStart != null">
@@ -273,10 +272,11 @@
IFNULL(t3.fee_packing_transport,0) as order_fee_packing_transport
from (
select
- t1.order_id,sum(t1.num) as order_num , sum(t1.total) as order_total, sum(t1.supplier_price_amount) as order_supplier_price_amount, sum(t1.markup_one_amount) as order_markup_one_amount,sum(t1.markup_two_amount) as order_markup_two_amount, sum(t1.markup_partner_amount) as order_markup_partner_amount,sum(t1.price_amount) as order_price_amount,sum(t1.original_price_amount) as order_original_price_amount,sum(t1.price_discount_amount) as order_price_discount_amount,sum(t1.coupon_amount_total) as order_coupon_amount_total,sum(t1.check_fee) as order_check_fee,sum(t1.lack_fee_supplier) as order_lack_fee_supplier,sum(t1.replace_fee) as order_replace_fee,
+ t1.order_id, t1.total_amount ,sum(t1.num) as order_num , (t1.flower_amount + t1.packing_fee + t1.transport_fee) as order_total, sum(t1.supplier_price_amount) as order_supplier_price_amount, sum(t1.markup_one_amount) as order_markup_one_amount,sum(t1.markup_two_amount) as order_markup_two_amount, sum(t1.markup_partner_amount) as order_markup_partner_amount,sum(t1.price_amount) as order_price_amount,sum(t1.original_price_amount) as order_original_price_amount,sum(t1.price_discount_amount) as order_price_discount_amount,sum(t1.coupon_amount_total) as order_coupon_amount_total,sum(t1.check_fee) as order_check_fee,sum(t1.lack_fee_supplier) as order_lack_fee_supplier,sum(t1.replace_fee) as order_replace_fee,
sum(replace_num) as order_replace_num,sum(reduce_num) as order_reduce_num,sum(lack_num) as order_lack_num
from (
SELECT
+ o.total_amount, o.flower_amount, o.packing_fee, o.transport_fee,
oi.order_id,
oi.id,
IFNULL(oi.num,0) as num,
@@ -310,9 +310,9 @@
IFNULL(ois.lack_fee_supplier,0) as lack_fee_supplier,
IFNULL(ois.replace_fee,0) as replace_fee
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace'),0) as replace_num
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'reduce'),0) as reduce_num
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack'),0) as lack_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as reduce_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num
FROM t_order o
left join t_order_item oi
on oi.order_id=o.id
@@ -401,9 +401,9 @@
IFNULL(ois.lack_fee_supplier,0) as lack_fee_supplier,
IFNULL(ois.replace_fee,0) as replace_fee
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace'),0) as replace_num
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'reduce'),0) as reduce_num
- ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack'),0) as lack_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as reduce_num
+ ,IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num
FROM t_order o
left join t_order_item oi
on oi.order_id=o.id
@@ -411,6 +411,12 @@
left join t_supplier_info si on si.id = oi.supplier_id
left join t_order_item_settlement ois on ois.order_item_id = oi.id
WHERE oi.deleted = 0
+ <if test="dto.startDate != null">
+ and o.payment_time > #{dto.startDate}
+ </if>
+ <if test="dto.endDate != null">
+ and o.payment_time <= #{dto.endDate}
+ </if>
)t1
where 1=1
<if test="dto.paymentDateStart != null">
@@ -473,7 +479,7 @@
IFNULL( ois.check_fee, 0 ) AS check_fee,
IFNULL( ois.replace_fee, 0 ) AS replace_fee,
IFNULL( ois.lack_fee_supplier, 0 ) AS lack_fee_supplier,
- IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack'),0) as lack_num
+ IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num
FROM
t_order o
LEFT JOIN t_order_item oi ON oi.order_id = o.id
@@ -483,6 +489,7 @@
WHERE
oi.deleted = 0
and o.payment_time is not null
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
<if test="dto.startDate != null">
and o.payment_time >= #{dto.startDate}
</if>
@@ -521,7 +528,7 @@
on vor.supplier_id=p.id
left join t_order o
on vor.order_id= o.id
- and o.status_backend not in ('PENDING','CANCEL','REFUND')
+-- and o.status_backend not in ('PENDING','CANCEL','REFUND')
) s group by dateinfo,supplier_id
</select>
@@ -548,7 +555,7 @@
on vor.supplier_id=p.id
left join t_order o
on vor.order_id= o.id
- and o.status_backend not in ('PENDING','CANCEL','REFUND')
+-- and o.status_backend not in ('PENDING','CANCEL','REFUND')
) s group by dateinfo,supplier_id
</select>
@@ -582,7 +589,7 @@
on vor.supplier_id=p.id
left join t_order o
on vor.order_id= o.id
- and o.status_backend not in ('PENDING','CANCEL','REFUND')
+-- and o.status_backend not in ('PENDING','CANCEL','REFUND')
) s group by dateinfo,supplier_id
) s2
</select>
--
Gitblit v1.9.3