Parcourir la source

#MOD 设备管理费用配置查询

tanbin il y a 1 an
Parent
commit
ce1adc7306

+ 5 - 1
device-api-service/src/main/java/com/xy/entity/DeviceChargingConfig.java

@@ -2,6 +2,7 @@ package com.xy.entity;
 
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -19,7 +20,7 @@ import lombok.experimental.Accessors;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="DeviceChargingConfig对象", description="设备计费配置表")
+@ApiModel(value = "DeviceChargingConfig对象", description = "设备计费配置表")
 public class DeviceChargingConfig implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -35,6 +36,9 @@ public class DeviceChargingConfig implements Serializable {
 
     @ApiModelProperty(value = "赠送天数/预充金额")
     private Integer configValue;
+    
+    @ApiModelProperty(value = "代理商额外费用")
+    private Integer extraMoney;
 
     @ApiModelProperty(value = "类型")
     private Integer type;

+ 46 - 68
device-api-service/src/main/java/com/xy/service/DeviceChargingConfigServiceImpl.java

@@ -3,18 +3,21 @@ package com.xy.service;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.map.MapUtil;
+import com.alipay.api.domain.Person;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.yitter.idgen.YitIdHelper;
 import com.xy.device.EnumDeviceCharging;
 import com.xy.device.EnumDeviceChargingConfigType;
 import com.xy.dto.DeviceChargingConfigDto;
+import com.xy.dto.MemberFeedBackDto;
 import com.xy.dto.be.MercDto;
 import com.xy.entity.DeviceChargingConfig;
 import com.xy.mapper.DeviceChargingConfigMapper;
 import com.xy.service.be.MercService;
 import com.xy.utils.*;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -26,6 +29,7 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 
@@ -58,90 +62,64 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
         return R.ok(Beans.copy(DeviceChargingConfigDto.Vo.class, list));
     }
 
+
     @PostMapping("listByFeeConfig")
     @ApiOperation("设备管理费用配置查询")
