From e234465f6edfcd1b781855c490c05c7c7c0d138d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 04:23:21 +0000 Subject: [PATCH] =?UTF-8?q?chore(admin):=20=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E5=8D=95=E9=A1=B5=E5=B1=95=E7=A4=BA=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E7=BA=BF=E7=B4=A2=E4=B8=8A=E4=B8=8B=E6=96=87=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/form.blade.php | 29 ++++++++ ...OrderFormShouldShowLeadContextHintTest.php | 68 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderFormShouldShowLeadContextHintTest.php diff --git a/resources/views/admin/platform_orders/form.blade.php b/resources/views/admin/platform_orders/form.blade.php index 89d2fad..589dfad 100644 --- a/resources/views/admin/platform_orders/form.blade.php +++ b/resources/views/admin/platform_orders/form.blade.php @@ -8,6 +8,35 @@

用于总台运营手工创建一笔平台订单(演示/补单/线下收款录入)。

创建后可在「平台订单」列表中继续推进:标记支付并生效 → 同步订阅(形成最小收费闭环)。

+ @php + $leadId = (int) old('lead_id', $defaults['lead_id'] ?? 0); + $incomingBackForLead = (string) ($defaults['back'] ?? ''); + $leadBack = (str_starts_with($incomingBackForLead, '/') + && !preg_match('/["\'<>]/', $incomingBackForLead) + && !preg_match('/(?:^|[?&])back=/', $incomingBackForLead)) + ? $incomingBackForLead + : ''; + + $viewLeadOrdersQuery = [ + 'lead_id' => $leadId, + ]; + if ($leadBack !== '') { + $viewLeadOrdersQuery['back'] = $leadBack; + } + + $viewLeadOrdersUrl = '/admin/platform-orders'; + if ($leadId > 0) { + $viewLeadOrdersUrl .= '?' . \Illuminate\Support\Arr::query($viewLeadOrdersQuery); + } + @endphp + + @if($leadId > 0) +
+ 来源线索:#{{ $leadId }} + 查看该线索关联订单 +
+ @endif + @if(($siteSubscription ?? null) && $siteSubscription->id)
本订单将关联订阅:
diff --git a/tests/Feature/AdminPlatformOrderFormShouldShowLeadContextHintTest.php b/tests/Feature/AdminPlatformOrderFormShouldShowLeadContextHintTest.php new file mode 100644 index 0000000..c607fdd --- /dev/null +++ b/tests/Feature/AdminPlatformOrderFormShouldShowLeadContextHintTest.php @@ -0,0 +1,68 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_create_form_should_show_lead_context_badge_and_view_orders_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'lead_context_form_plan', + 'name' => '下单页线索提示测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $lead = PlatformLead::query()->create([ + 'name' => '线索提示', + 'mobile' => '', + 'email' => '', + 'company' => '', + 'source' => 'test', + 'status' => 'new', + 'plan_id' => $plan->id, + 'meta' => ['merchant_id' => $merchant->id], + ]); + + $res = $this->get('/admin/platform-orders/create?' . Arr::query([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'lead_id' => $lead->id, + 'back' => '/admin/platform-leads', + ])); + + $res->assertOk(); + $res->assertSee('来源线索:#' . $lead->id, false); + + // 入口应指向 platform-orders?lead_id=xxx(可带 back) + $res->assertSee('/admin/platform-orders?lead_id=' . $lead->id, false); + $res->assertSee('查看该线索关联订单', false); + } +}