From 19abd26dd9db3bcf06d088297d3ad066c8d51d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 04:17:14 +0000 Subject: [PATCH] =?UTF-8?q?fix(platform):=20=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=9B=E5=BB=BA=E9=A1=B5=E9=80=8F=E4=BC=A0=20lead?= =?UTF-8?q?=5Fid=20=E4=BB=A5=E7=BB=B4=E6=8C=81=E7=BA=BF=E7=B4=A2=E8=81=94?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/PlatformOrderController.php | 2 + .../admin/platform_orders/form.blade.php | 2 + ...latformOrderCreateShouldKeepLeadIdTest.php | 67 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderCreateShouldKeepLeadIdTest.php diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 906f949..ec067c3 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -40,6 +40,8 @@ class PlatformOrderController extends Controller 'remark' => (string) $request->query('remark', ''), // back:用于创建成功后回到来源页(例如订阅详情) 'back' => (string) $request->query('back', ''), + // 线索联动:用于从开通线索进入下单页,需透传到 form hidden input + 'lead_id' => (int) $request->query('lead_id', 0), ]; // back 安全阀:必须为站内相对路径,并拒绝引号/尖括号。 diff --git a/resources/views/admin/platform_orders/form.blade.php b/resources/views/admin/platform_orders/form.blade.php index 1f32fcd..89d2fad 100644 --- a/resources/views/admin/platform_orders/form.blade.php +++ b/resources/views/admin/platform_orders/form.blade.php @@ -30,6 +30,8 @@ + + @php $backVal = (string) old('back', $defaults['back'] ?? ''); @endphp diff --git a/tests/Feature/AdminPlatformOrderCreateShouldKeepLeadIdTest.php b/tests/Feature/AdminPlatformOrderCreateShouldKeepLeadIdTest.php new file mode 100644 index 0000000..e91413d --- /dev/null +++ b/tests/Feature/AdminPlatformOrderCreateShouldKeepLeadIdTest.php @@ -0,0 +1,67 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_create_should_render_hidden_lead_id_input_when_present_in_query(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'lead_id_create_order_plan', + 'name' => '下单页lead_id透传测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $lead = PlatformLead::query()->create([ + 'name' => 'lead_id线索', + 'mobile' => '13800000005', + 'email' => 'lead5@example.com', + 'company' => 'lead_id公司', + 'source' => 'test', + 'status' => 'new', + 'plan_id' => $plan->id, + 'meta' => ['merchant_id' => $merchant->id], + ]); + + $url = '/admin/platform-orders/create?' . Arr::query([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'lead_id' => $lead->id, + 'back' => '/admin/platform-leads', + ]); + + $res = $this->get($url); + $res->assertOk(); + + $res->assertSee('name="lead_id"', false); + $res->assertSee('value="' . $lead->id . '"', false); + } +}