Commit 73cc61fc authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents a936d315 79886bd9
......@@ -12,6 +12,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleModelDayPriceVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPriceMapper, VehicleModelCalendarPrice> {
private static final int START_OF_WEEK = 1;
private static final int END_OF_WEEK = 7;
......@@ -45,6 +47,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
private static final Integer DEFAULT_FREE_DAYS = 1;
private static final Integer DEFAULT_MEMBER_LEVEL = 0;
private static final String PRICE_VAL = "price";
private static final String BASE_PRICE_VAL="basePrice";
private static final String DAYS_VAL = "freeDays";
private final VehicleModelHolidayPriceBiz vehicleModelHolidayPriceBiz;
......@@ -241,8 +244,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);
if (Objects.nonNull(userId)) {
BaseUserMember baseUserMember = userFeign.findBaseUserMemberByUserId(userId);
log.info("用户会员信息:【{}】",baseUserMember);
discount = baseUserMember == null ? discount : baseUserMember.getDiscount();
memberLevel = baseUserMember == null ? memberLevel : baseUserMember.getMemberLevel();
}
......@@ -291,6 +296,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
if (price_freeDays_map != null && !price_freeDays_map.isEmpty()) {
vehicle_price = (BigDecimal) price_freeDays_map.get(PRICE_VAL);
free_days = (Integer) price_freeDays_map.get(DAYS_VAL);
no_discount_price = (BigDecimal) price_freeDays_map.get(BASE_PRICE_VAL);
}
vehicleModelCalendarPriceDTO.setNo_discount_price(no_discount_price);
vehicleModelCalendarPriceDTO.setPrice(vehicle_price.setScale(2, RoundingMode.HALF_UP));
......@@ -302,7 +308,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
}
/**
* 节假日价格和免费天数 处理
* (节假日|非节假日未设置的)价格和免费天数 处理
*
* @param festivalDayMap
* @param current_date
......@@ -311,17 +317,21 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @return
*/
public Map<String, Object> transfromPriceAndFreeDaysByDate(Map<Date, VehicleModelHolidayPriceDTO> festivalDayMap, Date current_date, BigDecimal vehicle_price, Integer discount) {
Map<String, Object> vehicle_price_days_map = new HashMap<>(2);
log.info("参数:【{}==当前时间:{}==价格:{}==折扣:{}】",festivalDayMap,current_date,vehicle_price,discount);
Map<String, Object> vehicle_price_days_map = new HashMap<>(3);
Integer free_days = DEFAULT_FREE_DAYS;
vehicle_price_days_map.put(BASE_PRICE_VAL,vehicle_price);
if (festivalDayMap != null && !festivalDayMap.isEmpty()) {
Integer free_days = DEFAULT_FREE_DAYS;
VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO = festivalDayMap.get(current_date);
if (Objects.nonNull(vehicleModelHolidayPriceDTO)) {
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue() * (discount / 100.00)));
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue()));
free_days = vehicleModelHolidayPriceDTO.getFreeDays() == null ? free_days : vehicleModelHolidayPriceDTO.getFreeDays();
vehicle_price_days_map.put(PRICE_VAL, vehicle_price);
vehicle_price_days_map.put(DAYS_VAL, free_days);
}
}
vehicle_price = vehicle_price.multiply(new BigDecimal(discount / 100.00));
vehicle_price_days_map.put(PRICE_VAL, vehicle_price);
vehicle_price_days_map.put(DAYS_VAL, free_days);
log.info("(节假日|非节假日未设置的)价格和免费天数 处理【{}】",vehicle_price_days_map);
return vehicle_price_days_map;
}
......
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