From 23c13c7185f3faa8d2af9619a4b462179c4165f6 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Fri, 21 Oct 2022 12:33:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Count.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/Count.php b/app/Console/Commands/Count.php index dde62b6..65a0e11 100644 --- a/app/Console/Commands/Count.php +++ b/app/Console/Commands/Count.php @@ -48,10 +48,11 @@ public function handle() $users = User::count(); $transactions = new Transaction(); - // 获取今年的交易记录 - $transactions = $transactions->whereYear('created_at', date('Y')); + // 获取今年的交易记录 (MongoDB) + $startOfYear = now()->startOfYear(); + $endOfYear = now()->endOfYear(); - $transactions = $transactions->count(); + $transactions = Transaction::where('type', 'payout')->whereBetween('created_at', [$startOfYear, $endOfYear])->count(); $hosts = Host::count(); $workOrders = WorkOrder::count(); @@ -65,6 +66,6 @@ public function handle() $this->warn('服务器数量: ' . $servers); $this->warn('工单数量: ' . $workOrders); $this->warn('工单回复数量: ' . $replies); - $this->warn('今年的交易记录: ' . $transactions); + $this->warn('今年的交易记录: ' . $transactions . ' 条'); } }