diff --git a/resources/views/admin/platform_leads/index.blade.php b/resources/views/admin/platform_leads/index.blade.php
index d7ea358..5dbd65a 100644
--- a/resources/views/admin/platform_leads/index.blade.php
+++ b/resources/views/admin/platform_leads/index.blade.php
@@ -4,6 +4,39 @@
@section('page_title', '开通线索')
@section('content')
+@php
+ // back 参数用于“返回上一页(保留上下文)”,但 back 本身不应再包含 back(避免无限嵌套导致 URL 膨胀)
+ $currentQuery = request()->query();
+ unset($currentQuery['back']);
+ $selfWithoutBack = '/' . ltrim(request()->path(), '/');
+ if (count($currentQuery) > 0) {
+ $selfWithoutBack .= '?' . \Illuminate\Support\Arr::query($currentQuery);
+ }
+
+ // 从线索直达“创建平台订单”入口:预填 plan_id/remark,并带 back 回到当前线索列表(保留筛选)
+ $buildCreatePlatformOrderUrl = function (\App\Models\PlatformLead $l) use ($selfWithoutBack) {
+ $remarkParts = array_filter([
+ '线索#' . $l->id,
+ $l->name,
+ $l->mobile,
+ $l->company,
+ $l->email,
+ ], fn ($v) => (string) $v !== '');
+
+ $q = [
+ 'order_type' => 'new_purchase',
+ 'back' => $selfWithoutBack,
+ 'remark' => mb_substr(implode(' / ', $remarkParts), 0, 180),
+ ];
+
+ if ((int) $l->plan_id > 0) {
+ $q['plan_id'] = (int) $l->plan_id;
+ }
+
+ return '/admin/platform-orders/create?' . \Illuminate\Support\Arr::query($q);
+ };
+@endphp
+
对外平台(/platform)收集的开通意向线索,用于前期 A(站点开通型)人工运营承接。
后续会在此处逐步接入:一键生成站点/订阅/平台订单、跟进记录、转化漏斗与治理提示。
@@ -27,7 +60,7 @@
线索列表
-
当前阶段仅提供查询与筛选;后续补“状态流转/转化为站点/生成订单”等操作闭环。
+
当前阶段仅提供查询与筛选;已补“从线索创建订单”入口,先把收费闭环跑起来。
@@ -41,6 +74,7 @@
| 套餐ID |
来源 |
创建时间 |
+ 操作 |
@@ -55,10 +89,13 @@
{{ $l->plan_id ?: '-' }} |
{{ $l->source }} |
{{ optional($l->created_at)->format('Y-m-d H:i:s') }} |
+
+ 创建订单
+ |
@empty
- | 暂无线索 |
+ 暂无线索 |
@endforelse
diff --git a/tests/Feature/AdminPlatformLeadIndexCreateOrderLinkTest.php b/tests/Feature/AdminPlatformLeadIndexCreateOrderLinkTest.php
new file mode 100644
index 0000000..65d26f6
--- /dev/null
+++ b/tests/Feature/AdminPlatformLeadIndexCreateOrderLinkTest.php
@@ -0,0 +1,93 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_index_should_render_create_order_link_with_safe_back_and_prefills(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $plan = Plan::query()->create([
+ 'code' => 'lead_order_plan',
+ 'name' => '线索转订单测试套餐',
+ 'billing_cycle' => 'monthly',
+ 'price' => 10,
+ 'list_price' => 10,
+ 'status' => 'active',
+ 'sort' => 10,
+ 'published_at' => now(),
+ ]);
+
+ $lead = PlatformLead::query()->create([
+ 'name' => '张三',
+ 'mobile' => '13800000000',
+ 'email' => 'zs@example.com',
+ 'company' => '示例公司',
+ 'source' => 'platform_plans',
+ 'status' => 'new',
+ 'plan_id' => $plan->id,
+ 'meta' => ['from' => 'test'],
+ ]);
+
+ $currentUrl = '/admin/platform-leads?' . Arr::query([
+ 'status' => 'new',
+ 'keyword' => '张',
+ ]);
+
+ $res = $this->get($currentUrl);
+ $res->assertOk();
+
+ $selfWithoutBack = '/admin/platform-leads?' . Arr::query([
+ 'status' => 'new',
+ 'keyword' => '张',
+ ]);
+
+ $html = $res->getContent();
+
+ preg_match_all('/href="([^"]+)"/', $html, $matches);
+ $hrefs = $matches[1] ?? [];
+
+ $createUrls = array_values(array_filter($hrefs, fn ($u) => str_contains($u, '/admin/platform-orders/create?')));
+ $this->assertNotEmpty($createUrls, '未找到从线索创建订单的链接');
+
+ $found = false;
+ foreach ($createUrls as $u) {
+ $parts = parse_url($u);
+ parse_str($parts['query'] ?? '', $q);
+
+ if (($q['order_type'] ?? '') === 'new_purchase'
+ && (string) ($q['plan_id'] ?? '') === (string) $plan->id
+ && (string) ($q['back'] ?? '') === $selfWithoutBack
+ && str_contains((string) ($q['remark'] ?? ''), '线索#' . $lead->id)
+ && str_contains((string) ($q['remark'] ?? ''), '张三')) {
+ $found = true;
+ break;
+ }
+ }
+
+ $this->assertTrue($found, '未找到包含 plan_id/back/remark 预填的创建订单链接');
+ $res->assertSee('创建订单', false);
+
+ // 防 back 嵌套(URL 不应出现 back%3D)
+ $res->assertDontSee('back%3D', false);
+ }
+}