Просмотр исходного кода

优化临时停车费秒的问题

java110 лет назад: 3
Родитель
Сommit
45e060f8d3

+ 34 - 1
java110-core/src/main/java/com/java110/core/factory/TempCarFeeFactory.java

@@ -48,7 +48,7 @@ public class TempCarFeeFactory {
      * @param carInoutDto
      * @return
      */
-    public static long getTempCarMin(CarInoutDto carInoutDto) {
+    public static long getTempCarCeilMin(CarInoutDto carInoutDto) {
 
         //支付时间是否超过15分钟
         Date payTime = null;
@@ -77,6 +77,39 @@ public class TempCarFeeFactory {
         return 0;
     }
 
+    /**
+     * 判断 用户是支付完成
+     *
+     * @param carInoutDto
+     * @return
+     */
+    public static long getTempCarMin(CarInoutDto carInoutDto) {
+
+        //支付时间是否超过15分钟
+        Date payTime = null;
+        double min = 0.0;
+        try {
+            //不是支付完成 状态
+            if (CarInoutDto.STATE_PAY.equals(carInoutDto.getState())) {
+
+                try {
+                    payTime = DateUtil.getDateFromString(carInoutDto.getPayTime(), DateUtil.DATE_FORMATE_STRING_A);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+            } else {
+                payTime = DateUtil.getDateFromString(carInoutDto.getInTime(), DateUtil.DATE_FORMATE_STRING_A);
+            }
+            Date nowTime = DateUtil.getCurrentDate();
+            //支付完成超过15分钟
+
+            return (nowTime.getTime() - payTime.getTime()) / (60 * 1000);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
     public static double getAttrValueDouble(List<TempCarFeeConfigAttrDto> tempCarFeeConfigAttrDtos, String specCd) {
 
         for (TempCarFeeConfigAttrDto tempCarFeeConfigAttrDto : tempCarFeeConfigAttrDtos) {

+ 1 - 1
service-fee/src/main/java/com/java110/fee/tempCar/Basic2ComputeTempCarFeeImpl.java

@@ -42,7 +42,7 @@ public class Basic2ComputeTempCarFeeImpl extends BaseComputeTempCarFee {
 
 
         //获取停车时间
-        long min = TempCarFeeFactory.getTempCarMin(carInoutDto);
+        long min = TempCarFeeFactory.getTempCarCeilMin(carInoutDto);
 
         //免费分钟
         int freeMin = TempCarFeeFactory.getAttrValueInt(tempCarFeeConfigAttrDtos, SPEC_CD_5600012010);

+ 1 - 1
service-fee/src/main/java/com/java110/fee/tempCar/BasicComputeTempCarFeeImpl.java

@@ -42,7 +42,7 @@ public class BasicComputeTempCarFeeImpl extends BaseComputeTempCarFee {
 
 
         //获取停车时间
-        long min = TempCarFeeFactory.getTempCarMin(carInoutDto);
+        long min = TempCarFeeFactory.getTempCarCeilMin(carInoutDto);
 
         int freeMin = TempCarFeeFactory.getAttrValueInt(tempCarFeeConfigAttrDtos, SPEC_CD_5600012001);