diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 125ebb1..d36e15b 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -639,11 +639,33 @@ $refundTotal += (float) (data_get($r, 'amount') ?? 0); } } + + $paidAmountFloat = (float) ($order->paid_amount ?? 0); + $isRefundInconsistent = false; + if ($paidAmountFloat > 0) { + if ((string) $order->payment_status === 'refunded') { + $isRefundInconsistent = (round($refundTotal * 100) + 1) < round($paidAmountFloat * 100); + } else { + $isRefundInconsistent = round($refundTotal * 100) >= round($paidAmountFloat * 100); + } + } + + $refundShowUrl = '/admin/platform-orders/' . $order->id . '#refund-receipts'; @endphp @if($refundTotal > 0) - ¥{{ number_format($refundTotal, 2) }} + @if($isRefundInconsistent) + ¥{{ number_format($refundTotal, 2) }} +
用于记录退款动作与对账轨迹(先落 meta,不引入独立表)。追加退款后,系统会自动把支付状态推进为“部分退款/已退款”(仅在订单当前为已支付时)。
diff --git a/tests/Feature/AdminPlatformOrderRefundInconsistentRowHintTest.php b/tests/Feature/AdminPlatformOrderRefundInconsistentRowHintTest.php new file mode 100644 index 0000000..5a55fe0 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderRefundInconsistentRowHintTest.php @@ -0,0 +1,71 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_row_can_show_refund_inconsistent_hint_and_link_to_refund_anchor(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'refund_inconsistent_row_hint_plan', + 'name' => '退款不一致行级提示测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_ROW_REFUND_INCONS_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' => [ + 'refund_summary' => [ + 'count' => 1, + 'total_amount' => 10.00, + ], + ], + ]); + + $this->get('/admin/platform-orders') + ->assertOk() + ->assertSee('PO_ROW_REFUND_INCONS_0001') + ->assertSee('疑似不一致') + ->assertSee('#refund-receipts'); + } +}