refactor(douyu): 统一活动查询与直播商品映射
- 收口斗鱼活动、商品、绑定信息和兑换资格查询 - 工作台改为复用统一客户端、快照与实时商品目录 - 补充活动查询与商品映射测试
This commit is contained in:
@@ -35,6 +35,14 @@ from core.douyu import DouyuActivityClient
|
||||
from ..models import Account, DouyuTask
|
||||
from .account_binding import derive_from_bind_info, set_bind_status
|
||||
from .business_events import record_official_exchange
|
||||
from .douyu_activity_query import (
|
||||
query_activity_goods,
|
||||
query_bind_info,
|
||||
query_csrf,
|
||||
query_esports_bind_info,
|
||||
query_exchange_records,
|
||||
query_xpd_bind_info,
|
||||
)
|
||||
from .douyu_runner_donate import _parse_expire_at, _points_expire_at
|
||||
from .high_value_service import (
|
||||
DEFAULT_HIGH_VALUE_GOODS,
|
||||
@@ -189,10 +197,10 @@ class OverviewMixin:
|
||||
) -> dict[str, Any]:
|
||||
"""按作用域查绑定信息(三个接口不同,收敛在一处)。"""
|
||||
if scope == "elite":
|
||||
return client.bind_info(alias)
|
||||
return query_bind_info(client, act_alias=alias)
|
||||
if scope == "esports":
|
||||
return client.esports_bind_info(alias)
|
||||
return client.xpd_bind_info(act_alias=alias)
|
||||
return query_esports_bind_info(client, act_alias=alias)
|
||||
return query_xpd_bind_info(client, act_alias=alias)
|
||||
|
||||
def _fetch_elite_records(
|
||||
self,
|
||||
@@ -201,11 +209,10 @@ class OverviewMixin:
|
||||
manual_id: str,
|
||||
esports_manual_id: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
return (
|
||||
client.exchange_records(
|
||||
manual_id=manual_id, limit=EXCHANGE_RECORD_LIMIT
|
||||
).get("records")
|
||||
or []
|
||||
return query_exchange_records(
|
||||
client,
|
||||
manual_id=manual_id,
|
||||
limit=EXCHANGE_RECORD_LIMIT,
|
||||
)
|
||||
|
||||
def _fetch_esports_records(
|
||||
@@ -215,11 +222,10 @@ class OverviewMixin:
|
||||
manual_id: str,
|
||||
esports_manual_id: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
return (
|
||||
client.exchange_records(
|
||||
manual_id=esports_manual_id, limit=EXCHANGE_RECORD_LIMIT
|
||||
).get("records")
|
||||
or []
|
||||
return query_exchange_records(
|
||||
client,
|
||||
manual_id=esports_manual_id,
|
||||
limit=EXCHANGE_RECORD_LIMIT,
|
||||
)
|
||||
|
||||
def _fetch_xpd_records(
|
||||
@@ -281,7 +287,7 @@ class OverviewMixin:
|
||||
|
||||
# ---- 积分 + 到期时间 ----
|
||||
try:
|
||||
ctn = client.acf_ccn(refresh_subscribe=False)
|
||||
ctn = query_csrf(client)
|
||||
points = self._refresh_account_points(client, account, cookie, ctn=ctn)
|
||||
overview["assets"]["points"] = points.get("points")
|
||||
# `_refresh_account_points` 只回 {"points", "points_query"},
|
||||
@@ -349,8 +355,7 @@ class OverviewMixin:
|
||||
goods_items: list[dict[str, Any]] = []
|
||||
try:
|
||||
# 🎯 拉取完整商城商品列表(含每个商品准确的 status 状态:1=已达兑换上限,0=可兑换)
|
||||
goods = client.list_goods(manual_id=manual_id, rid=rid)
|
||||
goods_items = goods.get("goods") or []
|
||||
goods_items = query_activity_goods(client, manual_id=manual_id, rid=rid)
|
||||
overview["limited_goods_total"] = len(goods_items)
|
||||
goods_query_ok = True
|
||||
except Exception as exc: # noqa: BLE001
|
||||
|
||||
Reference in New Issue
Block a user