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

order

@@ -29,7 +29,12 @@ class AdminAllStatisticsController extends AdminBaseController{ @@ -29,7 +29,12 @@ class AdminAllStatisticsController extends AdminBaseController{
29 29
30 public function index(){ 30 public function index(){
31 $Order=new OrderModel(); 31 $Order=new OrderModel();
32 - $data=$Order->paginate(10); 32 + $data=$Order->alias('a')
  33 + ->field('a.*,b.serial_number,b.hospital,sum() as sumTime')
  34 + ->join('equipment b','a.mac_address=b.mac_address')
  35 + ->group('mac_address')
  36 + ->order('start_time','desc')
  37 + ->paginate(10);
33 $this->assign('data',$data); 38 $this->assign('data',$data);
34 return $this->fetch(); 39 return $this->fetch();
35 } 40 }
@@ -49,7 +49,7 @@ class AdminOrderController extends AdminBaseController{ @@ -49,7 +49,7 @@ class AdminOrderController extends AdminBaseController{
49 ->where($where) 49 ->where($where)
50 ->order('start_time','desc') 50 ->order('start_time','desc')
51 ->paginate(10)->each(function ($item){ 51 ->paginate(10)->each(function ($item){
52 - $item['time']=($item['end_time']-$item['start_time'])/3600; 52 + $item['time']=($item['end_time']-$item['start_time']);
53 return $item; 53 return $item;
54 }); 54 });
55 $this->assign('data',$data); 55 $this->assign('data',$data);