Commit 8678fc07 authored by 周健威's avatar 周健威

修改申请

parent 71abd114
...@@ -228,5 +228,9 @@ public class ShuntApply implements Serializable { ...@@ -228,5 +228,9 @@ public class ShuntApply implements Serializable {
@ApiModelProperty("型号名称") @ApiModelProperty("型号名称")
private String categoryName; private String categoryName;
@Column(name = "is_del")
private Integer isDel;
@Column(name = "is_bizdel")
private Integer isBizdel;
} }
...@@ -58,7 +58,7 @@ public class OrderItemBiz extends BaseBiz<OrderItemMapper,OrderItem> { ...@@ -58,7 +58,7 @@ public class OrderItemBiz extends BaseBiz<OrderItemMapper,OrderItem> {
Date overStart = DateUtil.offsetDay(endDate, 1); Date overStart = DateUtil.offsetDay(endDate, 1);
Date overEnd = DateUtil.offsetDay(overStart, overDays); Date overEnd = DateUtil.offsetDay(overStart, overDays);
// List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.findVehicleModelCalendarPriceByDate(overStart.getTime(), overEnd.getTime(), modelId, userId).getData(); // List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.findVehicleModelCalendarPriceByDate(overStart.getTime(), overEnd.getTime(), modelId, userId).getData();
List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.getPriceByVehicleIdFeignV2(vehicleId, overStart.toString(), overEnd.toString(), userId).getData(); List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.getPriceByVehicleIdFeignV2(vehicleId, overStart.getTime(), overEnd.getTime(), userId).getData();
for(VehicleModelCalendarPriceDTO vmcpd : overlist) { for(VehicleModelCalendarPriceDTO vmcpd : overlist) {
overAmountList.add(BeanUtil.toBean(vmcpd, VMCalendarPriceCostDTO.class)); overAmountList.add(BeanUtil.toBean(vmcpd, VMCalendarPriceCostDTO.class));
......
...@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.price.DelayAddPriceVO; ...@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.price.DelayAddPriceVO;
import com.xxfc.platform.universal.constant.DictionaryKey; import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.inter.CalculateInterface;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO; import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO;
...@@ -56,7 +57,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.*; ...@@ -56,7 +57,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.*;
*/ */
@Slf4j @Slf4j
@Service @Service
public class OrderCalculateBiz { public class OrderCalculateBiz implements CalculateInterface {
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
...@@ -85,6 +86,11 @@ public class OrderCalculateBiz { ...@@ -85,6 +86,11 @@ public class OrderCalculateBiz {
@Autowired @Autowired
OrderRentVehicleBiz orderRentVehicleBiz; OrderRentVehicleBiz orderRentVehicleBiz;
@Override
public ThirdFeign getThirdFeign() {
return thirdFeign;
}
public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, OrderRentVehicleDetail orvd, Integer useDays, OrderAccountDetail oad, Boolean isCancel) { public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, OrderRentVehicleDetail orvd, Integer useDays, OrderAccountDetail oad, Boolean isCancel) {
BigDecimal refundAmount = BigDecimal.ZERO; BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO; BigDecimal consumeAmount = BigDecimal.ZERO;
...@@ -351,73 +357,73 @@ public class OrderCalculateBiz { ...@@ -351,73 +357,73 @@ public class OrderCalculateBiz {
return inProgressVO; return inProgressVO;
} }
/** // /**
* 计算包含多少天 // * 计算包含多少天
* @param startLong // * @param startLong
* @param endLong // * @param endLong
* @return // * @return
*/ // */
public Integer getIncludeDays(Long startLong, Long endLong) { // public Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); // Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L); // Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24; // Long dayLong = hourLong * 24;
Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong; // Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong;
//
//计算:使用天数 当前时间 - 开始时间的0时0分0秒 // //计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong; // Long bookTimeLag = endLong - startLong;
//
//默认 已使用了一天 // //默认 已使用了一天
if(bookTimeLag <= 0) { // if(bookTimeLag <= 0) {
return 1; // return 1;
} // }
//
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + "")); // log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ "")); // log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong+ ""), 0, RoundingMode.DOWN).intValue(); // Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%dayLong; // Long excess = bookTimeLag%dayLong;
if(excess > bufferLong) { // if(excess > bufferLong) {
bookDays += 1; // bookDays += 1;
} // }
//
if(0 == bookDays) { // if(0 == bookDays) {
bookDays = 1; // bookDays = 1;
} // }
return bookDays; // return bookDays;
} // }
//
/** // /**
* 计算包含多少小时 // * 计算包含多少小时
* @param startLong // * @param startLong
* @param endLong // * @param endLong
* @return // * @return
*/ // */
public Integer getIncludeHours(Long startLong, Long endLong) { // public Integer getIncludeHours(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); // Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L); // Long hourLong = (60L * 60L * 1000L);
//Long dayLong = hourLong * 24; // //Long dayLong = hourLong * 24;
Long bufferLong = 0L; // Long bufferLong = 0L;
//
//计算:使用天数 当前时间 - 开始时间的0时0分0秒 // //计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong; // Long bookTimeLag = endLong - startLong;
//
//默认 已使用了1小时 // //默认 已使用了1小时
if(bookTimeLag <= 0) { // if(bookTimeLag <= 0) {
return 1; // return 1;
} // }
//
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + "")); // log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal(hourLong+ "")); // log.info("divide {}", new BigDecimal(hourLong+ ""));
Integer hourDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(hourLong+ ""), 0, RoundingMode.DOWN).intValue(); // Integer hourDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(hourLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%hourLong; // Long excess = bookTimeLag%hourLong;
if(excess > bufferLong) { // if(excess > bufferLong) {
hourDays += 1; // hourDays += 1;
} // }
//
if(0 == hourDays) { // if(0 == hourDays) {
hourDays = 1; // hourDays = 1;
} // }
return hourDays; // return hourDays;
} // }
public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) { public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) {
//根据no 查订单 //根据no 查订单
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface; import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
...@@ -98,8 +99,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -98,8 +99,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
// if(null != shuntApply.getCategoryId()) { // if(null != shuntApply.getCategoryId()) {
// VehicleCategory vehicleCategory = vehicleFeign.getVehicleCategory(shuntApply.getCategoryId()).getData(); // VehicleCategory vehicleCategory = vehicleFeign.getVehicleCategory(shuntApply.getCategoryId()).getData();
// shuntApply.setCategoryName(vehicleCategory.getName()); // shuntApply.setCategoryName(vehicleCategory.getName());
// }else if{
//
// } // }
shuntApply.setUserId(getCurrentUserIdInt()); shuntApply.setUserId(getCurrentUserIdInt());
...@@ -141,13 +140,12 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -141,13 +140,12 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
Query query = new Query(dto); Query query = new Query(dto);
PageDataVO<ShuntApplyVO> pages = PageDataVO.pageInfo(query, () -> baseBiz.selectByWeekend(w -> { PageDataVO<ShuntApplyVO> pages = PageDataVO.pageInfo(query, () -> baseBiz.selectByWeekend(w -> {
w.andEqualTo(ShuntApply::getUserId, dto.getUserId()); w.andEqualTo(ShuntApply::getUserId, dto.getUserId());
w.andEqualTo(ShuntApply::getIsDel, SYS_FALSE);
return w; return w;
}, " crt_time desc "), ShuntApplyVO.class); }, " crt_time desc "), ShuntApplyVO.class);
// pages.getData().forEach(data -> { pages.getData().forEach(data -> {
// if(null != data.getCategoryId()) { data.setAppUserDTO(userFeign.userDetailById(data.getUserId()).getData());
// data.setVehicleCategory(vehicleFeign.getVehicleCategory(data.getCategoryId()).getData()); });
// }
// });
return ObjectRestResponse.succ(pages); return ObjectRestResponse.succ(pages);
} }
...@@ -203,6 +201,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -203,6 +201,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
OrderPageVO orderPageVO; OrderPageVO orderPageVO;
VehicleCategory vehicleCategory; VehicleCategory vehicleCategory;
VehicleBrand vehicleBrand; VehicleBrand vehicleBrand;
AppUserDTO appUserDTO;
} }
@Data @Data
...@@ -227,16 +226,15 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -227,16 +226,15 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
PageDataVO<StewardShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> { PageDataVO<StewardShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
if(null != dto.getCityCode()) { if(null != dto.getCityCode()) {
w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode()); w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode());
w.andEqualTo(ShuntApply::getIsDel, SYS_FALSE);
} }
w.andEqualTo(ShuntApply::getStatus, STATUS_CRT); w.andEqualTo(ShuntApply::getStatus, STATUS_CRT);
return w; return w;
}, " crt_time desc "), StewardShuntApply.class); }, " crt_time desc "), StewardShuntApply.class);
// list.getData().forEach(data -> { list.getData().forEach(data -> {
// if(null != data.getCategoryId()) { data.setAppUserDTO(userFeign.userDetailById(data.getUserId()).getData());
// data.setVehicleCategory(vehicleFeign.getVehicleCategory(data.getCategoryId()).getData()); });
// }
// });
return ObjectRestResponse.succ(list); return ObjectRestResponse.succ(list);
} }
...@@ -304,6 +302,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -304,6 +302,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
Integer companyId = userDTO.getCompanyId(); Integer companyId = userDTO.getCompanyId();
ShuntApply shuntApply = baseBiz.selectById(applyId); ShuntApply shuntApply = baseBiz.selectById(applyId);
StewardShuntApply shuntApplyVO = BeanUtil.toBean(shuntApply, StewardShuntApply.class); StewardShuntApply shuntApplyVO = BeanUtil.toBean(shuntApply, StewardShuntApply.class);
shuntApplyVO.setAppUserDTO(userFeign.userDetailById(shuntApplyVO.getUserId()).getData());
RentVehicleBookDTO rbd = new RentVehicleBookDTO(); RentVehicleBookDTO rbd = new RentVehicleBookDTO();
//rbd.setModelId(shuntApply.getModelId()); //rbd.setModelId(shuntApply.getModelId());
rbd.setBrandId(shuntApply.getBrandId()); rbd.setBrandId(shuntApply.getBrandId());
...@@ -356,6 +355,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -356,6 +355,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId()); w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId());
if(StrUtil.isNotBlank(dto.getMultiStatus())) { if(StrUtil.isNotBlank(dto.getMultiStatus())) {
w.andIn(ShuntApply::getStatus, CollUtil.toList(dto.getMultiStatus().split(","))); w.andIn(ShuntApply::getStatus, CollUtil.toList(dto.getMultiStatus().split(",")));
w.andEqualTo(ShuntApply::getIsBizdel, SYS_FALSE);
} }
return w; return w;
}), ShuntApplyController.ShuntApplyVO.class); }), ShuntApplyController.ShuntApplyVO.class);
...@@ -400,5 +400,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -400,5 +400,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
List<UsableVeicleVO> vehicles; List<UsableVeicleVO> vehicles;
VehicleCategory vehicleCategory; VehicleCategory vehicleCategory;
VehicleBrand vehicleBrand; VehicleBrand vehicleBrand;
AppUserDTO appUserDTO;
} }
} }
\ No newline at end of file
...@@ -403,7 +403,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -403,7 +403,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
Vehicle vehicle = detail.getVehicle(); Vehicle vehicle = detail.getVehicle();
detail.initDate(); detail.initDate();
List<VehicleModelCalendarPriceDTO> metaVmcpds = vehicleFeign.getPriceByVehicleIdFeignV2(detail.getVehicleId(), detail.getStartDateStr(), detail.getEndDateStr(), dto.getUserid()).getData(); List<VehicleModelCalendarPriceDTO> metaVmcpds = vehicleFeign.getPriceByVehicleIdFeignV2(detail.getVehicleId(), detail.getStartTime(), detail.getEndTime(), dto.getUserid()).getData();
List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds); List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds);
...@@ -589,7 +589,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -589,7 +589,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
Vehicle vehicle = detail.getVehicle(); Vehicle vehicle = detail.getVehicle();
detail.initDate(); detail.initDate();
List<VehicleModelCalendarPriceDTO> metaVmcpds = vehicleFeign.getPriceByVehicleIdFeignV2(detail.getVehicleId(), detail.getStartDateStr(), detail.getEndDateStr(), dto.getUserid()).getData(); List<VehicleModelCalendarPriceDTO> metaVmcpds = vehicleFeign.getPriceByVehicleIdFeignV2(detail.getVehicleId(), detail.getStartTime(), detail.getEndTime(), dto.getUserid()).getData();
List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds); List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds);
......
package com.xxfc.platform.universal.inter;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
public interface CalculateInterface {
public ThirdFeign getThirdFeign();
/**
* 计算包含多少天
* @param startLong
* @param endLong
* @return
*/
default Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = getThirdFeign().dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24;
Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong;
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong;
//默认 已使用了一天
if(bookTimeLag <= 0) {
return 1;
}
// log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
// log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%dayLong;
if(excess > bufferLong) {
bookDays += 1;
}
if(0 == bookDays) {
bookDays = 1;
}
return bookDays;
}
/**
* 计算包含多少小时
* @param startLong
* @param endLong
* @return
*/
default Integer getIncludeHours(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = getThirdFeign().dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
//Long dayLong = hourLong * 24;
Long bufferLong = 0L;
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong;
//默认 已使用了1小时
if(bookTimeLag <= 0) {
return 1;
}
// log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
// log.info("divide {}", new BigDecimal(hourLong+ ""));
Integer hourDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(hourLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%hourLong;
if(excess > bufferLong) {
hourDays += 1;
}
if(0 == hourDays) {
hourDays = 1;
}
return hourDays;
}
}
...@@ -243,7 +243,7 @@ public interface VehicleFeign { ...@@ -243,7 +243,7 @@ public interface VehicleFeign {
@GetMapping(value = "/vehicleInfo/v2/getPriceByVehicleFeign") @GetMapping(value = "/vehicleInfo/v2/getPriceByVehicleFeign")
public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getPriceByVehicleIdFeignV2( public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getPriceByVehicleIdFeignV2(
@RequestParam("vehicleId") String vehicleId, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("userId") Integer userId); @RequestParam("vehicleId") String vehicleId, @RequestParam("startDateTemp") Long startDateTemp, @RequestParam("endDateTemp") Long endDateTemp, @RequestParam("userId") Integer userId);
@RequestMapping(value = "/vehicleInfo/selectByParam", method = RequestMethod.GET) @RequestMapping(value = "/vehicleInfo/selectByParam", method = RequestMethod.GET)
public RestResponse<List<Vehicle>> vehicleSelectByParam(@RequestParam(value = "vehicle")Map<String, Object> vehicleMap); public RestResponse<List<Vehicle>> vehicleSelectByParam(@RequestParam(value = "vehicle")Map<String, Object> vehicleMap);
......
...@@ -8,6 +8,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -8,6 +8,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.universal.constant.DictionaryKey; import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.inter.CalculateInterface;
import com.xxfc.platform.vehicle.entity.VehicleModelCalendarPrice; import com.xxfc.platform.vehicle.entity.VehicleModelCalendarPrice;
import com.xxfc.platform.vehicle.mapper.VehicleModelCalendarPriceMapper; import com.xxfc.platform.vehicle.mapper.VehicleModelCalendarPriceMapper;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
...@@ -48,7 +49,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER; ...@@ -48,7 +49,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
@Service @Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j @Slf4j
public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPriceMapper, VehicleModelCalendarPrice> { public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPriceMapper, VehicleModelCalendarPrice> implements CalculateInterface {
private static final int START_OF_WEEK = 1; private static final int START_OF_WEEK = 1;
private static final int END_OF_WEEK = 7; private static final int END_OF_WEEK = 7;
private static final Integer DEFAULT_DISCOUNT = 100; private static final Integer DEFAULT_DISCOUNT = 100;
...@@ -63,6 +64,10 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -63,6 +64,10 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
private final UserFeign userFeign; private final UserFeign userFeign;
private final ThirdFeign thirdFeign; private final ThirdFeign thirdFeign;
@Override
public ThirdFeign getThirdFeign() {
return thirdFeign;
}
/** /**
* 保存 * 保存
...@@ -233,40 +238,74 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -233,40 +238,74 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
return vehicleModelCalendarPrice; return vehicleModelCalendarPrice;
} }
/** // /**
* 计算包含多少天 // * 计算包含多少天
* // *
* @param startLong // * @param startLong
* @param endLong // * @param endLong
* @return // * @return
*/ // */
private Integer getIncludeDays(Long startLong, Long endLong) { // private Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); // Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L); // Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24; // Long dayLong = hourLong * 24;
Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong; // Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong;
//
//计算:使用天数 当前时间 - 开始时间的0时0分0秒 // //计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong; // Long bookTimeLag = endLong - startLong;
//
//默认 已使用了一天 // //默认 已使用了一天
if(bookTimeLag <= 0) { // if(bookTimeLag <= 0) {
return 1; // return 1;
} // }
//
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + "")); // log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000) + "")); // log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000) + ""));
Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong + ""), 0, RoundingMode.DOWN).intValue(); // Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong + ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag % dayLong; // Long excess = bookTimeLag % dayLong;
if (excess > bufferLong) { // if (excess > bufferLong) {
bookDays += 1; // bookDays += 1;
} // }
//
if (0 == bookDays) { // if (0 == bookDays) {
bookDays = 1; // bookDays = 1;
} // }
return bookDays; // return bookDays;
} // }
//
// /**
// * 计算包含多少小时
// * @param startLong
// * @param endLong
// * @return
// */
// public Integer getIncludeHours(Long startLong, Long endLong) {
// Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
// Long hourLong = (60L * 60L * 1000L);
// //Long dayLong = hourLong * 24;
// Long bufferLong = 0L;
//
// //计算:使用天数 当前时间 - 开始时间的0时0分0秒
// Long bookTimeLag = endLong - startLong;
//
// //默认 已使用了1小时
// if(bookTimeLag <= 0) {
// return 1;
// }
//
// log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
// log.info("divide {}", new BigDecimal(hourLong+ ""));
// Integer hourDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(hourLong+ ""), 0, RoundingMode.DOWN).intValue();
// Long excess = bookTimeLag%hourLong;
// if(excess > bufferLong) {
// hourDays += 1;
// }
//
// if(0 == hourDays) {
// hourDays = 1;
// }
// return hourDays;
// }
/** /**
* 价格24小时处理 * 价格24小时处理
......
...@@ -16,6 +16,8 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -16,6 +16,8 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.inter.CalculateInterface;
import com.xxfc.platform.vehicle.biz.*; import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -55,7 +57,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; ...@@ -55,7 +57,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
@Slf4j @Slf4j
@IgnoreClientToken @IgnoreClientToken
@Api(value="租车相关车辆管理controller",tags={"租车相关车辆管理接口"}) @Api(value="租车相关车辆管理controller",tags={"租车相关车辆管理接口"})
public class RentVehicleController extends BaseController<VehicleBiz> implements UserRestInterface { public class RentVehicleController extends BaseController<VehicleBiz> implements UserRestInterface, CalculateInterface {
private static final Integer DEFAULT_DISCOUNT = 100; private static final Integer DEFAULT_DISCOUNT = 100;
private static final Integer DEFAULT_MEMBER_LEVEL = 0; private static final Integer DEFAULT_MEMBER_LEVEL = 0;
private static final Integer DEFAULT_MEMBER_TYPE = 0; private static final Integer DEFAULT_MEMBER_TYPE = 0;
...@@ -69,6 +71,9 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -69,6 +71,9 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
@Autowired
ThirdFeign thirdFeign;
@Autowired @Autowired
VehicleBiz vehicleBiz; VehicleBiz vehicleBiz;
...@@ -81,6 +86,12 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -81,6 +86,12 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
@Autowired @Autowired
VehicleHolidayPriceInfoBiz vehicleHolidayPriceInfoBiz; VehicleHolidayPriceInfoBiz vehicleHolidayPriceInfoBiz;
@Override
public ThirdFeign getThirdFeign() {
return thirdFeign;
}
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
} }
...@@ -406,26 +417,46 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -406,26 +417,46 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
@GetMapping(value = "/app/unauth/v2/getPriceByVehicle") @GetMapping(value = "/app/unauth/v2/getPriceByVehicle")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getByVehicleIdV2(String vehicleId, String startDate, String endDate, Long startDateTemp, Long endDateTemp) { public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getByVehicleIdV2(String vehicleId, String startDate, String endDate, Long startDateTemp, Long endDateTemp) {
if(null != startDateTemp) { // if(null != startDateTemp) {
startDate = DateUtil.date(startDateTemp).toString(); // startDate = DateUtil.date(startDateTemp).toString();
} // }
if(null != endDateTemp) { // if(null != endDateTemp) {
endDate = DateUtil.date(endDateTemp).toString(); // endDate = DateUtil.date(endDateTemp).toString();
} // }
return ObjectRestResponse.succ(getSynthesizePrice(vehicleId, startDate, endDate, getCurrentUserIdInt())); return ObjectRestResponse.succ(getSynthesizePrice(vehicleId, startDateTemp, endDateTemp, getCurrentUserIdInt()));
} }
@GetMapping(value = "v2/getPriceByVehicleFeign") @GetMapping(value = "v2/getPriceByVehicleFeign")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getByVehicleIdFeignV2(String vehicleId, String startDate, String endDate, Integer userId) { public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> getByVehicleIdFeignV2(String vehicleId, Long startDateTemp, Long endDateTemp, Integer userId) {
return ObjectRestResponse.succ(getSynthesizePrice(vehicleId, startDate, endDate, userId));
List<VehicleModelCalendarPriceDTO> list = getSynthesizePrice(vehicleId, startDateTemp, endDateTemp, userId);
Vehicle vehicle = vehicleBiz.selectOne(new Vehicle(){{
setId(vehicleId);
}});
List<VehicleModelCalendarPriceDTO> list2 = CollUtil.newArrayList();
if(list.size() > 0) {
Integer cycle = 0;
if(Vehicle.PRICE_TYPE_HOUR == vehicle.getPriceType()) {
cycle = getIncludeHours(startDateTemp, endDateTemp);
}else {
cycle = getIncludeDays(startDateTemp, endDateTemp);
}
for(int i = 0; i < cycle; i++) {
list2.add(list.get(i));
}
}
return ObjectRestResponse.succ(list2);
} }
public List<VehicleModelCalendarPriceDTO> getSynthesizePrice (String vehicleId, String startDate, String endDate, Integer userId) { public List<VehicleModelCalendarPriceDTO> getSynthesizePrice (String vehicleId, Long startDateTemp, Long endDateTemp, Integer userId) {
List<VehicleModelCalendarPriceDTO> priceDTOS = CollUtil.newArrayList(); List<VehicleModelCalendarPriceDTO> priceDTOS = CollUtil.newArrayList();
String startDate = DateUtil.date(startDateTemp).toString();
String endDate = DateUtil.date(endDateTemp).toString();
cn.hutool.core.date.DateTime beginOfStartDate = DateUtil.beginOfDay(DateUtil.parse(startDate)); cn.hutool.core.date.DateTime beginOfStartDate = DateUtil.beginOfDay(DateUtil.parse(startDate));
cn.hutool.core.date.DateTime endOfEndDate = DateUtil.endOfDay(DateUtil.parse(endDate)); cn.hutool.core.date.DateTime endOfEndDate = DateUtil.endOfDay(DateUtil.parse(endDate));
//获取基本和周末价格 //获取基本和周末价格company_info
Vehicle vehicle = vehicleBiz.selectOne(new Vehicle(){{ Vehicle vehicle = vehicleBiz.selectOne(new Vehicle(){{
setId(vehicleId); setId(vehicleId);
}}); }});
......
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