diff --git a/backend/app/Controllers/AuthorizationController.php b/backend/app/Controllers/AuthorizationController.php index fc16194..07719f4 100644 --- a/backend/app/Controllers/AuthorizationController.php +++ b/backend/app/Controllers/AuthorizationController.php @@ -334,16 +334,13 @@ class AuthorizationController extends Controller $needDeductQuota = false; if ($cardAgentId > 0) { - // 该卡密是某个代理生成的(已扣费) - // 公开接口无登录态 → 拒绝使用代理卡密 - if (empty($currentUserId)) { - $this->error('该卡密需要登录后使用,请先登录'); - } - // 非归属代理 → 禁止使用他人卡密 - if ($cardAgentId !== $currentUserId) { + // 该卡密是某个代理生成的(生成时已扣额度) + // 公开激活(终端客户):直接允许,无需登录 + // 仅当已登录代理使用他人卡密时拒绝 + if ($currentUserId > 0 && $currentRole === 'agent' && $cardAgentId !== $currentUserId) { $this->error('此卡密不属于您,无法使用'); } - // 归属代理本人 → 允许(生成时已扣费) + // 公开用户 或 归属代理本人 → 允许 } else { // 该卡密非代理生成(管理员生成或其他渠道) // 如果当前用户是代理,使用此类卡密需按代理价格扣费