From d81d4ff55fb4a47745cd521a27426b9f81cc8f9a Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期一, 21 十月 2024 16:53:49 +0800 Subject: [PATCH] 1.小程序-供应商:统计-新增本月售后订单,本月售后扎数,总成交扎数 --- src/main/resources/mapper/report/OrderReportMapper.xml | 204 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 188 insertions(+), 16 deletions(-) diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml index 98ec9dd..c1a53c1 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, @@ -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"> @@ -265,7 +264,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) as order_fee_platform, + IFNULL(t3.fee_platform,0) + IFNULL(t3.fee_packing_transport,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, @@ -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 @@ -479,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 @@ -489,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> @@ -527,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> @@ -554,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> @@ -588,8 +589,179 @@ 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> + <select id="getAppSupplierAmountStatistics" + resultType="com.mzl.flower.dto.response.report.AppSupplierStatisticsVO"> + select + ( <include refid="all_supplier_amount"></include> ) as all_supplier_amount + , ( <include refid="cur_mon_supplier_amount"></include> ) as cur_mon_supplier_amount + , ( <include refid="last_mon_supplier_amount"></include> ) as last_mon_supplier_amount + , ( <include refid="today_supplier_amount"></include> ) as today_supplier_amount + , ( <include refid="cur_mon_lack_num"></include> ) as cur_mon_lack_num + , ( <include refid="last_mon_lack_num"></include> ) as last_mon_lack_num + , ( <include refid="cur_mon_reduce_num"></include> ) as cur_mon_reduce_num + , ( <include refid="last_mon_reduce_num"></include> ) as last_mon_reduce_num + , ( <include refid="cur_mon_replace_num"></include> ) as cur_mon_replace_num + , ( <include refid="last_mon_replace_num"></include> ) as last_mon_replace_num + + , ( <include refid="all_supplier_flower_num"></include> ) as all_supplier_flower_num + , ( <include refid="cur_mon_after_sale_order_num"></include> ) as cur_mon_after_sale_order_num + , ( <include refid="cur_mon_after_sale_flower_num"></include> ) as cur_mon_after_sale_flower_num + + </select> + + <!--供应商总价款--> + <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} + </sql> + <!--本月成交:本月售卖的底价合计--> + <sql id="cur_mon_supplier_amount"> + select IFNULL(sum(oi.supplier_price*oi.num),0) as cur_mon_supplier_amount + 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') + </sql> + <!--上月成交:上月售卖的底价合计--> + <sql id="last_mon_supplier_amount"> + select IFNULL(sum(oi.supplier_price*oi.num),0) as last_mon_supplier_amount + 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') + </sql> + <!--今日成交:今日售卖的底价合计 // todo 需要根据当前时间判断今日的开始时间和结束时间--> + <sql id="today_supplier_amount"> + select IFNULL(sum(oi.supplier_price*oi.num),0) as today_supplier_amount + 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} + </sql> + <!--缺货(本月):本月质检缺货,并且web端审核通过的数量合计--> + <sql id="cur_mon_lack_num"> + select IFNULL(sum(oic.num),0) as cur_mon_lack_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> + <!--缺货(上月):上月质检缺货,并且web端审核通过的数量合计--> + <sql id="last_mon_lack_num"> + select IFNULL(sum(oic.num),0) as last_mon_lack_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> + <!--降级(本月):本月质检降级,并且web端审核通过的数量合计--> + <sql id="cur_mon_reduce_num"> + select IFNULL(sum(oic.num),0) as cur_mon_reduce_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> + +<!-- 降级(上月):上月质检降级,并且web端审核通过的数量合计--> + <sql id="last_mon_reduce_num"> + select IFNULL(sum(oic.num),0) as last_mon_reduce_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> +<!-- 补货(本月):本月质检补货,并且web端审核通过的数量合计--> + <sql id="cur_mon_replace_num"> + select IFNULL(sum(oic.num),0) as cur_mon_replace_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> + <!-- 补货(上月):上月质检补货,并且web端审核通过的数量合计--> + <sql id="last_mon_replace_num"> + select IFNULL(sum(oic.num),0) as last_mon_replace_num + from t_order_item_check oic + left join t_order_item oi + on oic.order_item_id=oi.ID + left join t_order o + on oi.order_id = o.id + where 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') + </sql> + + <!-- 总成交扎数--> + <sql id="all_supplier_flower_num"> + select IFNULL(sum(oi.num),0) as all_supplier_flower_num + from t_order_item oi + where oi.supplier_id= #{dto.supplierId} + </sql> + + <!-- 本月售后订单--> + <sql id="cur_mon_after_sale_order_num"> + select IFNULL(count(distinct o.id),0) as cur_mon_after_sale_order_num + from t_order_item oi + left join t_order_item_sales ois + on oi.id=ois.order_item_id + left join t_order o + on oi.order_id = o.id + where oi.deleted=0 and ois.DELETEd=0 and ois.STATUS='AGREED' + 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="cur_mon_after_sale_flower_num"> + select IFNULL(sum(ois.num),0) as cur_mon_after_sale_flower_num + from t_order_item oi + left join t_order_item_sales ois + on oi.id=ois.order_item_id + left join t_order o + on oi.order_id = o.id + where oi.deleted=0 and ois.DELETEd=0 and ois.STATUS='AGREED' + 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> </mapper> \ No newline at end of file -- Gitblit v1.9.3