计算续租金额
This commit is contained in:
@ -131,6 +131,9 @@ public class OrderDetailDTO {
|
||||
@ApiModelProperty("逾期金额")
|
||||
private BigDecimal overdueAmount;
|
||||
|
||||
@ApiModelProperty("续租金额")
|
||||
private BigDecimal rerentAmount;
|
||||
|
||||
@ApiModelProperty("续租次数")
|
||||
private Integer renewalTimes;
|
||||
|
||||
|
||||
@ -264,20 +264,22 @@ public class OrderServiceImpl implements OrderService {
|
||||
// BigDecimal rentCarOrderAmount = getRentCarAmount(orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
||||
|
||||
//计算续租金额
|
||||
BigDecimal rentCarOrderAmount = new BigDecimal(0);
|
||||
if(RentCarTypeEnum.HOUR_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
Integer overdueHours = OrderUtil.getOrderOverdueHours(orderMainPO.getEndRentTime());
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(overdueHours+1)));
|
||||
} else if(RentCarTypeEnum.DAILY_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+1)));
|
||||
} else if(RentCarTypeEnum.DAYS_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+orderMainPO.getRentalDays())));
|
||||
} else {
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+30)));
|
||||
}
|
||||
// BigDecimal rentCarOrderAmount = new BigDecimal(0);
|
||||
// if(RentCarTypeEnum.HOUR_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
// Integer overdueHours = OrderUtil.getOrderOverdueHours(orderMainPO.getEndRentTime());
|
||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(overdueHours+1)));
|
||||
// } else if(RentCarTypeEnum.DAILY_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+1)));
|
||||
// } else if(RentCarTypeEnum.DAYS_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+orderMainPO.getRentalDays())));
|
||||
// } else {
|
||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+30)));
|
||||
// }
|
||||
|
||||
BigDecimal rentCarOrderAmount = getReRentCarAmount(orderMainPO.getEndRentTime(), orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
||||
|
||||
//生成租车子订单
|
||||
OrderSubPO rentOrder = new OrderSubPO();
|
||||
@ -615,6 +617,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderDetailDTO.setLastPayOrderNo(orderSubPOList2.get(0).getPaymentId());
|
||||
orderDetailDTO.setPayOrderDTOList(OrderSubConvert.INSTANCE.posToPayOrderDtos(orderSubPOList2));
|
||||
}
|
||||
//计算续租金额
|
||||
BigDecimal reRentCarAmount = getReRentCarAmount(orderMainPO.getEndRentTime(), orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
||||
orderDetailDTO.setRerentAmount(reRentCarAmount);
|
||||
|
||||
if(OrderStatusEnum.RENT_ING.getCode().equalsIgnoreCase(orderMainPO.getOrderStatus())){
|
||||
//如果是租车中,需要判断是否逾期了
|
||||
@ -885,5 +890,31 @@ public class OrderServiceImpl implements OrderService {
|
||||
return rentCarOrderAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取续租订单金额
|
||||
* @param endRentTime
|
||||
* @param rentalType
|
||||
* @param rentalPrice
|
||||
* @param ruleRentalDays
|
||||
* @return
|
||||
*/
|
||||
private static BigDecimal getReRentCarAmount(LocalDateTime endRentTime,String rentalType, BigDecimal rentalPrice, Integer ruleRentalDays) {
|
||||
//计算续租金额
|
||||
BigDecimal rentCarOrderAmount = new BigDecimal(0);
|
||||
if(RentCarTypeEnum.HOUR_RENTAL.getCode().equalsIgnoreCase(rentalType)){
|
||||
Integer overdueHours = OrderUtil.getOrderOverdueHours(endRentTime);
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(rentalPrice.multiply(new BigDecimal(overdueHours+1)));
|
||||
} else if(RentCarTypeEnum.DAILY_RENTAL.getCode().equalsIgnoreCase(rentalType)){
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(endRentTime);
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(rentalPrice.multiply(new BigDecimal(rentalDays+1)));
|
||||
} else if(RentCarTypeEnum.DAYS_RENTAL.getCode().equalsIgnoreCase(rentalType)){
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(endRentTime);
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(rentalPrice.multiply(new BigDecimal(rentalDays+ruleRentalDays)));
|
||||
} else {
|
||||
Integer rentalDays = OrderUtil.getOrderExpectedDays(endRentTime);
|
||||
rentCarOrderAmount = rentCarOrderAmount.add(rentalPrice.multiply(new BigDecimal(rentalDays+30)));
|
||||
}
|
||||
return rentCarOrderAmount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user