diff --git a/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeRegionController.java b/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeRegionController.java index 84c9c7b..731f912 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeRegionController.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeRegionController.java @@ -4,8 +4,11 @@ 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.entity.EbikeDefaultBillingConfiguration; 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.service.EbikeDefaultBillingConfigurationService; import com.cdzy.operations.service.EbikeRegionService; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; @@ -17,6 +20,7 @@ import org.springframework.web.bind.annotation.*; 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; /** @@ -33,6 +37,9 @@ public class EbikeRegionController { @Resource private EbikeRegionService ebikeRegionService; + @Resource + private EbikeDefaultBillingConfigurationService defaultConfigurationService; + /** * 添加运营区域。 * @@ -142,4 +149,29 @@ public class EbikeRegionController { 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); + } } diff --git a/ebike-operations/src/main/java/com/cdzy/operations/mapper/EbikeDefaultBillingConfigurationMapper.java b/ebike-operations/src/main/java/com/cdzy/operations/mapper/EbikeDefaultBillingConfigurationMapper.java new file mode 100644 index 0000000..72a754c --- /dev/null +++ b/ebike-operations/src/main/java/com/cdzy/operations/mapper/EbikeDefaultBillingConfigurationMapper.java @@ -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 { + +} diff --git a/ebike-operations/src/main/java/com/cdzy/operations/model/entity/EbikeDefaultBillingConfiguration.java b/ebike-operations/src/main/java/com/cdzy/operations/model/entity/EbikeDefaultBillingConfiguration.java new file mode 100644 index 0000000..28ce26f --- /dev/null +++ b/ebike-operations/src/main/java/com/cdzy/operations/model/entity/EbikeDefaultBillingConfiguration.java @@ -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; + +} diff --git a/ebike-operations/src/main/java/com/cdzy/operations/model/vo/EbikeDefaultBillingConfigurationVo.java b/ebike-operations/src/main/java/com/cdzy/operations/model/vo/EbikeDefaultBillingConfigurationVo.java new file mode 100644 index 0000000..9024a34 --- /dev/null +++ b/ebike-operations/src/main/java/com/cdzy/operations/model/vo/EbikeDefaultBillingConfigurationVo.java @@ -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; + +} \ No newline at end of file diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeDefaultBillingConfigurationService.java b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeDefaultBillingConfigurationService.java new file mode 100644 index 0000000..625fe5b --- /dev/null +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeDefaultBillingConfigurationService.java @@ -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 { + + /** + * 保存运营区默认配置 + * @param configurationVo 配置信息 + */ + void defaultConfiguration(EbikeDefaultBillingConfigurationVo configurationVo); +} diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeDefaultBillingConfigurationServiceImpl.java b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeDefaultBillingConfigurationServiceImpl.java new file mode 100644 index 0000000..2daf8c2 --- /dev/null +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeDefaultBillingConfigurationServiceImpl.java @@ -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 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); + } +} diff --git a/ebike-staff/src/test/java/com/cdzy/staff/EbikeStaffApplicationTests.java b/ebike-staff/src/test/java/com/cdzy/staff/EbikeStaffApplicationTests.java index 28c3abc..29e1d94 100644 --- a/ebike-staff/src/test/java/com/cdzy/staff/EbikeStaffApplicationTests.java +++ b/ebike-staff/src/test/java/com/cdzy/staff/EbikeStaffApplicationTests.java @@ -12,7 +12,7 @@ class EbikeStaffApplicationTests { private static final String mapperPath="D:/ebike_plus/ebike-operations/resources/mapper"; private static final String packageName ="com.cdzy.operations"; private static final String[] tables= new String[]{ - "ebike_region" + "ebike_default_billing_configuration" }; @Test