Commit 954a17b7 authored by libin's avatar libin

租车日历价格

parent ec0d3d45
......@@ -196,28 +196,13 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @return
*/
public List<VehicleModelCalendarPriceDTO> findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
LocalDate startLocalDate = DateUtils.dateToLocalDate(startDate);
LocalDate endLocalDate = DateUtils.dateToLocalDate(endDate);
Integer days = getIncludeDays(startDate.getTime(), endDate.getTime());
boolean isSelect = false;
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPrice = findVehicleModelCalendarPrice(startDate,endDate, vehicleModelId, userId);
for (int i = 0, y = 0; i < vehicleModelCalendarPrice.size(); i++) {
VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO = vehicleModelCalendarPrice.get(i);
LocalDate current_date = DateUtils.dateToLocalDate(vehicleModelCalendarPriceDTO.getDate());
if (y == 0) {
isSelect = (current_date.isAfter(startLocalDate) && current_date.isBefore(endLocalDate)) || current_date.isEqual(startLocalDate) || current_date.isEqual(endLocalDate);
}
if (isSelect) {
if (y < days) {
vehicleModelCalendarPriceDTO.setIsSelect(isSelect ? true : false);
y++;
}
}
}
vehicleModelCalendarPrice = wrapVehicleModelCalendarPrice(startDate, endDate,vehicleModelCalendarPrice);
return vehicleModelCalendarPrice.stream().filter(x->Objects.nonNull(x.getIsSelect())).collect(Collectors.toList());
}
/**
* 日历展示车型价格
*
......@@ -228,30 +213,14 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @return
*/
public List<VehicleModelCalendarPriceDTO> listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
LocalDate startLocalDate = DateUtils.dateToLocalDate(startDate);
LocalDate endLocalDate = DateUtils.dateToLocalDate(endDate);
boolean isSelect = false;
//处理后延伸的开始时间
AtomicReference<Date> startReference = new AtomicReference<>(startDate);
//处理后延伸的结束时间
AtomicReference<Date> endReference = new AtomicReference<>(endDate);
transformStartDateAndEndDate(startReference, endReference);
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPrice = findVehicleModelCalendarPrice(startReference.get(), endReference.get(), vehicleModelId, userId);
Integer days = getIncludeDays(startDate.getTime(), endDate.getTime());
for (int i = 0, y = 0; i < vehicleModelCalendarPrice.size(); i++) {
VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO = vehicleModelCalendarPrice.get(i);
LocalDate current_date = DateUtils.dateToLocalDate(vehicleModelCalendarPriceDTO.getDate());
if (y == 0) {
isSelect = (current_date.isAfter(startLocalDate) && current_date.isBefore(endLocalDate)) || current_date.isEqual(startLocalDate) || current_date.isEqual(endLocalDate);
}
if (isSelect) {
if (y < days) {
vehicleModelCalendarPriceDTO.setIsSelect(isSelect ? true : false);
y++;
}
}
}
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPrice = findVehicleModelCalendarPrice(startReference.get(), endReference.get(), vehicleModelId, userId);
vehicleModelCalendarPrice = wrapVehicleModelCalendarPrice(startDate, endDate, vehicleModelCalendarPrice);
return vehicleModelCalendarPrice;
}
......@@ -262,7 +231,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @param endLong
* @return
*/
public Integer getIncludeDays(Long startLong, Long endLong) {
private Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24;
......@@ -284,6 +253,33 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return bookDays;
}
/**
* 价格24小时处理
* @param startDate
* @param endDate
* @param vehicleModelCalendarPrice
* @return
*/
private List<VehicleModelCalendarPriceDTO> wrapVehicleModelCalendarPrice(Date startDate, Date endDate, List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPrice) {
LocalDate startLocalDate = DateUtils.dateToLocalDate(startDate);
LocalDate endLocalDate = DateUtils.dateToLocalDate(endDate);
Integer days = getIncludeDays(startDate.getTime(), endDate.getTime());
boolean isSelect = false;
for (int i = 0, y = 0; i < vehicleModelCalendarPrice.size(); i++) {
VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO = vehicleModelCalendarPrice.get(i);
LocalDate current_date = DateUtils.dateToLocalDate(vehicleModelCalendarPriceDTO.getDate());
if (y == 0) {
isSelect = (current_date.isAfter(startLocalDate) && current_date.isBefore(endLocalDate)) || current_date.isEqual(startLocalDate) || current_date.isEqual(endLocalDate);
}
if (isSelect) {
if (y < days) {
vehicleModelCalendarPriceDTO.setIsSelect(true);
y++;
}
}
}
return vehicleModelCalendarPrice;
}
/**
* 日历价格查询
......@@ -311,10 +307,10 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
BigDecimal vehicle_base_price = new BigDecimal(0);
BigDecimal vehicle_price = vehicleModelBiz.findVehicleModelPriceByVehicleModelId(vehicleModelId);
vehicle_base_price = vehicle_base_price.add(vehicle_price);
log.info("用户id【{}】", userId);
log.info("用户id【{}】",userId);
if (Objects.nonNull(userId)) {
BaseUserMember baseUserMember = userFeign.findBaseUserMemberByUserId(userId);
log.info("用户会员信息:【{}】", baseUserMember);
log.info("用户会员信息:【{}】",baseUserMember);
discount = baseUserMember == null ? discount : baseUserMember.getDiscount();
memberLevel = baseUserMember == null ? memberLevel : baseUserMember.getMemberLevel();
}
......@@ -383,7 +379,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @param discount
* @return
*/
public Map<String, Object> transfromPriceAndFreeDaysByDate(Map<Date, VehicleModelHolidayPriceDTO> festivalDayMap, Date current_date, BigDecimal vehicle_price, Integer discount) {
private Map<String, Object> transfromPriceAndFreeDaysByDate(Map<Date, VehicleModelHolidayPriceDTO> festivalDayMap, Date current_date, BigDecimal vehicle_price, Integer discount) {
log.info("参数:【{}==当前时间:{}==价格:{}==折扣:{}】", festivalDayMap, current_date, vehicle_price, discount);
Map<String, Object> vehicle_price_days_map = new HashMap<>(3);
Integer free_days = DEFAULT_FREE_DAYS;
......@@ -476,17 +472,6 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
startDatee.set(startDate);
endDatee.set(endDate);
}
public static void main(String[] args) {
AtomicReference<Date> start = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-03").atStartOfDay(ZoneId.systemDefault()).toInstant()));
AtomicReference<Date> end = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-29").atStartOfDay(ZoneId.systemDefault()).toInstant()));
transformStartDateAndEndDate(start, end);
System.out.println(start.get());
System.out.println(end.get());
}
/**
* 车型日历价格设置类型
*/
......
......@@ -61,9 +61,7 @@ public class VehicleModelCalendarPriceController {
@RequestParam(value = "userId") Integer userId) {
Date startDateDay = DateUtil.beginOfDay(DateUtil.date(startDate));
//Date.from(startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
Date endDateDay = DateUtil.beginOfDay(DateUtil.date(endDate));
//Date.from(endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, userId));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment