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

order

@@ -30,11 +30,14 @@ class AdminAllStatisticsController extends AdminBaseController{ @@ -30,11 +30,14 @@ class AdminAllStatisticsController extends AdminBaseController{
30 public function index(){ 30 public function index(){
31 $Order=new OrderModel(); 31 $Order=new OrderModel();
32 $data=$Order->alias('a') 32 $data=$Order->alias('a')
33 - ->field('a.*,b.serial_number,b.hospital,count(a.mac_address),sum(a.time) as sumTime') 33 + ->field('a.*,b.serial_number,b.hospital,count(a.mac_address) as num,sum(a.time) as sumTime')
34 ->join('equipment b','a.mac_address=b.mac_address') 34 ->join('equipment b','a.mac_address=b.mac_address')
35 ->group('a.mac_address') 35 ->group('a.mac_address')
36 ->order('start_time','desc') 36 ->order('start_time','desc')
37 - ->paginate(10); 37 + ->paginate(10)->each(function ($item){
  38 + $item['average']=$item['sumTime']/$item['num'];
  39 + return $item;
  40 + });
38 dump($data->toArray()); 41 dump($data->toArray());
39 $this->assign('data',$data); 42 $this->assign('data',$data);
40 return $this->fetch(); 43 return $this->fetch();
@@ -60,8 +60,12 @@ @@ -60,8 +60,12 @@
60 value="{$vo.id}" title="ID:{$vo.id}"> 60 value="{$vo.id}" title="ID:{$vo.id}">
61 </td> 61 </td>
62 <td><b>{$vo.id}</b></td> 62 <td><b>{$vo.id}</b></td>
63 -  
64 - 63 + <td>{$vo.mac_address}</td>
  64 + <td>{$vo.serial_number}</td>
  65 + <td>{$vo.hospital}</td>
  66 + <td>{$vo.sumTime}</td>
  67 + <td>{$vo.num}</td>
  68 + <td>{$vo.average}</td>
65 </tr> 69 </tr>
66 </foreach> 70 </foreach>
67 </table> 71 </table>