统计仪表板 * 功能: 展示种植点数系统的统计数据和分析图表 */ class PointDashboardController extends AdminController { /** * 页面标题 */ protected $title = '种植点数统计仪表板'; /** * 仪表板页面 */ #[Get('point/dashboard', name: 'admin.point.dashboard.index')] public function index(Content $content) { return $content ->title($this->title) ->description('积分系统数据统计') ->body($this->overview()) ->body($this->pointTypeStats()) ->body($this->recentActivity()); } /** * 概览统计 */ protected function overview() { $pointRepo = new PointRepository(); $logRepo = new PointLogRepository(); $adminRepo = new PointAdminRepository(); $circulationRepo = new PointCirculationRepository(); $transferRepo = new PointTransferRepository(); $orderRepo = new PointOrderRepository(); // 基础统计 $totalAccounts = $pointRepo->model()->count(); $totalLogs = $logRepo->model()->count(); $totalAdminOps = $adminRepo->model()->count(); $totalCirculations = $circulationRepo->model()->count(); $totalTransfers = $transferRepo->model()->count(); $totalOrders = $orderRepo->model()->count(); // 今日统计 $todayStart = strtotime('today'); $todayLogs = $logRepo->model()->where('create_time', '>=', $todayStart)->count(); $todayAdminOps = $adminRepo->model()->where('create_time', '>=', $todayStart)->count(); return new Card('系统概览', [ new InfoBox('积分账户总数', 'users', 'aqua', route('admin.point.index'), $totalAccounts), new InfoBox('积分日志总数', 'file-text-o', 'green', route('admin.point-log.index'), $totalLogs), new InfoBox('管理员操作', 'cog', 'yellow', route('admin.point-admin.index'), $totalAdminOps), new InfoBox('今日日志', 'calendar', 'red', route('admin.point-log.index'), $todayLogs), ]); } /** * 积分类型统计 */ protected function pointTypeStats() { $pointRepo = new PointRepository(); $stats = $pointRepo->getPointTypeStats(); $pointTypes = [ 1 => '经验积分', 2 => '成就积分', 3 => '活动积分', 4 => '签到积分', 5 => '推荐积分', ]; $html = '
| 时间 | 用户 | 积分类型 | 变更 | 备注 |
|---|---|---|---|---|
| {$time} | 用户{$log->user_id} | {$pointType} | {$amount} | {$remark} |