From 324c53294f2400f8c427752b9f2edb2e38281e1c Mon Sep 17 00:00:00 2001 From: lizhenhua <1075222162@qq.com> Date: Mon, 8 Sep 2025 09:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=8A=9F=E8=83=BD=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reportforms/mapper/OrgConsumeMapper.java | 4 + .../mapper/reportforms/OrgConsumerMapper.xml | 327 +++++++++--------- 2 files changed, 158 insertions(+), 173 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/mapper/OrgConsumeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/mapper/OrgConsumeMapper.java index 0e3ea829..f29d814b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/mapper/OrgConsumeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/mapper/OrgConsumeMapper.java @@ -43,4 +43,8 @@ public interface OrgConsumeMapper { List selectAllOrgs(); List getDeductionlist(OrgConsume orgConsume); + + List> selectReserveRecordsFromDatabase(OrgConsume orgConsume); + + List getlistForH5Special(OrgConsume orgConsume); } 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 bf25c50d..509405f0 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 @@ -9,102 +9,70 @@ WHEN t.flow_type = 120 THEN 'deduction' WHEN t.source_type = 7 THEN 'H5' WHEN t.source_type = 53 THEN 'super' - WHEN (t.source_type IS NULL OR t.source_type = '' OR t.source_type = 0) AND t.remark LIKE '%支付%' THEN 'station' + WHEN (t.source_type IS NULL OR t.source_type = 0 OR t.source_type = '') + AND t.remark LIKE '%支付%' THEN 'station' ELSE 'canteen' END AS conSource, - ROUND(SUM(t.flow_real_amount) / 100, 2) AS amount - FROM - ( - -- 第一段:正常消费(flow_type = 110) - SELECT DISTINCT - aa.canteen_name, + ROUND(SUM(t.amount) / 100, 2) AS amount + FROM ( + + SELECT aac.area_name, + f.flow_type, f.source_type, f.remark, - f.flow_id, - f.flow_real_amount, - f.flow_type, - f.ord_time + f.flow_real_amount AS amount, + f.flow_id FROM report_account_flow f LEFT JOIN device_info di ON f.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id LEFT JOIN alloc_canteen aa ON aa.canteen_id = bd.canteen_id LEFT JOIN alloc_area aac ON aac.area_id = aa.area_id - WHERE 1 = 1 - - AND f.pay_time >= #{startPayTime} - - - AND f.pay_time < #{endPayTime} - + WHERE f.pay_time = ]]> #{startPayTime} + AND f.pay_time #{endPayTime} AND f.flow_type = 110 UNION ALL - -- 第二段:补充没有设备号的消费(flow_type = 130) + SELECT - bo.canteen_name, - bo.area_name, + aac.area_name, + 130 AS flow_type, f.source_type, f.remark, - f.flow_id, - f.flow_real_amount, - f.flow_type, - f.ord_time - FROM report_account_flow f - INNER JOIN ( - SELECT - aa.canteen_name, - aac.area_name, - f.ord_time - FROM report_account_flow f + AT.actual_amount AS amount, + f.flow_id AS origin_flow_id + FROM acc_trade AT + INNER JOIN report_account_flow f + ON AT.origin_trade_id = f.flow_id + AND f.flow_type = 110 LEFT JOIN device_info di ON f.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id LEFT JOIN alloc_canteen aa ON aa.canteen_id = bd.canteen_id LEFT JOIN alloc_area aac ON aac.area_id = aa.area_id - WHERE 1 = 1 - - AND f.pay_time >= #{startPayTime} - - - AND f.pay_time < #{endPayTime} - - AND f.flow_type = 110 - ) bo ON f.ord_time = bo.ord_time - WHERE 1 = 1 - - AND f.pay_time >= #{startPayTime} - - - AND f.pay_time < #{endPayTime} - - AND f.flow_type = 130 - AND (f.mch_sn IS NULL OR f.mch_sn = '') + WHERE AT.trade_time = ]]> #{startPayTime} + AND AT.trade_time #{endPayTime} + AND AT.trade_type = 130 + AND AT.trade_state = 2 + AND (AT.machine_sn IS NULL OR AT.machine_sn = '') UNION ALL - -- 第三段:补扣金额(flow_type = 120) + SELECT - aa.canteen_name, aac.area_name, + f.flow_type, f.source_type, f.remark, - f.flow_id, - f.flow_real_amount, - f.flow_type, - f.ord_time + f.flow_real_amount AS amount, + f.flow_id FROM report_account_flow f LEFT JOIN device_info di ON f.mch_sn = di.device_sn LEFT JOIN device_bind bd ON di.device_id = bd.device_id LEFT JOIN alloc_canteen aa ON aa.canteen_id = bd.canteen_id LEFT JOIN alloc_area aac ON aac.area_id = aa.area_id - WHERE 1 = 1 - - AND f.pay_time >= #{startPayTime} - - - AND f.pay_time < #{endPayTime} - + WHERE f.pay_time = ]]> #{startPayTime} + AND f.pay_time #{endPayTime} AND f.flow_type = 120 ) t GROUP BY @@ -113,13 +81,11 @@ WHEN t.flow_type = 120 THEN 'deduction' WHEN t.source_type = 7 THEN 'H5' WHEN t.source_type = 53 THEN 'super' - WHEN (t.source_type IS NULL OR t.source_type = '' OR t.source_type = 0) AND t.remark LIKE '%支付%' THEN 'station' + WHEN (t.source_type IS NULL OR t.source_type = 0 OR t.source_type = '') + AND t.remark LIKE '%支付%' THEN 'station' ELSE 'canteen' END - ORDER BY - t.area_name - - + ORDER BY t.area_name