diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 7089186..79b4340 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -239,6 +239,18 @@

支付回执(对账留痕)

用于“线下收款/转账/人工核对”的留痕记录(当前阶段先落 meta,不引入独立表)。

+ @php + $isReconcileMismatch = (bool) $order->isReconcileMismatch(); + @endphp + + @if($isReconcileMismatch) +
+ 提示:该订单「回执总额 vs 已付金额」存在差异,可能对账不一致。 + + 查看全部对账不一致订单 +
+ @endif + @if(count($paymentReceipts) > 0) @php $items = array_slice(array_reverse($paymentReceipts), 0, 20); @endphp @@ -298,16 +310,8 @@

用于记录退款动作与对账轨迹(先落 meta,不引入独立表)。追加退款后,系统会自动把支付状态推进为“部分退款/已退款”(仅在订单当前为已支付时)。

@php - // 退款不一致(与列表/筛选口径保持一致,按分取整 + 0.01 容差) - $paidAmountFloat3 = (float) ($order->paid_amount ?? 0); - $isRefundInconsistent3 = false; - if ($paidAmountFloat3 > 0) { - if ((string) $order->payment_status === 'refunded') { - $isRefundInconsistent3 = (round($refundTotal * 100) + 1) < round($paidAmountFloat3 * 100); - } else { - $isRefundInconsistent3 = round($refundTotal * 100) >= round($paidAmountFloat3 * 100); - } - } + // 退款不一致(统一口径:模型方法) + $isRefundInconsistent3 = (bool) $order->isRefundInconsistent(); @endphp @if($isRefundInconsistent3) diff --git a/tests/Feature/AdminPlatformOrderShowReconcileMismatchHintTest.php b/tests/Feature/AdminPlatformOrderShowReconcileMismatchHintTest.php new file mode 100644 index 0000000..be821e9 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowReconcileMismatchHintTest.php @@ -0,0 +1,69 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_page_can_render_reconcile_mismatch_hint_and_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'show_reconcile_mismatch_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_SHOW_RECONCILE_MISMATCH_0001', + 'order_type' => 'subscription', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => 'monthly', + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'meta' => [ + 'payment_summary' => [ + 'count' => 1, + 'total_amount' => 9.99, + ], + ], + ]); + + $this->get('/admin/platform-orders/' . $order->id) + ->assertOk() + ->assertSee('对账不一致') + ->assertSee('/admin/platform-orders?reconcile_mismatch=1', false); + } +}