From 72cf5cdaef3be1e81da7f59d6ed61fe368f44816 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期三, 08 一月 2025 14:48:46 +0800 Subject: [PATCH] add:物流发货针对散户更改微信发货方式,保存物流单号,未发送之前可更改 --- src/main/resources/mapper/report/OrderReportMapper.xml | 248 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 214 insertions(+), 34 deletions(-) diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml index 93ffbf0..f88e5bb 100644 --- a/src/main/resources/mapper/report/OrderReportMapper.xml +++ b/src/main/resources/mapper/report/OrderReportMapper.xml @@ -5,12 +5,15 @@ <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, 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, @@ -38,15 +41,13 @@ 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 ( - select user_id from t_customer_info where partner_id=#{dto.partnerId} - ) + and o.partner_id=#{dto.partnerId} </if> ) t @@ -87,15 +88,13 @@ 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 ( - select user_id from t_customer_info where partner_id=#{dto.partnerId} - ) + and o.partner_id=#{dto.partnerId} </if> ) t @@ -110,6 +109,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 @@ -120,15 +120,13 @@ 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 ( - select user_id from t_customer_info where partner_id=#{dto.partnerId} - ) + and o.partner_id=#{dto.partnerId} </if> </select> @@ -149,15 +147,13 @@ 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 ( - select user_id from t_customer_info where partner_id=#{dto.partnerId} - ) + and o.partner_id=#{dto.partnerId} </if> </select> @@ -212,6 +208,7 @@ IFNULL(sum(order_markup_partner_amount),0) as order_markup_partner_amount, IFNULL(sum(order_price_discount_amount),0) as order_price_discount_amount, IFNULL(sum(order_coupon_amount_total),0) as order_coupon_amount_total, + IFNULL(sum(order_check_fee)+sum(order_lack_fee_supplier)+sum(order_replace_fee),0) as order_check_total_fee, IFNULL(sum(order_check_fee),0) as order_check_fee, IFNULL(sum(order_lack_fee_supplier),0) as order_lack_fee_supplier, IFNULL(sum(order_replace_fee),0) as order_replace_fee, @@ -232,7 +229,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 @@ -261,6 +258,8 @@ <sql id="baseSql"> select t2.*, + IFNULL(t2.order_check_fee+t2.order_lack_fee_supplier+t2.order_replace_fee,0) as order_check_total_fee, + IFNULL(t2.order_price_discount_amount+t2.order_coupon_amount_total,0) as order_discount_total_fee, 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, @@ -271,10 +270,24 @@ 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, - sum(replace_num) as order_replace_num,sum(reduce_num) as order_reduce_num,sum(lack_num) as order_lack_num + 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 + o.total_amount, o.flower_amount, o.packing_fee, o.transport_fee, oi.order_id, oi.id, IFNULL(oi.num,0) as num, @@ -319,10 +332,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 @@ -363,7 +376,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, @@ -410,10 +423,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 @@ -460,7 +473,9 @@ sum( t1.replace_fee ) AS order_replace_fee, sum( t1.lack_fee_supplier ) AS order_lack_fee_supplier, sum( t1.num ) AS order_num, - sum( t1.lack_num ) AS order_lack_num + sum( t1.lack_num ) AS order_lack_num, + sum( t1.reduce_num ) AS order_reduce_num, + sum( t1.replace_num ) AS order_replace_num FROM ( SELECT @@ -476,8 +491,11 @@ IFNULL( oi.supplier_price, 0 ) * IFNULL( oi.num, 0 ) AS supplier_price_amount, 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' and oic.audit_status='AGREED'),0) as lack_num + 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 = '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 @@ -492,7 +510,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} @@ -511,10 +529,14 @@ sum(order_supplier_price_amount) order_supplier_price_amount, sum(order_check_fee) order_check_fee, sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, + sum(order_num) as order_num, sum(order_num)-sum(order_lack_num) as real_sale_num, + sum(order_lack_num) as order_lack_num, + sum(order_reduce_num ) AS order_reduce_num, + sum(order_replace_num ) AS order_replace_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 @@ -538,10 +560,14 @@ sum(order_supplier_price_amount) order_supplier_price_amount, sum(order_check_fee) order_check_fee, sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, + sum(order_num) as order_num, sum(order_num)-sum(order_lack_num) as real_sale_num, + sum(order_lack_num) as order_lack_num, + sum(order_reduce_num ) AS order_reduce_num, + sum(order_replace_num ) AS order_replace_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 @@ -591,4 +617,158 @@ ) 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 + + </select> + + <!--供应商总价款--> + <sql id="all_supplier_amount"> + 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"> + 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 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"> + 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 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"> + 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 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"> + 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 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') + </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 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') + </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 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') + </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 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') + </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 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') + </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 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') + </sql> + </mapper> \ No newline at end of file -- Gitblit v1.9.3