Dashboard.php
4.1 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
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Config;
use think\Db;
/**
* 控制台
*
* @icon fa fa-dashboard
* @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
*/
class Dashboard extends Backend
{
/**
* 查看
*/
public function index()
{
$seventtime = \fast\Date::unixtime('day', -7);
$paylist = $createlist = [];
for ($i = 0; $i < 7; $i++)
{
$day = date("Y-m-d", $seventtime + ($i * 86400));
$createlist[$day] = mt_rand(20, 200);
$paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
}
$hooks = config('addons.hooks');
$uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
$addonComposerCfg = ROOT_PATH . '/vendor/karsonzhang/fastadmin-addons/composer.json';
Config::parse($addonComposerCfg, "json", "composer");
$config = Config::get("composer");
$addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
$status = config('verify.status');
//查询订单待发货数
$delivery = $this->orderNumber(['status'=>$status[2]]);
//待退换货订单数
$return_flag = $this->orderNumber(['status'=>$status[6]]);
//待退款订单数
$refund_flag = $this->orderNumber(['status'=>$status[3]]);
//今日销售额
$today_sales = Db::name('order')->where(['status'=>['not in',[$status[0],$status[1],$status[4]]]])->whereTime('paytime','today')->useSoftDelete('deletetime')->sum('total_price');
//今日订单数
$today_order = Db::name('order')->whereTime('createtime','today')->useSoftDelete('deletetime')->count();
//今日下单人数
$today_person_order = Db::name('order')->where(['status'=>['>=',$status[2]]])->whereTime('paytime','today')->useSoftDelete('deletetime')->group('uid')->count();
//今日访客数
$type = config('verify.browse_type');
$today_person_browse = Db::name('statistics')->where(['type'=>$type[0]])->whereTime('createtime','day')->group('uid')->count();
//今日商品浏览量
$today_goods_browser = Db::name('statistics')->where(['type'=>$type[1]])->whereTime('createtime','day')->count();
//今日商品收藏量
$today_goods_collection = Db::name('statistics')->where(['type'=>$type[2]])->whereTime('createtime','day')->count();
$this->view->assign([
'totaluser' => 35200,
'totalviews' => 219390,
'totalorder' => 1000,
'totalorderamount' => 174800,
'todayuserlogin' => 321,
'todayusersignup' => 430,
'todayorder' => 2324,
'unsettleorder' => 132,
'sevendnu' => '80%',
'sevendau' => '32%',
'paylist' => $paylist,
'createlist' => $createlist,
'addonversion' => $addonVersion,
'uploadmode' => $uploadmode,
'delivery' => $delivery,//待发货数
'return_flag' => $return_flag,//待退换货订单数
'refund_flag' => $refund_flag,//待退款订单数
'today_sales' => number_format($today_sales,'2'),//今日销售额
'today_order' => $today_order,//今日订单数
'today_person_order' => $today_person_order,//今日下单人数
'today_person_browse' => $today_person_browse??'0',//今日访客数
'today_goods_browser' => $today_goods_browser??'0',//今日商品浏览量
'today_goods_collection' => $today_goods_collection??'0',//今日商品收藏量
]);
return $this->view->fetch();
}
public function orderNumber($where){
$count = Db::name('order')
->where($where)
->useSoftDelete('deletetime')
->count();
return $count;
}
}