diff --git "a/\345\217\221\344\270\252sql\345\220\247 \345\216\273\351\231\244\344\272\206\344\270\200\344\272\233\346\263\250\351\207\212" "b/\345\217\221\344\270\252sql\345\220\247 \345\216\273\351\231\244\344\272\206\344\270\200\344\272\233\346\263\250\351\207\212" new file mode 100644 index 0000000000000000000000000000000000000000..11e4bbba32f6fde969d85755fd5c6ba52edf7ddf --- /dev/null +++ "b/\345\217\221\344\270\252sql\345\220\247 \345\216\273\351\231\244\344\272\206\344\270\200\344\272\233\346\263\250\351\207\212" @@ -0,0 +1,191 @@ +select + o.id, + o.user_name, + o.update_time, + o.creat_time, + o.is_rollout, + o.is_platform, + o.order_no, + o.appointed_time, + o.sku_level, + o.sku_name, + o.service_type_name, + o.repair_address, + o.address_details, + o.village, + o.remarks, + o.repair_remarks, + o.status, + o.status_name, + o.labor_cost, + o.material_cost, + o.additional_cost, + o.is_prepay, + o.prepayment, + o.merchant_id, + o.merchant_name, + o.is_assign, + o.longitude, + o.latitude, + o.is_activity, + o.activity_id, + o.activity_type, + o.activity_money, + o.is_coupon, + o.coupon_id, + o.coupon_money, + o.coupon_company_pay_money, + o.coupon_xg_pay_money, + o.coupon_dealer_pay_money, + o.coupon_merchant_pay_money, + o.payment_type, + o.end_type, + o.type, + o.origin, + o.count, + o.city_code, + o.city_name, + o.city_area, + o.city_area_name, + o.freezing_days, + o.commission_type, + o.dealer_commission, + o.xg_commission, + o.sku_type, + o.labor_cost_code, + o.material_cost_code, + o.additional_cost_code, + o.third_order_no, + o.sku_item_name, + o.sku_item_id, + o.quote_remarks, + o.merchant_order_no, + o.is_abnormality, + o.order_receiving_time, + o.retention_time, + o.refund_type, + o.refund_status, + o.material_cost_details, + o.additional_cost_details, + o.is_rewards_punish, + o.merchant_pay_type, + o.modify_count, + o.income_xg, + o.order_type, + o.groupon_id, + o.insurance_no1, + o.insurance_no2, + o.insurance_type, + o.unit, + o.price as cprice, o.price as bprice, a.name as activity_name, + CONCAT('每人',if(a.daily_limits is null,CONCAT(' ') , CONCAT('每天限',a.daily_limits,'单')),if(a.total_limits is null,' ' , CONCAT('总共限',a.total_limits,'单'))) as activity_summary, + -- p.details as problem_details, + + IF(ro.id is null and o.is_duty_free!='1', + + IF(o.sku_type = '1' , + IF(o.commission_type = '2', + + ROUND((o.labor_cost+o.additional_cost + o.material_cost) * (1 - 0.00) * (1 - o.xg_commission), + 2), + ROUND(o.xg_commission * (1 - 0.00), + 2)), + ROUND(o.price * (1 - 0.00) * (1 - o.xg_commission), 2)) + , + + IF(o.sku_type = '1' , + IF(o.commission_type = '2', + ROUND((o.labor_cost+o.additional_cost + o.material_cost) * (1 - o.xg_commission), + 2), + ROUND(o.xg_commission, + 2)), + ROUND(o.price * (1 - 0.00), 2)) + ) AS fixed_xg_money, + + + ROUND(asku.preferential_value, 2) as xg_activity_money + FROM + t_order o + LEFT JOIN + t_activity_record ar ON o.id = ar.order_id AND ar.is_enable=1 AND ar.user_type=2 + LEFT JOIN + t_activity a ON ar.activity_id = a.id AND a.is_enable=1 + LEFT JOIN + t_activity_sku asku ON asku.activity_id = a.id AND asku.is_enable=1 AND asku.id=ar.activity_sku_id + LEFT JOIN + t_problem p ON o.problem_id = p.id + LEFT JOIN + t_merchant m ON o.merchant_id = m.id AND o.is_enable=1 + LEFT JOIN + t_reward_order_record ro on o.id=ro.order_id and ro.type=1 and ro.is_tax=2 AND ro.is_enable = 1 + + + left join + t_grid_order tgo on o.id=tgo.order_id and tgo.is_enable=1 + left join + + (select s1.id as id, s1.suppliers_id as suppliers_id, s2.spu_id as spu_id, s1.grid_id as grid_id from t_suppliers_grid s1 inner join t_suppliers_spu s2 on s1.suppliers_id=s2.suppliers_id and s1.is_enable=1 and s2.is_enable=1) tsg + on tsg.spu_id=o.sku_item_id and tgo.grid_id=tsg.grid_id + + WHERE o.is_enable=1 + + and o.status = 2 + + + + + + + + + + and o.city_code = #{objectT.cityCode} + + and o.status in (3,4,5,6,7,10,11,12,21) + and o.xg_id = #{objectT.xgId} + + and o.is_assign = 2 and o.status in (15,17,19) + and o.xg_id = #{objectT.xgId} + + and o.status in (8,9,16,14,13) + and o.xg_id = #{objectT.xgId} + + + + AND o.`status` not in (1,22,23) + AND m.type =5 + AND o.merchant_id =(select xg.merchant_id from t_xg xg where xg.id = #{objectT.xgId} ) + + + + + AND ( (o.merchant_id is null or (o.merchant_id is not null and o.is_platform ='2')) or + IF(m.label_state = '2' AND o.is_platform = '1' , + o.merchant_id = (SELECT + tl.merchant_id + FROM + t_xg_label tl + where tl.is_enable = 1 + AND tl.merchant_id = o.merchant_id + AND tl.status = 3 + AND tl.xg_id = #{objectT.xgId} limit 0,1), + 1 = 1) + ) + + group by o.id + + + order by o.update_time desc + + + + order by o.appointed_time desc + + + order by o.creat_time desc + \ No newline at end of file