diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php
index 3f18fd7..eb9f2b4 100644
--- a/resources/views/admin/platform_orders/index.blade.php
+++ b/resources/views/admin/platform_orders/index.blade.php
@@ -28,6 +28,17 @@
? $incomingBackForLinks
: '';
+ // 金额展示:精简视图尽量更短(整数不显示 .00),full 视图保持两位小数(便于对账)
+ $formatMoneyCompact = function ($amount) {
+ $v = (float) $amount;
+ $rounded = round($v, 2);
+ if (abs($rounded - round($rounded)) < 0.00001) {
+ return (string) ((int) round($rounded));
+ }
+
+ return number_format($rounded, 2, '.', '');
+ };
+
// 安全版“保留当前 query 并覆盖字段”的链接构造器:
// - 强制使用站内相对路径(不包含域名)
// - back 仅保留安全值(否则移除),避免 `{!! !!}` 输出时发生属性注入
@@ -1074,8 +1085,20 @@
@endif
-
¥{{ number_format((float) $order->payable_amount, 2) }} |
- ¥{{ number_format((float) $order->paid_amount, 2) }} |
+
+ @if($isFullView)
+ ¥{{ number_format((float) $order->payable_amount, 2) }}
+ @else
+ ¥{{ $formatMoneyCompact($order->payable_amount) }}
+ @endif
+ |
+
+ @if($isFullView)
+ ¥{{ number_format((float) $order->paid_amount, 2) }}
+ @else
+ ¥{{ $formatMoneyCompact($order->paid_amount) }}
+ @endif
+ |
@if($isFullView)
{{ optional($order->placed_at)->format('Y-m-d H:i:s') ?: '-' }}
diff --git a/tests/Feature/AdminPlatformOrderIndexCompactViewMoneyFormatTest.php b/tests/Feature/AdminPlatformOrderIndexCompactViewMoneyFormatTest.php
new file mode 100644
index 0000000..899b19a
--- /dev/null
+++ b/tests/Feature/AdminPlatformOrderIndexCompactViewMoneyFormatTest.php
@@ -0,0 +1,73 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_compact_view_money_hides_trailing_zeros_but_full_view_keeps_two_decimals(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $merchant = Merchant::query()->firstOrFail();
+
+ $plan = Plan::query()->create([
+ 'code' => 'po_index_compact_money_format_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_INDEX_MONEY_FORMAT_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.00,
+ 'paid_amount' => 9.50,
+ 'placed_at' => now(),
+ 'paid_at' => now(),
+ 'activated_at' => now(),
+ 'meta' => [],
+ ]);
+
+ // 精简视图:整数不显示 .00
+ $this->get('/admin/platform-orders')
+ ->assertOk()
+ ->assertSee('¥10', false)
+ ->assertDontSee('¥10.00', false);
+
+ // full 视图:保持两位小数
+ $this->get('/admin/platform-orders?view=full')
+ ->assertOk()
+ ->assertSee('¥10.00', false)
+ ->assertSee('¥9.50', false);
+ }
+}
|