From 2a54cd3730750d887ce641e68526ea9be2cd0418 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Dec 2019 11:23:14 +0800 Subject: [PATCH] update --- app/Console/Commands/SystemCache.php | 4 ++-- app/Http/Controllers/Admin/StatController.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/SystemCache.php b/app/Console/Commands/SystemCache.php index 00b75a22..089b1f46 100644 --- a/app/Console/Commands/SystemCache.php +++ b/app/Console/Commands/SystemCache.php @@ -47,7 +47,7 @@ class SystemCache extends Command private function setMonthIncome() { Redis::set( - 'getMonthIncome', + 'month_income', Order::where('created_at', '>', strtotime(date('Y-m-1'))) ->where('created_at', '>', time()) ->where('status', '3') @@ -58,7 +58,7 @@ class SystemCache extends Command private function setMonthRegisterTotal() { Redis::set( - 'getMonthRegisterTotal', + 'month_register_total', User::where('created_at', '>', strtotime(date('Y-m-1'))) ->where('created_at', '>', time()) ->count() diff --git a/app/Http/Controllers/Admin/StatController.php b/app/Http/Controllers/Admin/StatController.php index f24c4af9..7af5f065 100644 --- a/app/Http/Controllers/Admin/StatController.php +++ b/app/Http/Controllers/Admin/StatController.php @@ -10,9 +10,16 @@ use App\Models\ServerGroup; use App\Models\Server; use App\Models\Plan; use App\Models\User; +use Illuminate\Support\Facades\Redis; class StatController extends Controller { public function dashboard (Request $request) { + return response([ + 'data' => [ + 'month_income' => Redis::get('month_income'), + 'month_register_total' => Redis::get('month_register_total') + ] + ]); } }