|
@@ -26,6 +26,7 @@ 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;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -129,6 +130,8 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
|
|
@PostMapping("save")
|
|
@PostMapping("save")
|
|
@ApiOperation("添加")
|
|
@ApiOperation("添加")
|
|
public R save(@RequestBody @Validated DeviceChargingConfigDto.Save save) {
|
|
public R save(@RequestBody @Validated DeviceChargingConfigDto.Save save) {
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+
|
|
Integer deviceType = save.getDeviceType();
|
|
Integer deviceType = save.getDeviceType();
|
|
Long mercId = save.getMercId();
|
|
Long mercId = save.getMercId();
|
|
MercDto.Vo merc = R.feignCheckData(mercService.obj(new MercDto.Vo().setId(mercId)));
|
|
MercDto.Vo merc = R.feignCheckData(mercService.obj(new MercDto.Vo().setId(mercId)));
|
|
@@ -136,12 +139,22 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
|
|
DeviceChargingConfig dc = this.getOne(Wrappers.<DeviceChargingConfig>lambdaQuery()
|
|
DeviceChargingConfig dc = this.getOne(Wrappers.<DeviceChargingConfig>lambdaQuery()
|
|
.eq(DeviceChargingConfig::getMercCode, mercCode)
|
|
.eq(DeviceChargingConfig::getMercCode, mercCode)
|
|
.eq(DeviceChargingConfig::getDeviceType, deviceType)
|
|
.eq(DeviceChargingConfig::getDeviceType, deviceType)
|
|
- .eq(DeviceChargingConfig::getType, save.getType())
|
|
|
|
|
|
+ .eq(DeviceChargingConfig::getType, EnumDeviceChargingConfigType.N_2.getCode())
|
|
);
|
|
);
|
|
|
|
+
|
|
if (dc != null) {
|
|
if (dc != null) {
|
|
throw new CommRuntimeException("该类型配置已存在,请勿重复添加!");
|
|
throw new CommRuntimeException("该类型配置已存在,请勿重复添加!");
|
|
}
|
|
}
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
+
|
|
|
|
+ //默认赠送天数
|
|
|
|
+ int giveDays = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode(), Integer.class);
|
|
|
|
+ //新增赠送天数
|
|
|
|
+ DeviceChargingConfig newDc = new DeviceChargingConfig().setDeviceType(deviceType).setConfigValue(giveDays).setMercCode(mercCode)
|
|
|
|
+ .setType(Integer.valueOf(EnumDeviceChargingConfigType.N_1.getCode())).setCreateTime(now)
|
|
|
|
+ .setUpdateTime(now).setMercCode(mercCode);
|
|
|
|
+ save(newDc);
|
|
|
|
+
|
|
|
|
+
|
|
DeviceChargingConfig saveInfo = copy(DeviceChargingConfig.class, save)
|
|
DeviceChargingConfig saveInfo = copy(DeviceChargingConfig.class, save)
|
|
.setCreateTime(now)
|
|
.setCreateTime(now)
|
|
.setUpdateTime(now).setMercCode(mercCode);
|
|
.setUpdateTime(now).setMercCode(mercCode);
|
|
@@ -152,7 +165,7 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
@ApiOperation("修改")
|
|
@ApiOperation("修改")
|
|
public R update(@RequestBody @Validated DeviceChargingConfigDto.Update update) {
|
|
public R update(@RequestBody @Validated DeviceChargingConfigDto.Update update) {
|
|
- DeviceChargingConfig deviceTypeAlgorithmBeforConfig = getById(update.getId());
|
|
|
|
|
|
+// DeviceChargingConfig dcc = getById(update.getId());
|
|
DeviceChargingConfig updateInfo = copy(DeviceChargingConfig.class, update)
|
|
DeviceChargingConfig updateInfo = copy(DeviceChargingConfig.class, update)
|
|
.setUpdateTime(LocalDateTime.now());
|
|
.setUpdateTime(LocalDateTime.now());
|
|
updateById(updateInfo);
|
|
updateById(updateInfo);
|
|
@@ -161,7 +174,18 @@ public class DeviceChargingConfigServiceImpl extends ServiceImpl<DeviceChargingC
|
|
|
|
|
|
@PostMapping("delete")
|
|
@PostMapping("delete")
|
|
@ApiOperation("删除")
|
|
@ApiOperation("删除")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public R delete(@RequestBody @Validated DeviceChargingConfigDto.Delete delete) {
|
|
public R delete(@RequestBody @Validated DeviceChargingConfigDto.Delete delete) {
|
|
|
|
+ Long id = delete.getId();
|
|
|
|
+ DeviceChargingConfig dcc = getById(delete.getId());
|
|
|
|
+ DeviceChargingConfig one = getOne(Wrappers.<DeviceChargingConfig>lambdaQuery()
|
|
|
|
+ .eq(DeviceChargingConfig::getMercCode, dcc.getMercCode())
|
|
|
|
+ .eq(DeviceChargingConfig::getDeviceType, dcc.getDeviceType())
|
|
|
|
+ .eq(DeviceChargingConfig::getType, Integer.valueOf(EnumDeviceChargingConfigType.N_1.getCode()))
|
|
|
|
+ );
|
|
|
|
+ if (one != null) {
|
|
|
|
+ removeById(one.getId());
|
|
|
|
+ }
|
|
removeById(delete.getId());
|
|
removeById(delete.getId());
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|