| | |
| | | |
| | | <select id="getOrderDateReport" resultType="com.mzl.flower.dto.response.report.OrderReportResultVO"> |
| | | select |
| | | sum(order_total) as order_total, |
| | | 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 |
| | | from ( |
| | | select |
| | | o.order_no,o.payment_time,o.status_backend,vor.* |
| | | from t_order o |
| | | left join ( |
| | | <include refid="baseSql"></include> |
| | | ) vor |
| | | on o.id =vor.order_id |
| | | where o.deleted=0 |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | <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 o.create_by in ( |
| | | select user_id from t_customer_info where partner_id=#{dto.partnerId} |
| | | ) |
| | | </if> |
| | | ) t |
| | | |
| | | </select> |
| | | |
| | | |
| | | <select id="getOrderDateReport2" resultType="com.mzl.flower.dto.response.report.OrderReportResultVO"> |
| | | select |
| | | sum(order_total) as order_total, |
| | | sum(order_supplier_price_amount) as order_supplier_price_amount, |
| | | sum(order_markup_one_amount) as order_markup_one_amount, |
| | |
| | | vor.order_num-vor.order_lack_num as real_sale_num, |
| | | vor.* |
| | | from t_order o |
| | | left join ( |
| | | <include refid="baseSql"></include> |
| | | ) vor |
| | | on o.id =vor.order_id |
| | | where o.deleted=0 |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | <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 o.create_by in ( |
| | | select user_id from t_customer_info where partner_id=#{dto.partnerId} |
| | | ) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getOrderDetailReport2" resultType="com.mzl.flower.dto.response.report.OrderDetailReportResultVO"> |
| | | select |
| | | o.order_no, |
| | | o.customer, |
| | | CONCAT( o.customer_province, ' ', o.customer_city, ' ', o.customer_region, ' ', o.customer_address ) AS address, |
| | | o.partner_name, |
| | | o.create_time as orderDate, |
| | | o.payment_time, |
| | | o.status_backend as settleStatus, |
| | | vor.order_num-vor.order_lack_num as real_sale_num, |
| | | vor.* |
| | | from t_order o |
| | | left join v_order_report vor |
| | | on o.id =vor.order_id |
| | | where o.deleted=0 |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <sql id="baseSql"> |
| | | 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 |
| | | 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 |
| | | <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 |
| | | 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> |