浏览代码

refactor(policy-fee): 调整企业和渠道方ID字段及逻辑

- 在DTO和实体中新增firmId字段,区分企业和渠道方ID
- 修改Controller接口,添加firmId参数支持企业ID传递
- 更新Service接口及实现,支持根据销售类型区分firmId和thirdPartyId查询
- 调整数据库查询条件,区分salesType对应的实体字段筛选
- 修改策略费用新增逻辑,按照企业或渠道方ID判断是否重复
- 更新字段注释中的销售类型含义说明,统一格式规范
SheepHy 13 小时之前
父节点
当前提交
18430f7832

+ 7 - 4
src/main/java/com/zsElectric/boot/business/controller/PolicyFeeController.java

@@ -72,7 +72,8 @@ public class PolicyFeeController {
      *
      * @param stationId 站点信息ID(关联third_party_station_info表)
      * @param salesType 销售类型(0-平台 1-企业 2-渠道方)
-     * @param thirdPartyId 渠道方ID(销售类型为1、2时必填)关联c_third_party_info
+     * @param firmId 企业ID(销售类型为1时必填)关联c_firm_info
+     * @param thirdPartyId 渠道方ID(销售类型为2时必填)关联c_third_party_info
      * @return 策略费用列表
      */
     @Operation(summary = "查询策略费用")
@@ -82,9 +83,11 @@ public class PolicyFeeController {
             @RequestParam Long stationId,
             @Parameter(description = "销售类型(0-平台 1-企业 2-渠道方)", required = true)
             @RequestParam Integer salesType,
-            @Parameter(description = "渠道方ID(销售类型为1、2时必填)关联c_third_party_info")
-            @RequestParam(required = false, defaultValue = "0") Integer thirdPartyId) {
-        return Result.success(policyFeeService.getPolicyFee(stationId, salesType, thirdPartyId));
+            @Parameter(description = "企业ID(销售类型为1时必填)关联c_firm_info")
+            @RequestParam(required = false) Long firmId,
+            @Parameter(description = "渠道方ID(销售类型为2时必填)关联c_third_party_info")
+            @RequestParam(required = false) Long thirdPartyId) {
+        return Result.success(policyFeeService.getPolicyFee(stationId, salesType, firmId, thirdPartyId));
     }
 
     /**

+ 6 - 2
src/main/java/com/zsElectric/boot/business/model/dto/AddPolicyFeeDTO.java

@@ -16,8 +16,12 @@ public class AddPolicyFeeDTO {
     private BigDecimal operationServiceFee;
     @Schema(description = "站点信息ID(关联third_party_station_info表)")
     private Long stationInfoId;
-    @Schema(description = "销售类型(0、平台 1、企业 2、渠道方)")
+    @Schema(description = "销售类型(0-平台 1-企业 2-渠道方)")
     private Integer salesType;
-    @Schema(description = "渠道方ID(销售类型为1、2时必填)关联c_third_party_info")
+
+    @Schema(description = "企业ID(销售类型为1时必填)关联c_firm_info")
+    private Long firmId;
+
+    @Schema(description = "渠道方ID(销售类型为2时必填)关联c_third_party_info")
     private Long thirdPartyId;
 }

+ 6 - 1
src/main/java/com/zsElectric/boot/business/model/entity/PolicyFee.java

@@ -57,7 +57,12 @@ public class PolicyFee implements Serializable {
     private Integer salesType;
 
     /**
-     * 渠道方ID(销售类型为1、2时必填)关联c_third_party_info
+     * 企业ID(销售类型为1时必填)关联c_firm_info
+     */
+    private Long firmId;
+
+    /**
+     * 渠道方ID(销售类型为2时必填)关联c_third_party_info
      */
     private Long thirdPartyId;
 

+ 6 - 1
src/main/java/com/zsElectric/boot/business/service/PolicyFeeService.java

@@ -15,8 +15,13 @@ public interface PolicyFeeService {
     /**
      * 根据站点查询策略费用
      *
+     * @param stationId 站点信息ID
+     * @param salesType 销售类型(0-平台 1-企业 2-渠道方)
+     * @param firmId 企业ID(salesType=1时使用)
+     * @param thirdPartyId 渠道方ID(salesType=2时使用)
+     * @return 策略费用列表
      */
-    List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, int thirdPartyId);
+    List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, Long firmId, Long thirdPartyId);
 
     /**
      * 新增站点查询策略费用

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

@@ -60,7 +60,7 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
     private final ThirdPartyStationInfoMapper stationInfoMapper;
 
     @Override
-    public List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, int thirdPartyId) {
+    public List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, Long firmId, Long thirdPartyId) {
         List<TimePeriodPriceVO> timePeriodPriceVOS = new ArrayList<>();
         
         // 查询设备信息
@@ -91,7 +91,8 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
                 .eq(PolicyFee::getStationInfoId, stationId)
                 .eq(PolicyFee::getIsDeleted, 0)
                 .eq(PolicyFee::getSalesType, salesType)
-                .eq(salesType != 0, PolicyFee::getThirdPartyId, thirdPartyId))
+                .eq(salesType == 1, PolicyFee::getFirmId, firmId)
+                .eq(salesType == 2, PolicyFee::getThirdPartyId, thirdPartyId))
                 .stream()
                 .collect(Collectors.toMap(
                         PolicyFee::getStartTime,
@@ -148,12 +149,13 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
 
     @Override
     public boolean addPolicyFee(AddPolicyFeeDTO addPolicyFeeDTO) {
-        // 根据站点+时段+销售类型+渠道方查询是否已存在
+        // 根据站点+时段+销售类型+企业/渠道方查询是否已存在
         PolicyFee existPolicyFee = policyFeeMapper.selectOne(Wrappers.<PolicyFee>lambdaQuery()
                 .eq(PolicyFee::getStationInfoId, addPolicyFeeDTO.getStationInfoId())
                 .eq(PolicyFee::getStartTime, addPolicyFeeDTO.getTimePeriod())
                 .eq(PolicyFee::getSalesType, addPolicyFeeDTO.getSalesType())
-                .eq(addPolicyFeeDTO.getSalesType() != 0, PolicyFee::getThirdPartyId, addPolicyFeeDTO.getThirdPartyId())
+                .eq(addPolicyFeeDTO.getSalesType() == 1, PolicyFee::getFirmId, addPolicyFeeDTO.getFirmId())
+                .eq(addPolicyFeeDTO.getSalesType() == 2, PolicyFee::getThirdPartyId, addPolicyFeeDTO.getThirdPartyId())
                 .eq(PolicyFee::getIsDeleted, 0)
                 .last("limit 1"));
         
@@ -168,6 +170,7 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
             policyFee.setStartTime(addPolicyFeeDTO.getTimePeriod());
             policyFee.setOpFee(addPolicyFeeDTO.getOperationServiceFee());
             policyFee.setSalesType(addPolicyFeeDTO.getSalesType());
+            policyFee.setFirmId(addPolicyFeeDTO.getFirmId());
             policyFee.setThirdPartyId(addPolicyFeeDTO.getThirdPartyId());
             boolean inserted = policyFeeMapper.insert(policyFee) > 0;