绑定车辆接口修改
This commit is contained in:
@ -2,8 +2,11 @@ package com.sczx.order.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Builder
|
||||
@ApiModel(value = "绑定车辆到订单请求参数")
|
||||
@Data
|
||||
public class BindCarToOrderReq {
|
||||
|
||||
@ -11,6 +11,7 @@ import com.sczx.order.common.enums.SubOrderTypeEnum;
|
||||
import com.sczx.order.convert.OrderConvert;
|
||||
import com.sczx.order.convert.OrderSubConvert;
|
||||
import com.sczx.order.dto.*;
|
||||
import com.sczx.order.exception.BizException;
|
||||
import com.sczx.order.exception.InnerException;
|
||||
import com.sczx.order.po.OrderMainPO;
|
||||
import com.sczx.order.po.OrderSubPO;
|
||||
@ -18,6 +19,7 @@ import com.sczx.order.repository.OrderMainRepo;
|
||||
import com.sczx.order.repository.OrderSubRepo;
|
||||
import com.sczx.order.service.OrderService;
|
||||
import com.sczx.order.thirdpart.dto.*;
|
||||
import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
|
||||
import com.sczx.order.thirdpart.integration.CarInteg;
|
||||
import com.sczx.order.thirdpart.integration.StoreInteg;
|
||||
import com.sczx.order.utils.JwtUtil;
|
||||
@ -188,14 +190,40 @@ public class OrderServiceImpl implements OrderService {
|
||||
return orderDTO;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OrderDTO bindCarToOrder(BindCarToOrderReq bindCarToOrderReq) {
|
||||
CarDTO carDTO = carInteg.getCarByCarCondition(CarQueryConditionReq.builder().vin(bindCarToOrderReq.getVin()).build());
|
||||
if(carDTO==null){
|
||||
throw new BizException("车辆不存在");
|
||||
}
|
||||
LambdaQueryWrapper<OrderMainPO> queryOrderWrapper = new LambdaQueryWrapper<>();
|
||||
queryOrderWrapper.eq(OrderMainPO::getOrderNo, bindCarToOrderReq.getOrderNo());
|
||||
OrderMainPO orderMainPO = orderMainRepo.getOne(queryOrderWrapper);
|
||||
if(orderMainPO==null){
|
||||
throw new BizException("订单不存在");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<OrderSubPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(OrderSubPO::getOrderId, orderMainPO.getOrderId())
|
||||
.eq(OrderSubPO::getSuborderType, SubOrderTypeEnum.RENTCAR.getCode())
|
||||
.isNull(OrderSubPO::getVinBatteryNo)
|
||||
.orderByDesc(OrderSubPO::getCreatedAt)
|
||||
.last(" limit 1");
|
||||
OrderSubPO renOrderSubPO = orderSubRepo.getOne(queryWrapper);
|
||||
if(renOrderSubPO==null){
|
||||
throw new BizException("租车子订单不存在");
|
||||
}
|
||||
//记录车架号
|
||||
LambdaUpdateWrapper<OrderSubPO> updateSubWrapper = new LambdaUpdateWrapper<>();
|
||||
updateSubWrapper.set(OrderSubPO::getVinBatteryNo, carDTO.getVin());
|
||||
updateSubWrapper.eq(OrderSubPO::getSuborderId, renOrderSubPO.getSuborderId());
|
||||
orderSubRepo.update(updateSubWrapper);
|
||||
//变更订单状态,记录租车时间
|
||||
LambdaUpdateWrapper<OrderMainPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(OrderMainPO::getOrderStatus, OrderStatusEnum.RENT_ING.getCode());
|
||||
updateWrapper.set(OrderMainPO::getStartRentTime, LocalDateTime.now());
|
||||
// updateWrapper.set(OrderMainPO::getVehicleId, bindCarToOrderReq.getVehicleId());
|
||||
updateWrapper.set(OrderMainPO::getVehicleId, carDTO.getId());
|
||||
updateWrapper.eq(OrderMainPO::getOrderNo, bindCarToOrderReq.getOrderNo());
|
||||
orderMainRepo.update(updateWrapper);
|
||||
//TODO 变更车辆状态
|
||||
|
||||
132
src/main/java/com/sczx/order/thirdpart/dto/CarDTO.java
Normal file
132
src/main/java/com/sczx/order/thirdpart/dto/CarDTO.java
Normal file
@ -0,0 +1,132 @@
|
||||
package com.sczx.order.thirdpart.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 电动车信息表
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-30 17:05:03
|
||||
*/
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "CarDTO对象", description = "电动车信息表")
|
||||
public class CarDTO {
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("车架号(VIN)")
|
||||
private String vin;
|
||||
|
||||
@ApiModelProperty("车牌号码")
|
||||
private String licensePlate;
|
||||
|
||||
@ApiModelProperty("车辆品牌ID")
|
||||
private Long brandId;
|
||||
|
||||
@ApiModelProperty("车辆品牌名称")
|
||||
private String brandName;
|
||||
|
||||
@ApiModelProperty("车辆型号ID")
|
||||
private Long modelId;
|
||||
|
||||
@ApiModelProperty("车辆型号名称")
|
||||
private String modelName;
|
||||
|
||||
@ApiModelProperty("支持电池类型(48V标准版/100km,48V超长版/200km等)")
|
||||
private String batteryType;
|
||||
|
||||
@ApiModelProperty("整车重量(kg)")
|
||||
private String weight;
|
||||
|
||||
@ApiModelProperty("最高时速(km/h)")
|
||||
private String maxSpeed;
|
||||
|
||||
@ApiModelProperty("LOT识别号")
|
||||
private String lotNumber;
|
||||
|
||||
@ApiModelProperty("采购日期")
|
||||
private LocalDateTime purchaseDate;
|
||||
|
||||
@ApiModelProperty("采购价格(元)")
|
||||
private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("车辆归属(0归属于合,1归属运营商)")
|
||||
private String belongType;
|
||||
|
||||
@ApiModelProperty("车辆图片(多个图片用逗号分隔)")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty("BRS车辆状态(空闲/使用中/维修中/丢失报损等)")
|
||||
private String brsStatus;
|
||||
|
||||
@ApiModelProperty("IoT设备状态")
|
||||
private String iotStatus;
|
||||
|
||||
@ApiModelProperty("IoT识别码")
|
||||
private String iotCode;
|
||||
|
||||
@ApiModelProperty("所属运营商ID")
|
||||
private Long operatorId;
|
||||
|
||||
@ApiModelProperty("所属运营商名称")
|
||||
private String operatorName;
|
||||
|
||||
@ApiModelProperty("所属门店ID")
|
||||
private Long storeId;
|
||||
|
||||
@ApiModelProperty("所属门店名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("应用套餐ID")
|
||||
private Long packageId;
|
||||
|
||||
@ApiModelProperty("应用套餐名称")
|
||||
private String packageName;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("更新者")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("扩展字段1")
|
||||
private String extend1;
|
||||
|
||||
@ApiModelProperty("扩展字段2")
|
||||
private String extend2;
|
||||
|
||||
@ApiModelProperty("扩展字段3")
|
||||
private String extend3;
|
||||
|
||||
@ApiModelProperty("扩展字段4")
|
||||
private String extend4;
|
||||
|
||||
@ApiModelProperty("扩展字段5")
|
||||
private String extend5;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.sczx.order.thirdpart.dto.req;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: 张黎
|
||||
* @Date: 2025/07/30/17:13
|
||||
* @Description:
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@ApiModel(value = "车辆查询请求", description = "CarQueryConditionReq对象")
|
||||
public class CarQueryConditionReq {
|
||||
|
||||
@ApiModelProperty(value = "车辆ID")
|
||||
private Long carId;
|
||||
|
||||
@ApiModelProperty(value = "车牌号码")
|
||||
private String licensePlate;
|
||||
|
||||
@ApiModelProperty(value = "车架号(VIN)")
|
||||
private String vin;
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
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.req.CarQueryConditionReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
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.*;
|
||||
|
||||
@FeignClient(name = "sczx-car")
|
||||
public interface CarFacade {
|
||||
@ -20,4 +20,7 @@ public interface CarFacade {
|
||||
|
||||
@GetMapping("/batteyRule/getRentBatteyRuleByBatteyRuleId")
|
||||
Result<RentBatteyRuleDTO> getRentBatteyRuleByBatteyRuleId(@RequestParam(name = "batteyRuleId") Long batteyRuleId);
|
||||
|
||||
@PostMapping("/car/getCarByCarCondition")
|
||||
Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req);
|
||||
}
|
||||
@ -2,13 +2,16 @@ 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.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
|
||||
@ -57,4 +60,17 @@ public class CarInteg {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarDTO getCarByCarCondition(CarQueryConditionReq req){
|
||||
try{
|
||||
Result<CarDTO> result = carFacade.getCarByCarCondition(req);
|
||||
if(result.isSuccess()){
|
||||
return result.getData();
|
||||
}
|
||||
} catch (Exception e){
|
||||
log.error("根据车辆查询条件查询车辆信息失败",e);
|
||||
throw new InnerException("根据车辆查询条件查询车辆信息失败");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user