fix: preserve xpd role platform in wallet queries

This commit is contained in:
yml2213
2026-08-09 10:06:57 +08:00
parent 8b7ff770e2
commit ba35ac5c0d
4 changed files with 359 additions and 7 deletions
+16 -4
View File
@@ -1067,7 +1067,15 @@ class DouyuBatchRunner:
return {"embed": embed, "role": role}
def _xpd_area_id(self, role: dict, account: Account) -> int:
"""角色大区: 微信=1, 手Q=2, 未知回退账号已存值或 1"""
"""角色大区: 优先使用接口值,微信=1手Q=2未知回退已存值。"""
raw_area = role.get("area")
if raw_area not in (None, ""):
try:
area_id = int(raw_area)
except (TypeError, ValueError):
area_id = 0
if area_id > 0:
return area_id
role_type = str(role.get("type") or "")
if role_type == "wx":
return 1
@@ -1344,12 +1352,14 @@ class DouyuBatchRunner:
self._mark_task(db, task, "failed", "未获取到小店绑定角色")
return
area_id = self._xpd_area_id(role, account)
role_plat = role.get("plat_id")
plat = str(role_plat) if role_plat not in (None, "") else "1"
result = client.xpd_balance(
embed_query=ctx["embed"]["query"],
act_id=str(config["xpd_act_id"]),
openid=str(role.get("game_open_id") or ""),
roleid=str(role.get("role_id") or ""),
plat=str(role.get("plat_id") or "1"),
plat=plat,
areaid=str(area_id),
)
balance = result.get("balance")
@@ -1386,7 +1396,8 @@ class DouyuBatchRunner:
embed_query: dict = {}
openid = str(account.xpd_openid or "")
roleid = str(account.xpd_role_id or "")
plat = str(account.xpd_plat_id or "1")
stored_plat = account.xpd_plat_id
plat = str(stored_plat) if stored_plat is not None else "1"
areaid = str(account.xpd_area_id or 1)
role: dict = {}
try:
@@ -1397,7 +1408,8 @@ class DouyuBatchRunner:
role_area = self._xpd_area_id(role, account)
openid = str(role.get("game_open_id") or "") or openid
roleid = str(role.get("role_id") or "") or roleid
plat = str(role.get("plat_id") or "1") or plat
role_plat = role.get("plat_id")
plat = str(role_plat) if role_plat not in (None, "") else plat
areaid = str(role_area) or areaid
self._apply_xpd_role_to_account(account, role, role_area)
except Exception: