generated from liutk/owl-admin-base
Update
parent
12bc95b45a
commit
74bb543e7e
|
|
@ -13,43 +13,50 @@ class StatisticsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function dashboard(Request $request, StatisticService $statisticService): array
|
public function dashboard(Request $request, StatisticService $statisticService): array
|
||||||
{
|
{
|
||||||
|
$request->validate(
|
||||||
|
rules: ['date' => ['filled', 'date_format:Y-m-d']],
|
||||||
|
attributes: ['date' => '日期'],
|
||||||
|
);
|
||||||
|
|
||||||
$input = $this->defaultFilterInput($request);
|
$input = $this->defaultFilterInput($request);
|
||||||
|
|
||||||
// 昨天
|
$date = Carbon::yesterday();
|
||||||
$yesterday = Carbon::yesterday();
|
if ($request->filled('date')) {
|
||||||
|
$date = Carbon::parse($request->input('date'));
|
||||||
|
}
|
||||||
|
|
||||||
// 本月上报数据统计
|
// 本月上报数据统计
|
||||||
$currentMonthLedger = array_merge(
|
$monthLedger = array_merge(
|
||||||
['deadline' => $yesterday->format('Y-m-d')],
|
['deadline' => $date->format('Y-m-d')],
|
||||||
$statisticService->ledger(
|
$statisticService->ledger(
|
||||||
$yesterday->copy()->startOfMonth(),
|
$date->copy()->startOfMonth(),
|
||||||
$yesterday->copy(),
|
$date->copy(),
|
||||||
$input,
|
$input,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 昨日总账录入
|
// 昨日总账录入
|
||||||
$yesterdayLedger = array_merge(
|
$yesdayLedger = array_merge(
|
||||||
['date' => $yesterday->format('Y-m-d')],
|
['date' => $date->format('Y-m-d')],
|
||||||
$statisticService->ledger(
|
$statisticService->ledger(
|
||||||
$yesterday->copy(),
|
$date->copy(),
|
||||||
$yesterday->copy(),
|
$date->copy(),
|
||||||
$input,
|
$input,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 近30天趋势数据
|
// 近30天趋势数据
|
||||||
$trendsOf30days = $statisticService->ledgerTrends(
|
$trendsOf30days = $statisticService->ledgerTrends(
|
||||||
$yesterday->copy()->subDays(29),
|
$date->copy()->subDays(29),
|
||||||
$yesterday->copy(),
|
$date->copy(),
|
||||||
$input,
|
$input,
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// 本月总账录入
|
// 本月总账录入
|
||||||
'current_month_ledger' => $currentMonthLedger,
|
'current_month_ledger' => $monthLedger,
|
||||||
// 昨日累计金额
|
// 昨日累计金额
|
||||||
'yesterday_ledger' => $yesterdayLedger,
|
'yesday_ledger' => $yesdayLedger,
|
||||||
// 近30天趋势数据
|
// 近30天趋势数据
|
||||||
'trends_of_30days' => $trendsOf30days,
|
'trends_of_30days' => $trendsOf30days,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue