PlatformOrder create: default order_type to renewal when from subscription
This commit is contained in:
@@ -30,11 +30,14 @@ class PlatformOrderController extends Controller
|
||||
$plans = Plan::query()->orderBy('sort')->orderByDesc('id')->get();
|
||||
|
||||
// 支持从其它页面(例如订阅详情)带默认值跳转过来,提高运营效率
|
||||
$orderTypeFromQuery = $request->query('order_type');
|
||||
|
||||
$defaults = [
|
||||
'merchant_id' => (int) $request->query('merchant_id', 0),
|
||||
'plan_id' => (int) $request->query('plan_id', 0),
|
||||
'site_subscription_id' => (int) $request->query('site_subscription_id', 0),
|
||||
'order_type' => (string) $request->query('order_type', 'new_purchase'),
|
||||
// 未显式传 order_type 时默认 new_purchase;若是从订阅进入(site_subscription_id 存在),稍后会进一步偏向 renewal。
|
||||
'order_type' => $orderTypeFromQuery === null ? 'new_purchase' : (string) $orderTypeFromQuery,
|
||||
'quantity' => (int) $request->query('quantity', 1),
|
||||
'discount_amount' => (float) $request->query('discount_amount', 0),
|
||||
'payment_channel' => (string) $request->query('payment_channel', ''),
|
||||
@@ -66,6 +69,11 @@ class PlatformOrderController extends Controller
|
||||
$defaults['plan_id'] = (int) ($siteSubscription->plan_id ?? 0);
|
||||
}
|
||||
|
||||
// 治理口径:从订阅进入(site_subscription_id 存在)时,若未显式指定 order_type,则默认偏向续费。
|
||||
if ($orderTypeFromQuery === null && trim((string) ($defaults['order_type'] ?? '')) === 'new_purchase') {
|
||||
$defaults['order_type'] = 'renewal';
|
||||
}
|
||||
|
||||
// 续费默认备注:若未显式传 remark,自动补齐“来自订阅:{subscription_no}”用于追溯/检索。
|
||||
if ((string) ($defaults['order_type'] ?? '') === 'renewal' && trim((string) ($defaults['remark'] ?? '')) === '') {
|
||||
$remarkPrefix = (string) config('saasshop.platform_orders.renewal_order_remark_prefix', '来自订阅:');
|
||||
|
||||
Reference in New Issue
Block a user