运营区特殊计费配置:多选周几

This commit is contained in:
attiya 2025-10-24 15:03:46 +08:00
parent 548078d26a
commit a6a0da11c7
4 changed files with 54 additions and 28 deletions

View File

@ -25,7 +25,6 @@ import java.util.List;
import static com.cdzy.operations.model.entity.table.EbikeDefaultBillingConfigurationTableDef.EBIKE_DEFAULT_BILLING_CONFIGURATION; import static com.cdzy.operations.model.entity.table.EbikeDefaultBillingConfigurationTableDef.EBIKE_DEFAULT_BILLING_CONFIGURATION;
import static com.cdzy.operations.model.entity.table.EbikeRegionTableDef.EBIKE_REGION; import static com.cdzy.operations.model.entity.table.EbikeRegionTableDef.EBIKE_REGION;
import static com.cdzy.operations.model.entity.table.EbikeSpecialBillingConfigurationTableDef.EBIKE_SPECIAL_BILLING_CONFIGURATION;
/** /**
* 运营区域表 控制层 * 运营区域表 控制层
@ -203,10 +202,8 @@ public class EbikeRegionController {
*/ */
@GetMapping("getSpecialConfiguration") @GetMapping("getSpecialConfiguration")
public JsonResult<?> getSpecialConfiguration(@RequestParam Long regionId) { public JsonResult<?> getSpecialConfiguration(@RequestParam Long regionId) {
QueryWrapper queryWrapper = QueryWrapper.create() EbikeSpecialBillingConfigurationDto configuration = specialBillingConfigurationService.info(regionId);
.where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(regionId)); return JsonResult.success(configuration);
EbikeSpecialBillingConfigurationDto configurationDto = specialBillingConfigurationService.getMapper().selectOneWithRelationsByQueryAs(queryWrapper, EbikeSpecialBillingConfigurationDto.class);
return JsonResult.success(configurationDto);
} }
/** /**
@ -229,9 +226,7 @@ public class EbikeRegionController {
*/ */
@GetMapping("getOperationConfiguration") @GetMapping("getOperationConfiguration")
public JsonResult<?> getOperationConfiguration(@RequestParam Long regionId) { public JsonResult<?> getOperationConfiguration(@RequestParam Long regionId) {
QueryWrapper queryWrapper = QueryWrapper.create() EbikeSpecialBillingConfigurationDto configuration = specialBillingConfigurationService.info(regionId);
.where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(regionId)); return JsonResult.success(configuration);
EbikeSpecialBillingConfigurationDto configurationDto = specialBillingConfigurationService.getMapper().selectOneWithRelationsByQueryAs(queryWrapper, EbikeSpecialBillingConfigurationDto.class);
return JsonResult.success(configurationDto);
} }
} }

View File

@ -2,7 +2,6 @@ package com.cdzy.operations.model.entity;
import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.RelationOneToMany;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -12,7 +11,6 @@ import lombok.NoArgsConstructor;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* 实体类 * 实体类
@ -51,10 +49,4 @@ public class EbikeSpecialBillingConfiguration implements Serializable {
private Long createdBy; private Long createdBy;
@RelationOneToMany(selfField = "regionId",targetField = "regionId")
List<EbiekSpecialDay> dayConfigs;
@RelationOneToMany(selfField = "regionId",targetField = "regionId")
List<EbiekSpecialTime> timeConfigs;
} }

View File

@ -1,5 +1,6 @@
package com.cdzy.operations.service; package com.cdzy.operations.service;
import com.cdzy.operations.model.dto.EbikeSpecialBillingConfigurationDto;
import com.cdzy.operations.model.vo.EbikeSpecialBillingConfigurationVo; import com.cdzy.operations.model.vo.EbikeSpecialBillingConfigurationVo;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import com.cdzy.operations.model.entity.EbikeSpecialBillingConfiguration; import com.cdzy.operations.model.entity.EbikeSpecialBillingConfiguration;
@ -17,4 +18,11 @@ public interface EbikeSpecialBillingConfigurationService extends IService<EbikeS
* @param configurationVo 配置信息 * @param configurationVo 配置信息
*/ */
void specialConfiguration(EbikeSpecialBillingConfigurationVo configurationVo); void specialConfiguration(EbikeSpecialBillingConfigurationVo configurationVo);
/**
* 获取特殊时间计费详情
* @param regionId 区域ID
* @return 详情
*/
EbikeSpecialBillingConfigurationDto info(Long regionId);
} }

