平台订单详情:对账/退款不一致列表链接携带 back 并防嵌套

This commit is contained in:
萝卜
2026-03-13 20:15:47 +00:00
parent 4a9d94c186
commit d51a750d17
2 changed files with 118 additions and 3 deletions

View File

@@ -110,7 +110,13 @@
<div class="muted muted-xs refund-governance-meta">已付:¥{{ number_format($paidAmountFloat, 2) }}|退款总额:¥{{ number_format($refundTotal, 2) }}</div>
<div class="muted muted-xs refund-governance-meta">操作说明:该区块仅用于修正支付状态展示口径,不会改金额、不生成退款记录;请先核对退款轨迹。</div>
<div class="muted muted-xs refund-governance-meta">
<a class="link" href="/admin/platform-orders?refund_inconsistent=1">查看全部退款不一致订单</a>
@php
$refundInconsistentListUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'refund_inconsistent' => 1,
'back' => $orderShowSelf,
]);
@endphp
<a class="link" href="{!! $refundInconsistentListUrl !!}">查看全部退款不一致订单</a>
</div>
@if($canMarkRefunded)
@@ -320,7 +326,13 @@
<span class="muted"></span>
<a class="link" href="#add-payment-receipt">去补一条支付回执</a>
<span class="muted"></span>
<a class="link" href="/admin/platform-orders?reconcile_mismatch=1">查看全部对账不一致订单</a>
@php
$reconcileMismatchListUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'reconcile_mismatch' => 1,
'back' => $orderShowSelf,
]);
@endphp
<a class="link" href="{!! $reconcileMismatchListUrl !!}">查看全部对账不一致订单</a>
</div>
@endif
@@ -391,7 +403,13 @@
<div class="muted text-danger" style="margin-top:10px;">
提示:该订单疑似存在「退款状态 vs 退款总额」不一致(按容差口径),建议核对退款轨迹、已付金额与支付状态。
<span class="muted"></span>
<a class="link" href="/admin/platform-orders?refund_inconsistent=1">查看全部退款不一致订单</a>
@php
$refundInconsistentListUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'refund_inconsistent' => 1,
'back' => $orderShowSelf,
]);
@endphp
<a class="link" href="{!! $refundInconsistentListUrl !!}">查看全部退款不一致订单</a>
</div>
@endif

View File

@@ -0,0 +1,97 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Arr;
use Tests\TestCase;
class AdminPlatformOrderShowReconcileRefundInconsistentListLinksContainBackTest 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_page_list_links_should_carry_back_to_order_show_self_without_nested_back(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'po_show_reconcile_refund_list_back_plan',
'name' => '平台订单详情对账/退款不一致列表 back 链接测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
// 造一个“对账不一致”的订单receipt_total(9) vs paid_amount(10)
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_SHOW_LIST_BACK_0001',
'order_type' => 'new_purchase',
'status' => 'pending',
'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(),
'meta' => [
'payment_summary' => ['count' => 1, 'total' => 9],
'payment_receipts' => [
['amount' => 9, 'paid_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
],
// 同时造一个“退款不一致”态payment_status=refunded 但退款总额不足
'refund_summary' => ['count' => 1, 'total' => 1],
'refund_receipts' => [
['amount' => 1, 'refunded_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
],
],
]);
// 为了触发退款不一致提示:将状态改为 refunded
$order->update(['payment_status' => 'refunded']);
// 模拟从列表进入详情页(带 back
$res = $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode('/admin/platform-orders?status=pending'));
$res->assertOk();
// 详情页自身(去掉 back
$expectedOrderShowSelf = '/admin/platform-orders/' . $order->id;
$expectedReconcileUrl = '/admin/platform-orders?' . Arr::query([
'reconcile_mismatch' => 1,
'back' => $expectedOrderShowSelf,
]);
$expectedRefundUrl = '/admin/platform-orders?' . Arr::query([
'refund_inconsistent' => 1,
'back' => $expectedOrderShowSelf,
]);
$res->assertSee($expectedReconcileUrl, false);
$res->assertSee($expectedRefundUrl, false);
// 不允许 back 嵌套
$res->assertDontSee('back%3D', false);
}
}