PlatformOrder store: require subscription for renewal orders

This commit is contained in:
萝卜
2026-03-15 02:03:04 +00:00
parent aaf774edbf
commit bdea18c976
3 changed files with 64 additions and 4 deletions

View File

@@ -78,8 +78,7 @@ class PlatformOrderController extends Controller
'plans' => $plans,
'siteSubscription' => $siteSubscription,
'billingCycleLabels' => $this->billingCycleLabels(),
// order_type label 映射已下沉到 PlatformOrder::orderTypeLabel();这里不再透传 orderTypeLabels
// 'orderTypeLabels' => $this->orderTypeLabels(),
'orderTypeLabels' => $this->orderTypeLabels(),
'defaults' => $defaults,
]);
}
@@ -91,7 +90,13 @@ class PlatformOrderController extends Controller
$data = $request->validate([
'merchant_id' => ['required', 'integer', 'exists:merchants,id'],
'plan_id' => ['required', 'integer', 'exists:plans,id'],
'site_subscription_id' => ['nullable', 'integer', 'exists:site_subscriptions,id'],
// 治理口径:续费单必须绑定订阅(否则无法做到“续期/延长到期”这一核心闭环)
'site_subscription_id' => [
Rule::requiredIf(fn () => (string) $request->input('order_type') === 'renewal'),
'nullable',
'integer',
'exists:site_subscriptions,id',
],
'order_type' => ['required', Rule::in(array_keys($this->orderTypeLabels()))],
'quantity' => ['required', 'integer', 'min:1', 'max:120'],
'discount_amount' => ['nullable', 'numeric', 'min:0'],