From b9732088174894a445bf04e15ffc235f22bb1f9e Mon Sep 17 00:00:00 2001 From: Jing Li Date: Wed, 15 May 2024 09:57:14 +0800 Subject: [PATCH] Update --- app/Services/StatisticService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/StatisticService.php b/app/Services/StatisticService.php index 1db3b2e..8744bcc 100644 --- a/app/Services/StatisticService.php +++ b/app/Services/StatisticService.php @@ -187,7 +187,12 @@ class StatisticService */ public function storeRanking(array $input = [], int $top = 0): array { - $storeLedgers = Ledger::select(['store_id', DB::raw('SUM(sales) as sales'), DB::raw('SUM(expenditure) as expenditure')]) + $storeLedgers = Ledger::select([ + 'store_id', + DB::raw('SUM(sales) as sales'), + DB::raw('SUM(expenditure) as expenditure'), + DB::raw('SUM(new_customers) as new_customers'), + ]) ->filter(Arr::except($input, ['region']), LedgerFilter::class) ->groupBy('store_id'); @@ -211,6 +216,7 @@ class StatisticService 'id' => $store->id, 'title' => $store->title, ], + 'new_customers' => $store->new_customers ?: 0, 'sales' => trim_zeros($store->sales ?: 0), 'expenditure' => trim_zeros($store->expenditure ?: 0), ];