main
Jing Li 2024-04-24 13:13:05 +08:00
parent 61f229cb70
commit c4dbeaaf22
1 changed files with 4 additions and 2 deletions

View File

@ -118,6 +118,10 @@ class StatisticService
*/
public function sales(Carbon $start, Carbon $end, array $input = []): array
{
$input = array_merge($input, [
'date_range' => $start->toDateString().','.$end->toDateString(),
]);
/** @var \Illuminate\Database\Eloquent\Collection */
$lotteryTypes = Keyword::where('parent_key', 'lottery_type')->get();
@ -129,7 +133,6 @@ class StatisticService
DB::raw('SUM(expenditure) as expenditure')
])
->filter($input, LedgerFilter::class)
->whereBetween('date', [$start->format('Y-m-d'), $end->format('Y-m-d')])
->groupBy(['date'])
->get()
->keyBy('date');
@ -143,7 +146,6 @@ class StatisticService
])
->filter($input, LedgerItemFilter::class)
->whereIn('ledger_item_type_id', $lotteryTypes->pluck('key'))
->whereBetween('date', [$start->format('Y-m-d'), $end->format('Y-m-d')])
->groupBy(['date', 'ledger_item_type_id'])
->get()
->groupBy('date');