diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 68f158f..a694582 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -1076,8 +1076,20 @@ ¥{{ number_format((float) $order->payable_amount, 2) }} ¥{{ number_format((float) $order->paid_amount, 2) }} - {{ optional($order->placed_at)->format('Y-m-d H:i:s') ?: '-' }} - {{ optional($order->paid_at)->format('Y-m-d H:i:s') ?: '-' }} + + @if($isFullView) + {{ optional($order->placed_at)->format('Y-m-d H:i:s') ?: '-' }} + @else + {{ optional($order->placed_at)->format('Y-m-d') ?: '-' }} + @endif + + + @if($isFullView) + {{ optional($order->paid_at)->format('Y-m-d H:i:s') ?: '-' }} + @else + {{ optional($order->paid_at)->format('Y-m-d') ?: '-' }} + @endif + @php $syncedId = (int) data_get($order->meta, 'subscription_activation.subscription_id', 0); diff --git a/tests/Feature/AdminPlatformOrderIndexCompactViewTimeFormatTest.php b/tests/Feature/AdminPlatformOrderIndexCompactViewTimeFormatTest.php new file mode 100644 index 0000000..70c9866 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexCompactViewTimeFormatTest.php @@ -0,0 +1,77 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_compact_view_shows_date_only_full_view_shows_datetime(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_index_compact_time_format_plan', + 'name' => '平台订单列表时间格式测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $placedAt = now()->setDate(2026, 3, 14)->setTime(11, 22, 33); + $paidAt = now()->setDate(2026, 3, 14)->setTime(12, 34, 56); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_INDEX_TIME_FORMAT_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => $placedAt, + 'paid_at' => $paidAt, + 'activated_at' => now(), + 'meta' => [], + ]); + + // 精简视图:只显示日期 + $this->get('/admin/platform-orders') + ->assertOk() + ->assertSee('2026-03-14', false) + ->assertDontSee('11:22:33', false) + ->assertDontSee('12:34:56', false); + + // full 视图:显示日期 + 时间 + $this->get('/admin/platform-orders?view=full') + ->assertOk() + ->assertSee('2026-03-14 11:22:33', false) + ->assertSee('2026-03-14 12:34:56', false); + } +}