运营区默认计费配置

This commit is contained in:
attiya 2025-10-23 10:14:41 +08:00
parent d802bd0625
commit 2e8afcdbb2
7 changed files with 325 additions and 1 deletions

View File

@ -4,8 +4,11 @@ import cn.dev33.satoken.stp.StpUtil;
import com.cdzy.common.model.request.PageParam; import com.cdzy.common.model.request.PageParam;
import com.cdzy.common.model.response.JsonResult; import com.cdzy.common.model.response.JsonResult;
import com.cdzy.operations.enums.RegionStatus; import com.cdzy.operations.enums.RegionStatus;
import com.cdzy.operations.model.entity.EbikeDefaultBillingConfiguration;
import com.cdzy.operations.model.entity.EbikeRegion; import com.cdzy.operations.model.entity.EbikeRegion;
import com.cdzy.operations.model.vo.EbikeDefaultBillingConfigurationVo;
import com.cdzy.operations.model.vo.EbikeRegionVo; import com.cdzy.operations.model.vo.EbikeRegionVo;
import com.cdzy.operations.service.EbikeDefaultBillingConfigurationService;
import com.cdzy.operations.service.EbikeRegionService; import com.cdzy.operations.service.EbikeRegionService;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
@ -17,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; 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.EbikeRegionTableDef.EBIKE_REGION;
/** /**
@ -33,6 +37,9 @@ public class EbikeRegionController {
@Resource @Resource
private EbikeRegionService ebikeRegionService; private EbikeRegionService ebikeRegionService;
@Resource
private EbikeDefaultBillingConfigurationService defaultConfigurationService;
/** /**
* 添加运营区域 * 添加运营区域
* *
@ -142,4 +149,29 @@ public class EbikeRegionController {
return JsonResult.success(); return JsonResult.success();
} }
/**
* 保存运营区默认计费规则
*
* @param configurationVo 配置信息
* @return 分页对象
*/
@PostMapping("defaultConfiguration")
public JsonResult<?> defaultConfiguration(@Validated @RequestBody EbikeDefaultBillingConfigurationVo configurationVo) {
defaultConfigurationService.defaultConfiguration(configurationVo);
return JsonResult.success();
}
/**
* 获取运营区默认计费规则
*
* @param regionId 区域ID
* @return 分页对象
*/
@GetMapping("getDefaultConfiguration")
public JsonResult<?> getDefaultConfiguration(@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);
}
} }

View File

@ -0,0 +1,14 @@
package com.cdzy.operations.mapper;
import com.mybatisflex.core.BaseMapper;
import com.cdzy.operations.model.entity.EbikeDefaultBillingConfiguration;
/**
* 映射层
*
* @author attiya
* @since 2025-10-23
*/
public interface EbikeDefaultBillingConfigurationMapper extends BaseMapper<EbikeDefaultBillingConfiguration> {
}

View File

@ -0,0 +1,106 @@
package com.cdzy.operations.model.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 实体类
*
* @author attiya
* @since 2025-10-23
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("ebike_default_billing_configuration")
public class EbikeDefaultBillingConfiguration implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id
private Long defaultEbikeDefaultBillingConfigurationId;
/**
* 区域ID - 关联运营区域的唯一标识
*/
private Long regionId;
/**
* 免费时长分钟使用服务前的免费时间
*/
private Integer freeDurationMinutes;
/**
* 起步费用
*/
private BigDecimal baseFee;
/**
* 时长费用
*/
private BigDecimal durationFee;
/**
* 运营区域外调度费
*/
private BigDecimal outOfServiceAreaFee;
/**
* 停车区外调度费
*/
private BigDecimal outOfParkingAreaFee;
/**
* 封顶金额)
*/
private BigDecimal maxFeeAmount;
/**
* 起步时长分钟
*/
private Integer baseDurationMinutes;
/**
* 时长分钟)
*/
private Integer chargeDurationMinutes;
/**
* 禁停区调度费)
*/
private BigDecimal noParkingZoneFee;
/**
* 头盔管理费)
*/
private BigDecimal helmetManagementFee;
/**
* 记录创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createdAt;
private Long createdBy;
/**
* 记录最后更新时间
*/
@Column(onUpdateValue = "now()")
private LocalDateTime updatedAt;
private Long updatedBy;
}

View File

