platform_orders index: compact view money format hides trailing .00

This commit is contained in:
萝卜
2026-03-14 12:49:22 +00:00
parent b89789faf1
commit c8b119c000
2 changed files with 98 additions and 2 deletions

View File

@@ -28,6 +28,17 @@
? $incomingBackForLinks
: '';
// 金额展示:精简视图尽量更短(整数不显示 .00full 视图保持两位小数(便于对账)
$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 @@
</div>
@endif
</td>
<td>¥{{ number_format((float) $order->payable_amount, 2) }}</td>
<td>¥{{ number_format((float) $order->paid_amount, 2) }}</td>
<td>
@if($isFullView)
¥{{ number_format((float) $order->payable_amount, 2) }}
@else
¥{{ $formatMoneyCompact($order->payable_amount) }}
@endif
</td>
<td>
@if($isFullView)
¥{{ number_format((float) $order->paid_amount, 2) }}
@else
¥{{ $formatMoneyCompact($order->paid_amount) }}
@endif
</td>
<td>
@if($isFullView)
{{ optional($order->placed_at)->format('Y-m-d H:i:s') ?: '-' }}