refactor(plans): hide create order action when plan not active
This commit is contained in:
@@ -151,45 +151,30 @@
|
||||
<div class="num-md">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['status' => 'active', 'page' => null]) !!}">{{ $summaryStats['active_plans'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['status' => 'inactive', 'page' => null]) !!}">查看停用套餐</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>月付套餐</h3>
|
||||
<div class="num-md">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['billing_cycle' => 'monthly', 'page' => null]) !!}">{{ $summaryStats['monthly_plans'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['billing_cycle' => 'yearly', 'page' => null]) !!}">查看年付套餐</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>年付套餐</h3>
|
||||
<div class="num-md">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['billing_cycle' => 'yearly', 'page' => null]) !!}">{{ $summaryStats['yearly_plans'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['billing_cycle' => 'monthly', 'page' => null]) !!}">查看月付套餐</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>已发布套餐</h3>
|
||||
<div class="num-md">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['published' => 'published', 'page' => null]) !!}">{{ $summaryStats['published_plans'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['published' => 'unpublished', 'page' => null]) !!}">查看未发布套餐</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>未发布套餐</h3>
|
||||
<div class="num-md">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['published' => 'unpublished', 'page' => null]) !!}">{{ $summaryStats['unpublished_plans'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['published' => 'published', 'page' => null]) !!}">查看已发布套餐</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>关联订阅总量</h3>
|
||||
@@ -281,7 +266,11 @@
|
||||
@endphp
|
||||
<div class="actions gap-10">
|
||||
<a href="{!! $editPlanUrl !!}" class="btn btn-secondary btn-sm">编辑</a>
|
||||
@if((string) ($plan->status ?? '') === 'active')
|
||||
<a href="{!! $createOrderUrl !!}" class="btn btn-sm">创建订单</a>
|
||||
@else
|
||||
<span class="muted muted-xs">未启用:不建议下单</span>
|
||||
@endif
|
||||
<a href="{!! $renewalMissingSubscriptionUrl !!}" class="btn btn-secondary btn-sm">续费缺订阅</a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Plan;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlanIndexCreateOrderLinkShouldHideWhenPlanNotActiveTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function loginAsPlatformAdmin(): void
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user