Dashboard.php
1.6 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace app\admin\controller\groupon\store;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use Exception;
/**
* 门店统计
*
* @icon fa fa-circle-o
*/
class Dashboard extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\groupon\order\Order;
}
/**
* 查看
*/
public function index()
{
if ($this->request->isAjax()) {
$params = $this->request->request();
$datetimerange = $params['datetimerange'] ? explode(' - ', $params['datetimerange']) : [];
$startTime = strtotime($datetimerange[0]);
$endTime = strtotime($datetimerange[1]);
$where = [
'createtime' => ['between', [$startTime, $endTime]]
];
$list = $this->buildSearch()
->with(['item'])
->where($where)
->order('id')
->select();
$data['order_list'] = $list;
$this->success('数据中心', null, $data);
}
return $this->view->fetch();
}
public function buildSearch()
{
$params = $this->request->request();
$store_id = isset($params['store_id']) ? $params['store_id'] : 0;
$name = $this->model->getQuery()->getTable();
$tableName = $name . '.';
$orders = $this->model->withTrashed();
if ($store_id) {
$orders = $orders->where('store_id', $store_id);
}
return $orders;
}
}