Commit afb68825 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/holiday-price' into holiday-price

parents 5d37e499 c614865b
...@@ -24,6 +24,7 @@ public class VehicleModelCalendarPriceDTO implements Serializable { ...@@ -24,6 +24,7 @@ public class VehicleModelCalendarPriceDTO implements Serializable {
private Date date; private Date date;
private BigDecimal price; private BigDecimal price;
private BigDecimal no_discount_price;
private Integer freeDays; private Integer freeDays;
private Boolean isSelect; private Boolean isSelect;
} }
package com.xxfc.platform.vehicle.pojo.dto; package com.xxfc.platform.vehicle.pojo.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -25,7 +26,10 @@ public class VehicleModelCalendarPriceSaveDTO implements Serializable { ...@@ -25,7 +26,10 @@ public class VehicleModelCalendarPriceSaveDTO implements Serializable {
/** /**
* 日期设置 * 日期设置
*/ */
@JSONField(serialize = false)
private Date vehicleModelDay; private Date vehicleModelDay;
private String date;
/** /**
* 是否全局设置 * 是否全局设置
*/ */
......
...@@ -6,7 +6,7 @@ import lombok.Data; ...@@ -6,7 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.List;
/** /**
* @author libin * @author libin
...@@ -24,7 +24,7 @@ public class VehicleModelHolidayPriceSaveDTO implements Serializable { ...@@ -24,7 +24,7 @@ public class VehicleModelHolidayPriceSaveDTO implements Serializable {
/** /**
* 节假日日期 * 节假日日期
*/ */
private Date festivalDay; private String date;
/** /**
* 节假日 * 节假日
*/ */
......
...@@ -29,4 +29,8 @@ public class VehicleModelDayPriceVo extends VehicleModelDTO implements Serializa ...@@ -29,4 +29,8 @@ public class VehicleModelDayPriceVo extends VehicleModelDTO implements Serializa
* 倍数 * 倍数
*/ */
private Double multiple; private Double multiple;
/**
* 会员等级
*/
private Integer level;
} }
...@@ -80,9 +80,14 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -80,9 +80,14 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
List<Date> dateList = vehicleModelCalendarPrices.stream().peek(x -> { List<Date> dateList = vehicleModelCalendarPrices.stream().peek(x -> {
VehicleModelCalendarPrice calendarPrice = new VehicleModelCalendarPrice(); VehicleModelCalendarPrice calendarPrice = new VehicleModelCalendarPrice();
BeanUtils.copyProperties(x, calendarPrice); BeanUtils.copyProperties(x, calendarPrice);
Date date = Date.from(LocalDate.parse(x.getDate()).atStartOfDay(ZoneId.systemDefault()).toInstant());
calendarPrice.setVehicleModelDay(date);
calendarPrice.setCrtTime(new Date()); calendarPrice.setCrtTime(new Date());
calendarPrice.setCrtUserId(userId); calendarPrice.setCrtUserId(userId);
calendarPrice.setIsDel(0);
x.setVehicleModelDay(date);
vehicleModelCalendarPriceList.add(calendarPrice); vehicleModelCalendarPriceList.add(calendarPrice);
}).map(VehicleModelCalendarPriceSaveDTO::getVehicleModelDay).distinct().collect(Collectors.toList()); }).map(VehicleModelCalendarPriceSaveDTO::getVehicleModelDay).distinct().collect(Collectors.toList());
//1.删除当月做更改了的日期的数据 //1.删除当月做更改了的日期的数据
...@@ -93,7 +98,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -93,7 +98,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Example example = new Example(VehicleModelCalendarPrice.class); Example example = new Example(VehicleModelCalendarPrice.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andIn("vehicleModelDay", dateList); criteria.andIn("vehicleModelDay", dateList);
mapper.updateByExample(vehicleModelCalendarPrice, example); mapper.updateByExampleSelective(vehicleModelCalendarPrice, example);
//2.插入新的数据 //2.插入新的数据
mapper.insertList(vehicleModelCalendarPriceList); mapper.insertList(vehicleModelCalendarPriceList);
} }
...@@ -144,6 +149,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -144,6 +149,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
vehicleModelDayPriceVo.setMultiple(multiple); vehicleModelDayPriceVo.setMultiple(multiple);
BigDecimal aPrice = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice(); BigDecimal aPrice = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice();
vehicleModelDayPriceVo.setPrice(aPrice); vehicleModelDayPriceVo.setPrice(aPrice);
Integer level = isNullOfVehicleModelPrice?null:vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getLevel();
vehicleModelDayPriceVo.setLevel(level);
vehicleModelDayPriceVos.add(vehicleModelDayPriceVo); vehicleModelDayPriceVos.add(vehicleModelDayPriceVo);
} }
return vehicleModelDayPriceVos; return vehicleModelDayPriceVos;
...@@ -174,8 +181,13 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -174,8 +181,13 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
for (VehicleModelCalendarPrice calendarPrice : vehicleModelCalendarPriceList) { for (VehicleModelCalendarPrice calendarPrice : vehicleModelCalendarPriceList) {
vehicleModelCalendarPrice = new VehicleModelCalendarPriceSaveDTO(); vehicleModelCalendarPrice = new VehicleModelCalendarPriceSaveDTO();
BeanUtils.copyProperties(calendarPrice, vehicleModelCalendarPrice); BeanUtils.copyProperties(calendarPrice, vehicleModelCalendarPrice);
vehicleModelCalendarPrice.setVehicleModelId(null);
vehicleModelCalendarPriceSaveDTOS.add(vehicleModelCalendarPrice); vehicleModelCalendarPriceSaveDTOS.add(vehicleModelCalendarPrice);
} }
Map<Date, Optional<VehicleModelCalendarPriceSaveDTO>> result = vehicleModelCalendarPriceSaveDTOS.stream()
.collect(Collectors.groupingBy(VehicleModelCalendarPriceSaveDTO::getVehicleModelDay, Collectors.maxBy(Comparator.comparing(VehicleModelCalendarPriceSaveDTO::getId))));
vehicleModelCalendarPriceSaveDTOS = result.values().stream().map(x->x.orElseGet(null)).filter(Objects::nonNull).collect(Collectors.toList());
return vehicleModelCalendarPriceSaveDTOS; return vehicleModelCalendarPriceSaveDTOS;
} }
...@@ -257,6 +269,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -257,6 +269,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
vehicleModelCalendarPriceDTO = new VehicleModelCalendarPriceDTO(); vehicleModelCalendarPriceDTO = new VehicleModelCalendarPriceDTO();
//价格重置 //价格重置
vehicle_price = vehicle_base_price; vehicle_price = vehicle_base_price;
//未乘以会员折扣的价格
BigDecimal no_discount_price = new BigDecimal(vehicle_price.doubleValue());
//免费天数重置 //免费天数重置
Integer free_days = DEFAULT_FREE_DAYS; Integer free_days = DEFAULT_FREE_DAYS;
//节假日对应的价格和免费天数 //节假日对应的价格和免费天数
...@@ -270,7 +284,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -270,7 +284,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
} else { } else {
switch (vehicleModelCalendarPrice.getType()) { switch (vehicleModelCalendarPrice.getType()) {
case VehicleModelPriceType.MULTIPLE: case VehicleModelPriceType.MULTIPLE:
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelCalendarPrice.getMultiple().doubleValue() * (discount / 100.00))); no_discount_price = vehicle_price.multiply(new BigDecimal(vehicleModelCalendarPrice.getMultiple().doubleValue()));
vehicle_price = no_discount_price.multiply(new BigDecimal(discount / 100.0));
break; break;
case VehicleModelPriceType.ABS: case VehicleModelPriceType.ABS:
vehicle_price = vehicleModelCalendarPrice.getPrice().multiply(new BigDecimal(discount / 100.00)); vehicle_price = vehicleModelCalendarPrice.getPrice().multiply(new BigDecimal(discount / 100.00));
...@@ -292,6 +307,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -292,6 +307,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
vehicle_price = (BigDecimal) price_freeDays_map.get(PRICE_VAL); vehicle_price = (BigDecimal) price_freeDays_map.get(PRICE_VAL);
free_days = (Integer) price_freeDays_map.get(DAYS_VAL); free_days = (Integer) price_freeDays_map.get(DAYS_VAL);
} }
vehicleModelCalendarPriceDTO.setNo_discount_price(no_discount_price);
vehicleModelCalendarPriceDTO.setPrice(vehicle_price.setScale(2, RoundingMode.DOWN)); vehicleModelCalendarPriceDTO.setPrice(vehicle_price.setScale(2, RoundingMode.DOWN));
vehicleModelCalendarPriceDTO.setFreeDays(free_days); vehicleModelCalendarPriceDTO.setFreeDays(free_days);
final_startLocalDate = final_startLocalDate.plusDays(1); final_startLocalDate = final_startLocalDate.plusDays(1);
......
...@@ -34,6 +34,8 @@ import java.util.Objects; ...@@ -34,6 +34,8 @@ import java.util.Objects;
@Service @Service
public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPriceMapper, VehicleModelHolidayPrice> { public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPriceMapper, VehicleModelHolidayPrice> {
/** /**
* 保存 * 保存
* *
...@@ -43,6 +45,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -43,6 +45,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
public void addVehicleModelHolidayPrice(VehicleModelHolidayPriceSaveDTO vehicleModelHolidayPriceSaveDTO, Integer userId) { public void addVehicleModelHolidayPrice(VehicleModelHolidayPriceSaveDTO vehicleModelHolidayPriceSaveDTO, Integer userId) {
VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice(); VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
BeanUtils.copyProperties(vehicleModelHolidayPriceSaveDTO, vehicleModelHolidayPrice); BeanUtils.copyProperties(vehicleModelHolidayPriceSaveDTO, vehicleModelHolidayPrice);
vehicleModelHolidayPrice.setFestivalDay(Date.from(LocalDate.parse(vehicleModelHolidayPriceSaveDTO.getDate()).atStartOfDay(ZoneId.systemDefault()).toInstant()));
//编辑 //编辑
if (Objects.nonNull(vehicleModelHolidayPriceSaveDTO.getId())) { if (Objects.nonNull(vehicleModelHolidayPriceSaveDTO.getId())) {
vehicleModelHolidayPrice.setUpdTime(new Date()); vehicleModelHolidayPrice.setUpdTime(new Date());
...@@ -62,20 +65,19 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -62,20 +65,19 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
} }
/** /**
*
* @param multiple 倍数 * @param multiple 倍数
* @param freeDays 免费天数 * @param freeDays 免费天数
* @param configDate 设置的日期*月份 * @param configDate 设置的日期*月份
*/ */
public void updateVehicleModelHolidayPrice(Double multiple,Integer freeDays,Date configDate){ public void updateVehicleModelHolidayPrice(Double multiple, Integer freeDays, Date configDate) {
VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice(); VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
vehicleModelHolidayPrice.setMultiple(multiple); vehicleModelHolidayPrice.setMultiple(multiple);
vehicleModelHolidayPrice.setFreeDays(freeDays); vehicleModelHolidayPrice.setFreeDays(freeDays);
Example example = new Example(VehicleModelHolidayPrice.class); Example example = new Example(VehicleModelHolidayPrice.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
setCondtionDate(configDate,criteria); setCondtionDate(configDate, criteria);
int effect = mapper.updateByExampleSelective(vehicleModelHolidayPrice,example); int effect = mapper.updateByExampleSelective(vehicleModelHolidayPrice, example);
if (effect<1){ if (effect < 1) {
throw new BaseException("车型节假日更新失败"); throw new BaseException("车型节假日更新失败");
} }
} }
...@@ -90,7 +92,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -90,7 +92,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
List<VehicleModelHolidayPriceVo> vehicleModelHolidayPriceVos = new ArrayList<>(); List<VehicleModelHolidayPriceVo> vehicleModelHolidayPriceVos = new ArrayList<>();
Example example = new Example(VehicleModelHolidayPrice.class); Example example = new Example(VehicleModelHolidayPrice.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
setCondtionDate(vehicleModelHolidayPriceFindDTO.getDate(),criteria); setCondtionDate(vehicleModelHolidayPriceFindDTO.getDate(), criteria);
if (StringUtils.isNotEmpty(vehicleModelHolidayPriceFindDTO.getFestival()) && vehicleModelHolidayPriceFindDTO.getFestival().trim().length() > 0) { if (StringUtils.isNotEmpty(vehicleModelHolidayPriceFindDTO.getFestival()) && vehicleModelHolidayPriceFindDTO.getFestival().trim().length() > 0) {
criteria.andLike("festival", String.format("%%%s%%", vehicleModelHolidayPriceFindDTO.getFestival())); criteria.andLike("festival", String.format("%%%s%%", vehicleModelHolidayPriceFindDTO.getFestival()));
} }
...@@ -148,10 +150,11 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -148,10 +150,11 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
/** /**
* 设置查询条件日期 * 设置查询条件日期
*
* @param conditionDate * @param conditionDate
* @param criteria * @param criteria
*/ */
private void setCondtionDate(Date conditionDate, Example.Criteria criteria){ private void setCondtionDate(Date conditionDate, Example.Criteria criteria) {
LocalDate localDate = LocalDate.from(conditionDate.toInstant()); LocalDate localDate = LocalDate.from(conditionDate.toInstant());
//开始日期 //开始日期
Instant startInstant = localDate.withDayOfMonth(1).atStartOfDay(ZoneId.systemDefault()).toInstant(); Instant startInstant = localDate.withDayOfMonth(1).atStartOfDay(ZoneId.systemDefault()).toInstant();
......
...@@ -11,6 +11,8 @@ import lombok.RequiredArgsConstructor; ...@@ -11,6 +11,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -34,16 +36,18 @@ public class VehicleModelCalendarPriceAdminController { ...@@ -34,16 +36,18 @@ public class VehicleModelCalendarPriceAdminController {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@ApiOperation("车型日历月份价格") @ApiOperation("车型日历价格")
@GetMapping("/day") @GetMapping("/day")
public ObjectRestResponse<VehicleModelDayPriceVo> listVehicleModelCalendarPriceWithMonth(@RequestParam(value = "date") Date date){ public ObjectRestResponse<VehicleModelDayPriceVo> listVehicleModelCalendarPriceWithMonth(@RequestParam(value = "date") String dateStr){
Date date = Date.from(LocalDate.parse(dateStr).atStartOfDay(ZoneId.systemDefault()).toInstant());
List<VehicleModelDayPriceVo> vehicleModelDayPriceVos = vehicleModelCalendarPriceBiz.findVehicleModelcalendarPriceByDateWithDay(date); List<VehicleModelDayPriceVo> vehicleModelDayPriceVos = vehicleModelCalendarPriceBiz.findVehicleModelcalendarPriceByDateWithDay(date);
return ObjectRestResponse.succ(vehicleModelDayPriceVos); return ObjectRestResponse.succ(vehicleModelDayPriceVos);
} }
@ApiOperation("根据日查询不同车型的设置") @ApiOperation("根据月份查询的设置")
@GetMapping("/month") @GetMapping("/month")
public ObjectRestResponse<List<VehicleModelCalendarPriceSaveDTO>> listVehicleModelCalendarPriceWithDay(@RequestParam(value = "date") Date date){ public ObjectRestResponse<List<VehicleModelCalendarPriceSaveDTO>> listVehicleModelCalendarPriceWithDay(@RequestParam(value = "date") String dateStr){
Date date = Date.from(LocalDate.parse(dateStr).atStartOfDay(ZoneId.systemDefault()).toInstant());
List<VehicleModelCalendarPriceSaveDTO> calendarPrices = vehicleModelCalendarPriceBiz.findVehicleModelCalendarPricesByDateWithMonth(date); List<VehicleModelCalendarPriceSaveDTO> calendarPrices = vehicleModelCalendarPriceBiz.findVehicleModelCalendarPricesByDateWithMonth(date);
return ObjectRestResponse.succ(calendarPrices); return ObjectRestResponse.succ(calendarPrices);
} }
......
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