平台订单列表摘要链接补齐 data-role 与 back 口径护栏

This commit is contained in:
萝卜
2026-03-18 17:05:16 +08:00
parent afd8302c79
commit 08b61b266c
2 changed files with 67 additions and 2 deletions

View File

@@ -776,7 +776,7 @@
<div class="metric-number">¥{{ number_format($delta, 2) }}</div>
<div class="muted muted-xs">{{ $summaryStats['reconciliation_delta_note'] ?? '回执总额 - 订单已付总额' }}(当前筛选范围)</div>
<div class="muted muted-xs">对账不一致订单:
<a class="link" href="{!! $safeFullUrlWithQuery(['reconcile_mismatch' => '1', 'page' => null]) !!}">{{ $summaryStats['reconcile_mismatch_orders'] ?? 0 }}</a>
<a data-role="po-summary-link-reconcile-mismatch-orders" class="link" href="{!! $safeFullUrlWithQuery(['reconcile_mismatch' => '1', 'page' => null]) !!}">{{ $summaryStats['reconcile_mismatch_orders'] ?? 0 }}</a>
</div>
@php $tol = (float) config('saasshop.amounts.tolerance', 0.01); @endphp
<div class="muted muted-xs">当前容差:¥{{ number_format($tol, 2) }}</div>
@@ -787,7 +787,7 @@
<div class="card">
<h3>退款不一致订单</h3>
<div class="metric-number">
<a class="link" href="{!! $safeFullUrlWithQuery(['refund_inconsistent' => '1', 'page' => null]) !!}">{{ $summaryStats['refund_inconsistent_orders'] ?? 0 }}</a>
<a data-role="po-summary-link-refund-inconsistent-orders" class="link" href="{!! $safeFullUrlWithQuery(['refund_inconsistent' => '1', 'page' => null]) !!}">{{ $summaryStats['refund_inconsistent_orders'] ?? 0 }}</a>
</div>
@php $refundTol = (float) config('saasshop.amounts.tolerance', 0.01); @endphp
<div class="muted muted-xs">口径:状态=refunded 但退款总额 + 容差 < 已付;或状态!=refunded 且退款总额 >= 已付 + 容差</div>

View File

@@ -0,0 +1,65 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexSummaryLinksShouldHaveDataRoleAndKeepBackTest 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_platform_orders_index_summary_links_should_have_data_role_and_keep_back(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/platform-orders?merchant_id=1&back=/admin&page=2');
$res->assertOk();
$html = (string) $res->getContent();
$cases = [
[
'role' => 'po-summary-link-reconcile-mismatch-orders',
'expect' => ['reconcile_mismatch' => '1'],
],
[
'role' => 'po-summary-link-refund-inconsistent-orders',
'expect' => ['refund_inconsistent' => '1'],
],
];
foreach ($cases as $c) {
$role = (string) ($c['role'] ?? '');
$this->assertNotSame('', $role);
$re = '/<a[^>]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u';
$this->assertMatchesRegularExpression($re, $html);
preg_match($re, $html, $m);
$rawHref = (string) ($m[1] ?? '');
$this->assertStringNotContainsString('&amp;back=', $rawHref);
$href = html_entity_decode($rawHref);
$query = parse_url($href, PHP_URL_QUERY) ?: '';
parse_str($query, $q);
foreach (($c['expect'] ?? []) as $k => $v) {
$this->assertSame((string) $v, (string) ($q[$k] ?? ''), $role . ' missing expected ' . $k);
}
$this->assertSame('/admin', (string) ($q['back'] ?? ''));
$this->assertArrayNotHasKey('page', $q);
}
}
}