View File

@ -5,16 +5,17 @@ import com.cdzy.common.ex.EbikeException;
import com.cdzy.operations.enums.SpecialBillingConfigurationType; import com.cdzy.operations.enums.SpecialBillingConfigurationType;
import com.cdzy.operations.mapper.EbiekSpecialDayMapper; import com.cdzy.operations.mapper.EbiekSpecialDayMapper;
import com.cdzy.operations.mapper.EbiekSpecialTimeMapper; import com.cdzy.operations.mapper.EbiekSpecialTimeMapper;
import com.cdzy.operations.mapper.EbikeSpecialBillingConfigurationMapper;
import com.cdzy.operations.model.dto.EbikeSpecialBillingConfigurationDto;
import com.cdzy.operations.model.entity.EbiekSpecialDay; import com.cdzy.operations.model.entity.EbiekSpecialDay;
import com.cdzy.operations.model.entity.EbiekSpecialTime; import com.cdzy.operations.model.entity.EbiekSpecialTime;
import com.cdzy.operations.model.entity.EbikeSpecialBillingConfiguration;
import com.cdzy.operations.model.vo.EbiekSpecialDayVo; import com.cdzy.operations.model.vo.EbiekSpecialDayVo;
import com.cdzy.operations.model.vo.EbiekSpecialTimeVo; import com.cdzy.operations.model.vo.EbiekSpecialTimeVo;
import com.cdzy.operations.model.vo.EbikeSpecialBillingConfigurationVo; import com.cdzy.operations.model.vo.EbikeSpecialBillingConfigurationVo;
import com.cdzy.operations.service.EbikeSpecialBillingConfigurationService;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.cdzy.operations.model.entity.EbikeSpecialBillingConfiguration;
import com.cdzy.operations.mapper.EbikeSpecialBillingConfigurationMapper;
import com.cdzy.operations.service.EbikeSpecialBillingConfigurationService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -22,14 +23,18 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.cdzy.operations.model.entity.table.EbiekSpecialDayTableDef.EBIEK_SPECIAL_DAY;
import static com.cdzy.operations.model.entity.table.EbiekSpecialTimeTableDef.EBIEK_SPECIAL_TIME;
import static com.cdzy.operations.model.entity.table.EbikeSpecialBillingConfigurationTableDef.EBIKE_SPECIAL_BILLING_CONFIGURATION;
/** /**
* 服务层实现 * 服务层实现
* *
* @author attiya * @author attiya
* @since 2025-10-24 * @since 2025-10-24
*/ */
@Service @Service
public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<EbikeSpecialBillingConfigurationMapper, EbikeSpecialBillingConfiguration> implements EbikeSpecialBillingConfigurationService{ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<EbikeSpecialBillingConfigurationMapper, EbikeSpecialBillingConfiguration> implements EbikeSpecialBillingConfigurationService {
@Resource @Resource
@ -45,7 +50,7 @@ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<Ebi
Integer type = configurationVo.getType(); Integer type = configurationVo.getType();
long loginId = StpUtil.getLoginIdAsLong(); long loginId = StpUtil.getLoginIdAsLong();
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
.eq("region_id", regionId); .where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(regionId));
this.mapper.deleteByQuery(queryWrapper); this.mapper.deleteByQuery(queryWrapper);
EbikeSpecialBillingConfiguration specialBillingConfiguration = EbikeSpecialBillingConfiguration.builder() EbikeSpecialBillingConfiguration specialBillingConfiguration = EbikeSpecialBillingConfiguration.builder()
.regionId(regionId) .regionId(regionId)
@ -53,14 +58,17 @@ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<Ebi
.createdBy(loginId) .createdBy(loginId)
.build(); .build();
this.mapper.insert(specialBillingConfiguration); this.mapper.insert(specialBillingConfiguration);
if (type == SpecialBillingConfigurationType.TIME){
if (type == SpecialBillingConfigurationType.TIME) {
List<EbiekSpecialTimeVo> timeConfigs = configurationVo.getTimeConfigs(); List<EbiekSpecialTimeVo> timeConfigs = configurationVo.getTimeConfigs();
if (timeConfigs == null || timeConfigs.isEmpty()){ if (timeConfigs == null || timeConfigs.isEmpty()) {
throw new EbikeException("选择高峰时段计费后必须配置时段费用"); throw new EbikeException("选择高峰时段计费后必须配置时段费用");
} }
queryWrapper.clear();
queryWrapper.where(EBIEK_SPECIAL_TIME.REGION_ID.eq(regionId));
timeMapper.deleteByQuery(queryWrapper); timeMapper.deleteByQuery(queryWrapper);
List<EbiekSpecialTime> list = new ArrayList<>(); List<EbiekSpecialTime> list = new ArrayList<>();
for (EbiekSpecialTimeVo timeConfig : timeConfigs){ for (EbiekSpecialTimeVo timeConfig : timeConfigs) {
EbiekSpecialTime time = EbiekSpecialTime.builder() EbiekSpecialTime time = EbiekSpecialTime.builder()
.regionId(regionId) .regionId(regionId)
.startTime(timeConfig.getStartTime()) .startTime(timeConfig.getStartTime())
@ -76,12 +84,15 @@ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<Ebi
timeMapper.insertBatch(list); timeMapper.insertBatch(list);
} else if (type == SpecialBillingConfigurationType.DAY) { } else if (type == SpecialBillingConfigurationType.DAY) {
List<EbiekSpecialDayVo> dayConfigs = configurationVo.getDayConfigs(); List<EbiekSpecialDayVo> dayConfigs = configurationVo.getDayConfigs();
if (dayConfigs == null || dayConfigs.isEmpty()){ if (dayConfigs == null || dayConfigs.isEmpty()) {
throw new EbikeException("选择高峰日计费后必须配置高峰日费用"); throw new EbikeException("选择高峰日计费后必须配置高峰日费用");
} }
queryWrapper.clear();
queryWrapper.where(EBIEK_SPECIAL_DAY.REGION_ID.eq(regionId));
dayMapper.deleteByQuery(queryWrapper); dayMapper.deleteByQuery(queryWrapper);
List<EbiekSpecialDay> list = new ArrayList<>(); List<EbiekSpecialDay> list = new ArrayList<>();
for (EbiekSpecialDayVo dayConfig : dayConfigs){ for (EbiekSpecialDayVo dayConfig : dayConfigs) {
EbiekSpecialDay day = EbiekSpecialDay.builder() EbiekSpecialDay day = EbiekSpecialDay.builder()
.regionId(regionId) .regionId(regionId)
.specialDayNum(dayConfig.getSpecialDayNum()) .specialDayNum(dayConfig.getSpecialDayNum())
@ -96,4 +107,24 @@ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<Ebi
dayMapper.insertBatch(list); dayMapper.insertBatch(list);
} }
} }
@Override
public EbikeSpecialBillingConfigurationDto info(Long regionId) {
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(regionId));
EbikeSpecialBillingConfigurationDto specialBillingConfiguration = this.mapper.selectOneByQueryAs(queryWrapper, EbikeSpecialBillingConfigurationDto.class);
if (specialBillingConfiguration == null) {
return null;
}
queryWrapper.clear();
queryWrapper.where(EBIEK_SPECIAL_DAY.REGION_ID.eq(regionId));
List<EbiekSpecialDay> days = dayMapper.selectListByQuery(queryWrapper);
queryWrapper.clear();
queryWrapper.where(EBIEK_SPECIAL_TIME.REGION_ID.eq(regionId));
List<EbiekSpecialTime> times = timeMapper.selectListByQuery(queryWrapper);
specialBillingConfiguration.setDayConfigs(days);
specialBillingConfiguration.setTimeConfigs(times);
return specialBillingConfiguration;
}
} }