feat(douyu): 支持外部协作单撤销并推荐账号

This commit is contained in:
yml
2026-11-20 13:02:40 +08:00
parent 1a49bcd481
commit 55021a683c
8 changed files with 1045 additions and 16 deletions
@@ -161,6 +161,8 @@ def live_candidate_accounts(
limit: int = 20,
required_points: int = 0,
commodity_id: str = "",
prefer_unbound: bool = False,
empty_only: bool = False,
) -> list[Account]:
"""按缓存质量优先排序,但保留实时检测作为最终准入判断。"""
owner_ids = _pool_owner_ids()
@@ -197,20 +199,25 @@ def live_candidate_accounts(
.exists()
)
query = query.filter(~exchanged)
if empty_only:
query = query.filter(Account.role_bind_status == "unbound")
order_by = [
case((Account.ck_check_status == "valid", 0), else_=1),
case((Account.status == "active", 0), else_=1),
case((Account.elite_opened.is_(True), 0), else_=1),
case(
(Account.points >= max(0, int(required_points)), 0),
else_=1,
),
Account.ck_checked_at.is_(None).desc(),
Account.ck_checked_at.asc(),
Account.points.asc(),
Account.id.asc(),
]
if prefer_unbound:
order_by.insert(0, case((Account.role_bind_status == "unbound", 0), else_=1))
return (
query.order_by(
case((Account.ck_check_status == "valid", 0), else_=1),
case((Account.status == "active", 0), else_=1),
case((Account.elite_opened.is_(True), 0), else_=1),
case(
(Account.points >= max(0, int(required_points)), 0),
else_=1,
),
Account.ck_checked_at.is_(None).desc(),
Account.ck_checked_at.asc(),
Account.points.asc(),
Account.id.asc(),
)
query.order_by(*order_by)
.limit(max(1, min(int(limit), 100)))
.all()
)