-    public R<List<DeviceChargingConfigDto.FeeConfigVO>> listByFeeConfig(@RequestBody @Validated DeviceChargingConfigDto.ListByFeeConfigDTO dto) {
+    public R<DeviceChargingConfigDto.DeviceManagerFeeConfigVO> listByFeeConfig(@RequestBody @Validated DeviceChargingConfigDto.ListByFeeConfigDTO dto) {
+        DeviceChargingConfigDto.DeviceManagerFeeConfigVO data = new DeviceChargingConfigDto.DeviceManagerFeeConfigVO();
+        List<Integer> deviceTypes = dto.getDeviceTypes();
+        //设备管理费-平台默认配置
+        List<DeviceChargingConfigDto.DeviceManagerFeePlatformVO> dmFeePlatforms = new ArrayList<>();
+        for (Integer type : deviceTypes) {//默认年费,赠送天数
+            DeviceChargingConfigDto.DeviceManagerFeePlatformVO vo = new DeviceChargingConfigDto.DeviceManagerFeePlatformVO();
+            int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(type), Integer.class);
+            //默认赠送天数
+            int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
+            vo.setDefFee(defaultMoney);
+            vo.setDefGiveDay(giveDays);
+            vo.setDeviceType(type);
+            dmFeePlatforms.add(vo);
+        }
         MercDto.Vo merc = mercService.obj(new MercDto.Vo().setId(dto.getMercId())).getData();
+
+        // 设备管理费-商家自定义费用
+        List<DeviceChargingConfigDto.DeviceManagerFeeMercVO> dmFeeMercs = new ArrayList<>();
         LambdaQueryWrapper<DeviceChargingConfig> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(dto, DeviceChargingConfig.class)
-                .in(DeviceChargingConfig::getDeviceType, dto.getDeviceTypes())
-                .eq(DeviceChargingConfig::getType, SysDictUtils.getValue(EnumDeviceChargingConfigType.Code.CODE.getCode(), EnumDeviceChargingConfigType.N_2.getCode(), Integer.class))
+                .in(DeviceChargingConfig::getDeviceType, deviceTypes)
                 .eq(DeviceChargingConfig::getMercCode, merc.getMercCode())
                 .build();
         //默认配置 type 2预充 1赠送天数
         List<DeviceChargingConfig> list = list(lambdaQueryWrapper);
-        Map<Integer, DeviceChargingConfig> typeConfigMap = MapUtil.newHashMap();
         if (CollUtil.isNotEmpty(list)) {
-            typeConfigMap = list.stream().collect(Collectors.toMap(DeviceChargingConfig::getDeviceType, c -> c));
-        }
-        //赠送天数
-        LambdaQueryWrapper<DeviceChargingConfig> lambdaQueryWrapper2 = new MybatisPlusQuery().eqWrapper(dto, DeviceChargingConfig.class)
-                .in(DeviceChargingConfig::getDeviceType, dto.getDeviceTypes())
-                .eq(DeviceChargingConfig::getType, SysDictUtils.getValue(EnumDeviceChargingConfigType.Code.CODE.getCode(), EnumDeviceChargingConfigType.N_1.getCode(), Integer.class))
-                .eq(DeviceChargingConfig::getMercCode, merc.getMercCode())
-                .build();
-        List<DeviceChargingConfig> list2 = list(lambdaQueryWrapper2);
-        Map<Integer, DeviceChargingConfig> typeConfigMap2 = MapUtil.newHashMap();
-        if (CollUtil.isNotEmpty(list2)) {
-            typeConfigMap2 = list2.stream().collect(Collectors.toMap(DeviceChargingConfig::getDeviceType, c -> c));
-        }
-
-        List<DeviceChargingConfigDto.FeeConfigVO> voList = new ArrayList<>();
-        List<Integer> deviceTypes = dto.getDeviceTypes();
-        for (Integer type : deviceTypes) {//默认年费,赠送天数
-            DeviceChargingConfigDto.FeeConfigVO vo = new DeviceChargingConfigDto.FeeConfigVO();
-            int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(type), Integer.class);
-            //默认赠送天数
-            int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
-            if ((CollUtil.isNotEmpty(typeConfigMap) && typeConfigMap.get(type) != null) || (CollUtil.isNotEmpty(typeConfigMap2) && typeConfigMap2.get(type) != null)) {
-                DeviceChargingConfig deviceChargingConfig = new DeviceChargingConfig();
-                //存在自定义配置 预充
-                if (CollUtil.isNotEmpty(typeConfigMap) && typeConfigMap.get(type) != null) {
-                    deviceChargingConfig = typeConfigMap.get(type);
-                    BeanUtil.copyProperties(deviceChargingConfig, vo);
+            for (DeviceChargingConfig dcc : list) {
+                Integer type = dcc.getType();
+                Integer deviceType = dcc.getDeviceType();
+                //预充
+                if (String.valueOf(type).equals(EnumDeviceChargingConfigType.N_2.getCode())) {
+                    int defaultMoney = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), String.valueOf(deviceType), Integer.class);
+                    //默认赠送天数
+                    int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
+                    DeviceChargingConfigDto.DeviceManagerFeeMercVO vo = new DeviceChargingConfigDto.DeviceManagerFeeMercVO();
+                    BeanUtil.copyProperties(dcc, vo);
                     vo.setDefFee(defaultMoney);
                     vo.setDefGiveDay(giveDays);
-                    vo.setFee(deviceChargingConfig.getConfigValue());
-                    vo.setGiveDay(giveDays);
-                }
-
-                //存在自定义配置 赠送天数
-                if (CollUtil.isNotEmpty(typeConfigMap2) && typeConfigMap2.get(type) != null) {
-                    if (deviceChargingConfig != null) {
-                        DeviceChargingConfig deviceChargingConfig2 = typeConfigMap2.get(type);
-                        vo.setDefFee(defaultMoney);
-                        vo.setDefGiveDay(giveDays);
-                        vo.setGiveDay(deviceChargingConfig2.getConfigValue());
-                        voList.add(vo);
-                    } else {
-                        //未设置预充
-                        deviceChargingConfig = typeConfigMap2.get(type);
-                        BeanUtil.copyProperties(deviceChargingConfig, vo);
-                        vo.setDefFee(defaultMoney);
-                        vo.setDefGiveDay(giveDays);
-                        vo.setFee(defaultMoney);
-                        vo.setGiveDay(deviceChargingConfig.getConfigValue());
-                        voList.add(vo);
-                    }
-
+                    vo.setFee(dcc.getConfigValue());
+                    Optional<DeviceChargingConfig> dcObj = list.stream()
+                            .filter(dc -> String.valueOf(dc.getType()).equals(EnumDeviceChargingConfigType.N_1.getCode()))
+                            .filter(dc -> dc.getDeviceType().intValue() == deviceType.intValue())
+                            .findFirst();
+                    vo.setGiveDay(dcObj.get().getConfigValue());
+                    dmFeeMercs.add(vo);
                 }
-
-
-            } else {
-                //不存在,则取字典默认值
-                vo.setId(YitIdHelper.nextId());
-                vo.setFee(defaultMoney);
-                vo.setGiveDay(giveDays);
-                vo.setDeviceType(type);
-                vo.setMercCode(merc.getMercCode());
-                vo.setDefFee(defaultMoney);
-                vo.setDefGiveDay(giveDays);
-                voList.add(vo);
             }
-
         }
