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

interface

@@ -211,7 +211,7 @@ class AdminEquipmentController extends AdminBaseController{ @@ -211,7 +211,7 @@ class AdminEquipmentController extends AdminBaseController{
211 211
212 $objActSheet->setCellValue('A1', '设备锁编号'); 212 $objActSheet->setCellValue('A1', '设备锁编号');
213 $objActSheet->setCellValue('B1', '设备锁名称'); 213 $objActSheet->setCellValue('B1', '设备锁名称');
214 - $objActSheet->setCellValue('C1', '商品图'); 214 + $objActSheet->setCellValue('C1', '二维码');
215 $objActSheet->setCellValue('D1', '初始医院'); 215 $objActSheet->setCellValue('D1', '初始医院');
216 $objActSheet->setCellValue('E1', 'MAC地址'); 216 $objActSheet->setCellValue('E1', 'MAC地址');
217 $objActSheet->setCellValue('F1', '备注'); 217 $objActSheet->setCellValue('F1', '备注');
@@ -107,36 +107,55 @@ class OrderController extends HomeBaseController{ @@ -107,36 +107,55 @@ class OrderController extends HomeBaseController{
107 $interval = Db::name('interval')->where('id',1)->find(); 107 $interval = Db::name('interval')->where('id',1)->find();
108 108
109 //用了多少天 109 //用了多少天
110 - $date=floor(($end_time-$start_time)/86400);  
111 - //去余数  
112 - $yu=($end_time-$start_time)%86400;  
113 -  
114 - $new_start_time=$end_time-$yu;//时间戳 110 + $day=floor(($end_time-$start_time)/86400);
  111 + $price=$day*1;
  112 + //去掉整天的金额
  113 + $new_start_time=$start_time+$day*86400;//时间戳
115 $new_end_time= $end_time;//时间戳 114 $new_end_time= $end_time;//时间戳
116 $hours_start_time=date('His',$new_start_time); 115 $hours_start_time=date('His',$new_start_time);
117 $hours_end_time=date('His',$new_end_time); 116 $hours_end_time=date('His',$new_end_time);
118 117
119 $stateTime=strtotime($interval['start_time']); 118 $stateTime=strtotime($interval['start_time']);
120 $endTime=strtotime($interval['end_time']); 119 $endTime=strtotime($interval['end_time']);
121 - $price=1;  
122 - //判断是否跨天 120 + //判断预设时间段是否跨天
123 if ($endTime < $stateTime){ 121 if ($endTime < $stateTime){
  122 + //设备使用时间段是否跨天(不跨天)
124 if ($hours_end_time > $hours_start_time){ 123 if ($hours_end_time > $hours_start_time){
125 - if ($new_start_time> strtotime('00:00:00') && $new_start_time < $endTime && $new_end_time > $endTime && $new_end_time < $stateTime){  
126 - $price=ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$endTime)/3600) * $cost['cost']; 124 + //在预设时间段左边并不与之重合
  125 + if (($new_start_time > strtotime('00:00:00') && $new_start_time < $endTime) && ($new_end_time > $new_start_time && $new_end_time < $endTime)){
  126 + $price +=(ceil(($new_end_time-$new_start_time)/3600) * $interval['price']);
127 } 127 }
128 - if ($new_start_time> strtotime('00:00:00') && $new_start_time < $endTime && $new_end_time > $stateTime){  
129 - $price=ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price'] + ceil(($stateTime-$endTime)/3600) * $cost['cost']; 128 + //与预设时间段的尾部重合
  129 + if (($new_start_time > strtotime('00:00:00') && $new_start_time < $endTime) && ($new_end_time > $endTime && $new_end_time < $stateTime)){
  130 + $price +=(ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$endTime)/3600) * $cost['cost']);
130 } 131 }
131 -  
132 - if ($new_start_time > $endTime && $new_end_time < $stateTime){  
133 - $price=ceil(($new_end_time-$new_start_time)/3600) * $cost['cost']; 132 + //与预设时间段的头尾都重合
  133 + if (($new_start_time > strtotime('00:00:00') && $new_start_time < $endTime) && $new_end_time > $stateTime){
  134 + $price +=(ceil(($endTime-$new_start_time)/3600) * $interval['price'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price'] + ceil(($stateTime-$endTime)/3600) * $cost['cost']);
  135 + }
  136 + //不与预设时间段重合
  137 + if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time < $new_start_time && $new_end_time < $stateTime)){
  138 + //存在首小时免费
  139 + $price +=(ceil(($new_end_time-$new_start_time)/3600) * $cost['cost']);
134 } 140 }
135 - if ($new_start_time > $endTime && $new_end_time > $stateTime && $new_end_time < strtotime('24:00:00')){  
136 - $price= ceil(($stateTime-$new_start_time)/3600) * $cost['cost'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price']; 141 + //与预设时间段的头部重合
  142 + if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time > $stateTime && $new_end_time < strtotime('24:00:00'))){
  143 + //存在首小时免费
  144 + $price += (ceil(($stateTime-$new_start_time)/3600) * $cost['cost'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price']);
  145 + }
  146 + //在预设时间段右边并不与之重合
  147 + 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'))){
  148 + $price +=(ceil(($new_end_time-$new_start_time)/3600) * $interval['price']);
137 } 149 }
138 150
  151 + //设备使用时间段是否跨天(跨天:开始时间在昨天,结束时间在今天)
139 }else{ 152 }else{
  153 + $YesterdayStateTime=$stateTime-86400;
  154 + $YesterdayEndTime=$endTime-86400;
  155 + //开始时间在预设开始时间的前面OR结束时间在预设结束时间的前面
  156 + if(($new_start_time > (strtotime('00:00:00')-86400) && $new_start_time < $YesterdayEndTime) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){
  157 + $price+= ceil(($YesterdayEndTime-$new_start_time)/3600) * $interval['price'];
  158 + }
140 159
141 } 160 }
142 }else{ 161 }else{
@@ -125,6 +125,9 @@ class UsersController extends HomeBaseController{ @@ -125,6 +125,9 @@ class UsersController extends HomeBaseController{
125 public function getOrderById(){ 125 public function getOrderById(){
126 $users_id=$this->request->param('users_id'); 126 $users_id=$this->request->param('users_id');
127 $order= Db::name('order')->field('order_no,users_id,start_time')->where(['users_id'=>$users_id,'state'=>1])->find(); 127 $order= Db::name('order')->field('order_no,users_id,start_time')->where(['users_id'=>$users_id,'state'=>1])->find();
  128 + if (empty($order)){
  129 + $this->apiResponse(200,'没有未完成订单');
  130 + }
128 $order['end_time']=time(); 131 $order['end_time']=time();
129 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600); 132 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600);
130 $price=new OrderController(); 133 $price=new OrderController();