Commit 9e315258 authored by libin's avatar libin

Merge branch 'holiday-price' into dev

parents 6e4ca67f 2159171b
...@@ -27,4 +27,6 @@ public class Festival { ...@@ -27,4 +27,6 @@ public class Festival {
private String name; private String name;
@Column(name = "crt_time") @Column(name = "crt_time")
private Date crtTime; private Date crtTime;
@Column(name = "is_del")
private Integer isDel;
} }
...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.Festival; import com.xxfc.platform.vehicle.entity.Festival;
import com.xxfc.platform.vehicle.mapper.FestivalMapper; import com.xxfc.platform.vehicle.mapper.FestivalMapper;
import io.swagger.models.auth.In;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -30,11 +31,11 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> { ...@@ -30,11 +31,11 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> {
} }
} }
public void deleteById(Integer festivalId){ /* public void deleteById(Integer festivalId){
Festival festival = new Festival(); Festival festival = new Festival();
festival.setId(festivalId); festival.setId(festivalId);
mapper.deleteByPrimaryKey(festival); mapper.deleteByPrimaryKey(festival);
} }*/
public Map<Integer, Festival> findFestivalsByIds(List<Integer> festivalIds) { public Map<Integer, Festival> findFestivalsByIds(List<Integer> festivalIds) {
Map<Integer,Festival> festivalMap = new HashMap<>(20); Map<Integer,Festival> festivalMap = new HashMap<>(20);
...@@ -44,4 +45,12 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> { ...@@ -44,4 +45,12 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> {
} }
return festivalMap; return festivalMap;
} }
@Override
public void deleteById(Object id) {
Festival festival = new Festival();
festival.setId((Integer) id);
festival.setIsDel(1);
mapper.updateByPrimaryKey(festival);
}
} }
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.map.MapUtil;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember; import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel; import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
...@@ -132,12 +133,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -132,12 +133,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
for (VehicleModelDTO vehicleModelDTO : vehicleModelDTOS) { for (VehicleModelDTO vehicleModelDTO : vehicleModelDTOS) {
vehicleModelDayPriceVo = new VehicleModelDayPriceVo(); vehicleModelDayPriceVo = new VehicleModelDayPriceVo();
BeanUtils.copyProperties(vehicleModelDTO, vehicleModelDayPriceVo); BeanUtils.copyProperties(vehicleModelDTO, vehicleModelDayPriceVo);
boolean isNullOfVehicleModelPrice = vehicleModelCalendarPriceMap == null ? true : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()) == null; boolean isNullOfVehicleModelPrice = MapUtil.isEmpty(vehicleModelCalendarPriceMap) ? true : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()) == null;
Double multiple = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getMultiple(); Double multiple = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getMultiple();
vehicleModelDayPriceVo.setMultiple(multiple); vehicleModelDayPriceVo.setMultiple(multiple);
BigDecimal aPrice = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice(); BigDecimal aPrice = isNullOfVehicleModelPrice ? BigDecimal.ZERO : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice();
vehicleModelDayPriceVo.setPrice(aPrice); vehicleModelDayPriceVo.setPrice(aPrice);
Integer level = isNullOfVehicleModelPrice?null:vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getLevel(); Integer level = isNullOfVehicleModelPrice? null:vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getLevel();
vehicleModelDayPriceVo.setLevel(level); vehicleModelDayPriceVo.setLevel(level);
vehicleModelDayPriceVos.add(vehicleModelDayPriceVo); vehicleModelDayPriceVos.add(vehicleModelDayPriceVo);
} }
...@@ -267,7 +268,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -267,7 +268,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Map<String, Object> price_freeDays_map = null; Map<String, Object> price_freeDays_map = null;
Date current_date = DateUtils.localDateToDate(final_startLocalDate); Date current_date = DateUtils.localDateToDate(final_startLocalDate);
vehicleModelCalendarPriceDTO.setDate(current_date); vehicleModelCalendarPriceDTO.setDate(current_date);
if (calendarPriceMap != null && !calendarPriceMap.isEmpty()) { if (MapUtil.isNotEmpty(calendarPriceMap)) {
VehicleModelCalendarPrice vehicleModelCalendarPrice = calendarPriceMap.get(current_date); VehicleModelCalendarPrice vehicleModelCalendarPrice = calendarPriceMap.get(current_date);
if (Objects.isNull(vehicleModelCalendarPrice)) { if (Objects.isNull(vehicleModelCalendarPrice)) {
price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount); price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount);
...@@ -294,7 +295,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -294,7 +295,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
} else { } else {
price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount); price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount);
} }
if (price_freeDays_map != null && !price_freeDays_map.isEmpty()) { if (MapUtil.isNotEmpty(price_freeDays_map)) {
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);
no_discount_price = (BigDecimal) price_freeDays_map.get(BASE_PRICE_VAL); no_discount_price = (BigDecimal) price_freeDays_map.get(BASE_PRICE_VAL);
...@@ -322,7 +323,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -322,7 +323,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Map<String, Object> vehicle_price_days_map = new HashMap<>(3); Map<String, Object> vehicle_price_days_map = new HashMap<>(3);
Integer free_days = DEFAULT_FREE_DAYS; Integer free_days = DEFAULT_FREE_DAYS;
vehicle_price_days_map.put(BASE_PRICE_VAL,vehicle_price); vehicle_price_days_map.put(BASE_PRICE_VAL,vehicle_price);
if (festivalDayMap != null && !festivalDayMap.isEmpty()) { if (MapUtil.isNotEmpty(festivalDayMap)) {
VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO = festivalDayMap.get(current_date); VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO = festivalDayMap.get(current_date);
if (Objects.nonNull(vehicleModelHolidayPriceDTO)) { if (Objects.nonNull(vehicleModelHolidayPriceDTO)) {
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue())); vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue()));
...@@ -412,7 +413,6 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -412,7 +413,6 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
} }
public static void main(String[] args) { public static void main(String[] args) {
AtomicReference<Date> start = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-03").atStartOfDay(ZoneId.systemDefault()).toInstant())); 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())); AtomicReference<Date> end = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-29").atStartOfDay(ZoneId.systemDefault()).toInstant()));
......
...@@ -24,9 +24,7 @@ import java.time.LocalDate; ...@@ -24,9 +24,7 @@ import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author libin * @author libin
...@@ -56,7 +54,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -56,7 +54,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
while (startLocaldate.isBefore(endLocaldate) || startLocaldate.isEqual(endLocaldate)){ while (startLocaldate.isBefore(endLocaldate) || startLocaldate.isEqual(endLocaldate)){
vehicleModelHolidayPrice = new VehicleModelHolidayPrice(); vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
BeanUtils.copyProperties(vehicleModelHolidayPriceSaveDTO, vehicleModelHolidayPrice); BeanUtils.copyProperties(vehicleModelHolidayPriceSaveDTO, vehicleModelHolidayPrice);
Date date = DateUtils.localDateToDate(startLocaldate.atStartOfDay(ZoneId.systemDefault()).toLocalDate()); Date date = DateUtils.localDateToDate(startLocaldate);
vehicleModelHolidayPrice.setFestivalDay(date); vehicleModelHolidayPrice.setFestivalDay(date);
vehicleModelHolidayPriceList.add(vehicleModelHolidayPrice); vehicleModelHolidayPriceList.add(vehicleModelHolidayPrice);
startLocaldate = startLocaldate.plusDays(1); startLocaldate = startLocaldate.plusDays(1);
...@@ -71,6 +69,10 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -71,6 +69,10 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
modelHolidayPrice.setUpdTime(new Date()); modelHolidayPrice.setUpdTime(new Date());
mapper.updateByExampleSelective(modelHolidayPrice, example); mapper.updateByExampleSelective(modelHolidayPrice, example);
} }
Festival festival = new Festival();
festival.setName(vehicleModelHolidayPriceSaveDTO.getFestival());
festival.setId(vehicleModelHolidayPriceSaveDTO.getId());
festivalBiz.add(festival);
} else { } else {
Festival festival = new Festival(); Festival festival = new Festival();
festival.setName(vehicleModelHolidayPriceSaveDTO.getFestival()); festival.setName(vehicleModelHolidayPriceSaveDTO.getFestival());
...@@ -193,6 +195,16 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -193,6 +195,16 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
return modelHolidayPriceSaveDTO; return modelHolidayPriceSaveDTO;
} }
public void deleteById(Integer festivalId){
Example example = new Example(VehicleModelHolidayPrice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("festivalId",festivalId);
VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
vehicleModelHolidayPrice.setIsDel(1);
mapper.updateByExampleSelective(vehicleModelHolidayPrice,example);
festivalBiz.deleteById(festivalId);
}
/** /**
* 设置查询条件日期 * 设置查询条件日期
* *
......
...@@ -46,4 +46,10 @@ public class VehicleModelHolidayPriceAdminController { ...@@ -46,4 +46,10 @@ public class VehicleModelHolidayPriceAdminController {
List<VehicleModelHolidayPriceVo> priceVoPageDataVO = vehicleModelHolidayPriceBiz.listVehicleModelHolidayPrice(vehicleModelHolidayPriceFindDTO); List<VehicleModelHolidayPriceVo> priceVoPageDataVO = vehicleModelHolidayPriceBiz.listVehicleModelHolidayPrice(vehicleModelHolidayPriceFindDTO);
return ObjectRestResponse.succ(priceVoPageDataVO); return ObjectRestResponse.succ(priceVoPageDataVO);
} }
@DeleteMapping("/{id}")
public ObjectRestResponse<Void> delete(@PathVariable(value = "id") Integer id){
vehicleModelHolidayPriceBiz.deleteById(id);
return ObjectRestResponse.succ();
}
} }
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