generated from liutk/owl-admin-base
Merge branch 'main' of https://gitea.hmily.club/pdkj/store-manage into main
commit
fb8de73aba
|
|
@ -187,7 +187,12 @@ class StatisticService
|
||||||
*/
|
*/
|
||||||
public function storeRanking(array $input = [], int $top = 0): array
|
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)
|
->filter(Arr::except($input, ['region']), LedgerFilter::class)
|
||||||
->groupBy('store_id');
|
->groupBy('store_id');
|
||||||
|
|
||||||
|
|
@ -211,6 +216,7 @@ class StatisticService
|
||||||
'id' => $store->id,
|
'id' => $store->id,
|
||||||
'title' => $store->title,
|
'title' => $store->title,
|
||||||
],
|
],
|
||||||
|
'new_customers' => $store->new_customers ?: 0,
|
||||||
'sales' => trim_zeros($store->sales ?: 0),
|
'sales' => trim_zeros($store->sales ?: 0),
|
||||||
'expenditure' => trim_zeros($store->expenditure ?: 0),
|
'expenditure' => trim_zeros($store->expenditure ?: 0),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue