From 2f744252ccc02b1608e37d518ee109a7bc27e137 Mon Sep 17 00:00:00 2001 From: zhangli <123879394@qq.com> Date: Sat, 2 Aug 2025 01:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/controller/PubOrderController.java | 17 ++-- .../com/sczx/order/convert/OrderConvert.java | 30 +++++- .../com/sczx/order/dto/OrderDetailDTO.java | 93 +++++++++++++++++++ .../com/sczx/order/service/OrderService.java | 7 ++ .../order/service/impl/OrderServiceImpl.java | 34 +++++++ .../order/thirdpart/dto/SysDictDataDTO.java | 22 +++++ .../order/thirdpart/facade/CarFacade.java | 8 +- .../order/thirdpart/integration/CarInteg.java | 19 +++- 8 files changed, 213 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/sczx/order/dto/OrderDetailDTO.java create mode 100644 src/main/java/com/sczx/order/thirdpart/dto/SysDictDataDTO.java diff --git a/src/main/java/com/sczx/order/controller/PubOrderController.java b/src/main/java/com/sczx/order/controller/PubOrderController.java index 4977470..1c19750 100644 --- a/src/main/java/com/sczx/order/controller/PubOrderController.java +++ b/src/main/java/com/sczx/order/controller/PubOrderController.java @@ -1,13 +1,15 @@ package com.sczx.order.controller; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.sczx.order.common.Result; -import com.sczx.order.dto.*; +import com.sczx.order.dto.OrderDetailDTO; import com.sczx.order.service.OrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** * @Author: 张黎 @@ -22,10 +24,11 @@ public class PubOrderController { @Autowired private OrderService orderService; - @ApiOperation(value = "根据订单查询订单信息") - @GetMapping("/getOrderInfoByOrderNo") - public Result getOrderInfoByOrderNo(@RequestParam("orderNo") String orderNo){ - return Result.ok(orderService.getOrderInfoByOrderNo(orderNo)); + + @ApiOperation(value = "根据订单查询订单详情") + @GetMapping("/getOrderDetailByOrderNo") + public Result getOrderDetailByOrderNo(@RequestParam("orderNo") String orderNo){ + return Result.ok(orderService.getOrderDetailByOrderNo(orderNo)); } } diff --git a/src/main/java/com/sczx/order/convert/OrderConvert.java b/src/main/java/com/sczx/order/convert/OrderConvert.java index 238690e..58980ff 100644 --- a/src/main/java/com/sczx/order/convert/OrderConvert.java +++ b/src/main/java/com/sczx/order/convert/OrderConvert.java @@ -1,10 +1,12 @@ package com.sczx.order.convert; import com.sczx.order.dto.OrderDTO; +import com.sczx.order.dto.OrderDetailDTO; import com.sczx.order.dto.RentCarOrderReq; import com.sczx.order.dto.SimpleUserInfoDTO; import com.sczx.order.po.OrderMainPO; -import com.sczx.order.thirdpart.dto.RentCarRuleDTO; +import com.sczx.order.po.OrderSubPO; +import com.sczx.order.thirdpart.dto.*; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; @@ -44,4 +46,30 @@ public interface OrderConvert { }) OrderMainPO subOrderToPo(RentCarOrderReq rentCarOrderReq, SimpleUserInfoDTO userInfoDTO, RentCarRuleDTO rentCarRuleDTO); + + @Mappings({ + + @Mapping(source = "orderMainPO.storeId", target = "orderId"), + @Mapping(source = "orderMainPO.orderNo", target = "orderNo"), + @Mapping(source = "orderMainPO.orderStatus", target = "orderStatus"), + @Mapping(source = "orderMainPO.customerId", target = "customerId"), + @Mapping(source = "orderMainPO.customerName", target = "customerName"), + @Mapping(source = "orderMainPO.rentalType", target = "rentalType"), + @Mapping(source = "orderMainPO.rentalPrice", target = "rentalPrice"), + @Mapping(source = "orderMainPO.depositPrice", target = "depositPrice"), + @Mapping(source = "orderMainPO.firstOrderTime", target = "firstOrderTime"), + @Mapping(source = "orderMainPO.startRentTime", target = "startRentTime"), + @Mapping(source = "orderMainPO.endRentTime", target = "endRentTime"), + @Mapping(source = "companyStoreDTO.name", target = "storeName"), + @Mapping(source = "carDTO.modelName", target = "modelName"), + @Mapping(source = "carDTO.brandName", target = "brandName"), + @Mapping(source = "carDTO.id", target = "carId"), + @Mapping(source = "carDTO.vin", target = "vin"), + @Mapping(source = "carDTO.licensePlate", target = "licensePlate"), + @Mapping(source = "rentBatteyRuleDTO.categoryName", target = "categoryName"), + @Mapping(source = "rentBatteyRuleDTO.title", target = "rentBatteyTitle"), + @Mapping(source = "rentBatteyRuleDTO.durationType", target = "durationType"), + @Mapping(source = "rentBatteyOrder.vinBatteryNo", target = "batteyNo"), + }) + OrderDetailDTO mainOrderToDetailDTO(OrderMainPO orderMainPO, CompanyStoreDTO companyStoreDTO, RentBatteyRuleDTO rentBatteyRuleDTO, CarDTO carDTO, OrderSubPO rentBatteyOrder); } diff --git a/src/main/java/com/sczx/order/dto/OrderDetailDTO.java b/src/main/java/com/sczx/order/dto/OrderDetailDTO.java new file mode 100644 index 0000000..688e58b --- /dev/null +++ b/src/main/java/com/sczx/order/dto/OrderDetailDTO.java @@ -0,0 +1,93 @@ +package com.sczx.order.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@ApiModel(value = "订单详情dto", description = "租车订单详情信息") +@Data +public class OrderDetailDTO { + + @ApiModelProperty("订单ID(主键)") + private Long orderId; + + @ApiModelProperty("订单编号") + private String orderNo; + + @ApiModelProperty("订单状态:下单未提车、租赁中、已结束-自动、已结束-手动") + private String orderStatus; + + @ApiModelProperty("门店名称") + private String storeName; + + @ApiModelProperty("车型名称") + private String modelName; + + @ApiModelProperty("品牌名称") + private String brandName; + + @ApiModelProperty("车辆id") + private String carId; + + @ApiModelProperty("车架号(VIN)") + private String vin; + + @ApiModelProperty("车牌号码") + private String licensePlate; + + @ApiModelProperty("客户id") + private Long customerId; + + @ApiModelProperty("客户姓名") + private String customerName; + + @ApiModelProperty("客户联系电话") + private String customerPhone; + + + @ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)") + private String rentalType; + + @ApiModelProperty("租赁类型标签") + private String rentalTypeLabel; + + @ApiModelProperty("租车价格(元)") + private BigDecimal rentalPrice; + + @ApiModelProperty("押金价格(元)") + private BigDecimal depositPrice; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("首次下单时间") + private LocalDateTime firstOrderTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("开始计费时间") + private LocalDateTime startRentTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("还车时间") + private LocalDateTime endRentTime; + + @ApiModelProperty("电池订单号") + private String rentBatteyOrderNo; + + @ApiModelProperty("电池类型名称") + private String categoryName; + + @ApiModelProperty("电池编码") + private String batteyNo; + + @ApiModelProperty("计时方式") + private Integer durationType; + + @ApiModelProperty("电池计时方式标签") + private String durationTypeLabel; + + @ApiModelProperty("租点套餐名称") + private String rentBatteyTitle; +} diff --git a/src/main/java/com/sczx/order/service/OrderService.java b/src/main/java/com/sczx/order/service/OrderService.java index 43baeff..90bda85 100644 --- a/src/main/java/com/sczx/order/service/OrderService.java +++ b/src/main/java/com/sczx/order/service/OrderService.java @@ -20,6 +20,13 @@ public interface OrderService { */ OrderDTO getOrderInfoByOrderNo(String orderNo); + /** + * 根据订单号查询订单详情信息 + * @param orderNo + * @return + */ + OrderDetailDTO getOrderDetailByOrderNo(String orderNo); + /** * 绑定车辆到订单 * @param bindCarToOrderReq diff --git a/src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java b/src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java index e98cccb..17772c3 100644 --- a/src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java +++ b/src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java @@ -36,6 +36,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; @Slf4j @@ -213,6 +214,39 @@ public class OrderServiceImpl implements OrderService { return orderDTO; } + @Override + public OrderDetailDTO getOrderDetailByOrderNo(String orderNo) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OrderMainPO::getOrderNo, orderNo); + OrderMainPO orderMainPO = orderMainRepo.getOne(queryWrapper); + + //获取租电子订单 + LambdaQueryWrapper querySubWrapper = new LambdaQueryWrapper<>(); + querySubWrapper.eq(OrderSubPO::getOrderId, orderMainPO.getOrderId()) + .eq(OrderSubPO::getSuborderType, SubOrderTypeEnum.RENTBATTEY.getCode()).last(" limit 1"); + OrderSubPO rentBatteyOrder = orderSubRepo.getOne(querySubWrapper); + + //获取门店信息 + CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(orderMainPO.getStoreId().toString())); + RentBatteyRuleDTO rentBatteyRuleDTO = null; + if(orderMainPO.getRentBatteyRuleId()!=null){ + rentBatteyRuleDTO = carInteg.getRentBatteyRuleByBatteyRuleId(orderMainPO.getRentBatteyRuleId()); + } + CarDTO carDTO = null; + if(orderMainPO.getVehicleId() !=null){ + carDTO = carInteg.getCarByCarCondition(CarQueryConditionReq.builder().carId(orderMainPO.getVehicleId()).build()); + } + OrderDetailDTO orderDetailDTO = OrderConvert.INSTANCE.mainOrderToDetailDTO(orderMainPO, companyStoreDTO, rentBatteyRuleDTO, carDTO, rentBatteyOrder); + + SysDictDataDTO rentCarTypeDictDataDTO = carInteg.getDictDataByDicTypeAndValue("key_order_rental_type", orderDetailDTO.getRentalType()); + orderDetailDTO.setRentalTypeLabel(Optional.ofNullable(rentCarTypeDictDataDTO).map(SysDictDataDTO::getDictLabel).orElse(null)); + + SysDictDataDTO rentCarBatteyDictDataDTO = carInteg.getDictDataByDicTypeAndValue("key_rental_type", orderDetailDTO.getDurationType().toString()); + orderDetailDTO.setDurationTypeLabel(Optional.ofNullable(rentCarBatteyDictDataDTO).map(SysDictDataDTO::getDictLabel).orElse(null)); + + return orderDetailDTO; + } + @Transactional(rollbackFor = Exception.class) @Override public OrderDTO bindCarToOrder(BindCarToOrderReq bindCarToOrderReq) { diff --git a/src/main/java/com/sczx/order/thirdpart/dto/SysDictDataDTO.java b/src/main/java/com/sczx/order/thirdpart/dto/SysDictDataDTO.java new file mode 100644 index 0000000..6d520cc --- /dev/null +++ b/src/main/java/com/sczx/order/thirdpart/dto/SysDictDataDTO.java @@ -0,0 +1,22 @@ +package com.sczx.order.thirdpart.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel(value = "SysDictDataDTO对象", description = "字典数据传输对象") +@Data +public class SysDictDataDTO { + + @ApiModelProperty("字典标签") + private String dictLabel; + + @ApiModelProperty("字典键值") + private String dictValue; + + @ApiModelProperty("字典类型") + private String dictType; + + @ApiModelProperty("状态(0正常 1停用)") + private String status; +} diff --git a/src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java b/src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java index dd3abf2..551cff8 100644 --- a/src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java +++ b/src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java @@ -1,10 +1,7 @@ package com.sczx.order.thirdpart.facade; import com.sczx.order.common.Result; -import com.sczx.order.thirdpart.dto.CarDTO; -import com.sczx.order.thirdpart.dto.CarModelSimpleDTO; -import com.sczx.order.thirdpart.dto.RentBatteyRuleDTO; -import com.sczx.order.thirdpart.dto.RentCarRuleDTO; +import com.sczx.order.thirdpart.dto.*; import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; @@ -23,4 +20,7 @@ public interface CarFacade { @PostMapping("/car/getCarByCarCondition") Result getCarByCarCondition(@RequestBody CarQueryConditionReq req); + + @GetMapping("/sys/getDictDataByDicTypeAndValue") + Result getDictDataByDicTypeAndValue(@RequestParam(name = "dicType") String dicType, @RequestParam(name = "dicValue") String dicValue); } \ No newline at end of file diff --git a/src/main/java/com/sczx/order/thirdpart/integration/CarInteg.java b/src/main/java/com/sczx/order/thirdpart/integration/CarInteg.java index ba457c2..dd0f5b5 100644 --- a/src/main/java/com/sczx/order/thirdpart/integration/CarInteg.java +++ b/src/main/java/com/sczx/order/thirdpart/integration/CarInteg.java @@ -2,16 +2,12 @@ package com.sczx.order.thirdpart.integration; import com.sczx.order.common.Result; import com.sczx.order.exception.InnerException; -import com.sczx.order.thirdpart.dto.CarDTO; -import com.sczx.order.thirdpart.dto.CarModelSimpleDTO; -import com.sczx.order.thirdpart.dto.RentBatteyRuleDTO; -import com.sczx.order.thirdpart.dto.RentCarRuleDTO; +import com.sczx.order.thirdpart.dto.*; import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq; import com.sczx.order.thirdpart.facade.CarFacade; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.RequestBody; @Slf4j @Component @@ -73,4 +69,17 @@ public class CarInteg { return null; } + public SysDictDataDTO getDictDataByDicTypeAndValue(String dicType, String dicValue){ + try{ + Result result = carFacade.getDictDataByDicTypeAndValue(dicType, dicValue); + if(result.isSuccess()){ + return result.getData(); + } + } catch (Exception e){ + log.error("根据字典类型和字典值获取字典数据失败",e); + throw new InnerException("根据字典类型和字典值获取字典数据失败"); + } + return null; + } + }