AdminOrderController.php 1.0 KB
<?php
/**
 * Created by PhpStorm.
 * User: ruidiudiu
 * Date: 2018/11/23
 * Time: 11:58
 */

namespace app\portal\controller;


use app\portal\model\EquipmentModel;
use app\portal\model\OrderModel;
use cmf\controller\AdminBaseController;
use EasyWeChat\Payment\Order;

/**
 * Class AdminOrderController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'订单统计',
 *     'action' =>'index',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 1,
 *     'icon'   =>'th',
 *     'remark' =>'订单统计'
 * )
 */
class AdminOrderController extends AdminBaseController{

    public function index(){
        $Order=new OrderModel();
        $data=$Order->alias('a')
            ->field('a.*,b.serial_number,b.hospital')
            ->join('equipment b','a.mac_address=b.mac_address')
            ->paginate(10)->items(function ($item){
                $item['time']=($item['end_time']-$item['start_time'])/3600;
            });
        $this->assign('data',$data);
        return $this->fetch();
    }
}