平台订单:提供手动标记已退款治理动作

This commit is contained in:
萝卜
2026-03-11 05:01:02 +00:00
parent 7633083f6a
commit 857ed4e424
4 changed files with 146 additions and 0 deletions

View File

@@ -580,6 +580,39 @@ class PlatformOrderController extends Controller
return redirect()->back()->with('success', '已追加退款记录(用于退款轨迹留痕)。');
}
public function markRefunded(Request $request, PlatformOrder $order): RedirectResponse
{
$admin = $this->ensurePlatformAdmin($request);
if ((float) ($order->paid_amount ?? 0) <= 0) {
return redirect()->back()->with('warning', '当前订单已付金额为 0无法标记为已退款。');
}
if ((string) $order->payment_status === 'refunded') {
return redirect()->back()->with('warning', '当前订单已是已退款状态,无需重复操作。');
}
$now = now();
$order->payment_status = 'refunded';
$order->refunded_at = $order->refunded_at ?: $now;
$meta = (array) ($order->meta ?? []);
$audit = (array) (data_get($meta, 'audit', []) ?? []);
$audit[] = [
'action' => 'mark_refunded',
'scope' => 'single',
'at' => $now->toDateTimeString(),
'admin_id' => $admin->id,
'note' => '手动标记为已退款(仅修正支付状态,不自动写退款回执)',
];
data_set($meta, 'audit', $audit);
$order->meta = $meta;
$order->save();
return redirect()->back()->with('success', '已将订单支付状态标记为已退款(未自动写入退款回执)。');
}
public function markActivated(Request $request, PlatformOrder $order): RedirectResponse
{
$admin = $this->ensurePlatformAdmin($request);