feat(douyu): 落地账号平台同步与登录配额
This commit is contained in:
@@ -733,6 +733,8 @@ def probe_account(
|
||||
points: int | None = None
|
||||
points_response: dict[str, Any] = {}
|
||||
limited_goods: list[dict[str, Any]] = []
|
||||
storehome_goods: list[dict[str, Any]] = []
|
||||
storehome_raw: dict[str, Any] = {}
|
||||
if with_eligibility:
|
||||
uid = str(account.uid or "").strip()
|
||||
if ctn:
|
||||
@@ -754,6 +756,22 @@ def probe_account(
|
||||
for item in limited_result.get("limited_goods") or []
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
raw_storehome = (
|
||||
limited_result.get("raw")
|
||||
if isinstance(limited_result.get("raw"), dict)
|
||||
else {}
|
||||
)
|
||||
raw_data = (
|
||||
raw_storehome.get("data")
|
||||
if isinstance(raw_storehome.get("data"), dict)
|
||||
else {}
|
||||
)
|
||||
raw_list = raw_data.get("list")
|
||||
storehome_goods = [
|
||||
dict(item)
|
||||
for item in (raw_list if isinstance(raw_list, list) else [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
except Exception as exc: # noqa: BLE001
|
||||
errors["limited_goods"] = f"{type(exc).__name__}: {_text(exc)}"
|
||||
|
||||
@@ -839,6 +857,8 @@ def probe_account(
|
||||
"error": errors.get("elite", ""),
|
||||
},
|
||||
"eligibility": {
|
||||
"manual_id": manual_id,
|
||||
"rid": str(config_info.get("rid") or ""),
|
||||
"points": points,
|
||||
"points_response": points_response,
|
||||
"points_expire_at": (
|
||||
@@ -854,6 +874,8 @@ def probe_account(
|
||||
).strip()
|
||||
}
|
||||
),
|
||||
"storehome_goods": storehome_goods,
|
||||
"storehome_raw": storehome_raw,
|
||||
"error": errors.get("points", ""),
|
||||
},
|
||||
"roles": roles,
|
||||
@@ -979,6 +1001,39 @@ def persist_probe_result(
|
||||
if gold.get("status") == CAPABILITY_OK and _to_int(gold.get("balance")) is not None:
|
||||
account.gold_balance = _to_int(gold.get("balance"))
|
||||
|
||||
eligibility = probe.get("eligibility") or {}
|
||||
storehome_goods = [
|
||||
dict(item)
|
||||
for item in eligibility.get("storehome_goods") or []
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
if account.id is not None and storehome_goods:
|
||||
from .account_sync_service import sync_storehome_snapshot
|
||||
from .douyu_read_gateway import StorehomeSnapshot
|
||||
|
||||
storehome_raw = (
|
||||
eligibility.get("storehome_raw")
|
||||
if isinstance(eligibility.get("storehome_raw"), dict)
|
||||
else {}
|
||||
)
|
||||
sync_storehome_snapshot(
|
||||
db,
|
||||
account,
|
||||
StorehomeSnapshot(
|
||||
manual_id=str(eligibility.get("manual_id") or ""),
|
||||
rid=str(eligibility.get("rid") or ""),
|
||||
observed_at=now,
|
||||
items=tuple(storehome_goods),
|
||||
limited_ids=frozenset(
|
||||
str(item)
|
||||
for item in eligibility.get("limited_ids") or []
|
||||
if str(item)
|
||||
),
|
||||
raw=storehome_raw,
|
||||
),
|
||||
source=source[:32],
|
||||
)
|
||||
|
||||
account.updated_at = now
|
||||
if record_event and account.id is not None:
|
||||
emit(
|
||||
|
||||
Reference in New Issue
Block a user