diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index f4ae45c..441c339 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -77,6 +77,15 @@ + @php + $paidAmountFloat = (float) ($order->paid_amount ?? 0); + @endphp + @if($order->payment_status === 'refunded' && ($refundTotal + 0.01) < $paidAmountFloat) +
提示:当前订单状态为「已退款」,但退款总额小于已付金额,可能存在数据不一致,请核对退款轨迹与订单金额。
+ @elseif($order->payment_status !== 'refunded' && $paidAmountFloat > 0 && $refundTotal >= $paidAmountFloat) +
提示:退款总额已达到/超过已付金额,建议核对是否应将支付状态调整为「已退款」。
+ @endif + @php $canActivate = ($order->payment_status === 'paid') && ($order->status === 'activated'); $alreadySynced = (int) data_get($order->meta, 'subscription_activation.subscription_id', 0) > 0; diff --git a/tests/Feature/AdminPlatformOrderRefundStatusConsistencyHintTest.php b/tests/Feature/AdminPlatformOrderRefundStatusConsistencyHintTest.php new file mode 100644 index 0000000..21a5aec --- /dev/null +++ b/tests/Feature/AdminPlatformOrderRefundStatusConsistencyHintTest.php @@ -0,0 +1,73 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_page_will_hint_when_refunded_status_but_refund_total_less_than_paid_amount(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'refund_consistency_hint_01', + 'name' => '退款一致性提示测试', + 'billing_cycle' => 'monthly', + 'price' => 30, + 'list_price' => 30, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_REFUND_HINT_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'refunded', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 30, + 'paid_amount' => 30, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'refunded_at' => now(), + 'meta' => [ + 'refund_summary' => [ + 'count' => 1, + 'total_amount' => 10, + 'last_at' => now()->toDateTimeString(), + 'last_amount' => 10, + 'last_channel' => 'wechat', + ], + ], + ]); + + $this->get('/admin/platform-orders/' . $order->id) + ->assertOk() + ->assertSee('提示:当前订单状态为「已退款」,但退款总额小于已付金额'); + } +}