feat(douyu): 和平小店绑定功能(生成绑定二维码/查询绑定信息)

- activity_client: xpd_bind_qr(roleParam 签发 livelink 绑定链接, 微信扫码进小程序绑定)
  + xpd_bind_info(bindInfo 查询绑定状态/角色/平台), gameRole 非 dict 边界防护
- runner/service: 注册 get_xpd_bind_qr / query_xpd_bind_info 任务, 回写
  xpd_game_name / xpd_bind_status
- router: get_xpd_bind_qr 的 url 加入列表接口保留白名单(二维码展示)
- 前端: 和平小店面板新增两个按钮, 二维码列支持 get_xpd_bind_qr 展示/放大
This commit is contained in:
yml2213
2026-08-06 17:33:11 +08:00
parent fdc74eba8c
commit 5f63d77dc3
5 changed files with 127 additions and 1 deletions
+53
View File
@@ -1076,6 +1076,57 @@ class DouyuBatchRunner:
{"role": role, "area_id": area_id},
)
def _execute_get_xpd_bind_qr(
self,
db: Session,
task: DouyuTask,
account: Account,
cookie: str,
config: dict,
):
"""生成和平小店绑定二维码(微信扫码在小程序内绑定角色)。"""
client = self._client(cookie)
act_alias = str(config.get("xpd_act_alias") or "").strip()
if not act_alias:
self._mark_task(db, task, "failed", "请先配置小店活动代号 actAlias")
return
result = client.xpd_bind_qr(act_alias=act_alias)
account.xpd_bind_status = "xpd_bind_qr_ready"
account.updated_at = datetime.now(timezone.utc)
db.commit()
self._mark_task(db, task, "success", "小店绑定二维码已生成", result)
def _execute_query_xpd_bind_info(
self,
db: Session,
task: DouyuTask,
account: Account,
cookie: str,
config: dict,
):
"""查询和平小店绑定信息(bindInfo)。"""
client = self._client(cookie)
act_alias = str(config.get("xpd_act_alias") or "").strip()
if not act_alias:
self._mark_task(db, task, "failed", "请先配置小店活动代号 actAlias")
return
result = client.xpd_bind_info(act_alias=act_alias)
role_name = str(result.get("role_name") or "")
if role_name:
account.xpd_game_name = role_name
account.xpd_bind_status = "xpd_bound" if result.get("bind_role") else "xpd_not_bound"
account.updated_at = datetime.now(timezone.utc)
db.commit()
status = "已绑定" if result.get("bind_role") else "未绑定"
text = str(result.get("role_name") or result.get("nick") or "-")
self._mark_task(
db,
task,
"success",
f"小店绑定: {status} ({text})",
result,
)
def _execute_refresh_xpd_goods(
self,
db: Session,
@@ -2443,6 +2494,8 @@ class DouyuBatchRunner:
"query_gold_balance": self._execute_query_gold_balance,
"query_exchange_records": self._execute_query_exchange_records,
"prefetch_csrf_token": self._execute_prefetch_csrf_token,
"get_xpd_bind_qr": self._execute_get_xpd_bind_qr,
"query_xpd_bind_info": self._execute_query_xpd_bind_info,
"query_xpd_role": self._execute_query_xpd_role,
"refresh_xpd_goods": self._execute_refresh_xpd_goods,
"query_xpd_balance": self._execute_query_xpd_balance,