refactor(platform-orders): created_at 快捷日期范围由 controller 注入
This commit is contained in:
@@ -367,6 +367,14 @@ class PlatformOrderController extends Controller
|
||||
$totalPayableAmount = (float) ((clone $baseQuery)->sum('payable_amount') ?: 0);
|
||||
$totalPaidAmount = (float) ((clone $baseQuery)->sum('paid_amount') ?: 0);
|
||||
|
||||
// created_at 快捷入口日期范围:由 Controller 统一注入,避免 Blade 内多次 now() 调用跨天漂移。
|
||||
$baseToday = now();
|
||||
$createdRangeToday = $baseToday->format('Y-m-d');
|
||||
// 近7天:包含今天共 7 天,因此 from = today - 6 days
|
||||
$createdRangeFrom7d = $baseToday->copy()->subDays(6)->format('Y-m-d');
|
||||
// 近30天:包含今天共 30 天,因此 from = today - 29 days
|
||||
$createdRangeFrom30d = $baseToday->copy()->subDays(29)->format('Y-m-d');
|
||||
|
||||
return view('admin.platform_orders.index', [
|
||||
'currentSubscription' => $currentSubscription,
|
||||
'orders' => $orders,
|
||||
@@ -397,6 +405,11 @@ class PlatformOrderController extends Controller
|
||||
'paymentStatusLabels' => $this->paymentStatusLabels(),
|
||||
// order_type label 映射已下沉到 PlatformOrder::orderTypeLabel();这里不再透传 orderTypeLabels
|
||||
// 'orderTypeLabels' => $this->orderTypeLabels(),
|
||||
// created_at 快捷入口日期范围
|
||||
'createdRangeToday' => $createdRangeToday,
|
||||
'createdRangeFrom7d' => $createdRangeFrom7d,
|
||||
'createdRangeFrom30d' => $createdRangeFrom30d,
|
||||
|
||||
'summaryStats' => [
|
||||
'total_orders' => (clone $baseQuery)->count(),
|
||||
'paid_orders' => (clone $baseQuery)->where('payment_status', 'paid')->count(),
|
||||
|
||||
Reference in New Issue
Block a user