Prechádzať zdrojové kódy

设备算法费用配置查询

tanbin 1 rok pred
rodič
commit
ad8804f9a7

+ 89 - 15
device-api-service/src/main/java/com/xy/service/MercFeeConfigAlgorithmTypeServiceImpl.java

@@ -1,25 +1,36 @@
 package com.xy.service;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
+import com.xy.device.EnumAlgorithmPayConfig;
+import com.xy.device.EnumAlgorithmTypes;
+import com.xy.device.EnumDeviceCharging;
+import com.xy.device.EnumDeviceChargingConfigType;
+import com.xy.dto.*;
+import com.xy.dto.be.MercDto;
+import com.xy.entity.DeviceChargingConfig;
 import com.xy.entity.MercFeeConfigAlgorithmType;
+import com.xy.entity.SysDictRedis;
 import com.xy.mapper.MercFeeConfigAlgorithmTypeMapper;
 import com.xy.service.MercFeeConfigAlgorithmTypeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xy.service.be.MercService;
+import com.xy.utils.*;
+import io.swagger.annotations.ApiModelProperty;
 import org.springframework.stereotype.Service;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 
-import java.util.List;
-import com.xy.utils.R;
-import com.xy.utils.PageBean;
-import com.xy.dto.MercFeeConfigAlgorithmTypeDto;
+import java.util.*;
+import java.util.stream.Collectors;
+
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.PostMapping;
 import io.swagger.annotations.ApiOperation;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.xy.utils.MybatisPlusQuery;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.validation.annotation.Validated;
-import com.xy.utils.Emptys;
 
 import static com.xy.utils.Beans.copy;
 import static com.xy.utils.PlusBeans.toIPage;
@@ -27,24 +38,27 @@ import static com.xy.utils.PlusBeans.toPageBean;
 
 
 /**
-* <p>
-* 商户算法扣费标准配置扩展 服务实现类
-* </p>
-*
-* @author 谭斌
-* @since 2024-04-07
-*/
+ * <p>
+ * 商户算法扣费标准配置扩展 服务实现类
+ * </p>
+ *
+ * @author 谭斌
+ * @since 2024-04-07
+ */
 @Service
 @AllArgsConstructor
 @Api(tags = "商户算法扣费标准配置扩展")
 public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeConfigAlgorithmTypeMapper, MercFeeConfigAlgorithmType> implements MercFeeConfigAlgorithmTypeService {
 
+    private MercService mercService;
+    private AlgorithmService algorithmService;
+
     @PostMapping("obj")
     @ApiOperation("对象查询")
     public R<MercFeeConfigAlgorithmTypeDto.Vo> obj(@RequestBody MercFeeConfigAlgorithmTypeDto.Vo vo) {
         MercFeeConfigAlgorithmTypeDto.SelectList selectList = copy(MercFeeConfigAlgorithmTypeDto.SelectList.class, vo);
         List<MercFeeConfigAlgorithmTypeDto.Vo> list = list(selectList).getData();
-        if(Emptys.check(list)) {
+        if (Emptys.check(list)) {
             return R.ok(list.get(0));
         }
         return R.ok();
@@ -58,6 +72,66 @@ public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeCo
         return R.ok(copy(MercFeeConfigAlgorithmTypeDto.Vo.class, list));
     }
 
+    @PostMapping("listByFeeConfig")
+    @ApiOperation("设备算法费用配置查询")
+    public R<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO> listByFeeConfig(@RequestBody @Validated MercFeeConfigAlgorithmTypeDto.ListByFeeConfigDTO dto) {
+        MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO data = new MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmConfigVO();
+        Long mercId = dto.getMercId();
+        MercDto.Vo merc = R.feignCheckData(mercService.obj(new MercDto.Vo().setId(mercId)));
+
+        //查询默认算法信息
+        //算法费-平台默认配置
+        List<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO> deviceAcPlatformList = new ArrayList<>();
+        List<AlgorithmDto.ListNameId> listNameIds = R.feignCheckData(algorithmService.ListNameId());
+        List<Long> algorithmIds = listNameIds.stream().map(AlgorithmDto.ListNameId::getId).collect(Collectors.toList());
+//        Map<Long, String> agMap = listNameIds.stream().collect(Collectors.toMap(AlgorithmDto.ListNameId::getId, AlgorithmDto.ListNameId::getName));
+        Map<Long, String> algorithmPayConfigMap = new HashMap<>();
+        for (Long algorithmId : algorithmIds) {
+            SysDictRedis moonAlgorithmTypes = SysDictUtils.get(EnumAlgorithmTypes.Code.CODE.getCode(), String.valueOf(algorithmId));
+            //算法类型对应的字典配置的默认激活费(无设备类型)
+            SysDictRedis algorithmPayConfig = SysDictUtils.get(EnumAlgorithmPayConfig.Code.CODE.getCode(), String.valueOf(algorithmId));
+            if (Emptys.check(algorithmPayConfig)) {
+                MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO dap = new MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmPlatformVO();
+                dap.setAlgorithmId(algorithmId);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig algorithmMoonConfig = JSONUtil.parseObj(algorithmPayConfig).toBean(DeviceAlgorithmChargingDto.AlgorithmMoonConfig.class);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Inf inf = algorithmMoonConfig.getInf();
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Moon moon = algorithmMoonConfig.getMoon();
+                dap.setMoonMoney(moon.getMoney());
+                dap.setMoonSize(moon.getSize());
+                dap.setSingleMoney(algorithmMoonConfig.getPrice());
+                deviceAcPlatformList.add(dap);
+                algorithmPayConfigMap.put(algorithmId, algorithmPayConfig.getValue());
+            }
+        }
+
+        // 设备管理费-商家自定义费用
+        List<MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO> deviceAcMercList = new ArrayList<>();
+        LambdaQueryWrapper<MercFeeConfigAlgorithmType> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(dto, MercFeeConfigAlgorithmType.class)
+                .in(MercFeeConfigAlgorithmType::getAlgorithmId, algorithmIds)
+                .eq(MercFeeConfigAlgorithmType::getMercCode, merc.getMercCode())
+                .build();
+        //默认配置 type 2预充 1赠送天数
+        List<MercFeeConfigAlgorithmType> list = list(lambdaQueryWrapper);
+        if (CollUtil.isNotEmpty(list)) {
+            for (MercFeeConfigAlgorithmType cfg : list) {
+                MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO damVo = BeanUtil.copyProperties(cfg, MercFeeConfigAlgorithmTypeDto.DeviceAlgorithmMercVO.class);
+                Long algorithmId = damVo.getAlgorithmId();
+                String algorithmPayConfig = algorithmPayConfigMap.get(algorithmId);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig algorithmMoonConfig = JSONUtil.parseObj(algorithmPayConfig).toBean(DeviceAlgorithmChargingDto.AlgorithmMoonConfig.class);
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Inf inf = algorithmMoonConfig.getInf();
+                DeviceAlgorithmChargingDto.AlgorithmMoonConfig.Moon moon = algorithmMoonConfig.getMoon();
+                damVo.setMoonMoney(moon.getMoney());
+                damVo.setMoonSize(moon.getSize());
+                damVo.setSingleMoney(algorithmMoonConfig.getPrice());
+                deviceAcMercList.add(damVo);
+            }
+        }
+        data.setDeviceAcMercList(deviceAcMercList);
+        data.setDeviceAcPlatformList(deviceAcPlatformList);
+        return R.ok(data);
+    }
+
+
     @PostMapping("page")
     @ApiOperation("分页查询")
     public R<PageBean<MercFeeConfigAlgorithmTypeDto.Vo>> page(@RequestBody MercFeeConfigAlgorithmTypeDto.Page page) {
@@ -82,4 +156,4 @@ public class MercFeeConfigAlgorithmTypeServiceImpl extends ServiceImpl<MercFeeCo
         updateById(updateInfo);
         return R.ok();
     }
-}
+}

