| | |
| | | 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, |
| | |
| | | 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 |
| | | |
| | |
| | | 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 |
| | | |
| | |
| | | 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> |
| | | |
| | |
| | | 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> |
| | | |
| | |
| | | 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, |
| | |
| | | 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 |
| | |
| | | |
| | | <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) + 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, |
| | |
| | | select |
| | | 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 |
| | | 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, |
| | |
| | | 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 |
| | |
| | | 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, |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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} |
| | |
| | | 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 ='COMPLETED' THEN NULL ELSE 1 END) = 0 Then '已完成' Else '进行中' end as settleStatus |
| | |
| | | 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 ='COMPLETED' THEN NULL ELSE 1 END) = 0 Then '已完成' Else '进行中' end as settleStatus |
| | |
| | | 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') |
| | | 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"> |
| | |
| | | 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') |
| | | 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"> |
| | |
| | | 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} |
| | | and o.payment_time >= #{dto.startDateTime} |
| | | and o.payment_time < #{dto.endDateTime} |
| | | </sql> |
| | | <!--缺货(本月):本月质检缺货,并且web端审核通过的数量合计--> |
| | | <sql id="cur_mon_lack_num"> |
| | |
| | | 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"> |
| | |
| | | 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"> |
| | |
| | | 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端审核通过的数量合计--> |
| | |
| | | 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"> |
| | |
| | | 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"> |
| | |
| | | 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> |