fix: 订阅批量过期动作透传 ends_at 区间筛选

This commit is contained in:
萝卜
2026-03-17 06:27:34 +08:00
parent f39fb9ebcd
commit 0b2f0c7d74
4 changed files with 88 additions and 1 deletions

View File

@@ -320,6 +320,9 @@ class SiteSubscriptionController extends Controller
// - expired已过期ends_at < now // - expired已过期ends_at < now
// - expiring_7d7 天内到期now <= ends_at < now+7d // - expiring_7d7 天内到期now <= ends_at < now+7d
'expiry' => trim((string) $request->query('expiry', '')), '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( $query = $this->applyFilters(
@@ -448,6 +451,9 @@ class SiteSubscriptionController extends Controller
'merchant_id' => trim((string) $request->input('merchant_id', '')), 'merchant_id' => trim((string) $request->input('merchant_id', '')),
'plan_id' => trim((string) $request->input('plan_id', '')), 'plan_id' => trim((string) $request->input('plan_id', '')),
'expiry' => trim((string) $request->input('expiry', '')), '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') { if ((string) ($filters['expiry'] ?? '') !== 'expired') {

View File

@@ -383,6 +383,8 @@
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}"> <input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}"> <input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
<input type="hidden" name="expiry" value="{{ $filters['expiry'] ?? '' }}"> <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'] ?? '' }}"> <input type="hidden" name="keyword" value="{{ $filters['keyword'] ?? '' }}">
<button class="btn btn-secondary btn-sm" type="submit">导出 CSV</button> <button class="btn btn-secondary btn-sm" type="submit">导出 CSV</button>
</form> </form>
@@ -411,6 +413,8 @@
<input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}"> <input type="hidden" name="merchant_id" value="{{ $filters['merchant_id'] ?? '' }}">
<input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}"> <input type="hidden" name="plan_id" value="{{ $filters['plan_id'] ?? '' }}">
<input type="hidden" name="expiry" value="{{ $filters['expiry'] ?? '' }}"> <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'] ?? '' }}"> <input type="hidden" name="keyword" value="{{ $filters['keyword'] ?? '' }}">
<label class="muted form-inline-row"> <label class="muted form-inline-row">
@@ -422,7 +426,16 @@
<div> <div>
<button class="btn btn-danger btn-sm" type="submit" @disabled(! $batchMarkExpiredEnabled) title="{{ $batchMarkExpiredReason }}">批量标记已过期(当前集合)</button> <button class="btn btn-danger btn-sm" type="submit" @disabled(! $batchMarkExpiredEnabled) title="{{ $batchMarkExpiredReason }}">批量标记已过期(当前集合)</button>
@if(! $batchMarkExpiredEnabled) @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 @endif
</div> </div>
</form> </form>

View File

@@ -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);
}
}

View File

@@ -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);
}
}