diff --git a/resources/views/admin/plans/index.blade.php b/resources/views/admin/plans/index.blade.php index 1a01404..a0e8dbe 100644 --- a/resources/views/admin/plans/index.blade.php +++ b/resources/views/admin/plans/index.blade.php @@ -151,45 +151,30 @@
{{ $summaryStats['active_plans'] ?? 0 }}
-
- 查看停用套餐 -

月付套餐

{{ $summaryStats['monthly_plans'] ?? 0 }}
-
- 查看年付套餐 -

年付套餐

{{ $summaryStats['yearly_plans'] ?? 0 }}
-
- 查看月付套餐 -

已发布套餐

{{ $summaryStats['published_plans'] ?? 0 }}
-
- 查看未发布套餐 -

未发布套餐

{{ $summaryStats['unpublished_plans'] ?? 0 }}
-
- 查看已发布套餐 -

关联订阅总量

@@ -281,7 +266,11 @@ @endphp
编辑 - 创建订单 + @if((string) ($plan->status ?? '') === 'active') + 创建订单 + @else + 未启用:不建议下单 + @endif 续费缺订阅
diff --git a/tests/Feature/AdminPlanIndexCreateOrderLinkShouldHideWhenPlanNotActiveTest.php b/tests/Feature/AdminPlanIndexCreateOrderLinkShouldHideWhenPlanNotActiveTest.php new file mode 100644 index 0000000..bd0162b --- /dev/null +++ b/tests/Feature/AdminPlanIndexCreateOrderLinkShouldHideWhenPlanNotActiveTest.php @@ -0,0 +1,48 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_plan_index_should_not_render_create_order_link_when_plan_not_active(): void + { + $this->loginAsPlatformAdmin(); + + $plan = Plan::query()->create([ + 'code' => 'plan_index_hide_create_order_when_not_active', + 'name' => '套餐页隐藏创建订单(未启用)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 99, + 'list_price' => 99, + // 非 active + 'status' => 'draft', + 'sort' => 1, + 'published_at' => null, + ]); + + $res = $this->get('/admin/plans'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 该套餐行内不应出现“创建订单”入口(避免对未启用套餐误下单) + $this->assertStringNotContainsString('/admin/platform-orders/create?plan_id=' . $plan->id, $html); + $this->assertStringContainsString('未启用:不建议下单', $html); + } +}