OrderController.php 1.3 KB
<?php
/**
 * Created by PhpStorm.
 * User: yhbr
 * Date: 2018/9/1
 * Time: 9:26
 */

namespace app\admin\controller;
use Think\Db;
use cmf\controller\AdminBaseController;

class OrderController extends AdminBaseController
{

    public function index()
    {
        $where = [];
        $order_sn = request()->param('order_sn');
        if ($order_sn != null) {
            $where['order_sn'] = ['like', "%$order_sn%"];
        }
        $status = request()->param('status');
        if ($status != null) {
            $where['status'] = ['eq', $status];
        }
        $res = Db::name('order_info')->alias('o')
            ->field('o.order_sn,o.id as oid,a.name,s.start_time,s.end_time,o.status,u.user_nickname')
            ->join('activity a', 'a.id=o.activity_id')
            ->join('activity_schedule s', 's.id=o.schedule_id')
            ->join('user u', 'u.id=o.user_id')
            ->where($where)
            ->order('add_time DESC')
            ->paginate(20, false, ['query' => request()->param()]);
        foreach ($res as $k => $v) {
            $v['status'] = getOrderStatusText($v['status']);
            $res[$k] = $v;
        }
        return $this->fetch('', [
            'posts' => $res,
            'page' => $res->render(),
            'order_sn' => $order_sn,
            'status' => $status
        ]);
    }

}