feat(platform-orders): 支持仅标记订单为已生效并写入审计
This commit is contained in:
@@ -310,6 +310,40 @@ class PlatformOrderController extends Controller
|
||||
return redirect()->back()->with('success', '订单已标记支付并生效,订阅已同步:' . $subscription->subscription_no);
|
||||
}
|
||||
|
||||
public function markActivated(Request $request, PlatformOrder $order): RedirectResponse
|
||||
{
|
||||
$admin = $this->ensurePlatformAdmin($request);
|
||||
|
||||
// 仅标记“已生效”:用于处理已支付但未生效的订单(不改 payment_status)
|
||||
if ($order->payment_status !== 'paid') {
|
||||
return redirect()->back()->with('warning', '当前订单尚未支付,无法仅标记为已生效。');
|
||||
}
|
||||
|
||||
if ($order->status === 'activated') {
|
||||
return redirect()->back()->with('warning', '当前订单已是已生效状态,无需重复操作。');
|
||||
}
|
||||
|
||||
$now = now();
|
||||
$order->status = 'activated';
|
||||
$order->activated_at = $order->activated_at ?: $now;
|
||||
$order->save();
|
||||
|
||||
// 轻量审计:记录这次“仅标记生效”的动作,便于追溯
|
||||
$meta = (array) ($order->meta ?? []);
|
||||
$audit = (array) (data_get($meta, 'audit', []) ?? []);
|
||||
$audit[] = [
|
||||
'action' => 'mark_activated',
|
||||
'scope' => 'single',
|
||||
'at' => $now->toDateTimeString(),
|
||||
'admin_id' => $admin->id,
|
||||
];
|
||||
data_set($meta, 'audit', $audit);
|
||||
$order->meta = $meta;
|
||||
$order->save();
|
||||
|
||||
return redirect()->back()->with('success', '订单已标记为已生效(未修改支付状态)。');
|
||||
}
|
||||
|
||||
public function export(Request $request): StreamedResponse
|
||||
{
|
||||
$this->ensurePlatformAdmin($request);
|
||||
|
||||
Reference in New Issue
Block a user