PlatformOrder create: force renewal type when subscription context present

This commit is contained in:
萝卜
2026-03-15 03:14:19 +00:00
parent 2e4c0c5ea8
commit 2400398dcb
3 changed files with 77 additions and 2 deletions

View File

@@ -131,10 +131,15 @@
$selectedOrderType = 'new_purchase';
}
// 更强治理:若来源页声明 require_subscription=1且当前未绑定订阅则不展示 upgrade/downgrade 等类型,避免误用。
// 更强治理:
// - 若存在订阅上下文(锁定订阅)=> 当前阶段仅允许“续费”类型避免出现“带订阅ID但非续费”导致语义混乱/误同步。
// - 若来源页声明 require_subscription=1 且未绑定订阅 => 仅允许新购(用于兜底展示/引导去选订阅)。
$requireSub = (bool) ($requireSubscription ?? false);
$allowedTypes = array_keys($orderTypeLabels ?? []);
if ($requireSub && ! $canRenew) {
if ($hasLockedSubscription) {
$allowedTypes = ['renewal'];
$selectedOrderType = 'renewal';
} elseif ($requireSub && ! $canRenew) {
$allowedTypes = ['new_purchase'];
}
@endphp