运营区特殊计费配置
This commit is contained in:
parent
2ee7dcc962
commit
29a09d6afe
@ -4,6 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.enums.RegionStatus;
|
||||
import com.cdzy.operations.model.dto.EbikeSpecialBillingConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeDefaultBillingConfiguration;
|
||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||
import com.cdzy.operations.model.vo.EbikeDefaultBillingConfigurationVo;
|
||||
@ -24,6 +25,7 @@ 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.EbikeRegionTableDef.EBIKE_REGION;
|
||||
import static com.cdzy.operations.model.entity.table.EbikeSpecialBillingConfigurationTableDef.EBIKE_SPECIAL_BILLING_CONFIGURATION;
|
||||
|
||||
/**
|
||||
* 运营区域表 控制层。
|
||||
@ -182,7 +184,7 @@ public class EbikeRegionController {
|
||||
|
||||
|
||||
/**
|
||||
* 保存运营区默认计费规则。
|
||||
* 保存运营区高峰计费规则。
|
||||
*
|
||||
* @param configurationVo 配置信息
|
||||
* @return 分页对象
|
||||
@ -194,16 +196,16 @@ public class EbikeRegionController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运营区默认计费规则。
|
||||
* 获取运营区高峰计费规则。
|
||||
*
|
||||
* @param regionId 区域ID
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("getspecialConfiguration")
|
||||
public JsonResult<?> getspecialConfiguration(@RequestParam Long regionId) {
|
||||
@GetMapping("getSpecialConfiguration")
|
||||
public JsonResult<?> getSpecialConfiguration(@RequestParam Long regionId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_DEFAULT_BILLING_CONFIGURATION.REGION_ID.eq(regionId));
|
||||
EbikeDefaultBillingConfiguration configuration = defaultConfigurationService.getOne(queryWrapper);
|
||||
return JsonResult.success(configuration);
|
||||
.where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(regionId));
|
||||
EbikeSpecialBillingConfigurationDto configurationDto = specialBillingConfigurationService.getMapper().selectOneWithRelationsByQueryAs(queryWrapper, EbikeSpecialBillingConfigurationDto.class);
|
||||
return JsonResult.success(configurationDto);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.cdzy.operations.enums;
|
||||
|
||||
/**
|
||||
* @author attiya
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
public interface SpecialBillingConfigurationType {
|
||||
int CLOSED = 1;
|
||||
int TIME = 2;
|
||||
int DAY = 3;
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.cdzy.operations.model.dto;
|
||||
|
||||
import com.cdzy.operations.model.entity.EbiekSpecialDay;
|
||||
import com.cdzy.operations.model.entity.EbiekSpecialTime;
|
||||
import com.mybatisflex.annotation.RelationOneToMany;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeSpecialBillingConfigurationDto implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 高峰日ID
|
||||
*/
|
||||
private Long specialDayId;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
private Long regionId;
|
||||
|
||||
/**
|
||||
* 1-关闭 2-高峰时段 3-高峰日
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
@RelationOneToMany(selfField = "regionId",targetField = "regionId")
|
||||
List<EbiekSpecialDay> dayConfigs;
|
||||
|
||||
@RelationOneToMany(selfField = "regionId",targetField = "regionId")
|
||||
List<EbiekSpecialTime> timeConfigs;
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -64,6 +65,7 @@ public class EbiekSpecialDay implements Serializable {
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -70,6 +71,7 @@ public class EbiekSpecialTime implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
@ -44,7 +44,8 @@ public class EbikeSpecialBillingConfiguration implements Serializable {
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private Timestamp createdAt;
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
|
||||
@ -1,14 +1,26 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.enums.SpecialBillingConfigurationType;
|
||||
import com.cdzy.operations.mapper.EbiekSpecialDayMapper;
|
||||
import com.cdzy.operations.mapper.EbiekSpecialTimeMapper;
|
||||
import com.cdzy.operations.model.entity.EbiekSpecialDay;
|
||||
import com.cdzy.operations.model.entity.EbiekSpecialTime;
|
||||
import com.cdzy.operations.model.vo.EbiekSpecialDayVo;
|
||||
import com.cdzy.operations.model.vo.EbiekSpecialTimeVo;
|
||||
import com.cdzy.operations.model.vo.EbikeSpecialBillingConfigurationVo;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
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 org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
@ -27,7 +39,61 @@ public class EbikeSpecialBillingConfigurationServiceImpl extends ServiceImpl<Ebi
|
||||
EbiekSpecialTimeMapper timeMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void specialConfiguration(EbikeSpecialBillingConfigurationVo configurationVo) {
|
||||
|
||||
Long regionId = configurationVo.getRegionId();
|
||||
Integer type = configurationVo.getType();
|
||||
long loginId = StpUtil.getLoginIdAsLong();
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.eq("region_id", regionId);
|
||||
this.mapper.deleteByQuery(queryWrapper);
|
||||
EbikeSpecialBillingConfiguration specialBillingConfiguration = EbikeSpecialBillingConfiguration.builder()
|
||||
.regionId(regionId)
|
||||
.type(type)
|
||||
.createdBy(loginId)
|
||||
.build();
|
||||
this.mapper.insert(specialBillingConfiguration);
|
||||
if (type == SpecialBillingConfigurationType.TIME){
|
||||
List<EbiekSpecialTimeVo> timeConfigs = configurationVo.getTimeConfigs();
|
||||
if (timeConfigs == null || timeConfigs.isEmpty()){
|
||||
throw new EbikeException("选择高峰时段计费后必须配置时段费用");
|
||||
}
|
||||
timeMapper.deleteByQuery(queryWrapper);
|
||||
List<EbiekSpecialTime> list = new ArrayList<>();
|
||||
for (EbiekSpecialTimeVo timeConfig : timeConfigs){
|
||||
EbiekSpecialTime time = EbiekSpecialTime.builder()
|
||||
.regionId(regionId)
|
||||
.startTime(timeConfig.getStartTime())
|
||||
.endTime(timeConfig.getEndTime())
|
||||
.baseFee(timeConfig.getBaseFee())
|
||||
.baseDurationMinutes(timeConfig.getBaseDurationMinutes())
|
||||
.durationFee(timeConfig.getDurationFee())
|
||||
.chargeDurationMinutes(timeConfig.getChargeDurationMinutes())
|
||||
.createdBy(loginId)
|
||||
.build();
|
||||
list.add(time);
|
||||
}
|
||||
timeMapper.insertBatch(list);
|
||||
} else if (type == SpecialBillingConfigurationType.DAY) {
|
||||
List<EbiekSpecialDayVo> dayConfigs = configurationVo.getDayConfigs();
|
||||
if (dayConfigs == null || dayConfigs.isEmpty()){
|
||||
throw new EbikeException("选择高峰日计费后必须配置高峰日费用");
|
||||
}
|
||||
dayMapper.deleteByQuery(queryWrapper);
|
||||
List<EbiekSpecialDay> list = new ArrayList<>();
|
||||
for (EbiekSpecialDayVo dayConfig : dayConfigs){
|
||||
EbiekSpecialDay day = EbiekSpecialDay.builder()
|
||||
.regionId(regionId)
|
||||
.specialDayNum(dayConfig.getSpecialDayNum())
|
||||
.baseFee(dayConfig.getBaseFee())
|
||||
.baseDurationMinutes(dayConfig.getBaseDurationMinutes())
|
||||
.durationFee(dayConfig.getDurationFee())
|
||||
.chargeDurationMinutes(dayConfig.getChargeDurationMinutes())
|
||||
.createdBy(loginId)
|
||||
.build();
|
||||
list.add(day);
|
||||
}
|
||||
dayMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user