修改生成子订单的逻辑
This commit is contained in:
@ -13,6 +13,7 @@ import lombok.Getter;
|
|||||||
public enum SubOrderTypeEnum {
|
public enum SubOrderTypeEnum {
|
||||||
DEPOSIT("DEPOSIT", "押金订单"),
|
DEPOSIT("DEPOSIT", "押金订单"),
|
||||||
RENTCAR("RENTCAR", "租车订单"),
|
RENTCAR("RENTCAR", "租车订单"),
|
||||||
|
RENTBATTEY("RENTBATTEY", "租电订单"),
|
||||||
;
|
;
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,7 @@ import com.sczx.order.po.OrderSubPO;
|
|||||||
import com.sczx.order.repository.OrderMainRepo;
|
import com.sczx.order.repository.OrderMainRepo;
|
||||||
import com.sczx.order.repository.OrderSubRepo;
|
import com.sczx.order.repository.OrderSubRepo;
|
||||||
import com.sczx.order.service.OrderService;
|
import com.sczx.order.service.OrderService;
|
||||||
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
import com.sczx.order.thirdpart.dto.*;
|
||||||
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
|
||||||
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
|
||||||
import com.sczx.order.thirdpart.dto.UnifiedPaymentInfoDTO;
|
|
||||||
import com.sczx.order.thirdpart.integration.CarInteg;
|
import com.sczx.order.thirdpart.integration.CarInteg;
|
||||||
import com.sczx.order.thirdpart.integration.StoreInteg;
|
import com.sczx.order.thirdpart.integration.StoreInteg;
|
||||||
import com.sczx.order.utils.JwtUtil;
|
import com.sczx.order.utils.JwtUtil;
|
||||||
@ -71,6 +68,11 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
|
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(rentCarOrderReq.getRentCarRuleId());
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(rentCarOrderReq.getRentCarRuleId());
|
||||||
|
|
||||||
|
RentBatteyRuleDTO rentBatteyRuleDTO = null;
|
||||||
|
if(rentCarOrderReq.getRentBatteyRuleId()!=null){
|
||||||
|
rentBatteyRuleDTO = carInteg.getRentBatteyRuleByBatteyRuleId(rentCarOrderReq.getRentBatteyRuleId());
|
||||||
|
}
|
||||||
|
|
||||||
//生成订单主表
|
//生成订单主表
|
||||||
OrderMainPO orderMainPO = OrderConvert.INSTANCE.subOrderToPo(rentCarOrderReq, userInfoDTO, rentCarRuleDTO);
|
OrderMainPO orderMainPO = OrderConvert.INSTANCE.subOrderToPo(rentCarOrderReq, userInfoDTO, rentCarRuleDTO);
|
||||||
orderMainPO.setOrderNo(OrderUtil.generateOrderNo());
|
orderMainPO.setOrderNo(OrderUtil.generateOrderNo());
|
||||||
@ -95,11 +97,11 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<OrderSubPO> orderSubPOList = new ArrayList<>();
|
List<OrderSubPO> orderSubPOList = new ArrayList<>();
|
||||||
String subOrderNo = OrderUtil.generateSubOrderNo();
|
|
||||||
//如果未开通免押则要生成押金订单
|
//如果未开通免押则要生成押金订单
|
||||||
if(!rentCarOrderReq.getIsDepositFree()){
|
if(!rentCarOrderReq.getIsDepositFree()){
|
||||||
OrderSubPO depositOrder = new OrderSubPO();
|
OrderSubPO depositOrder = new OrderSubPO();
|
||||||
depositOrder.setSuborderNo(subOrderNo);
|
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.YJ_PREFIX));
|
||||||
depositOrder.setOrderId(orderMainPO.getOrderId());
|
depositOrder.setOrderId(orderMainPO.getOrderId());
|
||||||
depositOrder.setSuborderType(SubOrderTypeEnum.DEPOSIT.getCode());
|
depositOrder.setSuborderType(SubOrderTypeEnum.DEPOSIT.getCode());
|
||||||
depositOrder.setAmount(orderMainPO.getDepositPrice());
|
depositOrder.setAmount(orderMainPO.getDepositPrice());
|
||||||
@ -107,8 +109,21 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
depositOrder.setPaymentMethod(paymentType);
|
depositOrder.setPaymentMethod(paymentType);
|
||||||
orderSubPOList.add(depositOrder);
|
orderSubPOList.add(depositOrder);
|
||||||
}
|
}
|
||||||
|
//如果选择了租电套餐,则还需要生成租电子订单
|
||||||
|
if(rentBatteyRuleDTO!=null){
|
||||||
|
rentBatteyRuleDTO = carInteg.getRentBatteyRuleByBatteyRuleId(rentCarOrderReq.getRentBatteyRuleId());
|
||||||
|
OrderSubPO depositOrder = new OrderSubPO();
|
||||||
|
depositOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZD_PREFIX));
|
||||||
|
depositOrder.setOrderId(orderMainPO.getOrderId());
|
||||||
|
depositOrder.setSuborderType(SubOrderTypeEnum.RENTBATTEY.getCode());
|
||||||
|
depositOrder.setAmount(rentBatteyRuleDTO.getRentPrice());
|
||||||
|
depositOrder.setCreatedAt(LocalDateTime.now());
|
||||||
|
depositOrder.setPaymentMethod(paymentType);
|
||||||
|
orderSubPOList.add(depositOrder);
|
||||||
|
}
|
||||||
|
//生成租车订单
|
||||||
OrderSubPO rentOrder = new OrderSubPO();
|
OrderSubPO rentOrder = new OrderSubPO();
|
||||||
rentOrder.setSuborderNo(subOrderNo);
|
rentOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.ZC_PREFIX));
|
||||||
rentOrder.setOrderId(orderMainPO.getOrderId());
|
rentOrder.setOrderId(orderMainPO.getOrderId());
|
||||||
rentOrder.setSuborderType(SubOrderTypeEnum.RENTCAR.getCode());
|
rentOrder.setSuborderType(SubOrderTypeEnum.RENTCAR.getCode());
|
||||||
rentOrder.setAmount(orderMainPO.getRentalPrice());
|
rentOrder.setAmount(orderMainPO.getRentalPrice());
|
||||||
|
|||||||
@ -0,0 +1,91 @@
|
|||||||
|
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 RentBatteyRuleDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("租电套餐id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("商品标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty("商品描述")
|
||||||
|
private String detail;
|
||||||
|
|
||||||
|
@ApiModelProperty("图标")
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压")
|
||||||
|
private String voltage;
|
||||||
|
|
||||||
|
@ApiModelProperty("电容")
|
||||||
|
private String ah;
|
||||||
|
|
||||||
|
@ApiModelProperty("最大里程")
|
||||||
|
private Integer maxMileage;
|
||||||
|
|
||||||
|
@ApiModelProperty("最小里程 默认0")
|
||||||
|
private Integer minMileage;
|
||||||
|
|
||||||
|
@ApiModelProperty("押金 ")
|
||||||
|
private BigDecimal depositPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("租金")
|
||||||
|
private BigDecimal rentPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("计时方式")
|
||||||
|
private Integer durationType;
|
||||||
|
|
||||||
|
@ApiModelProperty("租赁时长")
|
||||||
|
private Integer duration;
|
||||||
|
|
||||||
|
@ApiModelProperty("盗抢险")
|
||||||
|
private BigDecimal insurancePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否强制投保 默认0 false")
|
||||||
|
private Boolean compulsoryInsurance;
|
||||||
|
|
||||||
|
@ApiModelProperty("保险有效时长 默认12个月")
|
||||||
|
private Integer insuranceDuration;
|
||||||
|
|
||||||
|
@ApiModelProperty("换电次数")
|
||||||
|
private Integer changeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("1、有限次数 2无限次数")
|
||||||
|
private Integer changeType;
|
||||||
|
|
||||||
|
private Boolean isDelete;
|
||||||
|
|
||||||
|
private Integer cityId;
|
||||||
|
|
||||||
|
private Integer operatorId;
|
||||||
|
|
||||||
|
private Integer provinceId;
|
||||||
|
|
||||||
|
@ApiModelProperty("电池类型")
|
||||||
|
private Integer categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty("电池类型名称")
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐类型 换电/租电")
|
||||||
|
private Integer mealType;
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐排序规则")
|
||||||
|
private Integer mealSort;
|
||||||
|
|
||||||
|
private Boolean isJoinInvite;
|
||||||
|
|
||||||
|
@ApiModelProperty("套餐渠道租车默认 id号待定")
|
||||||
|
private Integer mealChannel;
|
||||||
|
|
||||||
|
@ApiModelProperty("购买限制类型")
|
||||||
|
private Integer buyLimitType;
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@ package com.sczx.order.thirdpart.facade;
|
|||||||
|
|
||||||
import com.sczx.order.common.Result;
|
import com.sczx.order.common.Result;
|
||||||
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
import com.sczx.order.thirdpart.dto.RentBatteyRuleDTO;
|
||||||
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -17,4 +17,7 @@ public interface CarFacade {
|
|||||||
|
|
||||||
@GetMapping("/carRule/getRentCarRuleByCarRuleId")
|
@GetMapping("/carRule/getRentCarRuleByCarRuleId")
|
||||||
Result<RentCarRuleDTO> getRentCarRuleByCarRuleId(@RequestParam(name = "carRuleId") Long carRuleId);
|
Result<RentCarRuleDTO> getRentCarRuleByCarRuleId(@RequestParam(name = "carRuleId") Long carRuleId);
|
||||||
|
|
||||||
|
@GetMapping("/batteyRule/getRentBatteyRuleByBatteyRuleId")
|
||||||
|
Result<RentBatteyRuleDTO> getRentBatteyRuleByBatteyRuleId(@RequestParam(name = "batteyRuleId") Long batteyRuleId);
|
||||||
}
|
}
|
||||||
@ -3,15 +3,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.CarModelSimpleDTO;
|
import com.sczx.order.thirdpart.dto.CarModelSimpleDTO;
|
||||||
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
import com.sczx.order.thirdpart.dto.RentBatteyRuleDTO;
|
||||||
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
import com.sczx.order.thirdpart.dto.RentCarRuleDTO;
|
||||||
import com.sczx.order.thirdpart.facade.CarFacade;
|
import com.sczx.order.thirdpart.facade.CarFacade;
|
||||||
import com.sczx.order.thirdpart.facade.StoreFacade;
|
|
||||||
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.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -47,4 +44,17 @@ public class CarInteg {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RentBatteyRuleDTO getRentBatteyRuleByBatteyRuleId(Long batteyRuleId){
|
||||||
|
try{
|
||||||
|
Result<RentBatteyRuleDTO> result = carFacade.getRentBatteyRuleByBatteyRuleId(batteyRuleId);
|
||||||
|
if(result.isSuccess()){
|
||||||
|
return result.getData();
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("根据租电套餐id获取套餐信息失败",e);
|
||||||
|
throw new InnerException("根据租电套餐id获取套餐信息失败");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,16 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class OrderUtil {
|
public class OrderUtil {
|
||||||
|
|
||||||
|
public static final String ORDER_PREFIX = "OC";
|
||||||
|
|
||||||
|
public static final String YJ_PREFIX = "YJ";
|
||||||
|
|
||||||
|
public static final String ZD_PREFIX = "ZD";
|
||||||
|
|
||||||
|
public static final String ZC_PREFIX = "ZC";
|
||||||
|
|
||||||
|
public static final String YQ_PREFIX = "YQ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成订单号的方法
|
* 生成订单号的方法
|
||||||
* @return 唯一订单号字符串
|
* @return 唯一订单号字符串
|
||||||
@ -21,10 +31,10 @@ public class OrderUtil {
|
|||||||
* 生成子订单号用于支付
|
* 生成子订单号用于支付
|
||||||
* @return 唯一订单号字符串
|
* @return 唯一订单号字符串
|
||||||
*/
|
*/
|
||||||
public static String generateSubOrderNo() {
|
public static String generateSubOrderNo(String prefix) {
|
||||||
// 使用时间戳+UUID后缀确保唯一性
|
// 使用时间戳+UUID后缀确保唯一性
|
||||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||||
String uuidSuffix = UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase();
|
String uuidSuffix = UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase();
|
||||||
return "SUB" + timestamp + uuidSuffix; // sub代表子订单号
|
return prefix + timestamp + uuidSuffix; // sub代表子订单号
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user