...
|
...
|
@@ -105,7 +105,7 @@ class OrderController extends HomeBaseController{ |
|
|
public function getPrice($start_time=1543298302,$end_time=1543303733){
|
|
|
$cost=Db::name('cost')->where('id',1)->find();
|
|
|
$interval = Db::name('interval')->where('id',1)->find();
|
|
|
|
|
|
$free=$cost['free'];
|
|
|
//用了多少天
|
|
|
$day=floor(($end_time-$start_time)/86400);
|
|
|
$price=$day*1;
|
...
|
...
|
@@ -137,11 +137,13 @@ class OrderController extends HomeBaseController{ |
|
|
if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time < $new_start_time && $new_end_time < $stateTime)){
|
|
|
//存在首小时免费
|
|
|
$price +=(ceil(($new_end_time-$new_start_time)/3600) * $cost['cost']);
|
|
|
$price-=$cost['cost'];
|
|
|
}
|
|
|
//与预设时间段的头部重合
|
|
|
if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time > $stateTime && $new_end_time < strtotime('24:00:00'))){
|
|
|
//存在首小时免费
|
|
|
$price += (ceil(($stateTime-$new_start_time)/3600) * $cost['cost'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price']);
|
|
|
$price-=$cost['cost'];
|
|
|
}
|
|
|
//在预设时间段右边并不与之重合
|
|
|
if (($new_start_time > $stateTime && $new_start_time < strtotime('24:00:00')) && ($new_end_time > $new_start_time && $new_end_time < strtotime('24:00:00'))){
|
...
|
...
|
@@ -159,25 +161,41 @@ class OrderController extends HomeBaseController{ |
|
|
+ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price'];
|
|
|
}
|
|
|
//昨天预设开始前使用,今天预设结束前停止
|
|
|
if(($new_start_time > (strtotime('00:00:00')-86400) && $new_start_time < $YesterdayEndTime) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){
|
|
|
$price+= ceil(($YesterdayEndTime-$new_start_time)/3600) * $interval['price']
|
|
|
+ceil(($YesterdayStateTime-$YesterdayEndTime)/3600) * $cost['cost']
|
|
|
+ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price'];
|
|
|
if(($new_start_time > $YesterdayEndTime && $new_start_time < $YesterdayStateTime) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){
|
|
|
//存在首小时免费
|
|
|
$price+= ceil(($YesterdayStateTime-$new_start_time)/3600) * $cost['cost']
|
|
|
+ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price'];
|
|
|
|
|
|
$price-=$cost['cost'];
|
|
|
}
|
|
|
//昨天预设开始前使用,今天预设结束后停止
|
|
|
if(($new_start_time > $YesterdayEndTime && $new_start_time < $YesterdayStateTime) && ($new_end_time > $endTime && $new_end_time < $stateTime)){
|
|
|
//存在首小时免费
|
|
|
$price+= ceil(($YesterdayStateTime-$new_start_time)/3600) * $cost['cost']
|
|
|
+ceil(($endTime-$YesterdayStateTime)/3600) * $interval['price']
|
|
|
+ceil(($new_end_time-$endTime)/3600) * $cost['cost'];
|
|
|
|
|
|
|
|
|
$price-=$cost['cost'];
|
|
|
}
|
|
|
//昨天预设开始后使用,今天预设结束前停止
|
|
|
|
|
|
if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){
|
|
|
$price+= ceil(($new_end_time-$new_start_time)/3600) * $interval['price'];
|
|
|
}
|
|
|
//昨天预设开始后使用,今天预设结束后停止
|
|
|
|
|
|
if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > $endTime && $new_end_time < $stateTime)){
|
|
|
$price+= ceil(($endTime-$new_start_time)/3600) * $interval['price']
|
|
|
+ceil(($new_end_time-$endTime)/3600) * $cost['cost'];
|
|
|
}
|
|
|
//昨天预设开始后使用,今天预设开始前停止
|
|
|
|
|
|
if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > $stateTime && $new_end_time < ($new_start_time+86400))){
|
|
|
$price+= ceil(($endTime-$new_start_time)/3600) * $interval['price']
|
|
|
+ceil(($stateTime-$endTime)/3600) * $cost['cost']
|
|
|
+ceil(($new_end_time-$stateTime)/3600) * $interval['price'];
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
//不跨天
|
|
|
|
|
|
|
|
|
}
|
|
|
return $price;
|
|
|
}
|
...
|
...
|
|