From ddca8e96ee1aa47ba33fcf3a9a1e7e964d63ad8b Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期四, 31 十月 2024 17:15:43 +0800 Subject: [PATCH] fix: 钱包供应商财务1 --- src/main/resources/mapper/payment/DeliveryOrderMapper.xml | 81 ++++++++++++++++++++++------------------ 1 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml index 34f3909..7af2ae0 100644 --- a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml +++ b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml @@ -188,40 +188,45 @@ </select> <select id="statisticStationList" resultType="com.mzl.flower.dto.response.flower.StationStatisticDTO"> - SELECT - s.station_id AS stationId, - st.`name`, - SUM( oi.num ) AS totalNum - FROM - t_delivery_order o - LEFT JOIN t_delivery_order_item i ON o.id = i.delivery_id - LEFT JOIN t_order_item oi ON oi.id = i.order_item_id - LEFT JOIN t_supplier_info s ON s.id = o.supplier_id - LEFT JOIN t_station st ON st.id = s.station_id - LEFT JOIN t_order t ON t.id = i.order_id - WHERE o.deleted = 0 - AND o.`status` IN ( 'PENDING', 'ARRIVED', 'CHECKED' ) - <if test="userId !=null and userId !=''"> - AND st.user_ids LIKE concat('%', #{userId},'%') - </if> - <if test="name !=null and name !=''"> - AND ( s.id LIKE concat('%', #{name},'%') OR - s.contact_tel LIKE concat('%', #{name},'%') OR - s.`name` LIKE concat('%', #{name},'%') OR - st.`name` LIKE concat('%', #{name},'%') OR - t.warehouse_location_code LIKE concat('%', #{name},'%') - ) - </if> - <if test="startDate != null"> - AND o.create_time > #{startDate} - </if> - <if test="endDate != null"> - AND o.create_time <= #{endDate} - </if> - GROUP BY - s.station_id, - st.`name`; + SELECT + s.station_id AS stationId, + st.`name`, + SUM( oi.num ) AS totalNum, + SUM(CASE WHEN o.`status` = 'CHECKED' THEN oi.num ELSE 0 END) AS checkedSupplierCount, + SUM(CASE WHEN o.`status` = 'PENDING' or o.`status`= 'ARRIVED' THEN oi.num ELSE 0 END) AS uncheckedSupplierCount + FROM t_delivery_order o + LEFT JOIN t_delivery_order_item i ON o.id = i.delivery_id + LEFT JOIN t_order_item oi ON oi.id = i.order_item_id + LEFT JOIN t_supplier_info s ON s.id = o.supplier_id + LEFT JOIN t_station st ON st.id = s.station_id + LEFT JOIN t_order t ON t.id = i.order_id + WHERE o.deleted = 0 + AND o.`status` IN ( 'PENDING', 'ARRIVED', 'CHECKED' ) + <if test="userId !=null and userId !=''"> + AND st.user_ids LIKE concat('%', #{userId},'%') + </if> + <if test="name !=null and name !=''"> + AND ( s.id LIKE concat('%', #{name},'%') OR + s.contact_tel LIKE concat('%', #{name},'%') OR + s.`name` LIKE concat('%', #{name},'%') OR + st.`name` LIKE concat('%', #{name},'%') OR + t.warehouse_location_code LIKE concat('%', #{name},'%') + ) + </if> + <if test="startDate != null"> + AND o.create_time > #{startDate} + </if> + <if test="endDate != null"> + AND o.create_time <= #{endDate} + </if> + <if test="statusList != null and statusList.size > 0"> + AND o.status in + <foreach collection="statusList" item="status" open="(" separator="," close=")"> + #{status} + </foreach> + </if> + GROUP BY s.station_id, st.`name` </select> <update id="setDeliveryOrderPending"> @@ -236,9 +241,13 @@ SELECT q.* FROM t_delivery_order q WHERE q.deleted = 0 - and q.status in ('PENDING', 'ARRIVED', 'CHECKED') + AND q.status in ('PENDING', 'ARRIVED') AND q.supplier_id = #{supplierId} - AND q.create_time > #{startDate} - AND q.create_time <= #{endDate} + <if test="startDate != null"> + AND q.create_time > #{startDate} + </if> + <if test="endDate != null"> + AND q.create_time <= #{endDate} + </if> </select> </mapper> \ No newline at end of file -- Gitblit v1.9.3