diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php
index 9089f0f..8bdd9f8 100644
--- a/resources/views/admin/platform_orders/show.blade.php
+++ b/resources/views/admin/platform_orders/show.blade.php
@@ -4,6 +4,21 @@
@section('page_title', '平台订单详情')
@section('content')
+@php
+ // 用于构建“保留当前上下文”的平台订单列表跳转链接(从详情跳回列表后可一键返回本订单详情)
+ $orderShowSelf = '/' . ltrim(request()->path(), '/');
+ $orderShowQuery = request()->query();
+ unset($orderShowQuery['back']);
+ if (count($orderShowQuery) > 0) {
+ $orderShowSelf .= '?' . \Illuminate\Support\Arr::query($orderShowQuery);
+ }
+
+ $makePlatformOrderIndexUrl = function (array $query) use ($orderShowSelf) {
+ $query = $query + ['back' => $orderShowSelf];
+
+ return '/admin/platform-orders?' . \Illuminate\Support\Arr::query($query);
+ };
+@endphp
这里用于运营排查:订单核心字段、关联订阅、以及订阅同步元数据(meta)。
@@ -18,7 +33,7 @@
站点 |
@if($order->merchant)
- {{ $order->merchant->name }}
+ {{ $order->merchant->name }}
@else
未关联站点
@endif
@@ -29,7 +44,7 @@
|
@php $planName = $order->plan_name ?: ($order->plan?->name ?? '-'); @endphp
@if($order->plan)
- {{ $planName }}
+ {{ $planName }}
@else
{{ $planName }}
@endif
diff --git a/tests/Feature/AdminPlatformOrderShowMerchantPlanLinksContainBackTest.php b/tests/Feature/AdminPlatformOrderShowMerchantPlanLinksContainBackTest.php
new file mode 100644
index 0000000..306c708
--- /dev/null
+++ b/tests/Feature/AdminPlatformOrderShowMerchantPlanLinksContainBackTest.php
@@ -0,0 +1,78 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_show_page_merchant_and_plan_links_should_contain_back_to_order_show(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $merchant = Merchant::query()->firstOrFail();
+
+ $plan = Plan::query()->create([
+ 'code' => 'po_show_merchant_plan_back_test',
+ 'name' => '平台订单详情商家/套餐 back 链接测试套餐',
+ 'billing_cycle' => 'monthly',
+ 'price' => 10,
+ 'list_price' => 10,
+ 'status' => 'active',
+ 'sort' => 10,
+ 'published_at' => now(),
+ ]);
+
+ $order = PlatformOrder::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'order_no' => 'PO_SHOW_MERCHANT_PLAN_BACK_0001',
+ 'order_type' => 'new_purchase',
+ 'status' => 'pending',
+ 'payment_status' => 'unpaid',
+ 'plan_name' => $plan->name,
+ 'billing_cycle' => $plan->billing_cycle,
+ 'period_months' => 1,
+ 'quantity' => 1,
+ 'payable_amount' => 10,
+ 'paid_amount' => 0,
+ 'placed_at' => now(),
+ 'meta' => [],
+ ]);
+
+ $res = $this->get('/admin/platform-orders/' . $order->id);
+ $res->assertOk();
+
+ $back = '/admin/platform-orders/' . $order->id;
+
+ $expectedMerchantUrl = '/admin/platform-orders?' . Arr::query([
+ 'merchant_id' => $merchant->id,
+ 'back' => $back,
+ ]);
+
+ $expectedPlanUrl = '/admin/platform-orders?' . Arr::query([
+ 'plan_id' => $plan->id,
+ 'back' => $back,
+ ]);
+
+ $res->assertSee($expectedMerchantUrl, false);
+ $res->assertSee($expectedPlanUrl, false);
+ }
+}
|