Files
fast_response/superadmin/application/admin/controller/Dashboard.php
Your Name dce091da91 t
2025-03-27 07:52:44 +00:00

84 lines
3.4 KiB
PHP
Executable File

<?php
namespace app\admin\controller;
use app\admin\model\Admin;
use app\admin\model\User;
use app\common\controller\Backend;
use app\common\model\Attachment;
use fast\Date;
use think\Db;
/**
* 控制台
*
* @icon fa fa-dashboard
* @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
*/
class Dashboard extends Backend
{
/**
* 查看
*/
public function index()
{
//dump(session('admin'));
try {
\think\Db::execute("SET @@sql_mode='';");
} catch (\Exception $e) {
}
$column = [];
$starttime = Date::unixtime('day', -6);
$endtime = Date::unixtime('day', 0, 'end');
$joinlist = Db("user")->where('jointime', 'between time', [$starttime, $endtime])
->field('jointime, status, COUNT(*) AS nums, DATE_FORMAT(FROM_UNIXTIME(jointime), "%Y-%m-%d") AS join_date')
->group('join_date')
->select();
for ($time = $starttime; $time <= $endtime;) {
$column[] = date("Y-m-d", $time);
$time += 86400;
}
$userlist = array_fill_keys($column, 0);
foreach ($joinlist as $k => $v) {
$userlist[$v['join_date']] = $v['nums'];
}
$dbTableList = Db::query("SHOW TABLE STATUS");
$addonList = get_addon_list();
$totalworkingaddon = 0;
$totaladdon = count($addonList);
foreach ($addonList as $index => $item) {
if ($item['state']) {
$totalworkingaddon += 1;
}
}
$this->view->assign([
'totaluser' => 0,//Db::table('fa_tt_userbaseinfo')->where('create_time','>=',date("Y-m-d",time()))->count('id'),//今日问诊
'totaladdon' => 0,//Db::table('fa_tt_userbaseinfo')->where('create_time','>=',date("Y-m-d",time()-30*86400))->count('id'),//30日问诊
'totaladmin' => 0,//Db::table('fa_tt_userbaseinfo')->where('create_time','>=',date("Y-m-d",time()-30*3*86400))->count('id'),//3个月问诊
'totalcategory' => 0,//Db::table('fa_tt_userbaseinfo')->count('id'),//总问诊
'todayusersignup' => 0,//User::whereTime('jointime', 'today')->count(),
'todayuserlogin' => 0,//User::whereTime('logintime', 'today')->count(),
'sevendau' => 0,//User::whereTime('jointime|logintime|prevtime', '-7 days')->count(),
'thirtydau' => 0,//User::whereTime('jointime|logintime|prevtime', '-30 days')->count(),
'threednu' => 0,//User::whereTime('jointime', '-3 days')->count(),
'sevendnu' => 0,//User::whereTime('jointime', '-7 days')->count(),
'dbtablenums' => 0,//count($dbTableList),
'dbsize' => 0,//array_sum(array_map(function ($item) { return $item['Data_length'] + $item['Index_length'];}, $dbTableList)),
'totalworkingaddon' => 0,//$totalworkingaddon,
'attachmentnums' => 0,//Attachment::count(),
'attachmentsize' => 0,//Attachment::sum('filesize'),
'picturenums' => 0,//Attachment::where('mimetype', 'like', 'image/%')->count(),
'picturesize' => 0,//Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
]);
$this->assignconfig('column', array_keys($userlist));
$this->assignconfig('userdata', array_values($userlist));
return $this->view->fetch();
}
}