From 88c58af55d8d8a9a73f8e95574897cbcb7ed47e8 Mon Sep 17 00:00:00 2001 From: jiask <1069621233@qq.com> Date: Thu, 9 Oct 2025 13:32:14 +0800 Subject: [PATCH] =?UTF-8?q?jsk=20=20=E6=B6=88=E8=B4=B9=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/reportforms/OrgConsumerMapper.xml | 114 +++++++----------- .../mapper/reportforms/placeMapper.xml | 48 +++----- 2 files changed, 60 insertions(+), 102 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml index b5045c12..18d2b4d3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml @@ -860,48 +860,32 @@ ap.area_name AS work_area_name, a.mch_sn FROM ( - SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount, - a.flow_real_amount AS real_amount, a.pay_time, - CASE - WHEN bd.canteen_id IS NOT NULL THEN bd.canteen_id - WHEN roi.canteen_id IS NOT NULL THEN roi.canteen_id - ELSE a.canteen_id END AS canteen_id, - CONCAT(a.cust_id,a.ord_time) AS id, - a.mch_sn AS mch_sn - FROM report_account_flow a + select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time, + case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id + when cdp.dining_place_id is not null then cdp.dining_place_id + else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id + ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id + else a.canteen_id end as canteen_id + ,a.mch_sn as mch_sn + from (select * from report_account_flow a where a.pay_time >= #{vo.startTime} AND a.flow_type IN ( 110, 120,130 ) + AND a.pay_time <= #{vo.endTime} ) a LEFT JOIN device_info di ON a.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id - LEFT JOIN report_order_info roi - ON CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) - WHERE a.pay_time >= #{vo.startTime} - AND a.flow_type IN (110, 120, 130) - AND a.pay_time <= #{vo.endTime} - AND (a.remark NOT LIKE '%支付' OR a.remark IS NULL) - - UNION ALL - - SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount, - a.flow_real_amount AS real_amount, a.pay_time, bd.canteen_id, - CONCAT(a.cust_id,a.ord_time) AS id, - a.mch_sn AS mch_sn - FROM report_account_flow a - LEFT JOIN device_info di ON a.mch_sn = di.device_sn - LEFT JOIN device_bind bd ON di.device_id = bd.device_id - WHERE a.pay_time >= #{vo.startTime} - AND a.flow_type IN (110, 120, 130) - AND a.pay_time <= #{vo.endTime} - AND a.remark LIKE '%支付' + LEFT JOIN (select * from report_order_info a where a.pay_time >= #{vo.startTime} + AND a.pay_time <= #{vo.endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) + LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id + left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area' ) a LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id LEFT JOIN cust_org co ON co.org_id = ci.org_id JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area' - LEFT JOIN alloc_area ar ON ar.area_id = ac.area_id + LEFT JOIN alloc_area ar ON ar.area_id = a.area_id LEFT JOIN alloc_area ap ON ap.area_id = p.dining_place_id - WHERE ac.area_id != p.dining_place_id + WHERE ar.area_id != p.dining_place_id - AND ac.area_id IN + AND ar.area_id IN #{id} @@ -929,34 +913,29 @@ p.dining_place_id FROM ( select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time, - case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id - else a.canteen_id end as canteen_id,CONCAT(a.cust_id,a.ord_time) as id + case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id + when cdp.dining_place_id is not null then cdp.dining_place_id + else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id + ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id + else a.canteen_id end as canteen_id ,a.mch_sn as mch_sn - from report_account_flow a + from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) + AND a.pay_time <= #{endTime} ) a LEFT JOIN device_info di ON a.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id - LEFT JOIN report_order_info roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) - where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) - AND a.pay_time <= #{endTime} and (a.remark not like '%支付' or a.remark is null) - - UNION ALL - - select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time,bd.canteen_id - ,CONCAT(a.cust_id,a.ord_time) as id - ,a.mch_sn as mch_sn - from report_account_flow a - LEFT JOIN device_info di ON a.mch_sn = di.device_sn - LEFT JOIN device_bind bd ON di.device_id = bd.device_id - where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) - AND a.pay_time <= #{endTime} and a.remark like '%支付' + LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime} + AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) + LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id + left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area' ) a LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id JOIN cust_info ci ON ci.cust_id = a.cust_id + LEFT JOIN alloc_area ar ON ar.area_id = a.area_id JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area' - WHERE ac.area_id != p.dining_place_id + WHERE ar.area_id != p.dining_place_id - AND ac.area_id IN + AND ar.area_id IN #{id} @@ -994,34 +973,29 @@ a.mch_sn FROM ( select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time, - case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id - else a.canteen_id end as canteen_id,CONCAT(a.cust_id,a.ord_time) as id + case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id + when cdp.dining_place_id is not null then cdp.dining_place_id + else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id + ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id + else a.canteen_id end as canteen_id ,a.mch_sn as mch_sn - from report_account_flow a + from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) + AND a.pay_time <= #{endTime} ) a LEFT JOIN device_info di ON a.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id - LEFT JOIN report_order_info roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) - where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) - AND a.pay_time <= #{endTime} and (a.remark not like '%支付' or a.remark is null) - - UNION ALL - - select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time,bd.canteen_id - ,CONCAT(a.cust_id,a.ord_time) as id - ,a.mch_sn as mch_sn - from report_account_flow a - LEFT JOIN device_info di ON a.mch_sn = di.device_sn - LEFT JOIN device_bind bd ON di.device_id = bd.device_id - where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) - AND a.pay_time <= #{endTime} and a.remark like '%支付' + LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime} + AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) + LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id + left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area' ) a LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id + LEFT JOIN alloc_area ar ON ar.area_id = a.area_id JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area' - WHERE ac.area_id != p.dining_place_id + WHERE ar.area_id != p.dining_place_id - AND ac.area_id IN + AND ar.area_id IN #{id} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/placeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/placeMapper.xml index e7e83fdd..6f70e6c6 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/placeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/placeMapper.xml @@ -34,48 +34,32 @@ ap.area_name AS work_area_name, a.mch_sn FROM ( - SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount, - a.flow_real_amount AS real_amount, a.pay_time, - CASE - WHEN bd.canteen_id IS NOT NULL THEN bd.canteen_id - WHEN roi.canteen_id IS NOT NULL THEN roi.canteen_id - ELSE a.canteen_id END AS canteen_id, - CONCAT(a.cust_id,a.ord_time) AS id, - a.mch_sn AS mch_sn - FROM report_account_flow a + select a.flow_id as order_id, a.cust_id,a.flow_amount as payable_amount,a.flow_real_amount as real_amount,a.pay_time, + case when bd.area_id is not null then bd.area_id when ac.area_id is not null then ac.area_id + when cdp.dining_place_id is not null then cdp.dining_place_id + else a.canteen_id end as area_id,CONCAT(a.cust_id,a.ord_time) as id + ,case when bd.canteen_id is not null then bd.canteen_id when roi.canteen_id is not null then roi.canteen_id + else a.canteen_id end as canteen_id + ,a.mch_sn as mch_sn + from (select * from report_account_flow a where a.pay_time >= #{startTime} AND a.flow_type IN ( 110, 120,130 ) + AND a.pay_time <= #{endTime} ) a LEFT JOIN device_info di ON a.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id - LEFT JOIN report_order_info roi - ON CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) - WHERE a.pay_time >= #{startTime} - AND a.flow_type IN (110, 120, 130) - AND a.pay_time <= #{endTime} - AND (a.remark NOT LIKE '%支付' OR a.remark IS NULL) - - UNION ALL - - SELECT a.flow_id AS order_id, a.cust_id, a.flow_amount AS payable_amount, - a.flow_real_amount AS real_amount, a.pay_time, bd.canteen_id, - CONCAT(a.cust_id,a.ord_time) AS id, - a.mch_sn AS mch_sn - FROM report_account_flow a - LEFT JOIN device_info di ON a.mch_sn = di.device_sn - LEFT JOIN device_bind bd ON di.device_id = bd.device_id - WHERE a.pay_time >= #{startTime} - AND a.flow_type IN (110, 120, 130) - AND a.pay_time <= #{endTime} - AND a.remark LIKE '%支付' + LEFT JOIN (select * from report_order_info a where a.pay_time >= #{startTime} + AND a.pay_time <= #{endTime} ) roi on CONCAT(a.cust_id,a.ord_time)=CONCAT(roi.cust_id,roi.order_time) + LEFT JOIN alloc_canteen ac ON ac.canteen_id = roi.canteen_id + left join cust_dining_place cdp on a.cust_id=cdp.cust_id and cdp.type = 'area' ) a LEFT JOIN alloc_canteen ac ON ac.canteen_id = a.canteen_id LEFT JOIN cust_info ci ON ci.cust_id = a.cust_id LEFT JOIN cust_org co ON co.org_id = ci.org_id JOIN cust_dining_place p ON p.cust_id = ci.cust_id AND p.type = 'area' - LEFT JOIN alloc_area ar ON ar.area_id = ac.area_id + LEFT JOIN alloc_area ar ON ar.area_id = a.area_id LEFT JOIN alloc_area ap ON ap.area_id = p.dining_place_id - WHERE ac.area_id != p.dining_place_id + WHERE ar.area_id != p.dining_place_id - AND ac.area_id IN + AND ar.area_id IN #{id}