订单详情:同步订阅治理提示与直达入口

This commit is contained in:
萝卜
2026-03-11 08:45:17 +00:00
parent f9b3af82b3
commit bebae1932c
2 changed files with 128 additions and 0 deletions

View File

@@ -157,6 +157,17 @@
<button type="submit" @disabled(! $canActivate || $alreadySynced)>{{ $alreadySynced ? '已同步' : '同步订阅' }}</button> <button type="submit" @disabled(! $canActivate || $alreadySynced)>{{ $alreadySynced ? '已同步' : '同步订阅' }}</button>
</form> </form>
@if($order->isReconcileMismatch())
<div class="muted text-danger" style="margin-top:6px; width:100%;">提示:当前订单命中「对账不一致」,建议先补齐支付回执并核对金额差额后再同步订阅。
<a class="link" href="/admin/platform-orders/{{ $order->id }}#add-payment-receipt">去补回执</a>
</div>
@endif
@if($order->isRefundInconsistent())
<div class="muted text-danger" style="margin-top:6px; width:100%;">提示:当前订单命中「退款不一致」,建议先核对退款轨迹/状态后再同步订阅。
<a class="link" href="/admin/platform-orders/{{ $order->id }}#refund-receipts">去核对退款</a>
</div>
@endif
@if($order->siteSubscription) @if($order->siteSubscription)
@php @php
$subBack = '/admin/platform-orders/' . $order->id; $subBack = '/admin/platform-orders/' . $order->id;

View File

@@ -0,0 +1,117 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderShowActivateSubscriptionGovernanceHintTest 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_order_show_page_shows_activate_subscription_governance_hint_when_reconcile_mismatch(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'show_activate_gov_hint_reconcile_test',
'name' => '详情页同步订阅提示(对账不一致)测试套餐',
'billing_cycle' => 'monthly',
'price' => 66,
'list_price' => 66,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_SHOW_ACT_GOV_HINT_RECON_0001',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 66,
'paid_amount' => 66,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'payment_summary' => [
'count' => 1,
'total_amount' => 65.98,
],
],
]);
$this->get('/admin/platform-orders/' . $order->id)
->assertOk()
->assertSee('命中「对账不一致」', false)
->assertSee('#add-payment-receipt', false);
}
public function test_order_show_page_shows_activate_subscription_governance_hint_when_refund_inconsistent(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'show_activate_gov_hint_refund_test',
'name' => '详情页同步订阅提示(退款不一致)测试套餐',
'billing_cycle' => 'monthly',
'price' => 66,
'list_price' => 66,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_SHOW_ACT_GOV_HINT_REFUND_0002',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'refunded',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 66,
'paid_amount' => 66,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'refunded_at' => now(),
'meta' => [
'refund_summary' => [
'count' => 1,
'total_amount' => 65.98,
],
],
]);
$this->get('/admin/platform-orders/' . $order->id)
->assertOk()
->assertSee('命中「退款不一致」', false)
->assertSee('#refund-receipts', false);
}
}