审计记录:快照列改为通用 key=value 渲染

This commit is contained in:
萝卜
2026-03-11 05:50:57 +00:00
parent eed863e54f
commit 3bcad91fd1

View File

@@ -440,38 +440,53 @@
@foreach($auditItems as $item) @foreach($auditItems as $item)
@php @php
$snap = (array) (data_get($item, 'snapshot', []) ?? []); $snap = (array) (data_get($item, 'snapshot', []) ?? []);
// 统一快照展示:优先 paid/refund剩余字段走 key=value无 snapshot 则降级展示 subscription_id/filters。
$pairs = [];
$snapPaid = data_get($snap, 'paid_amount'); $snapPaid = data_get($snap, 'paid_amount');
$snapRefund = data_get($snap, 'refund_total'); $snapRefund = data_get($snap, 'refund_total');
if ($snapPaid !== null || $snapRefund !== null) {
$pairs[] = 'paid=¥' . number_format((float) ($snapPaid ?? 0), 2);
$pairs[] = 'refund=¥' . number_format((float) ($snapRefund ?? 0), 2);
// 剩余字段key=value
foreach ($snap as $k => $v) {
if (in_array((string) $k, ['paid_amount', 'refund_total'], true)) {
continue;
}
if (is_array($v)) {
$v = json_encode($v, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} elseif (is_bool($v)) {
$v = $v ? 'true' : 'false';
}
$v = (string) $v;
$v = mb_substr($v, 0, 80);
$pairs[] = (string) $k . '=' . $v;
}
} else {
$subId = data_get($item, 'subscription_id');
$filtersText = (string) (data_get($item, 'filters') ?? '');
$filtersText = $filtersText !== '' ? mb_substr($filtersText, 0, 80) : '';
if ($subId) {
$pairs[] = 'subscription_id=' . (string) $subId;
}
if ($filtersText !== '') {
$pairs[] = 'filters=' . $filtersText;
}
}
$snapshotText = count($pairs) > 0 ? implode('', $pairs) : '-';
@endphp @endphp
<tr> <tr>
<td>{{ $auditActionLabels[data_get($item, 'action')] ?? (data_get($item, 'action') ?: '-') }}</td> <td>{{ $auditActionLabels[data_get($item, 'action')] ?? (data_get($item, 'action') ?: '-') }}</td>
<td>{{ data_get($item, 'scope') ?: '-' }}</td> <td>{{ data_get($item, 'scope') ?: '-' }}</td>
<td>{{ data_get($item, 'at') ?: '-' }}</td> <td>{{ data_get($item, 'at') ?: '-' }}</td>
<td>{{ data_get($item, 'admin_id') ?: '-' }}</td> <td>{{ data_get($item, 'admin_id') ?: '-' }}</td>
<td class="muted"> <td class="muted">{{ $snapshotText }}</td>
@if($snapPaid !== null || $snapRefund !== null)
paid=¥{{ number_format((float) ($snapPaid ?? 0), 2) }}refund=¥{{ number_format((float) ($snapRefund ?? 0), 2) }}
@else
@php
$subId = data_get($item, 'subscription_id');
$filtersText = (string) (data_get($item, 'filters') ?? '');
$filtersText = $filtersText !== '' ? mb_substr($filtersText, 0, 80) : '';
@endphp
@if($subId || $filtersText !== '')
@if($subId)
subscription_id={{ $subId }}
@endif
@if($subId && $filtersText !== '')
@endif
@if($filtersText !== '')
filters={{ $filtersText }}
@endif
@else
-
@endif
@endif
</td>
<td class="muted">{{ data_get($item, 'note') ?: '' }}</td> <td class="muted">{{ data_get($item, 'note') ?: '' }}</td>
</tr> </tr>
@endforeach @endforeach