新增查询订单详情接口

This commit is contained in:
2025-08-02 01:39:54 +08:00
parent 457ebde068
commit 2f744252cc
8 changed files with 213 additions and 17 deletions

View File

@ -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<OrderDTO> getOrderInfoByOrderNo(@RequestParam("orderNo") String orderNo){
return Result.ok(orderService.getOrderInfoByOrderNo(orderNo));
@ApiOperation(value = "根据订单查询订单详情")
@GetMapping("/getOrderDetailByOrderNo")
public Result<OrderDetailDTO> getOrderDetailByOrderNo(@RequestParam("orderNo") String orderNo){
return Result.ok(orderService.getOrderDetailByOrderNo(orderNo));
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -20,6 +20,13 @@ public interface OrderService {
*/
OrderDTO getOrderInfoByOrderNo(String orderNo);
/**
* 根据订单号查询订单详情信息
* @param orderNo
* @return
*/
OrderDetailDTO getOrderDetailByOrderNo(String orderNo);
/**
* 绑定车辆到订单
* @param bindCarToOrderReq

View File

@ -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<OrderMainPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OrderMainPO::getOrderNo, orderNo);
OrderMainPO orderMainPO = orderMainRepo.getOne(queryWrapper);
//获取租电子订单
LambdaQueryWrapper<OrderSubPO> 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) {

View File

@ -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;
}

View File

@ -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<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req);
@GetMapping("/sys/getDictDataByDicTypeAndValue")
Result<SysDictDataDTO> getDictDataByDicTypeAndValue(@RequestParam(name = "dicType") String dicType, @RequestParam(name = "dicValue") String dicValue);
}

View File

@ -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<SysDictDataDTO> result = carFacade.getDictDataByDicTypeAndValue(dicType, dicValue);
if(result.isSuccess()){
return result.getData();
}
} catch (Exception e){
log.error("根据字典类型和字典值获取字典数据失败",e);
throw new InnerException("根据字典类型和字典值获取字典数据失败");
}
return null;
}
}