|
|
@@ -45,30 +45,46 @@ class freight
|
|
|
$cost = 8; //起步价
|
|
|
//距离计算
|
|
|
Yii::info("距离为:".$phpStatDistance);
|
|
|
- if($phpStatDistance > 10){
|
|
|
- //每新增5km 加6
|
|
|
- $diff = ceil(($phpStatDistance - 10) / 5);
|
|
|
- $diffCost = $diff*6;
|
|
|
- $cost += $diffCost;
|
|
|
- }elseif ($phpStatDistance <=10 && $phpStatDistance > 2){
|
|
|
- //每新增1km加2
|
|
|
- $diff = ceil(($phpStatDistance - 2));
|
|
|
- $diffCost = $diff*2;
|
|
|
- $cost += $diffCost;
|
|
|
+ $phpStatDistance = $phpStatDistance -2;
|
|
|
+ if($phpStatDistance){
|
|
|
+ if ($phpStatDistance <=10){
|
|
|
+ //每新增1km加2
|
|
|
+ $diffCost = $phpStatDistance*2;
|
|
|
+ $cost += $diffCost;
|
|
|
+ }else{
|
|
|
+ //8*2
|
|
|
+ $cost += 16;
|
|
|
+ }
|
|
|
+ if($phpStatDistance > 10){
|
|
|
+ //每新增5km 加6
|
|
|
+ $diff = ceil(($phpStatDistance - 10) / 5);
|
|
|
+ $diffCost = $diff*6;
|
|
|
+ $cost += $diffCost;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//重量计算
|
|
|
Yii::info("重量为:".$weight);
|
|
|
- if($weight > 10){
|
|
|
- //每新增 5kg 加6
|
|
|
- $diff = ceil(($weight - 10) / 5);
|
|
|
- $diffCost = $diff*6;
|
|
|
- $cost += $diffCost;
|
|
|
- }elseif ($weight <=10 && $weight > 2){
|
|
|
- //每增1 kg 加2
|
|
|
- $diff = ceil(($weight - 2));
|
|
|
- $diffCost = $diff*2;
|
|
|
- $cost += $diffCost;
|
|
|
+ $weight = $weight -2;
|
|
|
+ if($weight){
|
|
|
+ if ($weight <=10){
|
|
|
+ //每增1 kg 加2
|
|
|
+ $diff = ceil(($weight - 2));
|
|
|
+ $diffCost = $diff*2;
|
|
|
+ $cost += $diffCost;
|
|
|
+ $weight = $weight -2;
|
|
|
+ }else{
|
|
|
+ //8*2
|
|
|
+ $cost += 16;
|
|
|
+ }
|
|
|
+ if($weight > 10){
|
|
|
+ //每新增 5kg 加6
|
|
|
+ $diff = ceil(($weight - 10) / 5);
|
|
|
+ $diffCost = $diff*6;
|
|
|
+ $cost += $diffCost;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
return $cost;
|
|
|
}
|
|
|
|