fix: restrict whitelist charging benefits
| | |
| | | |
| | | Map<String, Object> chargingOrderShareIncomeSummaryByOrderIds(@Param("orderIds") List<Long> orderIds); |
| | | |
| | | BigDecimal sumWhitelistRefundByOrderIds(@Param("orderIds") List<Long> orderIds); |
| | | |
| | | List<PayOrderDto> payOrderQuery(@Param("pageInfo") PageInfo<PayOrderDto> pageInfo, @Param("data") PayOrderQueryDto payOrderQueryDto); |
| | | |
| | | /** |
| | |
| | | AppUserWhitelistMatchVO whitelist = appUserWhitelistClient.matchWhitelist(userId, tChargingGun.getSiteId()).getData(); |
| | | boolean whitelistMatched = whitelist != null && Boolean.TRUE.equals(whitelist.getMatched()); |
| | | if (whitelistMatched) { |
| | | if (isBalancePayMode(payMethod)) { |
| | | return AjaxResult.error("白名单用户不支持余额支付"); |
| | | } |
| | | if (addChargingOrder.getAppUserCouponId() != null) { |
| | | return AjaxResult.error("白名单用户不支持使用优惠券"); |
| | | } |
| | | addChargingOrder.setAppUserCouponId(null); |
| | | } |
| | | boolean whitelistAllFree = whitelistMatched |
| | |
| | | platformIncomeTotal = platformIncomeTotal.add(getSummaryDecimal(batchMap, "platformIncomeTotal")); |
| | | partnerIncomeTotal = partnerIncomeTotal.add(getSummaryDecimal(batchMap, "partnerIncomeTotal")); |
| | | } |
| | | platformIncomeTotal = platformIncomeTotal.add(nullToZero(this.baseMapper.sumWhitelistRefundByOrderIds(batchIds))); |
| | | } |
| | | totalMap.put("platformIncomeTotal", platformIncomeTotal); |
| | | totalMap.put("partnerIncomeTotal", partnerIncomeTotal); |
| | |
| | | if (item == null) { |
| | | return; |
| | | } |
| | | item.setPlatformIncome(getSummaryDecimal(row, "platformIncome")); |
| | | item.setPlatformIncome(getSummaryDecimal(row, "platformIncome") |
| | | .add(getSummaryDecimal(row, "whitelistRefund"))); |
| | | item.setPartnerIncome(getSummaryDecimal(row, "partnerIncome")); |
| | | } |
| | | |
| | |
| | | } |
| | | for (ChargingOrderVO item : list) { |
| | | Map<String, Object> row = incomeMap.get(item.getId()); |
| | | item.setPlatformIncome(getSummaryDecimal(row, "platformIncome")); |
| | | item.setPlatformIncome(getSummaryDecimal(row, "platformIncome") |
| | | .add(getSummaryDecimal(row, "whitelistRefund"))); |
| | | item.setPartnerIncome(getSummaryDecimal(row, "partnerIncome")); |
| | | } |
| | | } |
| | |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | //计算优惠金额 |
| | | if (null != chargingOrder.getVipDiscount()) { |
| | | if (!isWhitelistOrder(chargingOrder) && null != chargingOrder.getVipDiscount()) { |
| | | //0.58折 |
| | | vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | //计算优惠金额 |
| | | if (null != chargingOrder.getVipDiscount()) { |
| | | if (!isWhitelistOrder(chargingOrder) && null != chargingOrder.getVipDiscount()) { |
| | | //0.58折 |
| | | vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | //计算优惠金额 |
| | | if (null != chargingOrder.getVipDiscount()) { |
| | | if (!isWhitelistOrder(chargingOrder) && null != chargingOrder.getVipDiscount()) { |
| | | //0.58折 |
| | | vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | |
| | | |
| | | <select id="chargingOrderShareIncomeByOrderIds" resultType="map"> |
| | | select |
| | | s.charging_order_id as orderId, |
| | | o.id as orderId, |
| | | sum(IFNULL(s.channel_pay_amount, 0) - IFNULL(s.share_amount, 0)) as platformIncome, |
| | | sum(IFNULL(s.share_amount, 0)) as partnerIncome |
| | | from `charging_pile_order`.t_charging_order_share_record s |
| | | inner join `charging_pile_order`.t_charging_order o on o.id = s.charging_order_id |
| | | where s.del_flag = 0 and s.charging_order_id is not null |
| | | sum(IFNULL(s.share_amount, 0)) as partnerIncome, |
| | | CASE WHEN o.is_whitelist = 1 THEN IFNULL(o.whitelist_electric_refund_amount, 0) |
| | | + IFNULL(o.whitelist_service_refund_amount, 0) ELSE 0 END as whitelistRefund |
| | | from `charging_pile_order`.t_charging_order o |
| | | left join `charging_pile_order`.t_charging_order_share_record s |
| | | on s.charging_order_id = o.id and s.del_flag = 0 |
| | | where o.del_flag = 0 |
| | | <if test="orderIds != null and orderIds.size()>0"> |
| | | and s.charging_order_id in |
| | | and o.id in |
| | | <foreach collection="orderIds" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | group by s.charging_order_id |
| | | group by o.id, o.is_whitelist, o.whitelist_electric_refund_amount, o.whitelist_service_refund_amount |
| | | </select> |
| | | |
| | | <select id="chargingOrderShareIncomeByPayChannel" resultType="map"> |
| | |
| | | GROUP BY period |
| | | </select> |
| | | |
| | | <select id="sumWhitelistRefundByOrderIds" resultType="java.math.BigDecimal"> |
| | | select coalesce(sum(IFNULL(whitelist_electric_refund_amount, 0) |
| | | + IFNULL(whitelist_service_refund_amount, 0)), 0) |
| | | from `charging_pile_order`.t_charging_order |
| | | where del_flag = 0 and is_whitelist = 1 |
| | | <if test="orderIds != null and orderIds.size()>0"> |
| | | and id in |
| | | <foreach collection="orderIds" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- 接口用: 最近七日收入,直接查询确保历史日切片升级后也能立即显示正确金额。 --> |
| | | <select id="incomeTrendFromOrders" resultType="com.ruoyi.order.dto.SixChargingDto"> |
| | | SELECT DATE_FORMAT(charging_order.create_time, '%Y-%m-%d') AS month, |
| New file |
| | |
| | | -- 合作商已拥有光储子菜单权限时,同时补齐父级目录权限。 |
| | | -- sys_role_menu 的菜单树要求目录(M)本身也被授权,否则前端不会展示整组子菜单。 |
| | | |
| | | SET @device_monitoring_menu_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = 0 |
| | | AND menu_type = 'M' |
| | | AND (path = '/deviceManagement' OR perms = '/deviceManagement') |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | SET @energy_data_menu_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = 0 |
| | | AND menu_type = 'M' |
| | | AND (path = '/energyReport' OR perms = '/energyReport') |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | -- 光储监控设备管理:监控摄像头、光伏电站、储能电站、逆变器、能量链任一权限。 |
| | | INSERT IGNORE INTO sys_role_menu (role_id, menu_id) |
| | | SELECT DISTINCT role_menu.role_id, @device_monitoring_menu_id |
| | | FROM sys_role_menu role_menu |
| | | INNER JOIN sys_menu child_menu ON child_menu.menu_id = role_menu.menu_id |
| | | WHERE @device_monitoring_menu_id IS NOT NULL |
| | | AND ( |
| | | child_menu.path LIKE '/deviceManagement/%' |
| | | OR child_menu.perms LIKE '/deviceManagement/%' |
| | | ); |
| | | |
| | | -- 光储监控数据:视频监控、光伏报表、储能日充放电报表任一权限。 |
| | | INSERT IGNORE INTO sys_role_menu (role_id, menu_id) |
| | | SELECT DISTINCT role_menu.role_id, @energy_data_menu_id |
| | | FROM sys_role_menu role_menu |
| | | INNER JOIN sys_menu child_menu ON child_menu.menu_id = role_menu.menu_id |
| | | WHERE @energy_data_menu_id IS NOT NULL |
| | | AND ( |
| | | child_menu.path LIKE '/energyReport/%' |
| | | OR child_menu.perms LIKE '/energyReport/%' |
| | | OR child_menu.path = '/videoMonitor' |
| | | OR child_menu.perms = '/energyReport/videoMonitor' |
| | | ); |
| New file |
| | |
| | | -- 补齐缺失的光伏电站管理 / 光伏逆变器管理菜单及按钮权限。 |
| | | -- 背景:20260807_energy_storage_monitoring_menu.sql 只对这两个菜单做了改名 UPDATE, |
| | | -- 但菜单本身从未 INSERT(光伏相关页面/路由一直存在),导致角色编辑里看不到、 |
| | | -- 后端权限数组里也没有对应 perms,工作台光伏看板按权限展示时永远不显示。 |
| | | -- 参照 20260725_device_management_energy_storage_menu.sql 模板,幂等可重复执行。 |
| | | |
| | | -- 光储监控设备管理目录(原设备管理,path = /deviceManagement) |
| | | SET @device_monitoring_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = 0 |
| | | AND menu_type = 'M' |
| | | AND (path = '/deviceManagement' OR perms = '/deviceManagement') |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | -- 1. 光伏电站管理(order 2,与 20260807 改名脚本的排序一致) |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '光伏电站管理', @device_monitoring_id, 2, '/deviceManagement/photovoltaicStation/list', |
| | | 'deviceManagement/photovoltaicStation', NULL, 1, 0, 'C', '0', 0, |
| | | '/deviceManagement/photovoltaicStation', '#', 'admin', NOW(), '光伏电站管理页面' |
| | | WHERE @device_monitoring_id IS NOT NULL |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM sys_menu |
| | | WHERE parent_id = @device_monitoring_id |
| | | AND (path = '/deviceManagement/photovoltaicStation/list' |
| | | OR perms = '/deviceManagement/photovoltaicStation') |
| | | ); |
| | | |
| | | SET @photovoltaic_station_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = @device_monitoring_id |
| | | AND (path = '/deviceManagement/photovoltaicStation/list' |
| | | OR perms = '/deviceManagement/photovoltaicStation') |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '光伏查询', @photovoltaic_station_id, 1, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicStation/select', '#', 'admin', NOW(), '光伏电站查询按钮权限' |
| | | WHERE @photovoltaic_station_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_station_id |
| | | AND perms = '/deviceManagement/photovoltaicStation/select'); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '光伏新增', @photovoltaic_station_id, 2, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicStation/add', '#', 'admin', NOW(), '光伏电站新增按钮权限' |
| | | WHERE @photovoltaic_station_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_station_id |
| | | AND perms = '/deviceManagement/photovoltaicStation/add'); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '光伏删除', @photovoltaic_station_id, 3, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicStation/del', '#', 'admin', NOW(), '光伏电站删除按钮权限' |
| | | WHERE @photovoltaic_station_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_station_id |
| | | AND perms = '/deviceManagement/photovoltaicStation/del'); |
| | | |
| | | -- 2. 光伏逆变器管理(order 4) |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '光伏逆变器管理', @device_monitoring_id, 4, '/deviceManagement/photovoltaicInverter/list', |
| | | 'deviceManagement/photovoltaicInverter', NULL, 1, 0, 'C', '0', 0, |
| | | '/deviceManagement/photovoltaicInverter', '#', 'admin', NOW(), '光伏逆变器管理页面' |
| | | WHERE @device_monitoring_id IS NOT NULL |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM sys_menu |
| | | WHERE parent_id = @device_monitoring_id |
| | | AND (path = '/deviceManagement/photovoltaicInverter/list' |
| | | OR perms = '/deviceManagement/photovoltaicInverter') |
| | | ); |
| | | |
| | | SET @photovoltaic_inverter_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = @device_monitoring_id |
| | | AND (path = '/deviceManagement/photovoltaicInverter/list' |
| | | OR perms = '/deviceManagement/photovoltaicInverter') |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '逆变器查询', @photovoltaic_inverter_id, 1, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicInverter/select', '#', 'admin', NOW(), '光伏逆变器查询按钮权限' |
| | | WHERE @photovoltaic_inverter_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_inverter_id |
| | | AND perms = '/deviceManagement/photovoltaicInverter/select'); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '逆变器新增', @photovoltaic_inverter_id, 2, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicInverter/add', '#', 'admin', NOW(), '光伏逆变器新增按钮权限' |
| | | WHERE @photovoltaic_inverter_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_inverter_id |
| | | AND perms = '/deviceManagement/photovoltaicInverter/add'); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '逆变器修改', @photovoltaic_inverter_id, 3, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicInverter/update', '#', 'admin', NOW(), '光伏逆变器修改按钮权限' |
| | | WHERE @photovoltaic_inverter_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_inverter_id |
| | | AND perms = '/deviceManagement/photovoltaicInverter/update'); |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '逆变器删除', @photovoltaic_inverter_id, 4, '', NULL, NULL, 1, 0, 'F', '0', 0, |
| | | '/deviceManagement/photovoltaicInverter/del', '#', 'admin', NOW(), '光伏逆变器删除按钮权限' |
| | | WHERE @photovoltaic_inverter_id IS NOT NULL |
| | | AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @photovoltaic_inverter_id |
| | | AND perms = '/deviceManagement/photovoltaicInverter/del'); |
| | | |
| | | -- 3. 按 20260807 规范重排目录下子菜单顺序: |
| | | -- 1=监控摄像头列表 2=光伏电站管理 3=储能电站管理 4=光伏逆变器管理 5=储能能量链管理 |
| | | UPDATE sys_menu |
| | | SET order_num = CASE path |
| | | WHEN '/deviceManagement/list' THEN 1 |
| | | WHEN '/deviceManagement/photovoltaicStation/list' THEN 2 |
| | | WHEN '/deviceManagement/energyStorage/list' THEN 3 |
| | | WHEN '/deviceManagement/photovoltaicInverter/list' THEN 4 |
| | | WHEN '/deviceManagement/energyChain/list' THEN 5 |
| | | ELSE order_num |
| | | END, update_time = NOW() |
| | | WHERE parent_id = @device_monitoring_id; |
| | | |
| | | -- 4. 授权:已拥有"光储监控设备管理"目录的角色,同步获得两个光伏菜单 |
| | | INSERT IGNORE INTO sys_role_menu (role_id, menu_id) |
| | | SELECT DISTINCT role_id, m.menu_id |
| | | FROM sys_role_menu r |
| | | JOIN sys_menu m ON m.parent_id = @device_monitoring_id |
| | | AND m.path IN ('/deviceManagement/photovoltaicStation/list', |
| | | '/deviceManagement/photovoltaicInverter/list') |
| | | WHERE r.menu_id = @device_monitoring_id; |
| | | |
| | | -- 5. 管理员角色(role_id = 1)默认拥有 |
| | | INSERT IGNORE INTO sys_role_menu (role_id, menu_id) |
| | | SELECT 1, menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = @device_monitoring_id |
| | | AND path IN ('/deviceManagement/photovoltaicStation/list', |
| | | '/deviceManagement/photovoltaicInverter/list'); |