feat(platform-orders): 支持退款留痕与支付状态自动推进(meta.refund_receipts)

This commit is contained in:
萝卜
2026-03-10 16:46:00 +00:00
parent 3bc2e20ef7
commit aa7c655043
4 changed files with 294 additions and 0 deletions

View File

@@ -87,6 +87,7 @@
$activationError = data_get($order->meta, 'subscription_activation_error');
$audit = (array) (data_get($order->meta, 'audit', []) ?? []);
$paymentReceipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []);
$refundReceipts = (array) (data_get($order->meta, 'refund_receipts', []) ?? []);
@endphp
@php
@@ -166,6 +167,64 @@
</details>
</div>
<div class="card mb-20">
<h3>退款记录(退款轨迹留痕)</h3>
<p class="muted muted-tight">用于记录退款动作与对账轨迹(先落 meta不引入独立表。追加退款后系统会自动把支付状态推进为“部分退款/已退款”(仅在订单当前为已支付时)。</p>
@if(count($refundReceipts) > 0)
@php $items = array_slice(array_reverse($refundReceipts), 0, 20); @endphp
<table>
<thead>
<tr>
<th style="width:140px;">类型</th>
<th style="width:120px;">渠道</th>
<th style="width:120px;">金额</th>
<th style="width:200px;">退款时间</th>
<th style="width:160px;">记录时间</th>
<th style="width:100px;">管理员</th>
<th>备注</th>
</tr>
</thead>
<tbody>
@foreach($items as $r)
<tr>
<td>{{ data_get($r, 'type') ?: '-' }}</td>
<td>{{ data_get($r, 'channel') ?: '-' }}</td>
<td>¥{{ number_format((float) (data_get($r, 'amount') ?? 0), 2) }}</td>
<td>{{ data_get($r, 'refunded_at') ?: '-' }}</td>
<td>{{ data_get($r, 'created_at') ?: '-' }}</td>
<td>{{ data_get($r, 'admin_id') ?: '-' }}</td>
<td class="muted">{{ data_get($r, 'note') ?: '' }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="muted">暂无退款记录。</p>
@endif
<details style="margin-top:12px;">
<summary class="muted">追加一条退款记录(会自动推进支付状态)</summary>
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-refund-receipt" style="margin-top:10px;" onsubmit="return confirm('确认追加退款记录?该操作会写入退款轨迹,并可能推进支付状态为部分退款/已退款');">
@csrf
<div class="grid-3">
<input type="text" name="type" placeholder="类型refund/chargeback/手工退款等" value="refund">
<input type="text" name="channel" placeholder="渠道(可选)" value="{{ (string) ($order->payment_channel ?? '') }}">
<input type="number" step="0.01" name="amount" placeholder="金额" value="0.00">
</div>
<div style="margin-top:10px;">
<input type="text" name="refunded_at" placeholder="退款时间YYYY-mm-dd HH:ii:ss可选" value="{{ optional($order->refunded_at)->format('Y-m-d H:i:s') }}">
</div>
<div style="margin-top:10px;">
<textarea name="note" placeholder="备注(可选,用于退款说明/对账)" rows="3" style="width:100%;"></textarea>
</div>
<div style="margin-top:10px;">
<button type="submit">追加退款记录</button>
</div>
</form>
</details>
</div>
<div class="card mb-20">
<h3>订阅同步记录</h3>
@if($activation)