Commit 7be3c65d authored by libin's avatar libin

提现账号

parent 447bf340
......@@ -84,4 +84,9 @@ public class VehicleModelCalendarPrice implements Serializable {
@Column(name = "is_del")
private Integer isDel;
/**
* 会员等级 1:普通 2:黄金 3:钻石
*/
private Integer level;
}
......@@ -22,7 +22,8 @@ import java.util.Date;
public class VehicleModelCalendarPriceDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Date date;
private BigDecimal price;
private Date bookDate;
private Integer freeDays;
private Boolean isSelect;
}
......@@ -51,4 +51,8 @@ public class VehicleModelCalendarPriceSaveDTO implements Serializable {
*/
private BigDecimal price;
/**
* 会员等级 1:普通 2:黄金 3:钻石
*/
private Integer level;
}
package com.xxfc.platform.vehicle.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/15 9:43
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class VehicleModelCalendarPriceVo implements Serializable {
private static final long serialVersionUID = 1L;
private Date date;
private BigDecimal price;
private Integer days;
private Boolean isSelect;
}
package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.VehicleModelCalendarPrice;
......@@ -9,7 +10,6 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceSaveDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleModelCalendarPriceVo;
import com.xxfc.platform.vehicle.pojo.vo.VehicleModelDayPriceVo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
......@@ -46,20 +46,18 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* 一个星期的最后一天
*/
private static final int END_OF_WEEK = 7;
/**
* 价格类型查询
*/
private static final int PRICE_OF_TYPE = 0;
/**
* 天数类型查询
*/
private static final int DAYS_OF_TYPE = 1;
private final VehicleModelHolidayPriceBiz vehicleModelHolidayPriceBiz;
private final VehicleModelBiz vehicleModelBiz;
private final UserFeign userFeign;
/**
* 保存
*
* @param vehicleModelCalendarPrices
* @param userId
*/
public void addVehicleModelCalendarPrice(List<VehicleModelCalendarPriceSaveDTO> vehicleModelCalendarPrices, Integer userId) {
if (CollectionUtils.isNotEmpty(vehicleModelCalendarPrices)) {
List<VehicleModelCalendarPrice> vehicleModelCalendarPriceList = new ArrayList<>();
......@@ -86,6 +84,11 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
}
/**
* 查询全部车型
*
* @return
*/
public List<VehicleModelDayPriceVo> listVehicleModelPrice() {
List<VehicleModelDayPriceVo> vehicleModelDayPriceVos = new ArrayList<>();
List<VehicleModelDTO> vehicleModelDTOS = vehicleModelBiz.findAllVehicleModel();
......@@ -98,6 +101,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return vehicleModelDayPriceVos;
}
/**
* 根据俱体日期查询
*
* @param currentDate
* @return
*/
public List<VehicleModelDayPriceVo> findVehicleModelcalendarPriceByDateWithDay(Date currentDate) {
List<VehicleModelDayPriceVo> vehicleModelDayPriceVos = new ArrayList<>();
Map<Integer, VehicleModelCalendarPrice> vehicleModelCalendarPriceMap = null;
......@@ -124,7 +133,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return vehicleModelDayPriceVos;
}
/**
* 根据月份查询
*
* @param currentDate
* @return
*/
public List<VehicleModelCalendarPriceSaveDTO> findVehicleModelCalendarPricesByDateWithMonth(Date currentDate) {
List<VehicleModelCalendarPriceSaveDTO> vehicleModelCalendarPriceSaveDTOS = new ArrayList<>();
Example example = new Example(VehicleModelCalendarPrice.class);
......@@ -149,121 +163,88 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return vehicleModelCalendarPriceSaveDTOS;
}
/**
* 根据下单时间查询
*
* @param startDate
* @param endDate
* @param vehicleModelId
* @param userId
* @return
*/
public List<VehicleModelCalendarPriceDTO> findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPriceDTOS = new ArrayList<>();
//车型的原价
BigDecimal vehicle_price = new BigDecimal(0);
Integer discount = 100;
int free_days = 1;
//日历价格转map
List<VehicleModelCalendarPrice> vehicleModelCalendarPrices = getVehicleModelCalendarPricesByVehicleModelIdAndDate(vehicleModelId, startDate, endDate);
Map<Date, VehicleModelCalendarPrice> calendarPriceMap = vehicleModelCalendarPrices.stream().collect(Collectors.toMap(VehicleModelCalendarPrice::getVehicleModelDay, Function.identity()));
//节假日转map
List<VehicleModelHolidayPriceDTO> vehicleModelHolidayPrices = vehicleModelHolidayPriceBiz.findVehicleModelHolidayPriceByMonth(startDate, endDate);
Map<Date, VehicleModelHolidayPriceDTO> festivalDayMap = vehicleModelHolidayPrices.stream().collect(Collectors.toMap(VehicleModelHolidayPriceDTO::getFestivalDay, Function.identity()));
vehicle_price = vehicleModelBiz.findVehicleModelPriceByVehicleModelId(vehicleModelId);
if (Objects.nonNull(userId)) {
BaseUserMember baseUserMember = userFeign.findBaseUserMemberByUserId(userId);
discount = baseUserMember == null ? discount : baseUserMember.getDiscount();
return findVehicleModelCalendarPrice(startDate, endDate, vehicleModelId, userId);
}
VehicleModelCalendarPriceVo vehicleModelCalendarPriceVo;
LocalDate final_startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate final_endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO;
while (final_startLocalDate.isBefore(final_endLocalDate) || final_startLocalDate.isEqual(final_endLocalDate)) {
vehicleModelCalendarPriceDTO = new VehicleModelCalendarPriceDTO();
Date current_date = Date.from(final_startLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
vehicleModelCalendarPriceDTO.setBookDate(current_date);
/**
* 日历展示车型价格
*
* @param startDate
* @param endDate
* @param vehicleModelId
* @param userId
* @return
*/
public List<VehicleModelCalendarPriceDTO> listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
LocalDate startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
if (calendarPriceMap != null && !calendarPriceMap.isEmpty()) {
VehicleModelCalendarPrice vehicleModelCalendarPrice = calendarPriceMap.get(Date.from(final_startLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
if (Objects.isNull(vehicleModelCalendarPrice)) {
if (festivalDayMap != null && !festivalDayMap.isEmpty()) {
VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO = festivalDayMap.get(current_date);
if (Objects.nonNull(vehicleModelHolidayPriceDTO)) {
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue() * (discount / 100)));
free_days = vehicleModelHolidayPriceDTO.getFreeDays();
}
}
//处理后延伸的开始时间
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);
for (VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO : vehicleModelCalendarPrice) {
LocalDate current_date = vehicleModelCalendarPriceDTO.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
boolean isSelect = (current_date.isAfter(startLocalDate) && current_date.isBefore(endLocalDate)) || current_date.isEqual(startLocalDate) || current_date.isEqual(endLocalDate);
if (isSelect) {
vehicleModelCalendarPriceDTO.setIsSelect(true);
} else {
switch (vehicleModelCalendarPrice.getType()) {
case VehicleModelPriceType.MULTIPLE:
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelCalendarPrice.getMultiple().doubleValue() * (discount / 100)));
break;
case VehicleModelPriceType.ABS:
vehicle_price = vehicleModelCalendarPrice.getPrice().multiply(new BigDecimal(discount / 100));
break;
case VehicleModelPriceType.MEMBER:
//todo
break;
default:
break;
vehicleModelCalendarPriceDTO.setIsSelect(false);
}
free_days = vehicleModelCalendarPrice.getFreeDays();
}
}
vehicleModelCalendarPriceDTO.setFreeDays(free_days);
vehicleModelCalendarPriceDTO.setPrice(vehicle_price);
final_startLocalDate = final_startLocalDate.plusDays(1);
vehicleModelCalendarPriceDTOS.add(vehicleModelCalendarPriceDTO);
}
return vehicleModelCalendarPriceDTOS;
return vehicleModelCalendarPrice;
}
/**
* 日历价格查询
*
* @param startDate
* @param endDate
* @param vehicleModelId
* @return
*/
public List<VehicleModelCalendarPriceVo> listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
List<VehicleModelCalendarPriceVo> vehicleModelCalendarPriceVos = new ArrayList<>();
//车型的原价
BigDecimal vehicle_price = new BigDecimal(0);
public List<VehicleModelCalendarPriceDTO> findVehicleModelCalendarPrice(Date startDate, Date endDate, Integer vehicleModelId, Integer userId) {
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPriceVos = new ArrayList<>();
//默认折扣
Integer discount = 100;
//默认免费天数
int free_days = 1;
AtomicReference<Date> startReference = new AtomicReference<>(startDate);
AtomicReference<Date> endReference = new AtomicReference<>(endDate);
transformStartDateAndEndDate(startReference, endReference);
//处理后延伸的开始时间
Date final_startDate = startReference.get();
//处理后延伸的结束时间
Date final_endDate = endReference.get();
//会员默认等级
Integer memberLevel = 0;
//日历价格转map
List<VehicleModelCalendarPrice> vehicleModelCalendarPrices = getVehicleModelCalendarPricesByVehicleModelIdAndDate(vehicleModelId, final_startDate, final_endDate);
List<VehicleModelCalendarPrice> vehicleModelCalendarPrices = getVehicleModelCalendarPricesByVehicleModelIdAndDate(vehicleModelId, startDate, endDate);
Map<Date, VehicleModelCalendarPrice> calendarPriceMap = vehicleModelCalendarPrices.stream().collect(Collectors.toMap(VehicleModelCalendarPrice::getVehicleModelDay, Function.identity()));
//节假日转map
List<VehicleModelHolidayPriceDTO> vehicleModelHolidayPrices = vehicleModelHolidayPriceBiz.findVehicleModelHolidayPriceByMonth(final_startDate, final_endDate);
List<VehicleModelHolidayPriceDTO> vehicleModelHolidayPrices = vehicleModelHolidayPriceBiz.findVehicleModelHolidayPriceByMonth(startDate, endDate);
Map<Date, VehicleModelHolidayPriceDTO> festivalDayMap = vehicleModelHolidayPrices.stream().collect(Collectors.toMap(VehicleModelHolidayPriceDTO::getFestivalDay, Function.identity()));
Map<Integer, Integer> levelAndDiscountMap = userFeign.levels().stream().collect(Collectors.toMap(BaseUserMemberLevel::getLevel, BaseUserMemberLevel::getDiscount));
vehicle_price = vehicleModelBiz.findVehicleModelPriceByVehicleModelId(vehicleModelId);
//车型的原价
BigDecimal vehicle_price = vehicleModelBiz.findVehicleModelPriceByVehicleModelId(vehicleModelId);
if (Objects.nonNull(userId)) {
BaseUserMember baseUserMember = userFeign.findBaseUserMemberByUserId(userId);
discount = baseUserMember == null ? discount : baseUserMember.getDiscount();
memberLevel = baseUserMember == null ? memberLevel : baseUserMember.getMemberLevel();
}
VehicleModelCalendarPriceVo vehicleModelCalendarPriceVo;
LocalDate startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate final_startLocalDate = final_startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate final_endLocalDate = final_endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
VehicleModelCalendarPriceDTO vehicleModelCalendarPriceDTO;
LocalDate final_startLocalDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate final_endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
while (final_startLocalDate.isBefore(final_endLocalDate) || final_startLocalDate.isEqual(final_endLocalDate)) {
vehicleModelCalendarPriceVo = new VehicleModelCalendarPriceVo();
vehicleModelCalendarPriceDTO = new VehicleModelCalendarPriceDTO();
Date current_date = Date.from(final_startLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
vehicleModelCalendarPriceVo.setDate(current_date);
if (final_startLocalDate.isAfter(startLocalDate) || final_startLocalDate.isEqual(startLocalDate) || final_startLocalDate.isEqual(endLocalDate)) {
vehicleModelCalendarPriceVo.setIsSelect(true);
} else {
vehicleModelCalendarPriceVo.setIsSelect(false);
}
vehicleModelCalendarPriceDTO.setDate(current_date);
if (calendarPriceMap != null && !calendarPriceMap.isEmpty()) {
VehicleModelCalendarPrice vehicleModelCalendarPrice = calendarPriceMap.get(current_date);
if (Objects.isNull(vehicleModelCalendarPrice)) {
......@@ -283,22 +264,32 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
vehicle_price = vehicleModelCalendarPrice.getPrice().multiply(new BigDecimal(discount / 100));
break;
case VehicleModelPriceType.MEMBER:
//todo
memberLevel = vehicleModelCalendarPrice.getLevel() > memberLevel ? vehicleModelCalendarPrice.getLevel() : memberLevel;
Integer level_discount = levelAndDiscountMap.get(memberLevel);
vehicle_price = level_discount == null ? vehicleModelCalendarPrice.getPrice() : vehicleModelCalendarPrice.getPrice().multiply(new BigDecimal(level_discount / 100));
break;
default:
break;
}
free_days = vehicleModelCalendarPrice.getFreeDays();
}
vehicleModelCalendarPriceVo.setPrice(vehicle_price);
vehicleModelCalendarPriceVo.setDays(free_days);
vehicleModelCalendarPriceDTO.setPrice(vehicle_price);
vehicleModelCalendarPriceDTO.setFreeDays(free_days);
}
final_startLocalDate = final_startLocalDate.plusDays(1);
vehicleModelCalendarPriceVos.add(vehicleModelCalendarPriceVo);
vehicleModelCalendarPriceVos.add(vehicleModelCalendarPriceDTO);
}
return vehicleModelCalendarPriceVos;
}
/**
* 根据时间范围查询
*
* @param vehicleModelId
* @param final_startDate
* @param final_endDate
* @return
*/
private List<VehicleModelCalendarPrice> getVehicleModelCalendarPricesByVehicleModelIdAndDate(Integer vehicleModelId, Date final_startDate, Date final_endDate) {
Example example = new Example(VehicleModelCalendarPrice.class);
Example.Criteria criteria = example.createCriteria();
......@@ -309,6 +300,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return CollectionUtils.isEmpty(vehicleModelCalendarPrices) ? Collections.EMPTY_LIST : vehicleModelCalendarPrices;
}
/**
* 时间处理
*
* @param startDatee
* @param endDatee
*/
public static void transformStartDateAndEndDate(AtomicReference<Date> startDatee, AtomicReference<Date> endDatee) {
Date startDate = startDatee.get();
Date endDate = endDatee.get();
......
......@@ -3,7 +3,7 @@ package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleModelCalendarPriceBiz;
import com.xxfc.platform.vehicle.pojo.vo.VehicleModelCalendarPriceVo;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -30,11 +30,11 @@ public class VehicleModelCalendarPriceController {
@ApiOperation("返回车型日历价格")
@GetMapping("/list/vehicle_model/calendar_price/{vehicleModelId}/{type}")
public ObjectRestResponse<VehicleModelCalendarPriceVo> listVehicleModelCalendarPriceByDateAndVehicleModelId(@RequestParam(value = "start",required = false) Date startDate,
public ObjectRestResponse<VehicleModelCalendarPriceDTO> listVehicleModelCalendarPriceByDateAndVehicleModelId(@RequestParam(value = "start",required = false) Date startDate,
@RequestParam(value = "end",required = false) Date endDate,
@PathVariable(value = "vehicleModelId") Integer vehicleModelId,
AppUserDTO appUserDTO){
List<VehicleModelCalendarPriceVo> vehicleModelCalendarPriceVos = vehicleModelCalendarPriceBiz.listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(startDate,endDate,vehicleModelId,appUserDTO.getUserid());
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPriceVos = vehicleModelCalendarPriceBiz.listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(startDate,endDate,vehicleModelId,appUserDTO.getUserid());
return ObjectRestResponse.succ(vehicleModelCalendarPriceVos);
}
}
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