From bdf65247e004a6090939bf14123e39bb84df1965 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Fri, 11 Mar 2022 13:34:10 +0800 Subject: [PATCH] update: fix commission statistics --- app/Console/Commands/V2boardStatistics.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Console/Commands/V2boardStatistics.php b/app/Console/Commands/V2boardStatistics.php index 36544867..612694b9 100644 --- a/app/Console/Commands/V2boardStatistics.php +++ b/app/Console/Commands/V2boardStatistics.php @@ -2,12 +2,10 @@ namespace App\Console\Commands; -use App\Jobs\StatServerJob; use Illuminate\Console\Command; use App\Models\Order; use App\Models\StatOrder; -use App\Models\ServerLog; -use Illuminate\Support\Facades\DB; +use App\Models\CommissionLog; class V2boardStatistics extends Command { @@ -50,14 +48,16 @@ class V2boardStatistics extends Command { $endAt = strtotime(date('Y-m-d')); $startAt = strtotime('-1 day', $endAt); - $builder = Order::where('paid_at', '>=', $startAt) + $orderBuilder = Order::where('paid_at', '>=', $startAt) ->where('paid_at', '<', $endAt) ->whereNotIn('status', [0, 2]); - $orderCount = $builder->count(); - $orderAmount = $builder->sum('total_amount'); - $builder = $builder->whereNotNull('actual_commission_balance'); - $commissionCount = $builder->count(); - $commissionAmount = $builder->sum('actual_commission_balance'); + $orderCount = $orderBuilder->count(); + $orderAmount = $orderBuilder->sum('total_amount'); + $commissionBuilder = CommissionLog::where('created_at', '>=', $startAt) + ->where('created_at', '<', $endAt) + ->where('get_amount', '>', 0); + $commissionCount = $commissionBuilder->count(); + $commissionAmount = $commissionBuilder->sum('get_amount'); $data = [ 'order_count' => $orderCount, 'order_amount' => $orderAmount,