feat(douyu): 高价值套装改用官方 storehome 三态判定
高价值套装的准入判定改为只认官方精英宝典 storehome 里账号级的 status:0=可兑换、1=已达兑换上限,商品缺失/接口异常=unknown。 兑换记录和积分记录只作历史展示,不参与是否拥有的判定。 原来的 high_value_owned(JSON 名单)无法区分「确认可兑换」和 「官方接口没返回商品」,也无法表达部分失败。改为两套独立状态 + 检查时间(迁移 20261106_0065),旧快照保守回填:status 缺失的 一律 unknown,不猜。 CK 判定失效时在数据层作废结论(降为 unknown),不是展示层降级。 官方 status 是账号维度的,但 CK 失效那段时间账号可能被别人手工 登录并兑换(这些号共享给客服),缓存里的「可兑换」就不成立了; 只在展示层降级的话,CK 恢复后那条陈旧的「可换」会重新变绿。 error(查不到)不作废 —— 查不到不等于账号出问题了。 高价值结论有自己的时钟:资料刷新除了看 overview_queried_at,还看 high_value_checked_at。两者会脱钩(商品接口单独失败时资料时间被刷新、 高价值时间停在原地),少了这一条这类账号会永久停在旧结论。作废的 结论按 6 小时慢速重试,但「从来没查到过」不因此重选 —— 那是接口对 该账号稳定失败,每轮都重选只会反复撞墙。 商城商品列表改用精英宝典的 manualID 拉取,不再寄生在电竞手册分支里 (否则没配电竞手册的配置就永远拉不到商城,三态全部停在待确认)。 筛选拆成三类「查不到」:unqueried(未查资料,旧口径不变)、 high_value_never(从未读到商城)、high_value_unknown(查过但结论 未知/过期)。之前第二类无处可寻 —— 它既不满足 unqueried 也不满足 high_value_unknown。
This commit is contained in:
@@ -57,15 +57,15 @@ from ..services.account_lifecycle import (
|
||||
)
|
||||
from ..services.account_service import parse_and_build_accounts
|
||||
from ..services.account_value import (
|
||||
SUIT_BAIRIMENG,
|
||||
SUIT_MENGTU,
|
||||
high_value_unknown_expr,
|
||||
is_high_value_expr,
|
||||
is_suit_queried_expr,
|
||||
suit_available_expr,
|
||||
suit_owned_expr,
|
||||
suit_sort_rank_expr,
|
||||
)
|
||||
from ..services.audit_service import record_account_action, record_audit
|
||||
from ..services.douyu_service import cookie_holding_filter
|
||||
from ..services.high_value_service import high_value_payload
|
||||
from ..services.login_failure import classify_failure, failure_kind_label
|
||||
|
||||
router = APIRouter(prefix="/api/accounts", tags=["账号管理"])
|
||||
@@ -205,33 +205,34 @@ def _filter_accounts_query(
|
||||
# 高价值套装筛选
|
||||
hv = _query_str(high_value_filter)
|
||||
if hv:
|
||||
suit_queried = is_suit_queried_expr()
|
||||
bairimeng_expr = suit_owned_expr(Account.high_value_owned, SUIT_BAIRIMENG)
|
||||
mengtu_expr = suit_owned_expr(Account.high_value_owned, SUIT_MENGTU)
|
||||
bairimeng_available = suit_available_expr("bairimeng")
|
||||
mengtu_available = suit_available_expr("mengtu")
|
||||
bairimeng_owned = suit_owned_expr("bairimeng")
|
||||
mengtu_owned = suit_owned_expr("mengtu")
|
||||
if hv == "both_available":
|
||||
query = query.filter(
|
||||
suit_queried,
|
||||
~bairimeng_expr,
|
||||
~mengtu_expr,
|
||||
)
|
||||
query = query.filter(bairimeng_available, mengtu_available)
|
||||
elif hv == "can_bairimeng":
|
||||
query = query.filter(
|
||||
suit_queried,
|
||||
~bairimeng_expr,
|
||||
)
|
||||
query = query.filter(bairimeng_available)
|
||||
elif hv == "can_mengtu":
|
||||
query = query.filter(
|
||||
suit_queried,
|
||||
~mengtu_expr,
|
||||
)
|
||||
query = query.filter(mengtu_available)
|
||||
elif hv == "owned_bairimeng":
|
||||
query = query.filter(bairimeng_expr)
|
||||
query = query.filter(bairimeng_owned)
|
||||
elif hv == "owned_mengtu":
|
||||
query = query.filter(mengtu_expr)
|
||||
query = query.filter(mengtu_owned)
|
||||
elif hv == "both_owned":
|
||||
query = query.filter(bairimeng_expr, mengtu_expr)
|
||||
query = query.filter(bairimeng_owned, mengtu_owned)
|
||||
elif hv == "unqueried":
|
||||
# 「未查资料」= 从没跑过一键查询(**旧口径**,保留不变)。
|
||||
# ⚠️ 别和「没读到官方商城」混为一谈:账号可能查过其它资料,
|
||||
# 只是商城接口对它稳定失败 —— 那是下面 high_value_never 那一档。
|
||||
query = query.filter(Account.overview_queried_at.is_(None))
|
||||
elif hv == "high_value_never":
|
||||
# 从没成功读到官方 storehome:商城接口失败 / 没配 manualID。
|
||||
# 高价值三态里的「unknown」要求 checked_at 非空(查过但没结论),
|
||||
# 所以这一档必须单独筛,否则这批账号在界面上**无处可寻**。
|
||||
query = query.filter(Account.high_value_checked_at.is_(None))
|
||||
elif hv == "high_value_unknown":
|
||||
query = query.filter(high_value_unknown_expr())
|
||||
elif hv == "high_value_broken":
|
||||
query = query.filter(
|
||||
is_high_value_expr(),
|
||||
@@ -457,7 +458,7 @@ def list_accounts(
|
||||
),
|
||||
high_value_filter: str = Query(
|
||||
"",
|
||||
description="按高价值套装状态筛选:both_available/can_bairimeng/can_mengtu/owned_bairimeng/owned_mengtu/both_owned/unqueried/high_value_broken",
|
||||
description="按高价值套装官方准入筛选:both_available/can_bairimeng/can_mengtu/owned_bairimeng/owned_mengtu/both_owned/unqueried/high_value_never/high_value_unknown/high_value_broken",
|
||||
),
|
||||
min_points: int | None = Query(None, description="最低积分"),
|
||||
max_points: int | None = Query(None, description="最高积分"),
|
||||
@@ -646,11 +647,8 @@ def list_accounts(
|
||||
last_exchange_at=exchange_stats.get(acc.id, (0, None, ""))[1],
|
||||
last_exchange_name=exchange_stats.get(acc.id, (0, None, ""))[2],
|
||||
**bind_payload(acc),
|
||||
# 一键查询得到的「已兑换过的高价值套装」(不是整份快照 ——
|
||||
# 列表带不起 1~2KB/账号 的 JSON)。兑换条数不在这里:
|
||||
# 上面的 exchange_count 已经是**官方事件**聚合的结果。
|
||||
high_value_owned=acc.high_value_owned,
|
||||
# 「有没有查过」靠它判断 —— 否则"查过但没兑换"和"没查过"都是空,分不开
|
||||
# 只返回官方 storehome 的紧凑三态,不把整份快照带进列表。
|
||||
high_value=high_value_payload(acc),
|
||||
overview_queried_at=acc.overview_queried_at,
|
||||
)
|
||||
# 只有管理员可看完整字段(密码、邮箱等)
|
||||
@@ -792,33 +790,45 @@ def accounts_summary(
|
||||
login_failures = {str(row[0] or ""): int(row[1] or 0) for row in failure_rows}
|
||||
|
||||
# 高价值及核心资产分布(单次聚合,供前端快捷胶囊展示)
|
||||
bairimeng_expr = suit_owned_expr(Account.high_value_owned, SUIT_BAIRIMENG)
|
||||
mengtu_expr = suit_owned_expr(Account.high_value_owned, SUIT_MENGTU)
|
||||
bairimeng_available = suit_available_expr("bairimeng")
|
||||
mengtu_available = suit_available_expr("mengtu")
|
||||
bairimeng_owned = suit_owned_expr("bairimeng")
|
||||
mengtu_owned = suit_owned_expr("mengtu")
|
||||
high_value_broken_expr = and_(
|
||||
is_high_value_expr(),
|
||||
Account.ck_check_status.in_(["invalid", "error"]),
|
||||
)
|
||||
|
||||
suit_queried = is_suit_queried_expr()
|
||||
hv_row = visible.with_entities(
|
||||
func.count(case((and_(suit_queried, ~bairimeng_expr, ~mengtu_expr), 1))),
|
||||
func.count(case((and_(suit_queried, ~bairimeng_expr), 1))),
|
||||
func.count(case((and_(suit_queried, ~mengtu_expr), 1))),
|
||||
func.count(case((~suit_queried, 1))),
|
||||
func.count(case((and_(bairimeng_available, mengtu_available), 1))),
|
||||
func.count(case((bairimeng_available, 1))),
|
||||
func.count(case((mengtu_available, 1))),
|
||||
func.count(case((Account.overview_queried_at.is_(None), 1))),
|
||||
func.count(case((Account.high_value_checked_at.is_(None), 1))),
|
||||
func.count(case((high_value_unknown_expr(), 1))),
|
||||
func.count(case((Account.points >= 300, 1))),
|
||||
func.count(case((Account.gold_balance > 0, 1))),
|
||||
func.count(case((Account.elite_opened.is_(True), 1))),
|
||||
func.count(case((high_value_broken_expr, 1))),
|
||||
func.count(case((bairimeng_owned, 1))),
|
||||
func.count(case((mengtu_owned, 1))),
|
||||
func.count(case((and_(bairimeng_owned, mengtu_owned), 1))),
|
||||
).first()
|
||||
high_value_summary = {
|
||||
"both_available": int(hv_row[0] or 0) if hv_row else 0,
|
||||
"can_bairimeng": int(hv_row[1] or 0) if hv_row else 0,
|
||||
"can_mengtu": int(hv_row[2] or 0) if hv_row else 0,
|
||||
"unqueried": int(hv_row[3] or 0) if hv_row else 0,
|
||||
"high_points": int(hv_row[4] or 0) if hv_row else 0,
|
||||
"has_gold": int(hv_row[5] or 0) if hv_row else 0,
|
||||
"elite_opened": int(hv_row[6] or 0) if hv_row else 0,
|
||||
"high_value_broken": int(hv_row[7] or 0) if hv_row else 0,
|
||||
# 从没成功读到官方商城结果的账号数(与「查过但没结论」分开)。
|
||||
"high_value_never": int(hv_row[4] or 0) if hv_row else 0,
|
||||
"high_value_unknown": int(hv_row[5] or 0) if hv_row else 0,
|
||||
"high_points": int(hv_row[6] or 0) if hv_row else 0,
|
||||
"has_gold": int(hv_row[7] or 0) if hv_row else 0,
|
||||
"elite_opened": int(hv_row[8] or 0) if hv_row else 0,
|
||||
"high_value_broken": int(hv_row[9] or 0) if hv_row else 0,
|
||||
"owned_bairimeng": int(hv_row[10] or 0) if hv_row else 0,
|
||||
"owned_mengtu": int(hv_row[11] or 0) if hv_row else 0,
|
||||
"both_owned": int(hv_row[12] or 0) if hv_row else 0,
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -1642,7 +1652,7 @@ def account_overview(
|
||||
"points_expire_at": acc.points_expire_at,
|
||||
"overview_snapshot": acc.overview_snapshot,
|
||||
"overview_queried_at": acc.overview_queried_at,
|
||||
"high_value_owned": acc.high_value_owned,
|
||||
"high_value": high_value_payload(acc),
|
||||
"elite_opened": acc.elite_opened,
|
||||
"elite_expire_time": acc.elite_expire_time,
|
||||
"esports_expire_time": acc.esports_expire_time,
|
||||
|
||||
Reference in New Issue
Block a user