Bläddra i källkod

fix(policy): 固定服务费为0.1元/度并调整相关计算逻辑

- 修改PolicyFeeServiceImpl中calculateCompSalesFee方法,服务费固定为0.1元/度,不从数据库读取
- 更新ThirdPartyChargingServiceImpl中相关逻辑,强制设置服务费为0.1,忽略传入值
- 调整计算综合销售费公式,添加固定服务费后计算
- 修正Mapper文件注释及查询条件,调整时段时间描述及对应SQL排序优化
SheepHy 3 dagar sedan
förälder
incheckning
f7d962d932

+ 5 - 4
src/main/java/com/zsElectric/boot/business/service/impl/PolicyFeeServiceImpl.java

@@ -119,21 +119,22 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
      */
     private BigDecimal calculateCompSalesFee(Long stationInfoId, Integer periodFlag, BigDecimal opFee) {
         BigDecimal elecPrice = BigDecimal.ZERO;
-        BigDecimal servicePrice = BigDecimal.ZERO;
+        // 服务费固定为0.1元/度
+        BigDecimal servicePrice = new BigDecimal("0.1");
         
-        // 通过stationInfoId和periodFlag查询电价和服务费(取该时段标志的第一条记录)
+        // 通过stationInfoId和periodFlag查询电价(取该时段标志的第一条记录)
         ThirdPartyPolicyInfo policyInfo = policyInfoMapper.selectElecAndServicePriceByStationAndPeriodFlag(stationInfoId, periodFlag);
         log.info("计算compSalesFee - stationInfoId: {}, periodFlag: {}, policyInfo: {}", stationInfoId, periodFlag, policyInfo);
         
         if (policyInfo != null) {
             elecPrice = policyInfo.getElecPrice() != null ? policyInfo.getElecPrice() : BigDecimal.ZERO;
-            servicePrice = policyInfo.getServicePrice() != null ? policyInfo.getServicePrice() : BigDecimal.ZERO;
+            // 服务费不从数据库读取,固定使用 0.1
         }
         
         // 从字典表获取periodFlag对应的值
         BigDecimal dictValue = getDictValueByPeriodFlag(periodFlag);
         
-        // 计算综合销售费 = elec_price + service_price + 字典值 + op_fee
+        // 计算综合销售费 = elec_price + service_price(0.1) + 字典值 + op_fee
         BigDecimal opFeeValue = opFee != null ? opFee : BigDecimal.ZERO;
         BigDecimal compSalesFee = elecPrice.add(servicePrice).add(dictValue).add(opFeeValue);
         

+ 10 - 7
src/main/java/com/zsElectric/boot/business/service/impl/ThirdPartyChargingServiceImpl.java

@@ -724,7 +724,8 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
      */
     private void updatePolicyInfoDetail(ThirdPartyPolicyInfo existing, ChargingPricePolicyVO.PolicyInfo policyInfo) {
         existing.setElecPrice(policyInfo.getElecPrice());
-        existing.setServicePrice(policyInfo.getServicePrice());
+        // 强制设置 service_price 为 0.1,不管第三方传什么值
+        existing.setServicePrice(new BigDecimal("0.1"));
         existing.setPeriodFlag(policyInfo.getPeriodFlag());
         existing.setUpdateTime(LocalDateTime.now());
         policyInfoMapper.updateById(existing);
@@ -806,19 +807,20 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
     
     /**
      * 计算 comp_sales_fee
-     * 公式:compSalesFee = elec_price + service_price + op_fee
-     * 注意:这里不加字典值,与 PolicyFeeServiceImpl 中的计算逻辑保持一致
+     * 公式:compSalesFee = elec_price + service_price(0.1) + op_fee
+     * 注意:服务费固定为0.1元/度
      */
     private BigDecimal calculateCompSalesFeeForPolicyFee(Long stationInfoId, Integer periodFlag, BigDecimal opFee) {
         BigDecimal elecPrice = BigDecimal.ZERO;
-        BigDecimal servicePrice = BigDecimal.ZERO;
+        // 服务费固定为0.1元/度
+        BigDecimal servicePrice = new BigDecimal("0.1");
         
-        // 查询电价和服务费
+        // 查询电价
         ThirdPartyPolicyInfo policyInfo = policyInfoMapper.selectElecAndServicePriceByStationAndPeriodFlag(stationInfoId, periodFlag);
         
         if (policyInfo != null) {
             elecPrice = policyInfo.getElecPrice() != null ? policyInfo.getElecPrice() : BigDecimal.ZERO;
-            servicePrice = policyInfo.getServicePrice() != null ? policyInfo.getServicePrice() : BigDecimal.ZERO;
+            // 服务费不从数据库读取,固定使用 0.1
         }
         
         BigDecimal opFeeValue = opFee != null ? opFee : BigDecimal.ZERO;
@@ -833,7 +835,8 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
         entity.setPricePolicyId(policyId);
         entity.setStartTime(policyInfo.getStartTime());
         entity.setElecPrice(policyInfo.getElecPrice());
-        entity.setServicePrice(policyInfo.getServicePrice());
+        // 强制设置 service_price 为 0.1,不管第三方传什么值
+        entity.setServicePrice(new BigDecimal("0.1"));
         entity.setPeriodFlag(policyInfo.getPeriodFlag());
         entity.setCreateTime(LocalDateTime.now());
 

+ 6 - 4
src/main/resources/mapper/business/ThirdPartyStationInfoMapper.xml

@@ -193,7 +193,7 @@
                 ORDER BY tppi.start_time DESC
                 LIMIT 1
             ) AS peak_value,
-            <!-- 峰时段时间(period_flag=2为峰时段),格式: HH:mm - HH:mm -->
+            <!-- 当前时段时间,格式: HH:mm - HH:mm -->
             (
                 SELECT CONCAT(
                     CONCAT(SUBSTRING(tppi.start_time, 1, 2), ':', SUBSTRING(tppi.start_time, 3, 2)),
@@ -216,7 +216,8 @@
                 INNER JOIN third_party_connector_info tpci5 ON tpepp.connector_id = tpci5.connector_id AND tpci5.is_deleted = 0
                 WHERE tpci5.station_id = tpsi.station_id
                     AND tppi.is_deleted = 0
-                    AND tppi.period_flag = 2
+                    AND tppi.start_time &lt;= #{currentTime}
+                ORDER BY tppi.start_time DESC
                 LIMIT 1
             ) AS peak_time,
             <!-- 平台价(综合销售费) -->
@@ -347,7 +348,7 @@
                 ORDER BY tppi.start_time DESC
                 LIMIT 1
             ) AS peak_value,
-            <!-- 峰时段时间(period_flag=2为峰时段),格式: HH:mm - HH:mm -->
+            <!-- 当前时段时间,格式: HH:mm - HH:mm -->
             (
                 SELECT CONCAT(
                     CONCAT(SUBSTRING(tppi.start_time, 1, 2), ':', SUBSTRING(tppi.start_time, 3, 2)),
@@ -370,7 +371,8 @@
                 INNER JOIN third_party_connector_info tpci5 ON tpepp.connector_id = tpci5.connector_id AND tpci5.is_deleted = 0
                 WHERE tpci5.station_id = tpsi.station_id
                     AND tppi.is_deleted = 0
-                    AND tppi.period_flag = 2
+                    AND tppi.start_time &lt;= #{currentTime}
+                ORDER BY tppi.start_time DESC
                 LIMIT 1
             ) AS peak_time,
             <!-- 平台价(综合销售费) -->