feat(admin): 订阅详情页补齐续费缺订阅治理入口(同站点/同套餐)

This commit is contained in:
萝卜
2026-03-15 08:01:35 +00:00
parent 553b064e51
commit 46f1a7a2ff
2 changed files with 71 additions and 0 deletions

View File

@@ -142,6 +142,7 @@
<div class="mt-6 actions gap-10">
<a class="btn btn-secondary btn-sm" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id]) !!}">查看关联平台订单按订阅ID精确过滤</a>
<a class="btn btn-secondary btn-sm" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'syncable_only' => '1']) !!}">查看可同步订单</a>
<a class="btn btn-secondary btn-sm" href="{!! $makePlatformOrderUrl(['merchant_id' => $subscription->merchant_id, 'plan_id' => $subscription->plan_id, 'renewal_missing_subscription' => '1']) !!}">查看续费缺订阅订单(同站点/同套餐)</a>
@php
$createRenewalOrderUrl = '/admin/platform-orders/create?' . \Illuminate\Support\Arr::query([
'merchant_id' => $subscription->merchant_id,

View File

@@ -0,0 +1,70 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\SiteSubscription;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminSiteSubscriptionShowRenewalMissingSubscriptionGovernanceLinkTest 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_show_should_render_renewal_missing_subscription_governance_link(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'sub_show_rms_link_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' => 'active',
'source' => 'manual',
'subscription_no' => 'SS_SHOW_RMS_LINK_0001',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'amount' => 10,
'starts_at' => now(),
'ends_at' => now()->addMonth(),
]);
$res = $this->get('/admin/site-subscriptions/' . $sub->id);
$res->assertOk();
$html = (string) $res->getContent();
$this->assertStringContainsString('查看续费缺订阅订单(同站点/同套餐)', $html);
$this->assertStringContainsString('/admin/platform-orders?', $html);
$this->assertStringContainsString('merchant_id=' . $merchant->id, $html);
$this->assertStringContainsString('plan_id=' . $plan->id, $html);
$this->assertStringContainsString('renewal_missing_subscription=1', $html);
// back 应回到订阅详情自身
$this->assertStringContainsString('back=' . urlencode('/admin/site-subscriptions/' . $sub->id), $html);
}
}