Keep site subscription index context via back param links
This commit is contained in:
@@ -4,6 +4,11 @@
|
|||||||
@section('page_title', '订阅管理')
|
@section('page_title', '订阅管理')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
@php
|
||||||
|
// 用于“跨页跳转后仍可返回订阅列表并保留筛选上下文”
|
||||||
|
// 注意:使用相对路径(RequestUri)而非绝对 URL,避免不同 APP_URL 环境影响,以及 show 页 back 安全校验(要求以 / 开头)
|
||||||
|
$back = request()->getRequestUri();
|
||||||
|
@endphp
|
||||||
<div class="card mb-20">
|
<div class="card mb-20">
|
||||||
<p class="muted muted-tight">这里是总台视角的订阅目录页,承接“套餐 -> 订阅 -> 平台订单”的收费主链中间层。</p>
|
<p class="muted muted-tight">这里是总台视角的订阅目录页,承接“套餐 -> 订阅 -> 平台订单”的收费主链中间层。</p>
|
||||||
<p class="muted">当前阶段先做到:可访问列表、可筛选、统计摘要;后续再接:订阅激活服务 / 续费 / 取消 / 对账。</p>
|
<p class="muted">当前阶段先做到:可访问列表、可筛选、统计摘要;后续再接:订阅激活服务 / 续费 / 取消 / 对账。</p>
|
||||||
@@ -124,7 +129,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ $subscription->id }}</td>
|
<td>{{ $subscription->id }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/admin/site-subscriptions/{{ $subscription->id }}">{{ $subscription->subscription_no }}</a>
|
<a href="/admin/site-subscriptions/{{ $subscription->id }}?back={{ urlencode($back) }}">{{ $subscription->subscription_no }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if($subscription->merchant)
|
@if($subscription->merchant)
|
||||||
@@ -165,7 +170,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@php $cnt = (int) ($subscription->platform_orders_count ?? 0); @endphp
|
@php $cnt = (int) ($subscription->platform_orders_count ?? 0); @endphp
|
||||||
@if($cnt > 0)
|
@if($cnt > 0)
|
||||||
<a href="/admin/platform-orders?site_subscription_id={{ $subscription->id }}">{{ $cnt }}</a>
|
<a href="/admin/platform-orders?site_subscription_id={{ $subscription->id }}&back={{ urlencode($back) }}">{{ $cnt }}</a>
|
||||||
@else
|
@else
|
||||||
<span class="muted">0</span>
|
<span class="muted">0</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use App\Models\SiteSubscription;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminSiteSubscriptionIndexOrderCountLinkKeepsFiltersTest 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_orders_count_link_in_index_should_keep_current_filters(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'sub_index_keep_filters_plan',
|
||||||
|
'name' => '订阅列表链接保留筛选测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sub = SiteSubscription::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'status' => 'activated',
|
||||||
|
'source' => 'manual',
|
||||||
|
'subscription_no' => 'SUB_INDEX_KEEP_FILTER_0001',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'amount' => 10,
|
||||||
|
'starts_at' => now()->subDay(),
|
||||||
|
'ends_at' => now()->addMonth(),
|
||||||
|
'activated_at' => now()->subDay(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'site_subscription_id' => $sub->id,
|
||||||
|
'order_no' => 'PO_SUB_INDEX_KEEP_FILTER_0001',
|
||||||
|
'order_type' => 'renewal',
|
||||||
|
'status' => 'activated',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'activated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/site-subscriptions?status=activated&keyword=' . urlencode('KEEP'));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
// 期望:点击“关联订单数”应该跳转到平台订单页,并保留“回到订阅列表的 back 参数”(保留上下文)
|
||||||
|
// 当前实现先仅要求存在 site_subscription_id;后续页面改造后可再加 back 参数断言。
|
||||||
|
$res->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user