feat(billing): audit add payment/refund receipts

This commit is contained in:
萝卜
2026-03-17 11:52:07 +08:00
parent 8bdb94aa0a
commit 416ad3de68
3 changed files with 223 additions and 0 deletions

View File

@@ -958,6 +958,27 @@ class PlatformOrderController extends Controller
'last_channel' => (string) (data_get($latest, 'channel') ?? ''),
]);
// 审计:追加支付回执(用于对账留痕,不自动改状态)
$audit = (array) (data_get($meta, 'audit', []) ?? []);
$audit[] = [
'action' => 'add_payment_receipt',
'scope' => 'single',
'at' => $now->toDateTimeString(),
'admin_id' => $admin->id,
'note' => '追加支付回执(对账留痕,不自动改状态)',
'snapshot' => [
'type' => (string) $data['type'],
'channel' => (string) ($data['channel'] ?? ''),
'amount' => (float) $data['amount'],
'paid_at' => $data['paid_at'] ? (string) $data['paid_at'] : null,
'summary' => [
'count' => (int) data_get($meta, 'payment_summary.count'),
'total_amount' => (float) data_get($meta, 'payment_summary.total_amount'),
],
],
];
data_set($meta, 'audit', $audit);
$order->meta = $meta;
$order->save();
@@ -1007,6 +1028,27 @@ class PlatformOrderController extends Controller
'last_channel' => (string) (data_get($latestRefund, 'channel') ?? ''),
]);
// 审计:追加退款回执(用于退款轨迹留痕)
$audit = (array) (data_get($meta, 'audit', []) ?? []);
$audit[] = [
'action' => 'add_refund_receipt',
'scope' => 'single',
'at' => $now->toDateTimeString(),
'admin_id' => $admin->id,
'note' => '追加退款回执(用于退款轨迹留痕)',
'snapshot' => [
'type' => (string) $data['type'],
'channel' => (string) ($data['channel'] ?? ''),
'amount' => (float) $data['amount'],
'refunded_at' => $data['refunded_at'] ? (string) $data['refunded_at'] : null,
'summary' => [
'count' => (int) data_get($meta, 'refund_summary.count'),
'total_amount' => (float) data_get($meta, 'refund_summary.total_amount'),
],
],
];
data_set($meta, 'audit', $audit);
// 可治理辅助:自动推进退款标记(仅当退款金额>0 时)
// 注意:允许从 paid / partially_refunded 推进到 partially_refunded / refunded
// 且不会把已 refunded 的订单降级。