实现虎牙充值商品列表与支付二维码

This commit is contained in:
yml2213
2026-07-04 23:48:53 +08:00
parent fa0d49ff8c
commit 5513b5a313
12 changed files with 1209 additions and 61 deletions
+27 -1
View File
@@ -286,6 +286,22 @@ class HuyaHttpClient:
timeout=timeout,
)
def get_act_task_detail(self, uid: int, cookie: str, act_id: int, timeout: float = 15.0):
"""查询活动任务详情,用于发现充值商品 SPU。"""
from .activity_structs import GetActTaskDetailReq, GetActTaskDetailResp
req = GetActTaskDetailReq()
req.userId = self._build_activity_user(uid, cookie)
req.actId = int(act_id or 0)
return self.call_rpc(
"webActUI",
"getActTaskDetail",
req,
GetActTaskDetailResp,
uid=uid,
cookie=cookie,
timeout=timeout,
)
def check_user_bind_game_account(
self,
uid: int,
@@ -593,6 +609,16 @@ class HuyaHttpClient:
self.logger(f" orderType={ot}: 无响应")
return last_result
@staticmethod
def _normalize_pay_channel(pay_type) -> str:
text = str(pay_type or "").strip()
lowered = text.lower()
if lowered in {"", "1", "zfb", "alipay", "支付宝"}:
return "Zfb"
if lowered in {"2", "wx", "weixin", "wechat", "微信"}:
return "Weixin"
return text
def pay_order_submit(self, uid, guid, cookie, order_id, pay_type=1,
pid=0, source_id="yellowcarlist", scene=7,
item_count=1):
@@ -604,7 +630,7 @@ class HuyaHttpClient:
os.write_struct(0, self._build_user(uid, guid, cookie))
os.write_struct(1, self._build_shop_app(source_id, scene))
os.write_int64(2, order_id)
os.write_string(3, "Zfb" if pay_type == 1 else str(pay_type))
os.write_string(3, self._normalize_pay_channel(pay_type))
os.write_string(4, "QrCode")
callback_url = (
f"https://m-shop.yaoguo.com/index.html#/consumer/paycallback"