审计记录:快照列改为通用 key=value 渲染
This commit is contained in:
@@ -440,38 +440,53 @@
|
||||
@foreach($auditItems as $item)
|
||||
@php
|
||||
$snap = (array) (data_get($item, 'snapshot', []) ?? []);
|
||||
|
||||
// 统一快照展示:优先 paid/refund;剩余字段走 key=value;无 snapshot 则降级展示 subscription_id/filters。
|
||||
$pairs = [];
|
||||
|
||||
$snapPaid = data_get($snap, 'paid_amount');
|
||||
$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
|
||||
<tr>
|
||||
<td>{{ $auditActionLabels[data_get($item, 'action')] ?? (data_get($item, 'action') ?: '-') }}</td>
|
||||
<td>{{ data_get($item, 'scope') ?: '-' }}</td>
|
||||
<td>{{ data_get($item, 'at') ?: '-' }}</td>
|
||||
<td>{{ data_get($item, 'admin_id') ?: '-' }}</td>
|
||||
<td class="muted">
|
||||
@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">{{ $snapshotText }}</td>
|
||||
<td class="muted">{{ data_get($item, 'note') ?: '' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user