新增查询订单详情接口
This commit is contained in:
@ -1,13 +1,15 @@
|
|||||||
package com.sczx.order.controller;
|
package com.sczx.order.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.sczx.order.common.Result;
|
import com.sczx.order.common.Result;
|
||||||
import com.sczx.order.dto.*;
|
import com.sczx.order.dto.OrderDetailDTO;
|
||||||
import com.sczx.order.service.OrderService;
|
import com.sczx.order.service.OrderService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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: 张黎
|
* @Author: 张黎
|
||||||
@ -22,10 +24,11 @@ public class PubOrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
@ApiOperation(value = "根据订单查询订单信息")
|
|
||||||
@GetMapping("/getOrderInfoByOrderNo")
|
@ApiOperation(value = "根据订单查询订单详情")
|
||||||
public Result<OrderDTO> getOrderInfoByOrderNo(@RequestParam("orderNo") String orderNo){
|
@GetMapping("/getOrderDetailByOrderNo")
|
||||||
return Result.ok(orderService.getOrderInfoByOrderNo(orderNo));
|
public Result<OrderDetailDTO> getOrderDetailByOrderNo(@RequestParam("orderNo") String orderNo){
|
||||||
|
return Result.ok(orderService.getOrderDetailByOrderNo(orderNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
package com.sczx.order.convert;
|
package com.sczx.order.convert;
|
||||||
|
|
||||||
import com.sczx.order.dto.OrderDTO;
|
import com.sczx.order.dto.OrderDTO;
|
||||||
|
import com.sczx.order.dto.OrderDetailDTO;
|
||||||
import com.sczx.order.dto.RentCarOrderReq;
|
import com.sczx.order.dto.RentCarOrderReq;
|
||||||
import com.sczx.order.dto.SimpleUserInfoDTO;
|
import com.sczx.order.dto.SimpleUserInfoDTO;
|
||||||
import com.sczx.order.po.OrderMainPO;
|
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.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
@ -44,4 +46,30 @@ public interface OrderConvert {
|
|||||||
|
|
||||||
})
|
})
|
||||||
OrderMainPO subOrderToPo(RentCarOrderReq rentCarOrderReq, SimpleUserInfoDTO userInfoDTO, RentCarRuleDTO rentCarRuleDTO);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
93
src/main/java/com/sczx/order/dto/OrderDetailDTO.java
Normal file
93
src/main/java/com/sczx/order/dto/OrderDetailDTO.java
Normal 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;
|
||||||
|
}
|
||||||
@ -20,6 +20,13 @@ public interface OrderService {
|
|||||||
*/
|
*/
|
||||||
OrderDTO getOrderInfoByOrderNo(String orderNo);
|
OrderDTO getOrderInfoByOrderNo(String orderNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号查询订单详情信息
|
||||||
|
* @param orderNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderDetailDTO getOrderDetailByOrderNo(String orderNo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定车辆到订单
|
* 绑定车辆到订单
|
||||||
* @param bindCarToOrderReq
|
* @param bindCarToOrderReq
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -213,6 +214,39 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return orderDTO;
|
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)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public OrderDTO bindCarToOrder(BindCarToOrderReq bindCarToOrderReq) {
|
public OrderDTO bindCarToOrder(BindCarToOrderReq bindCarToOrderReq) {
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
@ -1,10 +1,7 @@
|
|||||||
package com.sczx.order.thirdpart.facade;
|
package com.sczx.order.thirdpart.facade;
|
||||||
|
|
||||||
import com.sczx.order.common.Result;
|
import com.sczx.order.common.Result;
|
||||||
import com.sczx.order.thirdpart.dto.CarDTO;
|
import com.sczx.order.thirdpart.dto.*;
|
||||||
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.req.CarQueryConditionReq;
|
import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -23,4 +20,7 @@ public interface CarFacade {
|
|||||||
|
|
||||||
@PostMapping("/car/getCarByCarCondition")
|
@PostMapping("/car/getCarByCarCondition")
|
||||||
Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req);
|
Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req);
|
||||||
|
|
||||||
|
@GetMapping("/sys/getDictDataByDicTypeAndValue")
|
||||||
|
Result<SysDictDataDTO> getDictDataByDicTypeAndValue(@RequestParam(name = "dicType") String dicType, @RequestParam(name = "dicValue") String dicValue);
|
||||||
}
|
}
|
||||||
@ -2,16 +2,12 @@ package com.sczx.order.thirdpart.integration;
|
|||||||
|
|
||||||
import com.sczx.order.common.Result;
|
import com.sczx.order.common.Result;
|
||||||
import com.sczx.order.exception.InnerException;
|
import com.sczx.order.exception.InnerException;
|
||||||
import com.sczx.order.thirdpart.dto.CarDTO;
|
import com.sczx.order.thirdpart.dto.*;
|
||||||
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.req.CarQueryConditionReq;
|
import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
|
||||||
import com.sczx.order.thirdpart.facade.CarFacade;
|
import com.sczx.order.thirdpart.facade.CarFacade;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -73,4 +69,17 @@ public class CarInteg {
|
|||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user