| | |
| | | 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 |
| | |
| | | )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"> |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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 |
| | | where 1=1 |
| | | <if test="dto.paymentDateStart != null"> |
| | |
| | | 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 |
| | |
| | | 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> |
| | |
| | | and o.payment_time <= #{dto.endDate} |
| | | </if> |
| | | <if test="dto.supplierId != null"> |
| | | and oi.supplierId <= #{dto.supplierId} |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | </if> |
| | | ) t1 |
| | | GROUP BY |
| | |
| | | sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, |
| | | sum(order_num)-sum(order_lack_num) as real_sale_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 |
| | | 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 |
| | | from( |
| | | SELECT |
| | | oi.id,vor.*,p.name as supplierName |
| | | FROM t_order_item oi |
| | | left join (<include refid="baseSupplierSql"></include>) vor |
| | | on oi.id =vor.order_item_id |
| | | oi.id,vor.*,p.name as supplierName,o.status_backend |
| | | FROM |
| | | (<include refid="baseSupplierSql"></include>) vor |
| | | left join t_order_item oi |
| | | on vor.order_item_id = oi.id |
| | | left join t_supplier_info p |
| | | 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> |
| | | |
| | |
| | | sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, |
| | | sum(order_num)-sum(order_lack_num) as real_sale_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 |
| | | 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 |
| | | from( |
| | | SELECT |
| | | oi.id,vor.*,p.name as supplierName |
| | | FROM t_order_item oi |
| | | left join (<include refid="baseSupplierSql"></include>) vor |
| | | on oi.id =vor.order_item_id |
| | | oi.id,vor.*,p.name as supplierName,o.status_backend |
| | | FROM |
| | | (<include refid="baseSupplierSql"></include>) vor |
| | | left join t_order_item oi |
| | | on vor.order_item_id = oi.id |
| | | left join t_supplier_info p |
| | | 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> |
| | | |
| | |
| | | from( |
| | | SELECT |
| | | oi.id,vor.*,p.name as supplierName |
| | | FROM t_order_item oi |
| | | left join (<include refid="baseSupplierSql"></include>) vor |
| | | on oi.id =vor.order_item_id |
| | | FROM |
| | | (<include refid="baseSupplierSql"></include>) vor |
| | | left join t_order_item oi |
| | | on vor.order_item_id = oi.id |
| | | left join t_supplier_info p |
| | | 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> |