diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/reportformsServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/reportformsServiceImpl.java index d8de08bf..b0fd9f74 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/reportformsServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/reportformsServiceImpl.java @@ -35,11 +35,11 @@ public class reportformsServiceImpl implements reportformsService { .anyMatch(record -> "宏源工业园食堂".equals(record.get("orgName"))); // 如果没有找到食堂,重新查询并赋值 - if (!containsCanteen) { + /* if (!containsCanteen) { List> newReserveRecords = mapper.selectReserveRecordsFromDatabase(orgConsume); // 插入新的记录到原有的数据列表 reserveRecords.addAll(newReserveRecords); // 保证格式一致,直接合并 - } + }*/ //针对特殊食堂退款的问题进行处理,专门写一个方法 //查询区域关联的字段信息 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..c7cb4524 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 @@ -88,365 +88,365 @@ ORDER BY t.area_name - - WITH org_hierarchy AS ( - SELECT - co.org_id, - co.org_name - FROM cust_org co - WHERE - (co.org_level = 2 AND co.if_del = 2 AND co.org_id != 456365640698040320) - OR (co.super_id = 456365640698040320 AND co.if_del = 2) - ), - normal_transactions AS ( - SELECT - f.org_id, - f.flow_real_amount AS amount - FROM report_account_flow f - WHERE f.pay_time >= #{startPayTime} - AND f.pay_time <= #{endPayTime} - AND f.flow_type = 110 - AND f.source_type = 7 - ), - refund_transactions AS ( - SELECT - f.org_id, - at.actual_amount AS amount - FROM acc_trade at - INNER JOIN report_account_flow f - ON at.origin_trade_id = f.flow_id - AND f.flow_type = 110 - AND f.source_type = 7 - 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 = '') - ), - combined_transactions AS ( - SELECT org_id, amount FROM normal_transactions - UNION ALL - SELECT org_id, amount FROM refund_transactions - ) - SELECT - oh.org_name AS orgName, - ROUND(COALESCE(SUM(ct.amount), 0) / 100, 2) AS reserveAmount - FROM org_hierarchy oh - LEFT JOIN cust_org c - ON c.if_del = 2 - AND (c.org_id = oh.org_id OR c.org_full_id LIKE CONCAT('%/', oh.org_id, '/%')) - LEFT JOIN combined_transactions ct - ON c.org_id = ct.org_id - WHERE 1=1 - - AND oh.org_name LIKE CONCAT('%', #{orgName}, '%') - - GROUP BY oh.org_id, oh.org_name - HAVING COALESCE(SUM(ct.amount), 0) != 0 - ORDER BY oh.org_id - - - + + - + + - + SELECT + co2.org_full_name AS orgFullName, + co2.org_name AS orgName, + u.cust_name, + u.cust_name_like, + t.flow_id, + t.flow_type, + CASE + WHEN t.flow_type = 110 THEN '消费' + WHEN t.flow_type = 130 THEN '退款' + ELSE '其他' + END AS flow_type_name, + t.amount / 100 AS amount, -- 消费/退款金额 + t.org_id, + t.pay_time, + t.ord_time, + t.walletId + FROM cust_org co2 + LEFT JOIN ( + + SELECT + f.flow_id, + f.flow_real_amount AS amount, + f.flow_type, + f.org_id, + f.pay_time, + f.ord_time, + f.cust_id, + atwd.wallet_id AS walletId + FROM report_account_flow f + LEFT JOIN acc_trade_wallet_detail atwd + ON atwd.trade_id = f.flow_id + WHERE f.pay_time >= #{startPayTime} + AND f.pay_time < #{endPayTime} + AND f.flow_type = 110 + AND f.source_type = 7 - UNION ALL + UNION ALL - - SELECT - f.flow_id, - AT.actual_amount AS amount, - 130 AS flow_type, - f.org_id, - AT.trade_time AS pay_time, - f.ord_time, - AT.cust_id, - atwd.wallet_id AS walletId - FROM acc_trade AT - INNER JOIN report_account_flow f - ON AT.origin_trade_id = f.flow_id - AND f.flow_type = 110 - AND f.source_type = 7 - LEFT JOIN acc_trade_wallet_detail atwd - ON atwd.trade_id = f.flow_id - 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 = '') - ) t ON t.org_id = co2.org_id - OR EXISTS ( - SELECT 1 - FROM cust_org c3 - WHERE c3.org_id = t.org_id - AND c3.if_del = 2 - AND c3.org_full_id LIKE CONCAT('%/', co2.org_id, '/%') - ) - LEFT JOIN cust_info u ON t.cust_id = u.cust_id - WHERE co2.org_level = 2 - AND co2.if_del = 2 - AND co2.org_name LIKE CONCAT('%', #{orgName}, '%') - ORDER BY t.pay_time DESC + + SELECT + f.flow_id, + AT.actual_amount AS amount, + 130 AS flow_type, + f.org_id, + AT.trade_time AS pay_time, + f.ord_time, + AT.cust_id, + atwd.wallet_id AS walletId + FROM acc_trade AT + INNER JOIN report_account_flow f + ON AT.origin_trade_id = f.flow_id + AND f.flow_type = 110 + AND f.source_type = 7 + LEFT JOIN acc_trade_wallet_detail atwd + ON atwd.trade_id = f.flow_id + 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 = '') + ) t ON t.org_id = co2.org_id + OR EXISTS ( + SELECT 1 + FROM cust_org c3 + WHERE c3.org_id = t.org_id + AND c3.if_del = 2 + AND c3.org_full_id LIKE CONCAT('%/', co2.org_id, '/%') + ) + LEFT JOIN cust_info u ON t.cust_id = u.cust_id + WHERE co2.org_level = 2 + AND co2.if_del = 2 + AND co2.org_name LIKE CONCAT('%', #{orgName}, '%') + ORDER BY t.pay_time DESC - +