fix: 已用卡密重复激活改为幂等成功
- 同卡密+同机器人QQ已有授权 → 返回已激活成功, 不再报已使用 - 已绑定机器码的卡在网页激活 → 明确提示去客户端验证 - 客户端 verify 绑定机器后可正常校验
This commit is contained in:
1 parent
b317c1f1d8
commit
b5a10bc4b7
1 file changed
+29
@@ -324,6 +324,35 @@ class AuthorizationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($card['status'] === 'used') {
|
if ($card['status'] === 'used') {
|
||||||
|
// 已使用:同一卡密 + 同一机器人QQ 已有有效授权 → 幂等返回成功(避免客户端重试报已使用)
|
||||||
|
$already = $db->fetch(
|
||||||
|
"SELECT * FROM {$db->table('authorizations')}
|
||||||
|
WHERE card_id = ? AND bot_qq = ? AND status != 'revoked'
|
||||||
|
ORDER BY id DESC LIMIT 1",
|
||||||
|
[$card['id'], $botQq]
|
||||||
|
);
|
||||||
|
if ($already) {
|
||||||
|
$this->success([
|
||||||
|
'id' => (int) $already['id'],
|
||||||
|
'card_key' => $cardKey,
|
||||||
|
'bot_qq' => $botQq,
|
||||||
|
'contact_qq' => $already['contact_qq'],
|
||||||
|
'contact_name'=> $already['contact_name'] ?? '',
|
||||||
|
'project_id' => (int) $already['project_id'],
|
||||||
|
'project_name'=> $already['project_name'] ?? ($card['project_name'] ?? ''),
|
||||||
|
'expire_time' => $already['expire_time'],
|
||||||
|
'is_renew' => false,
|
||||||
|
'already_activated' => true,
|
||||||
|
], '卡密已激活');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡密已被客户端机器码绑定(verify 激活)
|
||||||
|
$bind = json_decode($card['bind_info'] ?? '{}', true) ?: [];
|
||||||
|
if (!empty($bind['machine_id'])) {
|
||||||
|
$this->error('该卡密已在客户端激活绑定机器码,无需在网页重复激活');
|
||||||
|
}
|
||||||
|
|
||||||
$this->error('该卡密已被使用');
|
$this->error('该卡密已被使用');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user