|
@@ -412,7 +412,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
iTime = tbBusiness.getChinaCarInTime();
|
|
|
oTime = tbBusiness.getChinaCarOutTime();
|
|
|
}
|
|
|
- BigDecimal price = calculationPartMoney(iTime, oTime);
|
|
|
+ BigDecimal price = calculationPartMoney(iTime, oTime, true);
|
|
|
if (itemType.contains("中国")) {
|
|
|
int len = tbBusiness.getCardNo().split(" ").length;
|
|
|
tbBusiness.setChinaPartMoney(price.multiply(new BigDecimal(len)));
|
|
@@ -422,7 +422,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
tbBusiness.setTotalMoney(tbBusiness.getItemPrice().add(tbBusiness.getChinaPartMoney()).add(tbBusiness.getPartMoney()));
|
|
|
}
|
|
|
|
|
|
- public BigDecimal calculationPartMoney(Date iTime, Date oTime) {
|
|
|
+ public BigDecimal calculationPartMoney(Date iTime, Date oTime, boolean businessCar) {
|
|
|
LocalDateTime inDayTime = iTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
LocalDateTime outDayTime = oTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
long minutes = ChronoUnit.MINUTES.between(inDayTime, outDayTime);
|
|
@@ -432,11 +432,16 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
long days = ChronoUnit.DAYS.between(inDayTime.toLocalDate(), outDayTime.toLocalDate());
|
|
|
long hour = ChronoUnit.HOURS.between(inDayTime, outDayTime);
|
|
|
- BigDecimal basePrice = partConfig.getBasePrice();
|
|
|
+ BigDecimal basePrice = businessCar ? partConfig.getBasePrice() : new BigDecimal("0");
|
|
|
+ BigDecimal p = partConfig.getBasePrice();//乘积因子
|
|
|
BigDecimal extraPrice = partConfig.getExtraPrice();
|
|
|
- return basePrice.add(basePrice.multiply(new BigDecimal(hour / 24))).add(new BigDecimal(days).multiply(extraPrice));
|
|
|
+ if (minutes>partConfig.getFreeMinutes()&&minutes<24*60){
|
|
|
+ days=1;
|
|
|
+ }
|
|
|
+ return basePrice.add(p.multiply(new BigDecimal(hour / 24))).add(new BigDecimal(days).multiply(extraPrice));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @param carNo
|
|
|
* @param inOrOut 1入 2出
|
|
@@ -468,23 +473,19 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
String businessId = car.getBusinessId();
|
|
|
result.put("businessId", businessId);
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(businessId);
|
|
|
- if (cars.isEmpty()){
|
|
|
+ if (cars.isEmpty()) {
|
|
|
cars.add(car);
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
List<Map<String, Object>> carsList = new ArrayList<>();
|
|
|
for (TbBusinessCar tbBusinessCar : cars) {
|
|
|
- double partMoney = tbBusinessCar.getBasePartMoney().doubleValue();
|
|
|
- if (!StrUtil.equals("STATE", state)) {
|
|
|
- Date inTime = tbBusinessCar.getRealInTime();
|
|
|
- if (inTime != null) {
|
|
|
- BigDecimal price = this.calculationPartMoney(inTime, now);
|
|
|
- BigDecimal money = tbBusinessCar.getMoney();
|
|
|
- BigDecimal basePrice = tbBusinessCar.getBasePartMoney();
|
|
|
- partMoney = money == null ? price.subtract(basePrice).doubleValue() : price.subtract(money).doubleValue();
|
|
|
- } else {
|
|
|
- partMoney = 0D;
|
|
|
- }
|
|
|
+ BigDecimal basePrice = StrUtil.isEmpty(tbBusinessCar.getBusinessId()) ? new BigDecimal("0") : tbBusinessCar.getBasePartMoney();
|
|
|
+ double partMoney = basePrice.doubleValue();
|
|
|
+ Date inTime = tbBusinessCar.getRealInTime();
|
|
|
+ if (inTime != null) {
|
|
|
+ BigDecimal price = this.calculationPartMoney(inTime, now, StrUtil.isNotEmpty(tbBusinessCar.getBusinessId()));
|
|
|
+ BigDecimal money = tbBusinessCar.getMoney();
|
|
|
+ partMoney = money == null ? price.subtract(basePrice).doubleValue() : price.subtract(money).doubleValue();
|
|
|
}
|
|
|
Map<String, Object> carMap = new HashMap<>();
|
|
|
carMap.put("price", partMoney);
|