diff --git a/ebike-user/src/main/java/com/cdzy/user/controller/EbikeOrderController.java b/ebike-user/src/main/java/com/cdzy/user/controller/EbikeOrderController.java index 3af4d43..d476df8 100644 --- a/ebike-user/src/main/java/com/cdzy/user/controller/EbikeOrderController.java +++ b/ebike-user/src/main/java/com/cdzy/user/controller/EbikeOrderController.java @@ -5,6 +5,7 @@ import com.cdzy.common.model.response.JsonResult; import com.cdzy.user.model.dto.EbikeUserCyclingDto; import com.cdzy.user.model.dto.EbikeUserCyclingEndDto; import com.cdzy.user.model.entity.EbikeOrder; +import com.cdzy.user.model.vo.EbikeBikeInfoVo; import com.cdzy.user.model.vo.EbikeRevenueStatisticsVo; import com.cdzy.user.model.vo.EbikeUserAllOrdersVo; import com.cdzy.user.service.EbikeOrderService; @@ -51,7 +52,7 @@ public class EbikeOrderController { */ @GetMapping("queryBikeInfo") public JsonResult queryBikeInfo(@RequestParam("bikeCode") String bikeCode) { - FeignEbikeUserBikeInfo result = ebikeOrderService.queryBikeInfo(bikeCode); + EbikeBikeInfoVo result = ebikeOrderService.queryBikeInfo(bikeCode); return JsonResult.success(result); } diff --git a/ebike-user/src/main/java/com/cdzy/user/model/vo/EbikeBikeInfoVo.java b/ebike-user/src/main/java/com/cdzy/user/model/vo/EbikeBikeInfoVo.java new file mode 100644 index 0000000..6871911 --- /dev/null +++ b/ebike-user/src/main/java/com/cdzy/user/model/vo/EbikeBikeInfoVo.java @@ -0,0 +1,108 @@ +package com.cdzy.user.model.vo; + +import com.cdzy.user.handler.PGpolygonDeserializer; +import com.cdzy.user.handler.PGpolygonSerializer; +import com.cdzy.user.handler.PGpolygonTypeHandler; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.mybatisflex.annotation.Column; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.postgresql.geometric.PGpolygon; + +import java.math.BigDecimal; + +/** + * 车辆详情 信息 + * + * @author yanglei + * @since 2025-12-12 09:58 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class EbikeBikeInfoVo { + + /** + * 运营商ID + */ + private Long operatorId; + + /** + * 运营区ID + */ + private Long regionId; + + /** + * 车辆电量 + */ + private Float soc; + + /** + * 车辆编号(与车辆二维码编号相同 + */ + private String bikeCode; + + /** + * 免费时长(分钟):使用服务前的免费时间 + */ + private Integer freeDurationMinutes; + + /** + * 起步时长(分钟 + */ + private Integer baseDurationMinutes; + + + /** + * 起步费用(元) + */ + private BigDecimal baseFee; + + + /** + * 时长(分钟) + */ + private Integer chargeDurationMinutes; + + /** + * 时长费用(元) + */ + private BigDecimal durationFee; + + /** + * 运营区域外调度费(元) + */ + private BigDecimal outOfServiceAreaFee; + + /** + * 停车区外调度费(元) + */ + private BigDecimal outOfParkingAreaFee; + + /** + * 封顶金额(元) + */ + private BigDecimal maxFeeAmount; + + /** + * 禁停区调度费(元) + */ + private BigDecimal noParkingZoneFee; + + /** + * 头盔管理费(元) + */ + private BigDecimal helmetManagementFee; + + /** + * 车辆运营区 + */ + @Column(typeHandler = PGpolygonTypeHandler.class) + @JsonSerialize(using = PGpolygonSerializer.class) + @JsonDeserialize(using = PGpolygonDeserializer.class) + private PGpolygon regionPolygon; +} diff --git a/ebike-user/src/main/java/com/cdzy/user/service/EbikeOrderService.java b/ebike-user/src/main/java/com/cdzy/user/service/EbikeOrderService.java index 2139fe4..9828fb1 100644 --- a/ebike-user/src/main/java/com/cdzy/user/service/EbikeOrderService.java +++ b/ebike-user/src/main/java/com/cdzy/user/service/EbikeOrderService.java @@ -4,6 +4,7 @@ import com.cdzy.common.model.request.PageParam; import com.cdzy.user.model.dto.EbikeUserCyclingDto; import com.cdzy.user.model.dto.EbikeUserCyclingEndDto; import com.cdzy.user.model.entity.EbikeOrder; +import com.cdzy.user.model.vo.EbikeBikeInfoVo; import com.cdzy.user.model.vo.EbikeRevenueStatisticsVo; import com.cdzy.user.model.vo.EbikeUserAllOrdersVo; import com.ebike.feign.model.dto.FeignEbikeDto; @@ -95,7 +96,7 @@ public interface EbikeOrderService extends IService { * @param bikeCode 车辆编码 * @return 车辆基本信息 */ - FeignEbikeUserBikeInfo queryBikeInfo(String bikeCode); + EbikeBikeInfoVo queryBikeInfo(String bikeCode); /** * 结束骑行 diff --git a/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeOrderImpl.java b/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeOrderImpl.java index bee0d93..da35305 100644 --- a/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeOrderImpl.java +++ b/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeOrderImpl.java @@ -12,6 +12,7 @@ import com.cdzy.user.model.dto.EbikeUserCyclingEndDto; import com.cdzy.user.model.entity.EbikeOrder; import com.cdzy.user.model.entity.EbikeOrderDetail; import com.cdzy.user.model.entity.EbikePayment; +import com.cdzy.user.model.vo.EbikeBikeInfoVo; import com.cdzy.user.model.vo.EbikeRevenueStatisticsVo; import com.cdzy.user.model.vo.EbikeUserAllOrdersVo; import com.cdzy.user.service.EbikeOrderDetailService; @@ -82,7 +83,7 @@ public class EbikeOrderImpl extends ServiceImpl im throw new EbikeException("请完成未支付订单后再试"); } } - FeignEbikeUserBikeInfo bikeInfo = queryBikeInfo(orderDto.getBikeCode()); + EbikeBikeInfoVo bikeInfo = queryBikeInfo(orderDto.getBikeCode()); // 创建订单 EbikeOrder order = EbikeOrder.builder() .userId(userId) @@ -193,12 +194,29 @@ public class EbikeOrderImpl extends ServiceImpl im } @Override - public FeignEbikeUserBikeInfo queryBikeInfo(String bikeCode) { + public EbikeBikeInfoVo queryBikeInfo(String bikeCode) { JsonResult jsonResult = operationsFeignClient.bikeInfo(bikeCode); if (jsonResult.getCode() != Code.SUCCESS) { throw new EbikeException("获取车辆详情"); } - return jsonResult.getData(); + FeignEbikeUserBikeInfo source = jsonResult.getData(); + return EbikeBikeInfoVo.builder() + .operatorId(source.getOperatorId()) + .regionId(source.getRegionId()) + .soc(source.getSoc()) + .bikeCode(source.getBikeCode()) + .freeDurationMinutes(source.getFreeDurationMinutes()) + .baseDurationMinutes(source.getBaseDurationMinutes()) + .baseFee(source.getBaseFee()) + .chargeDurationMinutes(source.getChargeDurationMinutes()) + .durationFee(source.getDurationFee()) + .outOfServiceAreaFee(source.getOutOfServiceAreaFee()) + .outOfParkingAreaFee(source.getOutOfParkingAreaFee()) + .maxFeeAmount(source.getMaxFeeAmount()) + .noParkingZoneFee(source.getNoParkingZoneFee()) + .helmetManagementFee(source.getHelmetManagementFee()) + .regionPolygon(source.getRegionPolygon()) + .build(); } @Transactional @@ -207,7 +225,7 @@ public class EbikeOrderImpl extends ServiceImpl im // 先校验是否有当前订单 EbikeOrder order = getOrder(endDto); // 获取车辆信息,计算费用 - FeignEbikeUserBikeInfo bikeInfo = queryBikeInfo(endDto.getBikeCode()); + EbikeBikeInfoVo bikeInfo = queryBikeInfo(endDto.getBikeCode()); order.setEndTime(LocalDateTime.now()); order.setEndLocation(endDto.getEndPoint()); order.setOperatorId(bikeInfo.getOperatorId()); @@ -391,7 +409,7 @@ public class EbikeOrderImpl extends ServiceImpl im * @return 订单费用 */ private BigDecimal costCalculation(LocalDateTime startTime, LocalDateTime endTime, - FeignEbikeUserBikeInfo bikeInfo, FeignEbikeUserLockDto data) { + EbikeBikeInfoVo bikeInfo, FeignEbikeUserLockDto data) { // 基础费用计算 BigDecimal baseFee = bikeInfo.getBaseFee(); BigDecimal durationFee = bikeInfo.getDurationFee();