OrderController.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?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
]);
}
}