-        return R.ok(voList);
+
+        data.setDmFeeMercs(dmFeeMercs);
+        data.setDmFeePlatforms(dmFeePlatforms);
+        return R.ok(data);
     }
 
+
     @PostMapping("saveOrUpdate")
     @ApiOperation("添加或修改")
     public R saveOrUpdate(@RequestBody @Validated DeviceChargingConfigDto.SaveOrUpdate saveOrUpdate) {

+ 78 - 0
device-api/src/main/java/com/xy/dto/DeviceChargingConfigDto.java

@@ -113,6 +113,84 @@ public class DeviceChargingConfigDto {
         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
         private LocalDateTime updateTime;
 
+        @ApiModelProperty(value = "代理商额外费用")
+        private Integer extraMoney;
+
+
+    }
+
+    /**
+     * 设备管理费配置
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeeConfigVO {
+        @ApiModelProperty(value = "设备管理费-平台默认配置")
+        private List<DeviceManagerFeePlatformVO> dmFeePlatforms;
+        @ApiModelProperty(value = "设备管理费-商家自定义费用")
+        private List<DeviceManagerFeeMercVO> dmFeeMercs;
+    }
+
+    /**
+     * 设备管理费-平台默认配置
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeePlatformVO {
+        @ApiModelProperty(value = "默认赠送年费")
+        private Integer defFee;
+        @ApiModelProperty(value = "默认赠送天数")
+        private Integer defGiveDay;
+
+        @ApiModelProperty(value = "设备类型")
+        private Integer deviceType;
+ 
+
+    }
+
+    /**
+     * 设备管理费-商家自定义费用
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceManagerFeeMercVO {
+        @ApiModelProperty(value = "默认赠送年费")
+        private Integer defFee;
+        @ApiModelProperty(value = "默认赠送天数")
+        private Integer defGiveDay;
+
+        @ApiModelProperty(value = "id")
+        private Long id;
+
+        @ApiModelProperty(value = "商户编码")
+        private String mercCode;
+
+        @ApiModelProperty(value = "设备类型")
+        private Integer deviceType;
+
+        @ApiModelProperty(value = "自定义赠送天数")
+        private Integer giveDay;
+
+        @ApiModelProperty(value = "自定义年费")
+        private Integer fee;
+
+        @ApiModelProperty(value = "备注")
+        private String note;
+
+        @ApiModelProperty(value = "类型")
+        private Integer type;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+        @ApiModelProperty(value = "代理商额外费用")
+        private Integer extraMoney;
+
 
     }