50 ){ return ""; // util::fail("重量太重了哦!"); } //后端计算距离 m $phpStatDistance = util::getDistance($startLat, $starLng, $endLat, $endLng); $phpStatDistance = $phpStatDistance/1000; if($phpStatDistance > 50) { return ""; // util::fail("距离太远了哦!"); } //起步 $cost = 9; //距离计算 Yii::info("距离为:".$phpStatDistance); $phpStatDistance = $phpStatDistance -2; if($phpStatDistance > 0){ if ($phpStatDistance <=10){ //每新增1km加2 $phpStatDistanceCeil = ceil($phpStatDistance); $diffCost = $phpStatDistanceCeil*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); $weight = $weight -2; if($weight > 0){ if ($weight <=10){ //每增1 kg 加2 $weightCeil = ceil($weight); $diffCost = $weightCeil*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; } }