From e85fdf203ae71c03d1269def55ad4abc5bad9404 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Dec 2019 18:08:52 +0800 Subject: [PATCH] update --- app/Console/Commands/SystemCache.php | 12 ------- .../Controllers/Admin/DashboardController.php | 33 +++++++++++++++++++ app/Http/Controllers/Admin/StatController.php | 23 ------------- routes/api.php | 4 +-- 4 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 app/Http/Controllers/Admin/DashboardController.php delete mode 100644 app/Http/Controllers/Admin/StatController.php diff --git a/app/Console/Commands/SystemCache.php b/app/Console/Commands/SystemCache.php index 9b72d778..a7a162f7 100644 --- a/app/Console/Commands/SystemCache.php +++ b/app/Console/Commands/SystemCache.php @@ -45,7 +45,6 @@ class SystemCache extends Command { $this->setMonthIncome(); $this->setMonthRegisterTotal(); - $this->setMonthServerTrafficTotal(); } private function setMonthIncome() { @@ -66,15 +65,4 @@ class SystemCache extends Command ->count() ); } - - private function setMonthServerTrafficTotal () { - $servers = Server::get(); - foreach ($servers as $item) { - $serverLog = ServerLog::where('created_at', '>=', strtotime(date('Y-m-1'))) - ->where('created_at', '<', time()) - ->where('node_id', $item->id); - Redis::set('month_server_traffic_total_u_' . $item->id, $serverLog->sum('u')); - Redis::set('month_server_traffic_total_d_' . $item->id, $serverLog->sum('d')); - } - } } diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php new file mode 100644 index 00000000..fe1a589a --- /dev/null +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -0,0 +1,33 @@ + [ + 'month_income' => Redis::get('month_income'), + 'month_register_total' => Redis::get('month_register_total'), + 'server_offline_total' => Server::where('last_check_at', '<', time() - 300) + ->count(), + 'ticket_pendding_total' => Ticket::where('status', 0) + ->count(), + 'commission_pendding_total' => Order::where('commission_status', 0) + ->where('status', 3) + ->count(), + + ] + ]); + } +} diff --git a/app/Http/Controllers/Admin/StatController.php b/app/Http/Controllers/Admin/StatController.php deleted file mode 100644 index 9af79f9a..00000000 --- a/app/Http/Controllers/Admin/StatController.php +++ /dev/null @@ -1,23 +0,0 @@ - [ - 'month_income' => Redis::get('month_income'), - 'month_register_total' => Redis::get('month_register_total') - ] - ]); - } -} diff --git a/routes/api.php b/routes/api.php index c3982256..81941f63 100755 --- a/routes/api.php +++ b/routes/api.php @@ -43,8 +43,8 @@ Route::prefix('v1') Route::get ('user', 'Admin\\UserController@index'); Route::post('user/update', 'Admin\\UserController@update'); Route::get ('user/id2UserInfo/{id}', 'Admin\\UserController@id2UserInfo'); - // Stat - Route::get ('stat/dashboard', 'Admin\\StatController@dashboard'); + // Dashboard + Route::get ('dashboard', 'Admin\\DashboardController@index'); // Notice Route::get ('notice', 'Admin\\NoticeController@index'); Route::post('notice/save', 'Admin\\NoticeController@save');