From 6c0093c90e75eca727d0abde0d84ddfaf76242c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 04:49:24 +0000 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E5=B1=95=E7=A4=BA=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E7=BA=BF=E7=B4=A2=E8=B7=B3=E8=BD=AC=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/show.blade.php | 19 ++++ ...howShouldRenderLeadLinkWhenPresentTest.php | 93 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderShowShouldRenderLeadLinkWhenPresentTest.php diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index c8ebf2b..c18b02e 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -40,6 +40,25 @@ ID{{ $order->id }} 订单号{{ $order->order_no }} + @php + $platformLeadId = (int) (data_get($order->meta, 'platform_lead_id') ?? 0); + $platformLeadUrl = ''; + if ($platformLeadId > 0) { + $platformLeadUrl = '/admin/platform-leads?' . \Illuminate\Support\Arr::query([ + 'lead_id' => $platformLeadId, + 'back' => $orderShowSelf, + ]); + } + @endphp + @if($platformLeadId > 0) + + 来源线索 + + #{{ $platformLeadId }} + (从线索链路创建/关联的订单) + + + @endif 站点 diff --git a/tests/Feature/AdminPlatformOrderShowShouldRenderLeadLinkWhenPresentTest.php b/tests/Feature/AdminPlatformOrderShowShouldRenderLeadLinkWhenPresentTest.php new file mode 100644 index 0000000..85e2579 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowShouldRenderLeadLinkWhenPresentTest.php @@ -0,0 +1,93 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_should_render_lead_link_when_meta_has_platform_lead_id(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'show_lead_link_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' => ['from' => 'test'], + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'site_subscription_id' => null, + 'created_by_admin_id' => 1, + 'order_no' => 'PO_SHOW_LEAD_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'payment_channel' => null, + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'list_amount' => 10, + 'discount_amount' => 0, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'plan_snapshot' => ['plan_id' => $plan->id], + 'meta' => ['platform_lead_id' => $lead->id], + 'remark' => 'from lead', + ]); + + $showUrl = '/admin/platform-orders/' . $order->id; + + $res = $this->get($showUrl); + $res->assertOk(); + + $expected = '/admin/platform-leads?' . Arr::query([ + 'lead_id' => $lead->id, + 'back' => $showUrl, + ]); + + $res->assertSee($expected, false); + $res->assertSee('来源线索', false); + $res->assertSee('#' . $lead->id, false); + } +}