This commit is contained in:
huangzhenpc
2025-04-01 18:38:16 +08:00
parent 221d7d79f1
commit 31fe73f998
2 changed files with 30 additions and 6 deletions

View File

@@ -39,11 +39,15 @@ class EmailManager:
"""批量获取未使用的邮箱账号"""
logger.info(f"尝试获取 {num} 个未使用的邮箱账号")
# 1. 先查询符合条件的账号ID列表
# 使用简单条件获取未使用的账号
select_query = """
SELECT id, email, password, client_id, refresh_token
FROM email_accounts
WHERE in_use = 0 AND sold = 0 AND status = 'pending'
AND email NOT IN (
SELECT email FROM email_accounts
WHERE status = 'success' OR status = 'unavailable'
)
LIMIT %s
"""
accounts = await self.db.fetch_all(select_query, (num,))
@@ -125,6 +129,10 @@ class EmailManager:
SELECT COUNT(*)
FROM email_accounts
WHERE status = 'pending' AND in_use = 0 AND sold = 0
AND email NOT IN (
SELECT email FROM email_accounts
WHERE status = 'success' OR status = 'unavailable'
)
"""
result = await self.db.fetch_one(query)
if result: