refactor(dashboard): centralize 7d range + merchant/plan links

This commit is contained in:
萝卜
2026-03-17 03:35:27 +08:00
parent 8aaae252ec
commit 080585b0f6

View File

@@ -15,6 +15,10 @@
'plans' => \App\Support\BackUrl::withBack('/admin/plans', $selfWithoutBack),
];
// 仪表盘内所有“近7天”口径统一在这里计算避免散落 now()->subDays(6) 导致未来改动遗漏。
$rangeFrom7d = now()->subDays(6)->format('Y-m-d');
$rangeTo7d = now()->format('Y-m-d');
$platformOrdersQuickLinks = [
// 复用工作台入口(避免 /admin/platform-orders 入口口径分叉)
'platform_orders' => $billingEntryLinks['platform_orders'],
@@ -30,6 +34,31 @@
);
},
// 站点收入排行已付订单集合merchant_id + payment_status=paid + 日期范围)
'merchant_paid_orders_range' => function (int $merchantId, string $from, string $to) use ($selfWithoutBack): string {
return \App\Support\BackUrl::withBack(
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'merchant_id' => $merchantId,
'payment_status' => 'paid',
'created_from' => $from,
'created_to' => $to,
]),
$selfWithoutBack
);
},
// 套餐订单占比:按套餐筛选 + 日期范围(用于 Top5 表格链接,同时被 JS 复用为 mini chart 点击入口)
'plan_orders_range' => function (int $planId, string $from, string $to) use ($selfWithoutBack): string {
return \App\Support\BackUrl::withBack(
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'plan_id' => $planId,
'created_from' => $from,
'created_to' => $to,
]),
$selfWithoutBack
);
},
// 平台订单(收费闭环)工作台入口:尽量保持与列表页筛选语义一致。
'unpaid_pending' => \App\Support\BackUrl::withBack('/admin/platform-orders?payment_status=unpaid&status=pending', $selfWithoutBack),
// 待生效paid + pending并显式锁定 sync_status=unsynced排除同步失败等异常单
@@ -241,15 +270,7 @@
@php
$mid = (int) ($row['merchant_id'] ?? 0);
$mname = (string) (($merchantIdToName[$mid] ?? '') ?: ('#' . $mid));
$merchantOrdersUrl = \App\Support\BackUrl::withBack(
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'merchant_id' => $mid,
'payment_status' => 'paid',
'created_from' => now()->subDays(6)->format('Y-m-d'),
'created_to' => now()->format('Y-m-d'),
]),
$selfWithoutBack
);
$merchantOrdersUrl = ($platformOrdersQuickLinks['merchant_paid_orders_range'])($mid, $rangeFrom7d, $rangeTo7d);
@endphp
<tr>
<td><a class="link" href="{!! $merchantOrdersUrl !!}">{{ $mname }}</a></td>
@@ -761,14 +782,7 @@
$planName = (string) (($planIdToName[$planId] ?? '') ?: ('#' . $planId));
@endphp
@php
$planOrdersUrl = \App\Support\BackUrl::withBack(
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'plan_id' => $planId,
'created_from' => now()->subDays(6)->format('Y-m-d'),
'created_to' => now()->format('Y-m-d'),
]),
$selfWithoutBack
);
$planOrdersUrl = ($platformOrdersQuickLinks['plan_orders_range'])($planId, $rangeFrom7d, $rangeTo7d);
@endphp
<tr>
<td><a class="link" href="{!! $planOrdersUrl !!}">{{ $planName }}</a></td>