Enhance: platform order create flow carries back and redirects with back
This commit is contained in:
@@ -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 . '(待支付/待生效)');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user