fix: 订阅批量过期动作透传 ends_at 区间筛选
This commit is contained in:
@@ -320,6 +320,9 @@ class SiteSubscriptionController extends Controller
|
||||
// - expired:已过期(ends_at < now)
|
||||
// - expiring_7d:7 天内到期(now <= ends_at < now+7d)
|
||||
'expiry' => trim((string) $request->query('expiry', '')),
|
||||
// 到期时间范围筛选(用于到期治理更精确定位 ends_at)
|
||||
'ends_from' => trim((string) $request->query('ends_from', '')),
|
||||
'ends_to' => trim((string) $request->query('ends_to', '')),
|
||||
];
|
||||
|
||||
$query = $this->applyFilters(
|
||||
@@ -448,6 +451,9 @@ class SiteSubscriptionController extends Controller
|
||||
'merchant_id' => trim((string) $request->input('merchant_id', '')),
|
||||
'plan_id' => trim((string) $request->input('plan_id', '')),
|
||||
'expiry' => trim((string) $request->input('expiry', '')),
|
||||
// 到期时间范围筛选:批量动作必须与当前列表口径一致
|
||||
'ends_from' => trim((string) $request->input('ends_from', '')),
|
||||
'ends_to' => trim((string) $request->input('ends_to', '')),
|
||||
];
|
||||
|
||||
if ((string) ($filters['expiry'] ?? '') !== 'expired') {
|
||||
|
||||
@@ -383,6 +383,8 @@
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="expiry" value="{{ $filters['expiry'] ?? '' }}">
|
||||
<input type="hidden" name="ends_from" value="{{ $filters['ends_from'] ?? '' }}">
|
||||
<input type="hidden" name="ends_to" value="{{ $filters['ends_to'] ?? '' }}">
|
||||
<input type="hidden" name="keyword" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<button class="btn btn-secondary btn-sm" type="submit">导出 CSV</button>
|
||||
</form>
|
||||
@@ -411,6 +413,8 @@
|
||||
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
|
||||
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
|
||||
<input type="hidden" name="expiry" value="{{ $filters['expiry'] ?? '' }}">
|
||||
<input type="hidden" name="ends_from" value="{{ $filters['ends_from'] ?? '' }}">
|
||||
<input type="hidden" name="ends_to" value="{{ $filters['ends_to'] ?? '' }}">
|
||||
<input type="hidden" name="keyword" value="{{ $filters['keyword'] ?? '' }}">
|
||||
|
||||
<label class="muted form-inline-row">
|
||||
@@ -422,7 +426,16 @@
|
||||
<div>
|
||||
<button class="btn btn-danger btn-sm" type="submit" @disabled(! $batchMarkExpiredEnabled) title="{{ $batchMarkExpiredReason }}">批量标记已过期(当前集合)</button>
|
||||
@if(! $batchMarkExpiredEnabled)
|
||||
<div class="adm-tool-blocked-hint">提示:{{ $batchMarkExpiredReason }}</div>
|
||||
<div class="adm-tool-blocked-hint" data-role="batch-mark-expired-blocked-hint">
|
||||
<div>提示:{{ $batchMarkExpiredReason }}</div>
|
||||
@php
|
||||
// 提效:被阻断时给一键跳转到「已过期(expiry=expired)」集合,避免运营来回找入口。
|
||||
$goExpiredUrl = $buildQuickFilterUrl(['status' => null, 'expiry' => 'expired', 'page' => null]);
|
||||
@endphp
|
||||
<div class="mt-6 actions gap-10">
|
||||
<a class="btn btn-secondary btn-sm" href="{!! $goExpiredUrl !!}">切到已过期集合</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminSiteSubscriptionIndexBatchMarkExpiredBlockedHintShouldIncludeGoExpiredLinkTest 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_blocked_hint_should_include_link_to_expired_scope(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
// 不在 expiry=expired 集合时,按钮应禁用并出现 blocked hint + 一键跳转。
|
||||
$res = $this->get('/admin/site-subscriptions');
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
$this->assertStringContainsString('data-role="batch-mark-expired-blocked-hint"', $html);
|
||||
$this->assertStringContainsString('切到已过期集合', $html);
|
||||
$this->assertStringContainsString('expiry=expired', $html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminSiteSubscriptionIndexBatchMarkExpiredFormShouldKeepEndsAtRangeFiltersTest 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_batch_mark_expired_form_should_keep_ends_at_range_filters(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/site-subscriptions?expiry=expired&ends_from=2026-03-01&ends_to=2026-03-31');
|
||||
$res->assertOk();
|
||||
|
||||
$res->assertSee('name="ends_from" value="2026-03-01"', false);
|
||||
$res->assertSee('name="ends_to" value="2026-03-31"', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user