| | |
| | | ) |
| | | </if> |
| | | </select> |
| | | <select id="getPartnerOrderDateReport" resultType="com.mzl.flower.dto.response.report.OrderPartnerReportResultVO"> |
| | | <include refid="partnerBaseSql"></include> |
| | | </select> |
| | | |
| | | <select id="getPartnerOrderDateReportStatis" |
| | | resultType="com.mzl.flower.dto.response.report.OrderPartnerReportResultVO"> |
| | | select |
| | |
| | | sum(order_reduce_num) as order_reduce_num, |
| | | sum(order_lack_num) as order_lack_num, |
| | | sum(real_sale_num) as real_sale_num |
| | | from <include refid="partnerBaseSql"></include> |
| | | from ( <include refid="partnerBaseSqlWithDate"></include> ) t |
| | | </select> |
| | | |
| | | <sql id="partnerBaseSql"> |
| | | <select id="getPartnerOrderDateReportPage" |
| | | resultType="com.mzl.flower.dto.response.report.OrderPartnerReportResultVO"> |
| | | <include refid="partnerBaseSqlWithDate"></include> |
| | | </select> |
| | | <select id="getPartnerOrderDateReportList" |
| | | resultType="com.mzl.flower.dto.response.report.OrderPartnerReportResultVO"> |
| | | <include refid="partnerBaseSqlWithDate"></include> |
| | | </select> |
| | | |
| | | |
| | | <sql id="partnerBaseSqlWithDate"> |
| | | select |
| | | sum(order_total) as order_total, |
| | | sum(order_supplier_price_amount)+sum(order_markup_one_amount)+sum(order_markup_two_amount) as order_partner_price_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) as order_price_discount_amount, |
| | | sum(order_coupon_amount_total) as order_coupon_amount_total, |
| | | 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, |
| | | 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_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, |
| | | sum(order_total_fee) as order_total_fee, |
| | | sum(order_fee_packing_transport) as order_fee_packing_transport, |
| | | sum(order_num) as order_num, |
| | | sum(order_replace_num) as order_replace_num, |
| | | sum(order_reduce_num) as order_reduce_num, |
| | | sum(order_lack_num) as order_lack_num, |
| | | sum(order_num)-sum(order_lack_num) as real_sale_num, |
| | | partner_id, |
| | | partner_name |
| | | t3.payment_date as orderDate ,t3.partner_id,t3.partner_name, |
| | | IFNULL(sum(order_total),0) as order_total, |
| | | IFNULL(sum(order_supplier_price_amount)+sum(order_markup_one_amount)+sum(order_markup_two_amount),0) as order_partner_price_amount, |
| | | IFNULL(sum(order_supplier_price_amount),0) as order_supplier_price_amount, |
| | | IFNULL(sum(order_markup_one_amount),0) as order_markup_one_amount, |
| | | IFNULL(sum(order_markup_two_amount),0) as order_markup_two_amount, |
| | | 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),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, |
| | | IFNULL(sum(order_fee_supplier),0) as order_fee_supplier, |
| | | IFNULL(sum(order_fee_partner),0) as order_fee_partner, |
| | | IFNULL(sum(order_fee_platform),0) as order_fee_platform, |
| | | IFNULL(sum(order_fee_platform_pack),0) as order_fee_platform_pack, |
| | | IFNULL(sum(order_fee_platform_check),0) as order_fee_platform_check, |
| | | IFNULL(sum(order_fee_platform_transport),0) as order_fee_platform_transport, |
| | | IFNULL(sum(order_total_fee),0) as order_total_fee, |
| | | IFNULL(sum(order_fee_packing_transport),0) as order_fee_packing_transport, |
| | | IFNULL(sum(order_num),0) as order_num, |
| | | IFNULL(sum(order_replace_num),0) as order_replace_num, |
| | | IFNULL(sum(order_reduce_num),0) as order_reduce_num, |
| | | 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 |
| | | o.order_no,o.payment_time,o.status_backend,vor.*,ci.partner_id,p.name as partner_name |
| | | from t_order o |
| | | left join ( |
| | | <include refid="baseSql"></include> |
| | | ) vor |
| | | on o.id =vor.order_id |
| | | select t2.payment_date,t2.id,t2.order_no,t2.create_by,ci.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 |
| | | ELSE DATE(t.payment_time) |
| | | END AS payment_date, |
| | | t.payment_time as payment_time2 |
| | | FROM t_order t |
| | | WHERE t.deleted = 0 |
| | | and t.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | )t2 |
| | | left join ( <include refid="baseSqlWithDate"></include> ) r2 |
| | | on t2.id = r2.order_id |
| | | left join t_customer_info ci |
| | | on o.create_by=ci.user_id |
| | | on t2.create_by=ci.user_id |
| | | left join t_partner_info p |
| | | on ci.partner_id=p.id |
| | | where o.deleted=0 |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and ci.partner_id is not null |
| | | <if test="dto.startDate != null"> |
| | | and o.payment_time > #{dto.startDate} |
| | | </if> |
| | | <if test="dto.endDate != null"> |
| | | and o.payment_time <= #{dto.endDate} |
| | | </if> |
| | | <if test="dto.partnerId != null"> |
| | | and ci.partner_id = #{dto.partnerId} |
| | | </if> |
| | | ) t |
| | | group by partner_id,partner_name |
| | | )t3 |
| | | where t3.partner_id is not null |
| | | <if test="dto.paymentDateStart != null"> |
| | | and t3.payment_date >= #{dto.paymentDateStart} |
| | | </if> |
| | | <if test="dto.paymentDateEnd != null"> |
| | | and t3.payment_date <= #{dto.paymentDateEnd} |
| | | </if> |
| | | <if test="dto.partnerId != null"> |
| | | and t3.partner_id = #{dto.partnerId} |
| | | </if> |
| | | group by t3.payment_date,t3.partner_id,t3.partner_name |
| | | order by t3.payment_date desc,t3.partner_id |
| | | </sql> |
| | | |
| | | |
| | | <sql id="baseSql"> |
| | | select t2.*, |
| | |
| | | on t2.order_id =t3.order_id |
| | | </sql> |
| | | |
| | | |
| | | <sql id="baseSqlWithDate"> |
| | | 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_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, |
| | | IFNULL(t3.total_fee,0) as order_total_fee, |
| | | 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 |
| | | from ( |
| | | SELECT |
| | | CASE |
| | | 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, |
| | | oi.id, |
| | | IFNULL(oi.num,0) as num, |
| | | IFNULL(oi.total,0) as total, |
| | | IFNULL(oi.supplier_price,0) as supplier_price, |
| | | IFNULL(oi.supplier_price,0) * IFNULL(oi.num,0) as supplier_price_amount, |
| | | |
| | | IFNULL(oi.markup_one,0) as markup_one, |
| | | IFNULL(oi.markup_one,0)* IFNULL(oi.num,0) as markup_one_amount, |
| | | |
| | | IFNULL(oi.markup_two,0) as markup_two, |
| | | IFNULL(oi.markup_two,0)* IFNULL(oi.num,0) as markup_two_amount, |
| | | |
| | | IFNULL(oi.markup_partner,0) as markup_partner, |
| | | IFNULL(oi.markup_partner,0)* IFNULL(oi.num,0) as markup_partner_amount, |
| | | IFNULL(oi.price,0) as price, |
| | | IFNULL(oi.price,0)* IFNULL(oi.num,0) as price_amount, |
| | | |
| | | IFNULL(oi.original_price,0) as original_price, |
| | | IFNULL(oi.original_price,0)*IFNULL(oi.num,0) as original_price_amount, |
| | | |
| | | IFNULL(oi.original_price,0)*IFNULL(oi.num,0) - IFNULL(oi.price,0)* IFNULL(oi.num,0) as price_discount_amount, |
| | | |
| | | |
| | | IFNULL(oi.real_price,0) as real_price, |
| | | IFNULL(oi.real_total,0) as real_total, |
| | | |
| | | IFNULL(oi.coupon_amount_total,0) as coupon_amount_total, |
| | | |
| | | IFNULL(ois.check_fee,0) as check_fee, |
| | | 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 |
| | | FROM t_order o |
| | | left join t_order_item oi |
| | | on oi.order_id=o.id |
| | | left join t_station s on s.id = oi.station_id |
| | | 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 |
| | | )t1 |
| | | where 1=1 |
| | | <if test="dto.paymentDateStart != null"> |
| | | and t1.payment_date >= #{dto.paymentDateStart} |
| | | </if> |
| | | <if test="dto.paymentDateEnd != null"> |
| | | and t1.payment_date <= #{dto.paymentDateEnd} |
| | | </if> |
| | | group by order_id |
| | | ) t2 |
| | | left join ( |
| | | select |
| | | ois.order_id, |
| | | IFNULL(sum(ois.fee_supplier),0) as fee_supplier, |
| | | IFNULL(sum(ois.fee_partner),0) as fee_partner, |
| | | IFNULL(sum(ois.fee_platform),0) as fee_platform, |
| | | IFNULL(sum(ois.fee_platform_pack),0) as fee_platform_pack, |
| | | IFNULL(sum(ois.fee_platform_check),0) as fee_platform_check, |
| | | IFNULL(sum(ois.fee_platform_transport),0) as fee_platform_transport, |
| | | IFNULL(sum(ois.total_fee),0) as total_fee, |
| | | IFNULL(sum(ois.fee_packing_transport),0) as fee_packing_transport |
| | | from t_order_item_sales ois |
| | | group by order_id |
| | | )t3 |
| | | on t2.order_id =t3.order_id |
| | | </sql> |
| | | |
| | | |
| | | </mapper> |