@ -0,0 +1,105 @@
package com.cdzy.operations.model.vo;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 运营区默认计费配置入参
*
* @author attiya
* @since 2025-10-23
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EbikeDefaultBillingConfigurationVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 区域ID - 关联运营区域的唯一标识
*/
@NotNull(message = "区域ID不能为空")
private Long regionId;
/**
* 免费时长分钟使用服务前的免费时间
*/
@NotNull(message = "免费时长不能为空")
@Min(value = 0, message = "免费时长不能小于0")
private Integer freeDurationMinutes;
/**
* 起步费用
*/
@NotNull(message = "起步费用不能为空")
@Min(value = 0, message = "起步费用不能小于0")
private BigDecimal baseFee;
/**
* 时长费用
*/
@NotNull(message = "时长费用不能为空")
@Min(value = 0, message = "时长费用不能小于0")
private BigDecimal durationFee;
/**
* 运营区域外调度费
*/
@NotNull(message = "运营区域外调度费不能为空")
@Min(value = 0, message = "运营区域外调度费不能小于0")
private BigDecimal outOfServiceAreaFee;
/**
* 停车区外调度费
*/
@NotNull(message = "停车区外调度费不能为空")
@Min(value = 0, message = "停车区外调度费不能小于0")
private BigDecimal outOfParkingAreaFee;
/**
* 封顶金额
*/
@NotNull(message = "封顶金额不能为空")
@Min(value = 0, message = "封顶金额不能小于0")
private BigDecimal maxFeeAmount;
/**
* 起步时长分钟
*/
@NotNull(message = "起步时长不能为空")
@Min(value = 0, message = "起步时长不能小于0")
private Integer baseDurationMinutes;
/**
* 时长分钟
*/
@NotNull(message = "时长不能为空")
@Min(value = 0, message = "时长不能小于0")
private Integer chargeDurationMinutes;
/**
* 禁停区调度费
*/
@NotNull(message = "禁停区调度费不能为空")
@Min(value = 0, message = "禁停区调度费不能小于0")
private BigDecimal noParkingZoneFee;
/**
* 头盔管理费
*/
@NotNull(message = "头盔管理费不能为空")
@Min(value = 0, message = "头盔管理费不能小于0")
private BigDecimal helmetManagementFee;
}

View File

@ -0,0 +1,20 @@
package com.cdzy.operations.service;
import com.cdzy.operations.model.vo.EbikeDefaultBillingConfigurationVo;
import com.mybatisflex.core.service.IService;
import com.cdzy.operations.model.entity.EbikeDefaultBillingConfiguration;
/**
* 服务层
*
* @author attiya
* @since 2025-10-23
*/
public interface EbikeDefaultBillingConfigurationService extends IService<EbikeDefaultBillingConfiguration> {
/**
* 保存运营区默认配置
* @param configurationVo 配置信息
*/
void defaultConfiguration(EbikeDefaultBillingConfigurationVo configurationVo);
}

View File

@ -0,0 +1,47 @@
package com.cdzy.operations.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.cdzy.operations.model.vo.EbikeDefaultBillingConfigurationVo;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.cdzy.operations.model.entity.EbikeDefaultBillingConfiguration;
import com.cdzy.operations.mapper.EbikeDefaultBillingConfigurationMapper;
import com.cdzy.operations.service.EbikeDefaultBillingConfigurationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static com.cdzy.operations.model.entity.table.EbikeDefaultBillingConfigurationTableDef.EBIKE_DEFAULT_BILLING_CONFIGURATION;
/**
* 服务层实现
*
* @author attiya
* @since 2025-10-23
*/
@Service
public class EbikeDefaultBillingConfigurationServiceImpl extends ServiceImpl<EbikeDefaultBillingConfigurationMapper, EbikeDefaultBillingConfiguration> implements EbikeDefaultBillingConfigurationService{
@Override
@Transactional(rollbackFor = Exception.class)
public void defaultConfiguration(EbikeDefaultBillingConfigurationVo configurationVo) {
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_DEFAULT_BILLING_CONFIGURATION.REGION_ID.eq(configurationVo.getRegionId()));
this.mapper.deleteByQuery(queryWrapper);
EbikeDefaultBillingConfiguration billingConfiguration = EbikeDefaultBillingConfiguration.builder()
.regionId(configurationVo.getRegionId())
.freeDurationMinutes(configurationVo.getFreeDurationMinutes())
.baseFee(configurationVo.getBaseFee())
.durationFee(configurationVo.getDurationFee())
.outOfServiceAreaFee(configurationVo.getOutOfServiceAreaFee())
.outOfParkingAreaFee(configurationVo.getOutOfParkingAreaFee())
.maxFeeAmount(configurationVo.getMaxFeeAmount())
.baseDurationMinutes(configurationVo.getBaseDurationMinutes())
.chargeDurationMinutes(configurationVo.getChargeDurationMinutes())
.noParkingZoneFee(configurationVo.getNoParkingZoneFee())
.helmetManagementFee(configurationVo.getHelmetManagementFee())
.helmetManagementFee(configurationVo.getHelmetManagementFee())
.createdBy(StpUtil.getLoginIdAsLong())
.build();
this.mapper.insert(billingConfiguration);
}
}

View File

@ -12,7 +12,7 @@ class EbikeStaffApplicationTests {
private static final String mapperPath="D:/ebike_plus/ebike-operations/resources/mapper"; private static final String mapperPath="D:/ebike_plus/ebike-operations/resources/mapper";
private static final String packageName ="com.cdzy.operations"; private static final String packageName ="com.cdzy.operations";
private static final String[] tables= new String[]{ private static final String[] tables= new String[]{
"ebike_region" "ebike_default_billing_configuration"
}; };
@Test @Test