From c7d127ae867c00f01a7eb4977836565bcae6ee9f Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期三, 11 十二月 2024 11:29:56 +0800
Subject: [PATCH] 1.财务报表-部分统计字段新增 2.合伙人报表-部分统计字段新增
---
src/main/resources/mapper/report/OrderReportMapper.xml | 123 +++++++++++++++++++++++++---------------
1 files changed, 76 insertions(+), 47 deletions(-)
diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml
index b5f0454..f58f1ae 100644
--- a/src/main/resources/mapper/report/OrderReportMapper.xml
+++ b/src/main/resources/mapper/report/OrderReportMapper.xml
@@ -10,8 +10,10 @@
sum(order_markup_one_amount) as order_markup_one_amount,
sum(order_markup_two_amount) as order_markup_two_amount,
sum(order_markup_partner_amount) as order_markup_partner_amount,
+ sum(order_price_discount_amount)+sum(order_coupon_amount_total) as order_discount_total_fee,
sum(order_price_discount_amount) as order_price_discount_amount,
sum(order_coupon_amount_total) as order_coupon_amount_total,
+ sum(order_check_fee)+sum(order_lack_fee_supplier)+sum(order_replace_fee) as order_check_total_fee,
sum(order_check_fee) as order_check_fee,
sum(order_lack_fee_supplier) as order_lack_fee_supplier,
sum(order_replace_fee) as order_replace_fee,
@@ -39,10 +41,10 @@
where o.deleted=0
and o.status_backend not in ('PENDING','CANCEL','REFUND')
<if test="dto.startDate != null">
- and o.payment_time > #{dto.startDate}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
<if test="dto.partnerId != null">
and o.create_by in (
@@ -88,10 +90,10 @@
where o.deleted=0
and o.status_backend not in ('PENDING','CANCEL','REFUND')
<if test="dto.startDate != null">
- and o.payment_time > #{dto.startDate}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
<if test="dto.partnerId != null">
and o.create_by in (
@@ -111,6 +113,7 @@
o.create_time as orderDate,
o.payment_time,
o.status_backend as settleStatus,
+ vor.order_num as order_num,
vor.order_num-vor.order_lack_num as real_sale_num,
vor.*
from t_order o
@@ -121,10 +124,10 @@
where o.deleted=0
and o.status_backend not in ('PENDING','CANCEL','REFUND')
<if test="dto.startDate != null">
- and o.payment_time > #{dto.startDate}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
<if test="dto.partnerId != null">
and o.create_by in (
@@ -150,10 +153,10 @@
where o.deleted=0
and o.status_backend not in ('PENDING','CANCEL','REFUND')
<if test="dto.startDate != null">
- and o.payment_time > #{dto.startDate}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
<if test="dto.partnerId != null">
and o.create_by in (
@@ -233,7 +236,7 @@
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
+ 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.payment_time as payment_time2
@@ -264,7 +267,7 @@
select t2.*,
IFNULL(t3.fee_supplier,0) as order_fee_supplier,
IFNULL(t3.fee_partner,0) as order_fee_partner,
- IFNULL(t3.fee_platform,0) + IFNULL(t3.fee_packing_transport,0) as order_fee_platform,
+ IFNULL(t3.fee_platform,0) as order_fee_platform,
IFNULL(t3.fee_platform_pack,0) as order_fee_platform_pack,
IFNULL(t3.fee_platform_check,0) as order_fee_platform_check,
IFNULL(t3.fee_platform_transport,0) as order_fee_platform_transport,
@@ -272,7 +275,9 @@
IFNULL(t3.fee_packing_transport,0) as order_fee_packing_transport
from (
select
- 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,
+ t1.order_id, t1.total_amount ,sum(t1.num) as order_num ,
+ ( sum( t1.supplier_price_amount )+sum( t1.markup_one_amount )+sum( t1.markup_two_amount )+sum( t1.markup_partner_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
@@ -321,10 +326,10 @@
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}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
)t1
@@ -365,7 +370,7 @@
from (
SELECT
CASE
- WHEN o.payment_time > DATE(o.payment_time) + INTERVAL 17 HOUR THEN DATE(o.payment_time) + INTERVAL 1 DAY
+ WHEN o.payment_time >= DATE(o.payment_time) + INTERVAL 17 HOUR THEN DATE(o.payment_time) + INTERVAL 1 DAY
ELSE DATE(o.payment_time)
END AS payment_date,
oi.order_id,
@@ -412,10 +417,10 @@
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}
+ and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
)t1
where 1=1
@@ -494,7 +499,7 @@
and o.payment_time >= #{dto.startDate}
</if>
<if test="dto.endDate != null">
- and o.payment_time <= #{dto.endDate}
+ and o.payment_time < #{dto.endDate}
</if>
<if test="dto.supplierId != null">
and oi.supplier_id = #{dto.supplierId}
@@ -516,7 +521,7 @@
sum(order_num)-sum(order_lack_num) as real_sale_num,
sum(sales_fee_supplier) sales_fee_supplier,
sum(order_supplier_price_amount) - sum(order_check_fee) - sum(order_replace_fee) - sum(order_lack_fee_supplier) - sum(sales_fee_supplier) profitFeeAmount,
- case when COUNT(CASE WHEN status_backend IS NULL THEN 1 ELSE NULL END) = 0 Then '已完成' Else '进行中' end as settleStatus
+ case when COUNT(CASE WHEN status_backend ='COMPLETED' THEN NULL ELSE 1 END) = 0 Then '已完成' Else '进行中' end as settleStatus
from(
SELECT
oi.id,vor.*,p.name as supplierName,o.status_backend
@@ -543,7 +548,7 @@
sum(order_num)-sum(order_lack_num) as real_sale_num,
sum(sales_fee_supplier) sales_fee_supplier,
sum(order_supplier_price_amount) - sum(order_check_fee) - sum(order_replace_fee) - sum(order_lack_fee_supplier) - sum(sales_fee_supplier) profitFeeAmount,
- case when COUNT(CASE WHEN status_backend IS NULL THEN 1 ELSE NULL END) = 0 Then '已完成' Else '进行中' end as settleStatus
+ case when COUNT(CASE WHEN status_backend ='COMPLETED' THEN NULL ELSE 1 END) = 0 Then '已完成' Else '进行中' end as settleStatus
from(
SELECT
oi.id,vor.*,p.name as supplierName,o.status_backend
@@ -611,7 +616,13 @@
<!--供应商总价款-->
<sql id="all_supplier_amount">
- select IFNULL(sum(oi.supplier_price*oi.num),0) as supplier_amount from t_order_item oi where oi.supplier_id=#{dto.supplierId}
+ select IFNULL(sum(oi.supplier_price*oi.num),0) as supplier_amount
+ from t_order_item oi
+ left join t_order o
+ on oi.order_id = o.id
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
</sql>
<!--本月成交:本月售卖的底价合计-->
<sql id="cur_mon_supplier_amount">
@@ -619,9 +630,11 @@
from t_order_item oi
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
</sql>
<!--上月成交:上月售卖的底价合计-->
<sql id="last_mon_supplier_amount">
@@ -629,9 +642,11 @@
from t_order_item oi
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
</sql>
<!--今日成交:今日售卖的底价合计 // todo 需要根据当前时间判断今日的开始时间和结束时间-->
<sql id="today_supplier_amount">
@@ -639,9 +654,11 @@
from t_order_item oi
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
- and o.payment_time > #{dto.startDateTime}
- and o.payment_time <= #{dto.endDateTime}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
+ and o.payment_time >= #{dto.startDateTime}
+ and o.payment_time < #{dto.endDateTime}
</sql>
<!--缺货(本月):本月质检缺货,并且web端审核通过的数量合计-->
<sql id="cur_mon_lack_num">
@@ -651,10 +668,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'lack' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
</sql>
<!--缺货(上月):上月质检缺货,并且web端审核通过的数量合计-->
<sql id="last_mon_lack_num">
@@ -664,10 +683,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'lack' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
</sql>
<!--降级(本月):本月质检降级,并且web端审核通过的数量合计-->
<sql id="cur_mon_reduce_num">
@@ -677,10 +698,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'reduce' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
</sql>
<!-- 降级(上月):上月质检降级,并且web端审核通过的数量合计-->
@@ -691,10 +714,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'reduce' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
</sql>
<!-- 补货(本月):本月质检补货,并且web端审核通过的数量合计-->
<sql id="cur_mon_replace_num">
@@ -704,10 +729,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'replace' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
</sql>
<!-- 补货(上月):上月质检补货,并且web端审核通过的数量合计-->
<sql id="last_mon_replace_num">
@@ -717,10 +744,12 @@
on oic.order_item_id=oi.ID
left join t_order o
on oi.order_id = o.id
- where oi.supplier_id = #{dto.supplierId}
+ where o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oi.supplier_id = #{dto.supplierId}
and oic.type = 'replace' and oic.audit_status='AGREED'
- and o.payment_time > DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
- and o.payment_time <= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
+ and o.payment_time >= DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 2 MONTH)), '%Y-%m-%d 17:00:00')
+ and o.payment_time < DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
</sql>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3