From 118623071a97b66f21c29e2bc02b8f15855ede5d Mon Sep 17 00:00:00 2001 From: Cui Zhi Feng <cuizf@fengyuntec.com> Date: 星期三, 25 九月 2024 19:54:11 +0800 Subject: [PATCH] 均价计算 优化 --- src/main/resources/mapper/payment/DeliveryOrderItemMapper.xml | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/resources/mapper/payment/DeliveryOrderItemMapper.xml b/src/main/resources/mapper/payment/DeliveryOrderItemMapper.xml index 024312f..5ef7bb0 100644 --- a/src/main/resources/mapper/payment/DeliveryOrderItemMapper.xml +++ b/src/main/resources/mapper/payment/DeliveryOrderItemMapper.xml @@ -4,8 +4,8 @@ <select id="selectDoItemList" resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemListDTO"> SELECT q.id, o.order_no, o.warehouse_name, o.warehouse_location_code - , oi.flower_name, oi.flower_unit, oi.flower_color, oi.flower_cover, oi.num - , oi.supplier_price price, oi.flower_level + , oi.flower_name, oi.flower_unit, oi.flower_color, oi.flower_cover, oi.num + , oi.supplier_price price, oi.flower_level FROM t_delivery_order_item q join t_order o on q.order_id = o.id join t_order_item oi on oi.id = q.order_item_id @@ -16,7 +16,8 @@ <select id="selectDoItemCheckList" resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemCheckDTO"> SELECT oi.id, oi.flower_name, oi.flower_unit, oi.flower_color, oi.flower_cover, oi.num , oi.supplier_price price, oi.flower_level, oi.status, oi.check_images, oi.check_time, oi.check_remarks - , (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace') replaceNum + , (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'replace') + replaceNum , (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'reduce') reduceNum , (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack') lackNum FROM t_delivery_order_item q @@ -41,19 +42,21 @@ group by oi.flower_name, oi.flower_level </select> - <select id="selectSettlementListByTime" resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemSettlementDTO"> - SELECT ois.order_item_id, oi.flower_name, oi.flower_level, oi.num, oi.supplier_price price , s.`status` + <select id="selectSettlementListByTime" + resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemSettlementDTO"> + SELECT oi.id orderItemId, oi.flower_name, oi.flower_level, oi.num, oi.supplier_price price , ois.check_num, ois.check_fee, ois.replace_num, ois.replace_fee, ois.lack_num, ois.lack_fee_supplier lackFee , ois.station_fee, ois.sales_fee_supplier salesFee, ois.service_fee_rate, ois.service_fee - , ois.income_supplier income, o.status_backend, o.create_time orderTime + , ois.income_supplier income, o.status_backend, o.create_time orderTime, o.receive_time, o.order_no , (select count(1) from t_order_item_sales sa where sa.order_item_id = oi.id) salesNum + , (select s.`status` from t_order_settlement_detail sd, t_order_settlement s + where sd.order_item_id = oi.id + and sd.settlement_id = s.id and s.type = 'supplier') status FROM t_delivery_order_item doi join t_delivery_order q on q.id = doi.delivery_id join t_order o on o.id = q.order_id join t_order_item oi on oi.id = doi.order_item_id left join t_order_item_settlement ois on ois.order_item_id = oi.id - left join t_order_settlement_detail sd on sd.order_item_id = oi.id - left join t_order_settlement s on sd.settlement_id = s.id WHERE q.deleted = 0 and doi.deleted = 0 and q.supplier_id = #{supplierId} <if test="startDate != null"> @@ -62,10 +65,11 @@ <if test="endDate != null"> AND q.create_time <= #{endDate} </if> - order by q.create_time desc + order by q.create_time desc, oi.flower_name, oi.flower_level </select> - <select id="getSupplierStatisticsByTime" resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemStatisticsDTO"> + <select id="getSupplierStatisticsByTime" + resultType="com.mzl.flower.dto.response.payment.DeliveryOrderItemStatisticsDTO"> SELECT sum(oi.num) num, sum(oi.supplier_price*oi.num) price FROM t_delivery_order_item doi join t_delivery_order q on q.id = doi.delivery_id @@ -102,16 +106,16 @@ SELECT oi.id, q.delivery_id, oi.flower_name, oi.flower_unit, oi.flower_color , oi.flower_cover, oi.num , oi.supplier_price price, oi.flower_level, oi.status , (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' or oic.audit_status is null) + where oic.order_item_id = oi.id and oic.type = 'replace' + and (oic.audit_status = 'AGREED' or oic.audit_status is null) ) replaceNum , (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' or oic.audit_status is null) + where oic.order_item_id = oi.id and oic.type = 'reduce' + and (oic.audit_status = 'AGREED' or oic.audit_status is null) ) reduceNum , (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' or oic.audit_status is null) + where oic.order_item_id = oi.id and oic.type = 'lack' + and (oic.audit_status = 'AGREED' or oic.audit_status is null) ) lackNum FROM t_delivery_order_item q join t_order_item oi on oi.id = q.order_item_id -- Gitblit v1.9.3