|
@@ -3,18 +3,21 @@ package com.xy.service;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
|
+import com.alipay.api.domain.Person;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.yitter.idgen.YitIdHelper;
|
|
import com.github.yitter.idgen.YitIdHelper;
|
|
import com.xy.device.EnumDeviceCharging;
|
|
import com.xy.device.EnumDeviceCharging;
|
|
import com.xy.device.EnumDeviceChargingConfigType;
|
|
import com.xy.device.EnumDeviceChargingConfigType;
|
|
import com.xy.dto.DeviceChargingConfigDto;
|
|
import com.xy.dto.DeviceChargingConfigDto;
|
|
|
|
+import com.xy.dto.MemberFeedBackDto;
|
|
import com.xy.dto.be.MercDto;
|
|
import com.xy.dto.be.MercDto;
|
|
import com.xy.entity.DeviceChargingConfig;
|
|
import com.xy.entity.DeviceChargingConfig;
|
|
import com.xy.mapper.DeviceChargingConfigMapper;
|
|
import com.xy.mapper.DeviceChargingConfigMapper;
|
|
import com.xy.service.be.MercService;
|
|
import com.xy.service.be.MercService;
|
|
import com.xy.utils.*;
|
|
import com.xy.utils.*;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,6 +29,7 @@ import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Optional;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@@ -58,90 +62,64 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
|
|
return R.ok(Beans.copy(DeviceChargingConfigDto.Vo.class, list));
|
|
return R.ok(Beans.copy(DeviceChargingConfigDto.Vo.class, list));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@PostMapping("listByFeeConfig")
|
|
@PostMapping("listByFeeConfig")
|
|
@ApiOperation("设备管理费用配置查询")
|
|
@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();
|
|
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)
|
|
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())
|
|
.eq(DeviceChargingConfig::getMercCode, merc.getMercCode())
|
|
.build();
|
|
.build();
|
|
//默认配置 type 2预充 1赠送天数
|
|
//默认配置 type 2预充 1赠送天数
|
|
List<DeviceChargingConfig> list = list(lambdaQueryWrapper);
|
|
List<DeviceChargingConfig> list = list(lambdaQueryWrapper);
|
|
- Map<Integer, DeviceChargingConfig> typeConfigMap = MapUtil.newHashMap();
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
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.setDefFee(defaultMoney);
|
|
vo.setDefGiveDay(giveDays);
|
|
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")
|
|
@PostMapping("saveOrUpdate")
|
|
@ApiOperation("添加或修改")
|
|
@ApiOperation("添加或修改")
|
|
public R saveOrUpdate(@RequestBody @Validated DeviceChargingConfigDto.SaveOrUpdate saveOrUpdate) {
|
|
public R saveOrUpdate(@RequestBody @Validated DeviceChargingConfigDto.SaveOrUpdate saveOrUpdate) {
|