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

order

... ... @@ -30,11 +30,14 @@ class AdminAllStatisticsController extends AdminBaseController{
public function index(){
$Order=new OrderModel();
$data=$Order->alias('a')
->field('a.*,b.serial_number,b.hospital,count(a.mac_address),sum(a.time) as sumTime')
->field('a.*,b.serial_number,b.hospital,count(a.mac_address) as num,sum(a.time) as sumTime')
->join('equipment b','a.mac_address=b.mac_address')
->group('a.mac_address')
->order('start_time','desc')
->paginate(10);
->paginate(10)->each(function ($item){
$item['average']=$item['sumTime']/$item['num'];
return $item;
});
dump($data->toArray());
$this->assign('data',$data);
return $this->fetch();
... ...
... ... @@ -60,8 +60,12 @@
value="{$vo.id}" title="ID:{$vo.id}">
</td>
<td><b>{$vo.id}</b></td>
<td>{$vo.mac_address}</td>
<td>{$vo.serial_number}</td>
<td>{$vo.hospital}</td>
<td>{$vo.sumTime}</td>
<td>{$vo.num}</td>
<td>{$vo.average}</td>
</tr>
</foreach>
</table>
... ...