MainController.php
5.2 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use app\admin\model\Menu;
class MainController extends AdminBaseController
{
public function _initialize()
{
parent::_initialize();
}
/**
* 后台欢迎页
*/
// public function index()
// {
// $dashboardWidgets = [];
// $widgets = cmf_get_option('admin_dashboard_widgets');
//
// $defaultDashboardWidgets = [
// '_SystemCmfHub' => ['name' => 'CmfHub', 'is_system' => 1],
// '_SystemMainContributors' => ['name' => 'MainContributors', 'is_system' => 1],
// '_SystemContributors' => ['name' => 'Contributors', 'is_system' => 1],
// '_SystemCustom1' => ['name' => 'Custom1', 'is_system' => 1],
// '_SystemCustom2' => ['name' => 'Custom2', 'is_system' => 1],
// '_SystemCustom3' => ['name' => 'Custom3', 'is_system' => 1],
// '_SystemCustom4' => ['name' => 'Custom4', 'is_system' => 1],
// '_SystemCustom5' => ['name' => 'Custom5', 'is_system' => 1],
// ];
//
// if (empty($widgets)) {
// $dashboardWidgets = $defaultDashboardWidgets;
// } else {
// foreach ($widgets as $widget) {
// if ($widget['is_system']) {
// $dashboardWidgets['_System' . $widget['name']] = ['name' => $widget['name'], 'is_system' => 1];
// } else {
// $dashboardWidgets[$widget['name']] = ['name' => $widget['name'], 'is_system' => 0];
// }
// }
//
// foreach ($defaultDashboardWidgets as $widgetName => $widget) {
// $dashboardWidgets[$widgetName] = $widget;
// }
//
//
// }
//
// $dashboardWidgetPlugins = [];
//
// $hookResults = hook('admin_dashboard');
//
// if (!empty($hookResults)) {
// foreach ($hookResults as $hookResult) {
// if (isset($hookResult['width']) && isset($hookResult['view']) && isset($hookResult['plugin'])) { //验证插件返回合法性
// $dashboardWidgetPlugins[$hookResult['plugin']] = $hookResult;
// if (!isset($dashboardWidgets[$hookResult['plugin']])) {
// $dashboardWidgets[$hookResult['plugin']] = ['name' => $hookResult['plugin'], 'is_system' => 0];
// }
// }
// }
// }
//
// $smtpSetting = cmf_get_option('smtp_setting');
//
// $this->assign('dashboard_widgets', $dashboardWidgets);
// $this->assign('dashboard_widget_plugins', $dashboardWidgetPlugins);
// $this->assign('has_smtp_setting', empty($smtpSetting) ? false : true);
//
// return $this->fetch();
// }
public function index(){
$where=[];
if (cmf_get_current_admin_id()!=1){
$where['user_id']=cmf_get_current_admin_id();
};
$today_start = strtotime(date("Y-m-d"),time());
$today_end=$today_start+24*60*60;
$today_order=Db::name('light_order')
->alias('lo')
->join('light l','lo.light_id=l.id')
->join('temple t','l.temple_id=t.id')
->whereTime('lo.create_time', 'between', [$today_start, $today_end])
->where('lo.status',1)
->whereNotNull('lo.pay_time')
->sum('lo.money');
$users=Db::name('users')->where('status',1)->count();
$order=Db::name('temple')
->where($where)
->sum('money');
$expect=Db::name('temple')
->where($where)
->sum('money*percent');
$data=Db::name('temple')->where($where)->order('money','desc')->select();
$this->assign([
'today_order'=>$today_order,
'users'=>$users,
'order'=>$order,
'expect'=>$expect,
'list'=>$data,
]);
return $this->fetch();
}
public function dashboardWidget()
{
$dashboardWidgets = [];
$widgets = $this->request->param('widgets/a');
if (!empty($widgets)) {
foreach ($widgets as $widget) {
if ($widget['is_system']) {
array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 1]);
} else {
array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 0]);
}
}
}
cmf_set_option('admin_dashboard_widgets', $dashboardWidgets, true);
$this->success('更新成功!');
}
}