From ab9a23063091581b8c173163fe13fcdae7ace570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 04:47:50 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=9A=E9=80=80=E6=AC=BE=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E8=A1=8C=E7=BA=A7=E6=8F=90=E7=A4=BA=E4=B8=8E=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 26 ++++++- .../admin/platform_orders/show.blade.php | 2 +- ...formOrderRefundInconsistentRowHintTest.php | 71 +++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderRefundInconsistentRowHintTest.php 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) }} +
疑似不一致
+ @else + ¥{{ number_format($refundTotal, 2) }} + @endif @else - - + @if($isRefundInconsistent) + - +
疑似不一致
+ @else + - + @endif @endif diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 441c339..3cbe806 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -256,7 +256,7 @@ -
+

退款记录(退款轨迹留痕)

用于记录退款动作与对账轨迹(先落 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'); + } +}