Enhance: platform order create flow carries back and redirects with back

This commit is contained in:
萝卜
2026-03-13 19:25:55 +00:00
parent 843db0fef9
commit 2feb8055f2
3 changed files with 97 additions and 2 deletions

View File

@@ -38,6 +38,8 @@ class PlatformOrderController extends Controller
'discount_amount' => (float) $request->query('discount_amount', 0),
'payment_channel' => (string) $request->query('payment_channel', ''),
'remark' => (string) $request->query('remark', ''),
// back用于创建成功后回到来源页例如订阅详情
'back' => (string) $request->query('back', ''),
];
$siteSubscription = null;
@@ -69,6 +71,7 @@ class PlatformOrderController extends Controller
'discount_amount' => ['nullable', 'numeric', 'min:0'],
'payment_channel' => ['nullable', 'string', 'max:30'],
'remark' => ['nullable', 'string', 'max:2000'],
'back' => ['nullable', 'string', 'max:2000'],
]);
$plan = Plan::query()->findOrFail((int) $data['plan_id']);
@@ -122,7 +125,15 @@ class PlatformOrderController extends Controller
'remark' => $data['remark'] ?? null,
]);
return redirect('/admin/platform-orders/' . $order->id)
$back = (string) ($data['back'] ?? '');
$safeBack = str_starts_with($back, '/') ? $back : '';
$redirectUrl = '/admin/platform-orders/' . $order->id;
if ($safeBack !== '') {
$redirectUrl .= '?back=' . urlencode($safeBack);
}
return redirect($redirectUrl)
->with('success', '平台订单已创建:' . $order->order_no . '(待支付/待生效)');
}