作者 董瑞恩
1 个管道 的构建 通过 耗费 1 秒

interface

... ... @@ -211,7 +211,7 @@ class AdminEquipmentController extends AdminBaseController{
$objActSheet->setCellValue('A1', '设备锁编号');
$objActSheet->setCellValue('B1', '设备锁名称');
$objActSheet->setCellValue('C1', '商品图');
$objActSheet->setCellValue('C1', '二维码');
$objActSheet->setCellValue('D1', '初始医院');
$objActSheet->setCellValue('E1', 'MAC地址');
$objActSheet->setCellValue('F1', '备注');
... ...
... ... @@ -107,36 +107,55 @@ class OrderController extends HomeBaseController{
$interval = Db::name('interval')->where('id',1)->find();
//用了多少天
$date=floor(($end_time-$start_time)/86400);
//去余数
$yu=($end_time-$start_time)%86400;
$new_start_time=$end_time-$yu;//时间戳
$day=floor(($end_time-$start_time)/86400);
$price=$day*1;
//去掉整天的金额
$new_start_time=$start_time+$day*86400;//时间戳
$new_end_time= $end_time;//时间戳
$hours_start_time=date('His',$new_start_time);
$hours_end_time=date('His',$new_end_time);
$stateTime=strtotime($interval['start_time']);
$endTime=strtotime($interval['end_time']);
$price=1;
//判断是否跨天
//判断预设时间段是否跨天
if ($endTime < $stateTime){
//设备使用时间段是否跨天(不跨天)
if ($hours_end_time > $hours_start_time){
if ($new_start_time> strtotime('00:00:00') && $new_start_time < $endTime && $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 > strtotime('00:00:00') && $new_start_time < $endTime) && ($new_end_time > $new_start_time && $new_end_time < $endTime)){
$price +=(ceil(($new_end_time-$new_start_time)/3600) * $interval['price']);
}
if ($new_start_time> strtotime('00:00:00') && $new_start_time < $endTime && $new_end_time > $stateTime){
$price=ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price'] + ceil(($stateTime-$endTime)/3600) * $cost['cost'];
//与预设时间段的尾部重合
if (($new_start_time > strtotime('00:00:00') && $new_start_time < $endTime) && ($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 > $endTime && $new_end_time < $stateTime){
$price=ceil(($new_end_time-$new_start_time)/3600) * $cost['cost'];
//与预设时间段的头尾都重合
if (($new_start_time > strtotime('00:00:00') && $new_start_time < $endTime) && $new_end_time > $stateTime){
$price +=(ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price'] + ceil(($stateTime-$endTime)/3600) * $cost['cost']);
}
//不与预设时间段重合
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']);
}
if ($new_start_time > $endTime && $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'];
//与预设时间段的头部重合
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']);
}
//在预设时间段右边并不与之重合
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'))){
$price +=(ceil(($new_end_time-$new_start_time)/3600) * $interval['price']);
}
//设备使用时间段是否跨天(跨天:开始时间在昨天,结束时间在今天)
}else{
$YesterdayStateTime=$stateTime-86400;
$YesterdayEndTime=$endTime-86400;
//开始时间在预设开始时间的前面OR结束时间在预设结束时间的前面
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'];
}
}
}else{
... ...
... ... @@ -125,6 +125,9 @@ class UsersController extends HomeBaseController{
public function getOrderById(){
$users_id=$this->request->param('users_id');
$order= Db::name('order')->field('order_no,users_id,start_time')->where(['users_id'=>$users_id,'state'=>1])->find();
if (empty($order)){
$this->apiResponse(200,'没有未完成订单');
}
$order['end_time']=time();
$order['time']=ceil(($order['end_time']-$order['start_time'])/3600);
$price=new OrderController();
... ...