From 2f05f6df471a26e483d742d232c1eff6d45cd99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 08:16:31 +0000 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E7=BA=BF=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=88=9B=E5=BB=BA=E7=BB=AD=E8=B4=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=85=A5=E5=8F=A3=EF=BC=88require=5Fsubscription?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_leads/index.blade.php | 24 +++++++ ...ormLeadIndexCreateRenewalOrderLinkTest.php | 62 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/Feature/AdminPlatformLeadIndexCreateRenewalOrderLinkTest.php diff --git a/resources/views/admin/platform_leads/index.blade.php b/resources/views/admin/platform_leads/index.blade.php index 85a9cd5..123fc15 100644 --- a/resources/views/admin/platform_leads/index.blade.php +++ b/resources/views/admin/platform_leads/index.blade.php @@ -48,6 +48,29 @@ return '/admin/platform-orders/create?' . \Illuminate\Support\Arr::query($q); }; + + // 从线索直达“创建续费订单”入口:本质是 require_subscription 治理链路。 + // 线索自身通常没有订阅ID,因此这里不直接传 site_subscription_id,而是引导先去订阅管理选择订阅再返回。 + $buildCreateRenewalOrderUrl = function (\App\Models\PlatformLead $l) use ($selfWithoutBack) { + $q = []; + + if ((int) $l->plan_id > 0) { + $q['plan_id'] = (int) $l->plan_id; + } + + $meta = is_array($l->meta) ? $l->meta : []; + $merchantId = (int) ($meta['merchant_id'] ?? 0); + if ($merchantId > 0) { + $q['merchant_id'] = $merchantId; + } + + // require_subscription:用于“续费必须先选订阅”的治理 UI 口径 + $q['require_subscription'] = '1'; + $q['lead_id'] = (int) $l->id; + $q['back'] = $selfWithoutBack; + + return '/admin/platform-orders/create?' . \Illuminate\Support\Arr::query($q); + }; @endphp
@@ -155,6 +178,7 @@
创建订单 + 创建续费订单 @php $viewOrdersUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([ diff --git a/tests/Feature/AdminPlatformLeadIndexCreateRenewalOrderLinkTest.php b/tests/Feature/AdminPlatformLeadIndexCreateRenewalOrderLinkTest.php new file mode 100644 index 0000000..fcb57c3 --- /dev/null +++ b/tests/Feature/AdminPlatformLeadIndexCreateRenewalOrderLinkTest.php @@ -0,0 +1,62 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_lead_index_should_include_create_renewal_order_link(): void + { + $this->loginAsPlatformAdmin(); + + $plan = Plan::query()->create([ + 'code' => 'lead_index_create_renewal_plan', + 'name' => '线索页创建续费订单入口测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $lead = PlatformLead::query()->create([ + 'status' => 'new', + 'name' => '张三', + 'mobile' => '13800000000', + 'email' => 'zs@example.com', + 'company' => '测试公司', + 'plan_id' => $plan->id, + 'source' => 'test', + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-leads'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertStringContainsString('创建续费订单', $html); + $this->assertStringContainsString('/admin/platform-orders/create?', $html); + $this->assertStringContainsString('require_subscription=1', $html); + $this->assertStringContainsString('lead_id=' . $lead->id, $html); + $this->assertStringContainsString('plan_id=' . $plan->id, $html); + $this->assertStringContainsString('back=' . urlencode('/admin/platform-leads'), $html); + } +}