预计还车时间修改
This commit is contained in:
@ -103,17 +103,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
// orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PAY.getCode());
|
||||
orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PICK.getCode());
|
||||
orderMainPO.setFirstOrderTime(LocalDateTime.now());
|
||||
|
||||
//设置预计还车时间
|
||||
if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.HOUR_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
orderMainPO.setEndRentTime(LocalDateTime.now().plusHours(1));
|
||||
}else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAILY_RENTAL.getCode(), rentCarRuleDTO.getRentalType())){
|
||||
orderMainPO.setEndRentTime(LocalDateTime.now().plusDays(1));
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAYS_RENTAL.getCode(), rentCarRuleDTO.getRentalType())){
|
||||
orderMainPO.setEndRentTime(LocalDateTime.now().plusDays(rentCarRuleDTO.getRentalDays()));
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.RENT_INSTEAD_SELL.getCode(), rentCarRuleDTO.getRentalType())){
|
||||
//以租代售默认期限为30天
|
||||
orderMainPO.setEndRentTime(LocalDateTime.now().plusDays(30));
|
||||
}
|
||||
LocalDateTime endRentTime = OrderUtil.getEndRentTime(orderMainPO.getFirstOrderTime(),rentCarRuleDTO.getRentalDays(), rentCarRuleDTO.getRentalType());
|
||||
orderMainPO.setEndRentTime(endRentTime);
|
||||
|
||||
|
||||
//生成子表订单
|
||||
String paymentType;
|
||||
@ -259,17 +253,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
LocalDateTime nowTime = LocalDateTime.now();
|
||||
LocalDateTime oldEndRentTime = orderMainPO.getEndRentTime().isAfter(nowTime) ? orderMainPO.getEndRentTime() : nowTime;
|
||||
LocalDateTime newEndRentTime = oldEndRentTime;
|
||||
|
||||
//刷新预计还车时间
|
||||
if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.HOUR_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
newEndRentTime = oldEndRentTime.plusHours(1);
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAILY_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
newEndRentTime = oldEndRentTime.plusDays(1);
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAYS_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
newEndRentTime = oldEndRentTime.plusDays(orderMainPO.getRentalDays());
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.RENT_INSTEAD_SELL.getCode(), orderMainPO.getRentalType())){
|
||||
newEndRentTime = oldEndRentTime.plusDays(30);
|
||||
}
|
||||
LocalDateTime newEndRentTime = OrderUtil.getEndRentTime(oldEndRentTime, orderMainPO.getRentalDays(), orderMainPO.getRentalType());
|
||||
|
||||
|
||||
//更新订单状态及信息
|
||||
LambdaUpdateWrapper<OrderMainPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(OrderMainPO::getRenewalTimes, orderMainPO.getRenewalTimes()+1);
|
||||
@ -555,13 +543,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderSubRepo.update(updateSubWrapper);
|
||||
//变更订单状态,记录租车时间
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
LocalDateTime endRentTime = null;
|
||||
|
||||
//设置预计还车时间
|
||||
if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAILY_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
endRentTime = currentTime.plusDays(1);
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAYS_RENTAL.getCode(), orderMainPO.getRentalType())){
|
||||
endRentTime = currentTime.plusDays(orderMainPO.getRentalDays());
|
||||
}
|
||||
LocalDateTime endRentTime = OrderUtil.getEndRentTime(currentTime,orderMainPO.getRentalDays(), orderMainPO.getRentalType());
|
||||
|
||||
LambdaUpdateWrapper<OrderMainPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(OrderMainPO::getOrderStatus, OrderStatusEnum.RENT_ING.getCode());
|
||||
@ -666,4 +650,5 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
return rentCarOrderAmount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.sczx.order.utils;
|
||||
|
||||
import com.sczx.order.common.enums.RentCarTypeEnum;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -100,4 +103,26 @@ public class OrderUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算订单预计还车时间
|
||||
* @param rentalDays 租期天数
|
||||
* @param rentalType 租期类型
|
||||
* @return 预计还车时间
|
||||
*/
|
||||
public static LocalDateTime getEndRentTime(LocalDateTime origTime,Integer rentalDays, String rentalType) {
|
||||
LocalDateTime endRentTime = null;
|
||||
//设置预计还车时间
|
||||
if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.HOUR_RENTAL.getCode(), rentalType)){
|
||||
endRentTime = origTime.plusHours(1);
|
||||
}else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAILY_RENTAL.getCode(), rentalType)){
|
||||
endRentTime = origTime.plusDays(1);
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.DAYS_RENTAL.getCode(), rentalType)){
|
||||
endRentTime = origTime.plusDays(rentalDays);
|
||||
} else if(StringUtils.equalsIgnoreCase(RentCarTypeEnum.RENT_INSTEAD_SELL.getCode(), rentalType)){
|
||||
//以租代售默认期限为30天
|
||||
endRentTime = origTime.plusDays(30);
|
||||
}
|
||||
return endRentTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user