增加确认租车接口
This commit is contained in:
@ -0,0 +1,7 @@
|
|||||||
|
package com.sczx.order.common.constant;
|
||||||
|
|
||||||
|
public interface RedisKeyConstants {
|
||||||
|
String SERVICE_PREFIX = "sczxOrder:";
|
||||||
|
|
||||||
|
String ORDER_SUB_KEY = SERVICE_PREFIX + "orderSub:";
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2024/03/08/17:42
|
||||||
|
* @Description: 小程序类型枚举
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum MiniPogramTypeEnum {
|
||||||
|
WX_MINI_PROGRAM("WX_MINI_PROGRAM", "微信小程序"),
|
||||||
|
ZFB_MINI_PROGRAM("ZFB_MINI_PROGRAM", "支付宝小程序"),
|
||||||
|
;
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.sczx.order.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2024/03/08/17:42
|
||||||
|
* @Description: 支付方式枚举
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum PaymentTypeEnum {
|
||||||
|
WX_PAY("WX_PAY", "微信支付"),
|
||||||
|
WX_DQ("WX_DQ", "微信代扣"),
|
||||||
|
ZFB_PAY("ZFB_PAY", "支付宝支付"),
|
||||||
|
ZFB_DQ("ZFB_DQ", "支付宝代扣"),
|
||||||
|
;
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2024/03/08/17:42
|
||||||
|
* @Description: 报考场次:统考unified,区域专场areaSpecial
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum SubOrderTypeEnum {
|
||||||
|
DEPOSIT("DEPOSIT", "押金订单"),
|
||||||
|
RENTCAR("RENTCAR", "租车订单"),
|
||||||
|
;
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
}
|
||||||
20
src/main/java/com/sczx/order/common/enums/YesOrNoEnum.java
Normal file
20
src/main/java/com/sczx/order/common/enums/YesOrNoEnum.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2024/03/08/17:42
|
||||||
|
* @Description: 报考场次:统考unified,区域专场areaSpecial
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum YesOrNoEnum {
|
||||||
|
YES(1, "是"),
|
||||||
|
NO(0, "否"),
|
||||||
|
;
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.sczx.order.controller;
|
package com.sczx.order.controller;
|
||||||
|
|
||||||
import com.sczx.order.common.Result;
|
import com.sczx.order.common.Result;
|
||||||
|
import com.sczx.order.dto.OrderMainDTO;
|
||||||
import com.sczx.order.dto.RentCarOrderReq;
|
import com.sczx.order.dto.RentCarOrderReq;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -18,10 +19,10 @@ import java.util.List;
|
|||||||
@RequestMapping("/clientOrder")
|
@RequestMapping("/clientOrder")
|
||||||
public class ClientOrderController {
|
public class ClientOrderController {
|
||||||
|
|
||||||
// @ApiOperation(value = "生成租车订单")
|
@ApiOperation(value = "生成租车订单")
|
||||||
// @PostMapping("/confirmRentalCarOrder")
|
@PostMapping("/confirmRentalCarOrder")
|
||||||
// public Result<List<RentBatteyRuleDTO>> confirmRentalCarOrder(@RequestBody RentCarOrderReq rentCarOrderReq){
|
public Result<OrderMainDTO> confirmRentalCarOrder(@RequestBody RentCarOrderReq rentCarOrderReq){
|
||||||
// return Result.ok(carRentalService.queryRentBatteyRuleByCarRuleId(carRuleId));
|
return Result.ok(null);
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
46
src/main/java/com/sczx/order/convert/OrderConvert.java
Normal file
46
src/main/java/com/sczx/order/convert/OrderConvert.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package com.sczx.order.convert;
|
||||||
|
|
||||||
|
import com.sczx.order.dto.OrderMainDTO;
|
||||||
|
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 org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface OrderConvert {
|
||||||
|
|
||||||
|
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
|
||||||
|
|
||||||
|
OrderMainDTO poToDto(OrderMainPO orderMainPO);
|
||||||
|
|
||||||
|
OrderMainPO dtoToPo(OrderMainDTO orderMainDTO);
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(target = "orderId", ignore = true),
|
||||||
|
@Mapping(target = "createTime", ignore = true),
|
||||||
|
@Mapping(target = "updateTime", ignore = true),
|
||||||
|
@Mapping(target = "delFlag", ignore = true),
|
||||||
|
@Mapping(source = "rentCarOrderReq.storeId", target = "storeId"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.operatorId", target = "operatorId"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.carModelId", target = "carModelId"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.rentCarRuleId", target = "rentCarRuleId"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.rentBatteyRuleId", target = "rentBatteyRuleId"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.isAutoDeduct", target = "isAutoDeduct"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.isDepositFree", target = "isDepositFree"),
|
||||||
|
@Mapping(source = "rentCarOrderReq.batteryType", target = "batteryType"),
|
||||||
|
@Mapping(source = "userInfoDTO.userName", target = "customerName"),
|
||||||
|
@Mapping(source = "userInfoDTO.mobileNumber", target = "customerPhone"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.rentalType", target = "rentalType"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.rentalDays", target = "rentalDays"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.rentalPrice", target = "rentalPrice"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.depositPrice", target = "depositPrice"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.overdueFee", target = "overdueFee"),
|
||||||
|
@Mapping(source = "rentCarRuleDTO.overdueType", target = "overdueType")
|
||||||
|
|
||||||
|
})
|
||||||
|
OrderMainPO subOrderToPo(RentCarOrderReq rentCarOrderReq, SimpleUserInfoDTO userInfoDTO, RentCarRuleDTO rentCarRuleDTO);
|
||||||
|
}
|
||||||
@ -2,6 +2,8 @@ package com.sczx.order.dto;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -30,12 +32,21 @@ public class OrderMainDTO {
|
|||||||
@ApiModelProperty("所属运营商ID")
|
@ApiModelProperty("所属运营商ID")
|
||||||
private Long operatorId;
|
private Long operatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("门店信息")
|
||||||
|
private CompanyStoreDTO companyStoreDTO;
|
||||||
|
|
||||||
@ApiModelProperty("所属门店ID")
|
@ApiModelProperty("所属门店ID")
|
||||||
private Long storeId;
|
private Long storeId;
|
||||||
|
|
||||||
@ApiModelProperty("车辆ID")
|
@ApiModelProperty("车辆ID")
|
||||||
private Long vehicleId;
|
private Long vehicleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车型ID")
|
||||||
|
private Long carModelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车型信息")
|
||||||
|
private CarModelSimpleDTO carModelSimpleDTO;
|
||||||
|
|
||||||
@ApiModelProperty("客户id")
|
@ApiModelProperty("客户id")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@ -45,6 +56,9 @@ public class OrderMainDTO {
|
|||||||
@ApiModelProperty("客户联系电话")
|
@ApiModelProperty("客户联系电话")
|
||||||
private String customerPhone;
|
private String customerPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("选择的电池类型")
|
||||||
|
private String batteryType;
|
||||||
|
|
||||||
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)")
|
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)")
|
||||||
private String rentalType;
|
private String rentalType;
|
||||||
|
|
||||||
@ -60,6 +74,9 @@ public class OrderMainDTO {
|
|||||||
@ApiModelProperty("逾期金额(元)")
|
@ApiModelProperty("逾期金额(元)")
|
||||||
private BigDecimal overdueFee;
|
private BigDecimal overdueFee;
|
||||||
|
|
||||||
|
@ApiModelProperty("逾期计费类型(按日计费/按月计费)")
|
||||||
|
private String overdueType;
|
||||||
|
|
||||||
@ApiModelProperty("是否开通免押")
|
@ApiModelProperty("是否开通免押")
|
||||||
private Boolean isDepositFree;
|
private Boolean isDepositFree;
|
||||||
|
|
||||||
@ -72,6 +89,12 @@ public class OrderMainDTO {
|
|||||||
@ApiModelProperty("开始计费时间")
|
@ApiModelProperty("开始计费时间")
|
||||||
private LocalDateTime startRentTime;
|
private LocalDateTime startRentTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("还车时间")
|
||||||
|
private LocalDateTime endRentTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("实际还车时间")
|
||||||
|
private LocalDateTime actEndRentTime;
|
||||||
|
|
||||||
@ApiModelProperty("逾期天数")
|
@ApiModelProperty("逾期天数")
|
||||||
private Integer overdueDays;
|
private Integer overdueDays;
|
||||||
|
|
||||||
|
|||||||
@ -23,9 +23,22 @@ public class RentCarOrderReq {
|
|||||||
@ApiModelProperty(value = "客户id")
|
@ApiModelProperty(value = "客户id")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车型ID")
|
||||||
|
private Long carModelId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "租车套餐id")
|
@ApiModelProperty(value = "租车套餐id")
|
||||||
private Long rentCarRuleId;
|
private Long rentCarRuleId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "租电套餐id")
|
@ApiModelProperty(value = "租电套餐id")
|
||||||
private Long rentBatteyRuleId;
|
private Long rentBatteyRuleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("选择的电池类型")
|
||||||
|
private String batteryType;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("是否开通免押")
|
||||||
|
private Boolean isDepositFree;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否开通代扣")
|
||||||
|
private Boolean isAutoDeduct;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,12 @@ public class SimpleUserInfoDTO {
|
|||||||
@ApiModelProperty(value = "用户姓名")
|
@ApiModelProperty(value = "用户姓名")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "手机号")
|
||||||
|
private String mobileNumber;
|
||||||
|
|
||||||
@ApiModelProperty(value = "角色id")
|
@ApiModelProperty(value = "角色id")
|
||||||
private Integer roleId;
|
private Integer roleId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "小程序类型")
|
||||||
|
private String miniPogramType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,9 @@ public class OrderMainPO implements Serializable {
|
|||||||
@ApiModelProperty("车辆ID")
|
@ApiModelProperty("车辆ID")
|
||||||
private Long vehicleId;
|
private Long vehicleId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车型ID")
|
||||||
|
private Long carModelId;
|
||||||
|
|
||||||
@ApiModelProperty("客户id")
|
@ApiModelProperty("客户id")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@ -55,6 +58,9 @@ public class OrderMainPO implements Serializable {
|
|||||||
@ApiModelProperty("客户联系电话")
|
@ApiModelProperty("客户联系电话")
|
||||||
private String customerPhone;
|
private String customerPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("选择的电池类型")
|
||||||
|
private String batteryType;
|
||||||
|
|
||||||
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)")
|
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)")
|
||||||
private String rentalType;
|
private String rentalType;
|
||||||
|
|
||||||
@ -70,6 +76,9 @@ public class OrderMainPO implements Serializable {
|
|||||||
@ApiModelProperty("逾期金额(元)")
|
@ApiModelProperty("逾期金额(元)")
|
||||||
private BigDecimal overdueFee;
|
private BigDecimal overdueFee;
|
||||||
|
|
||||||
|
@ApiModelProperty("逾期计费类型(按日计费/按月计费)")
|
||||||
|
private String overdueType;
|
||||||
|
|
||||||
@ApiModelProperty("是否开通免押")
|
@ApiModelProperty("是否开通免押")
|
||||||
private Boolean isDepositFree;
|
private Boolean isDepositFree;
|
||||||
|
|
||||||
@ -82,6 +91,12 @@ public class OrderMainPO implements Serializable {
|
|||||||
@ApiModelProperty("开始计费时间")
|
@ApiModelProperty("开始计费时间")
|
||||||
private LocalDateTime startRentTime;
|
private LocalDateTime startRentTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("还车时间")
|
||||||
|
private LocalDateTime endRentTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("实际还车时间")
|
||||||
|
private LocalDateTime actEndRentTime;
|
||||||
|
|
||||||
@ApiModelProperty("逾期天数")
|
@ApiModelProperty("逾期天数")
|
||||||
private Integer overdueDays;
|
private Integer overdueDays;
|
||||||
|
|
||||||
|
|||||||
14
src/main/java/com/sczx/order/service/OrderService.java
Normal file
14
src/main/java/com/sczx/order/service/OrderService.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.sczx.order.service;
|
||||||
|
|
||||||
|
import com.sczx.order.dto.OrderMainDTO;
|
||||||
|
import com.sczx.order.dto.RentCarOrderReq;
|
||||||
|
|
||||||
|
public interface OrderService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交租车订单
|
||||||
|
* @param rentCarOrderReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderMainDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq);
|
||||||
|
}
|
||||||
131
src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java
Normal file
131
src/main/java/com/sczx/order/service/impl/OrderServiceImpl.java
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
package com.sczx.order.service.impl;
|
||||||
|
|
||||||
|
import com.sczx.order.common.constant.RedisKeyConstants;
|
||||||
|
import com.sczx.order.common.enums.MiniPogramTypeEnum;
|
||||||
|
import com.sczx.order.common.enums.PaymentTypeEnum;
|
||||||
|
import com.sczx.order.common.enums.SubOrderTypeEnum;
|
||||||
|
import com.sczx.order.common.enums.YesOrNoEnum;
|
||||||
|
import com.sczx.order.convert.OrderConvert;
|
||||||
|
import com.sczx.order.dto.OrderMainDTO;
|
||||||
|
import com.sczx.order.dto.RentCarOrderReq;
|
||||||
|
import com.sczx.order.dto.SimpleUserInfoDTO;
|
||||||
|
import com.sczx.order.exception.InnerException;
|
||||||
|
import com.sczx.order.po.OrderMainPO;
|
||||||
|
import com.sczx.order.po.OrderSubPO;
|
||||||
|
import com.sczx.order.repository.OrderMainRepo;
|
||||||
|
import com.sczx.order.repository.OrderSubRepo;
|
||||||
|
import com.sczx.order.service.OrderService;
|
||||||
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
||||||
|
import com.sczx.order.thirdpart.integration.CarInteg;
|
||||||
|
import com.sczx.order.thirdpart.integration.StoreInteg;
|
||||||
|
import com.sczx.order.utils.JwtUtil;
|
||||||
|
import com.sczx.order.utils.OrderUtil;
|
||||||
|
import com.sczx.order.utils.RedisUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreInteg storeInteg;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarInteg carInteg;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderMainRepo orderMainRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderSubRepo orderSubRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtUtil jwtUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMainDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq) {
|
||||||
|
|
||||||
|
SimpleUserInfoDTO userInfoDTO = jwtUtil.getUserInfoFromToken();
|
||||||
|
|
||||||
|
String redisLockKey = RedisKeyConstants.ORDER_SUB_KEY + userInfoDTO.getUserId();
|
||||||
|
if(redisUtil.getRedisLock(redisLockKey, "租车下单")) {
|
||||||
|
try{
|
||||||
|
//获取门店信息
|
||||||
|
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(rentCarOrderReq.getStoreId().toString()));
|
||||||
|
|
||||||
|
CarModelSimpleDTO carModelSimpleDTO = carInteg.getCarModelByModelId(rentCarOrderReq.getCarModelId());
|
||||||
|
|
||||||
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(rentCarOrderReq.getRentCarRuleId());
|
||||||
|
|
||||||
|
//生成订单主表
|
||||||
|
OrderMainPO orderMainPO = OrderConvert.INSTANCE.subOrderToPo(rentCarOrderReq, userInfoDTO, rentCarRuleDTO);
|
||||||
|
orderMainPO.setOrderNo(OrderUtil.generateOrderNo());
|
||||||
|
orderMainRepo.save(orderMainPO);
|
||||||
|
|
||||||
|
//生成子表订单
|
||||||
|
String paymentType;
|
||||||
|
if(rentCarOrderReq.getIsAutoDeduct()){
|
||||||
|
if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniPogramType(), MiniPogramTypeEnum.WX_MINI_PROGRAM.getCode())){
|
||||||
|
paymentType = PaymentTypeEnum.WX_DQ.getCode();
|
||||||
|
}else {
|
||||||
|
paymentType = PaymentTypeEnum.ZFB_DQ.getCode();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniPogramType(), MiniPogramTypeEnum.WX_MINI_PROGRAM.getCode())){
|
||||||
|
paymentType = PaymentTypeEnum.WX_PAY.getCode();
|
||||||
|
}else {
|
||||||
|
paymentType = PaymentTypeEnum.ZFB_PAY.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<OrderSubPO> orderSubPOList = new ArrayList<>();
|
||||||
|
//如果未开通免押则要生成押金订单
|
||||||
|
if(!rentCarOrderReq.getIsDepositFree()){
|
||||||
|
OrderSubPO depositOrder = new OrderSubPO();
|
||||||
|
depositOrder.setOrderId(orderMainPO.getOrderId());
|
||||||
|
depositOrder.setSuborderType(SubOrderTypeEnum.DEPOSIT.getCode());
|
||||||
|
depositOrder.setAmount(orderMainPO.getDepositPrice());
|
||||||
|
depositOrder.setCreatedAt(LocalDateTime.now());
|
||||||
|
depositOrder.setPaymentMethod(paymentType);
|
||||||
|
orderSubPOList.add(depositOrder);
|
||||||
|
}
|
||||||
|
OrderSubPO rentOrder = new OrderSubPO();
|
||||||
|
rentOrder.setOrderId(orderMainPO.getOrderId());
|
||||||
|
rentOrder.setSuborderType(SubOrderTypeEnum.RENTCAR.getCode());
|
||||||
|
rentOrder.setAmount(orderMainPO.getRentalPrice());
|
||||||
|
rentOrder.setCreatedAt(LocalDateTime.now());
|
||||||
|
rentOrder.setPaymentMethod(paymentType);
|
||||||
|
orderSubPOList.add(rentOrder);
|
||||||
|
orderSubRepo.saveBatch(orderSubPOList);
|
||||||
|
// TODO 发起支付
|
||||||
|
|
||||||
|
//返回订单信息
|
||||||
|
OrderMainDTO orderMainDTO = OrderConvert.INSTANCE.poToDto(orderMainPO);
|
||||||
|
orderMainDTO.setCompanyStoreDTO(companyStoreDTO);
|
||||||
|
orderMainDTO.setCarModelSimpleDTO(carModelSimpleDTO);
|
||||||
|
|
||||||
|
return orderMainDTO;
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.warn("下单失败", e);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
redisUtil.deleteRedisLock(redisLockKey);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("下单失败,锁已被占用");
|
||||||
|
throw new InnerException("服务器正在处理,请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.sczx.order.thirdpart.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "车型简单对象")
|
||||||
|
public class CarModelSimpleDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("车型ID")
|
||||||
|
private Long carModelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("门店id")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("门店编号")
|
||||||
|
private String storeNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("车型名称")
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
@ApiModelProperty("品牌名称")
|
||||||
|
private String brandName;
|
||||||
|
|
||||||
|
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售),用逗号分隔")
|
||||||
|
private String batteryTypes;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否支持免押(0不支持 1支持)")
|
||||||
|
private String depositFree;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否支持代扣(0不支持 1支持)")
|
||||||
|
private String autoDeduct;
|
||||||
|
|
||||||
|
@ApiModelProperty("电池类型")
|
||||||
|
private String batteryType;
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
package com.sczx.order.thirdpart.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "CompanyStoreDTO对象", description = "门店信息")
|
||||||
|
public class CompanyStoreDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("主键id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("门店名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系人")
|
||||||
|
private String contactPerson;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号码")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系人2")
|
||||||
|
private String contactPerson2;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号码2")
|
||||||
|
private String phone2;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("详细地址")
|
||||||
|
private String detailedAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("门店logo")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
@ApiModelProperty("纬度")
|
||||||
|
private Double latitude;
|
||||||
|
|
||||||
|
@ApiModelProperty("经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
@ApiModelProperty("标签 1.可租车 2.可换电 3.二手车,多个用,号隔开,例如1,2,3")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@ApiModelProperty("运营公司id")
|
||||||
|
private Integer operatingCompanyId;
|
||||||
|
|
||||||
|
@ApiModelProperty("运营性质 1.直营 0.合作")
|
||||||
|
private Boolean operatingNature;
|
||||||
|
|
||||||
|
@ApiModelProperty("简介")
|
||||||
|
private String introduction;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("门店编号")
|
||||||
|
private String storeNumber;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.sczx.order.thirdpart.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@ApiModel(value = "租车计费规则对象")
|
||||||
|
@Data
|
||||||
|
public class RentCarRuleDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("规则ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐名称")
|
||||||
|
private String ruleName;
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐编码")
|
||||||
|
private String ruleCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售)")
|
||||||
|
private String rentalType;
|
||||||
|
|
||||||
|
@ApiModelProperty("租赁天数(当类型为\"按天数\"时使用)")
|
||||||
|
private Integer rentalDays;
|
||||||
|
|
||||||
|
@ApiModelProperty("租车价格(元)")
|
||||||
|
private BigDecimal rentalPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("押金价格(元)")
|
||||||
|
private BigDecimal depositPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("逾期金额(元)")
|
||||||
|
private BigDecimal overdueFee;
|
||||||
|
|
||||||
|
@ApiModelProperty("逾期计费类型(按日计费/按月计费)")
|
||||||
|
private String overdueType;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否支持免押(0不支持 1支持)")
|
||||||
|
private String depositFree;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否支持代扣(0不支持 1支持)")
|
||||||
|
private String autoDeduct;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属运营商")
|
||||||
|
private Integer operatingCompanyId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(0正常 1停用)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否默认套餐(0否 1是)")
|
||||||
|
private String isDefault;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
}
|
||||||
20
src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java
Normal file
20
src/main/java/com/sczx/order/thirdpart/facade/CarFacade.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.thirdpart.facade;
|
||||||
|
|
||||||
|
import com.sczx.order.common.Result;
|
||||||
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@FeignClient(name = "sczx-car")
|
||||||
|
public interface CarFacade {
|
||||||
|
|
||||||
|
@RequestMapping("/carModel/getCarModelByModelId")
|
||||||
|
Result<CarModelSimpleDTO> getCarModelByModelId(@RequestParam(name = "modelId") Long modelId);
|
||||||
|
|
||||||
|
@GetMapping("/carRule/getRentCarRuleByCarRuleId")
|
||||||
|
Result<RentCarRuleDTO> getRentCarRuleByCarRuleId(@RequestParam(name = "carRuleId") Long carRuleId);
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.sczx.order.thirdpart.facade;
|
||||||
|
|
||||||
|
import com.sczx.order.common.Result;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@FeignClient(name = "sczx-store")
|
||||||
|
public interface StoreFacade {
|
||||||
|
|
||||||
|
@RequestMapping("/pub/getStoreById")
|
||||||
|
Result<CompanyStoreDTO> getStoreById(@RequestParam(name = "storeId") Integer storeId);
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package com.sczx.order.thirdpart.integration;
|
||||||
|
|
||||||
|
import com.sczx.order.common.Result;
|
||||||
|
import com.sczx.order.exception.InnerException;
|
||||||
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
||||||
|
import com.sczx.order.thirdpart.facade.CarFacade;
|
||||||
|
import com.sczx.order.thirdpart.facade.StoreFacade;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CarInteg {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarFacade carFacade;
|
||||||
|
|
||||||
|
public CarModelSimpleDTO getCarModelByModelId(Long modelId){
|
||||||
|
try{
|
||||||
|
Result<CarModelSimpleDTO> result = carFacade.getCarModelByModelId(modelId);
|
||||||
|
if(result.isSuccess()){
|
||||||
|
return result.getData();
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("根据车型id查询车型信息失败",e);
|
||||||
|
throw new InnerException("根据车型id查询车型信息失败");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RentCarRuleDTO getRentCarRuleByCarRuleId(Long carRuleId){
|
||||||
|
try{
|
||||||
|
Result<RentCarRuleDTO> result = carFacade.getRentCarRuleByCarRuleId(carRuleId);
|
||||||
|
if(result.isSuccess()){
|
||||||
|
return result.getData();
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("根据租车套餐id获取套餐信息失败",e);
|
||||||
|
throw new InnerException("根据租车套餐id获取套餐信息失败");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.sczx.order.thirdpart.integration;
|
||||||
|
|
||||||
|
import com.sczx.order.common.Result;
|
||||||
|
import com.sczx.order.exception.InnerException;
|
||||||
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
|
import com.sczx.order.thirdpart.facade.StoreFacade;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class StoreInteg {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreFacade storeFacade;
|
||||||
|
|
||||||
|
public CompanyStoreDTO getStoreById(Integer storeId){
|
||||||
|
try{
|
||||||
|
Result<CompanyStoreDTO> result = storeFacade.getStoreById(storeId);
|
||||||
|
if(result.isSuccess()){
|
||||||
|
return result.getData();
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("根据门店id获取门店信息失败",e);
|
||||||
|
throw new InnerException("根据门店id获取门店信息失败");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,8 +9,11 @@ import io.jsonwebtoken.security.Keys;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -85,4 +88,33 @@ public class JwtUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HttpServletRequest getCurrentRequest() {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
return attributes != null ? attributes.getRequest() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前请求的Authorization头内容
|
||||||
|
* @return Authorization头的值,如果不存在则返回null
|
||||||
|
*/
|
||||||
|
public String getAuthorizationHeader() {
|
||||||
|
HttpServletRequest request = getCurrentRequest();
|
||||||
|
return request != null ? request.getHeader("Authorization") : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从token中获取用户信息
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
public SimpleUserInfoDTO getUserInfoFromToken() {
|
||||||
|
String authHeader = getAuthorizationHeader();
|
||||||
|
if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||||
|
String token = authHeader.substring(7);
|
||||||
|
// 进行token验证等操作
|
||||||
|
return getClaim(token, "userInfo", SimpleUserInfoDTO.class);
|
||||||
|
}else {
|
||||||
|
throw new RuntimeException("token不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main/java/com/sczx/order/utils/OrderUtil.java
Normal file
19
src/main/java/com/sczx/order/utils/OrderUtil.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.sczx.order.utils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class OrderUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成订单号的方法
|
||||||
|
* @return 唯一订单号字符串
|
||||||
|
*/
|
||||||
|
public static String generateOrderNo() {
|
||||||
|
// 使用时间戳+UUID后缀确保唯一性
|
||||||
|
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||||
|
String uuidSuffix = UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase();
|
||||||
|
return "OC" + timestamp + uuidSuffix; // OC代表Order Car
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user