+ 82 - 0
device-api/src/main/java/com/xy/dto/MercFeeConfigAlgorithmTypeDto.java

@@ -3,6 +3,7 @@ package com.xy.dto;
 import java.time.LocalDateTime;
 
 import java.io.Serializable;
+import java.util.List;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -10,6 +11,9 @@ import lombok.experimental.Accessors;
 import com.xy.utils.PageBean;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
 /**
  * <p>
  * 商户算法扣费标准配置扩展
@@ -26,6 +30,14 @@ public class MercFeeConfigAlgorithmTypeDto {
 
     }
 
+    @Data
+    @Accessors(chain = true)
+    public static class ListByFeeConfigDTO extends Vo {
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户id", required = true)
+        private Long mercId;
+    }
+
     @Data
     @Accessors(chain = true)
     public static class Page extends Vo {
@@ -45,6 +57,76 @@ public class MercFeeConfigAlgorithmTypeDto {
     @Accessors(chain = true)
     public static class Update extends Vo {
 
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmConfigVO {
+        @ApiModelProperty(value = "算法费-平台默认配置")
+        private List<DeviceAlgorithmPlatformVO> deviceAcPlatformList;
+        @ApiModelProperty(value = "算法费-商家自定义费用")
+        private List<DeviceAlgorithmMercVO> deviceAcMercList;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmPlatformVO {
+
+        @ApiModelProperty(value = "包月费用,单位 分")
+        private Integer moonMoney;
+        @ApiModelProperty(value = "包月笔数")
+        private Integer moonSize;
+        @ApiModelProperty(value = "单笔费用,单位 分")
+        private Integer singleMoney;
+        @ApiModelProperty(value = "算法类型")
+        private Long algorithmId;
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceAlgorithmMercVO {
+
+        @ApiModelProperty(value = "ID")
+        private Long id;
+
+        @ApiModelProperty(value = "商户编码")
+        private String mercCode;
+
+        @ApiModelProperty(value = "商户id")
+        private Long mercId;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "创建人")
+        private Long createUser;
+
+        @ApiModelProperty(value = "更新人")
+        private Long updateUser;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+        @ApiModelProperty(value = "算法ID")
+        private Long algorithmId;
+
+        @ApiModelProperty(value = "包月费用(比平台多收的金额)")
+        private Integer extraMonthMoney;
+
+        @ApiModelProperty(value = "算法单笔金额(比平台多收的金额)")
+        private Integer extraSingleMoney;
+
+        @ApiModelProperty(value = "平台包月费用,单位 分")
+        private Integer moonMoney;
+        @ApiModelProperty(value = "平台单笔费用,单位 分")
+        private Integer singleMoney;
+        @ApiModelProperty(value = "包月笔数")
+        private Integer moonSize;
+
+
     }
 
     @Data