作者 sgj
1 个管道 的构建 通过 耗费 0 秒

添加时间信息

@@ -209,6 +209,8 @@ class UsersController extends HomeBaseController{ @@ -209,6 +209,8 @@ class UsersController extends HomeBaseController{
209 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600); 209 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600);
210 $price=new OrderController(); 210 $price=new OrderController();
211 $order['price']=$price->getPrice($users_id,$order['start_time'],$order['end_time']); 211 $order['price']=$price->getPrice($users_id,$order['start_time'],$order['end_time']);
  212 + $time_info=$this->getTimeInfo($order['start_time'],$order['end_time']);
  213 + array_merge($order,$time_info);
212 $this->apiResponse(200,'success',$order); 214 $this->apiResponse(200,'success',$order);
213 } 215 }
214 216
@@ -235,9 +237,12 @@ class UsersController extends HomeBaseController{ @@ -235,9 +237,12 @@ class UsersController extends HomeBaseController{
235 public function getOrderById2(){ 237 public function getOrderById2(){
236 $users_id=$this->request->param('users_id'); 238 $users_id=$this->request->param('users_id');
237 $order= Db::name('order')->where(['users_id'=>$users_id,'state'=>2])->find(); 239 $order= Db::name('order')->where(['users_id'=>$users_id,'state'=>2])->find();
  240 +
238 if (empty($order)){ 241 if (empty($order)){
239 $this->apiResponse(200,'没有未支付订单'); 242 $this->apiResponse(200,'没有未支付订单');
240 } 243 }
  244 + $time_info=$this->getTimeInfo($order['start_time'],$order['end_time']);
  245 + array_merge($order,$time_info);
241 $this->apiResponse(200,'success',$order); 246 $this->apiResponse(200,'success',$order);
242 } 247 }
243 248
@@ -370,12 +375,10 @@ class UsersController extends HomeBaseController{ @@ -370,12 +375,10 @@ class UsersController extends HomeBaseController{
370 } 375 }
371 376
372 377
373 - public function getTimeInfo(){  
374 - $start='1543812320';  
375 - $end='1543812407'; 378 + public function getTimeInfo($start,$end){
376 $time=$end-$start; 379 $time=$end-$start;
377 $return['hour']=floor($time/3600); 380 $return['hour']=floor($time/3600);
378 $return['min']=floor(($time-$return['hour']*3600)/60); 381 $return['min']=floor(($time-$return['hour']*3600)/60);
379 - dump($return); 382 + $return;
380 } 383 }
381 } 384 }