فهرست منبع

新停车费计费规则

qzyReal 2 سال پیش
والد
کامیت
bfd811fe24

+ 3 - 0
sp-server/src/main/java/com/pj/api/jh/service/JhService.java

@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.nio.charset.Charset;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -183,4 +184,6 @@ public class JhService {
     }
 
 
+
+
 }

+ 9 - 9
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -486,25 +486,25 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         if (minutes < 0 || minutes < partConfig.getFreeMinutes()) {
             return zero;
         }
-        BigDecimal extraPrice=partConfig.getExtraPrice();
-        BigDecimal basePrice=partConfig.getBasePrice();
+        BigDecimal extraPrice = partConfig.getExtraPrice();
+        BigDecimal basePrice = partConfig.getBasePrice();
         BigDecimal uniPrice = basePrice.add(extraPrice);//超过24小时之后每24个小时收费金额
         //4.2~9.6
         if (carSize <= partConfig.getMildCarLength() && carSize > partConfig.getFreeCarLength()) {
-            basePrice=partConfig.getMildCarBasePrice();
+            basePrice = partConfig.getMildCarBasePrice();
             uniPrice = basePrice.add(extraPrice);
         }
         //间隔小时
         long hours = ChronoUnit.HOURS.between(inDayTime, outDayTime);
-        final  int hoursOf24=24;
+        final int hoursOf24 = 24;
         //24小时内只用交20或者30元
-        if (hours<hoursOf24){
+        if (hours < hoursOf24) {
             return basePrice;
         }
         //24小时个数
-        int count=(int) Math.ceil(NumberUtil.div(hours, hoursOf24));
+        long count = hours / hoursOf24;
         //超过24小时总停车费
-        BigDecimal price=new BigDecimal(count).multiply(uniPrice);
+        BigDecimal price = new BigDecimal(count).multiply(uniPrice);
         return price.add(basePrice);
 
     }
@@ -570,10 +570,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 }
                 partMoney = this.calculationPartMoney(inTime, now, tbBusinessCar.getCarSize());
             }
-            if (StrUtil.isNotEmpty(tbBusinessCar.getColor())&&tbBusinessCar.getCarSize()!=null) {
+            if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
                 String freeColor = partConfig.getFreeColor();
                 //4.2米以下蓝色车辆
-                if (tbBusinessCar.getColor().contains(freeColor)&&tbBusinessCar.getCarSize()<=partConfig.getFreeCarLength()) {
+                if (tbBusinessCar.getColor().contains(freeColor) && tbBusinessCar.getCarSize() <= partConfig.getFreeCarLength()) {
                     partMoney = new BigDecimal("0");
                 }
             }