feat: reconcile mismatch row hint link to payment receipts anchor

This commit is contained in:
萝卜
2026-03-11 07:12:20 +00:00
parent b270632a90
commit 73dd49ac43
3 changed files with 81 additions and 4 deletions

View File

@@ -597,9 +597,15 @@
@endif
</td>
<td>
@php $rowDelta = (float) ($order->reconciliation_delta_row ?? 0); @endphp
@if(abs($rowDelta) >= 0.01)
<span class="muted text-danger">¥{{ number_format($rowDelta, 2) }}</span>
@php
$rowDelta = (float) ($order->reconciliation_delta_row ?? 0);
// 统一口径:按分取整判断是否对账不一致,避免浮点误差导致 0.01 边界不稳定
$isReconcileMismatchRow = (bool) $order->isReconcileMismatch();
$reconcileShowUrl = '/admin/platform-orders/' . $order->id . '#payment-receipts';
@endphp
@if($isReconcileMismatchRow)
<a class="link text-danger" href="{{ $reconcileShowUrl }}">¥{{ number_format($rowDelta, 2) }}</a>
<div class="muted text-danger muted-xs">对账不一致</div>
@else
<span class="muted">¥0.00</span>
@endif

View File

@@ -235,7 +235,7 @@
@endif
</div>
<div class="card mb-20">
<div class="card mb-20" id="payment-receipts">
<h3>支付回执(对账留痕)</h3>
<p class="muted muted-tight">用于“线下收款/转账/人工核对”的留痕记录(当前阶段先落 meta不引入独立表</p>

View File

@@ -0,0 +1,71 @@
<?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 AdminPlatformOrderReconcileMismatchRowHintTest 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_row_can_show_reconcile_mismatch_hint_and_link_to_payment_receipts_anchor(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'reconcile_mismatch_row_hint_01',
'name' => '对账不一致行级提示测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_RECON_ROW_HINT_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' => 10,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'payment_summary' => [
'count' => 1,
'total_amount' => 9.99,
],
],
]);
$this->get('/admin/platform-orders?reconcile_mismatch=1')
->assertOk()
->assertSee('PO_RECON_ROW_HINT_0001')
->assertSee('/admin/platform-orders/' . $order->id . '#payment-receipts', false)
->assertSee('对账不一致');
}
}