Przeglądaj źródła

优化运费计算

林琦海 5 lat temu
rodzic
commit
22abeebfac
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      common/components/freight.php

+ 5 - 2
common/components/freight.php

@@ -49,7 +49,8 @@ class freight
         if($phpStatDistance > 0){
             if ($phpStatDistance <=10){
                 //每新增1km加2
-                $diffCost = $phpStatDistance*2;
+                $phpStatDistanceCeil = ceil($phpStatDistance);
+                $diffCost = $phpStatDistanceCeil*2;
                 $cost += $diffCost;
             }else{
                 //8*2
@@ -65,11 +66,13 @@ class freight
 
         //重量计算
         Yii::info("重量为:".$weight);
+        $weight = 5.5;
         $weight = $weight -2;
         if($weight > 0){
             if ($weight <=10){
                 //每增1 kg 加2
-                $diffCost = $weight*2;
+                $weightCeil = ceil($weight);
+                $diffCost = $weightCeil*2;
                 $cost += $diffCost;
                 $weight = $weight -2;
             }else{