接入虎牙精英宝典最新商城前置流程

This commit is contained in:
yml2213
2026-09-01 11:42:52 +08:00
parent 684e16a07a
commit eb065a7c77
6 changed files with 243 additions and 2 deletions
+46
View File
@@ -851,6 +851,52 @@ class HuyaHttpClient:
"shopMiddleUI", "getGoodsInfoV5", req, GoodsInfoRsp, uid, guid, cookie
)
def list_pay_channels(
self, uid: int, guid: str, cookie: str, spu_id: str, sku_id: int,
supplier_id: int = 87401, timeout: float = 15.0,
):
from .shop_structs import ListPayChannelReq, ListPayChannelRsp
req = ListPayChannelReq()
req.userId = self._build_shop_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", 4)
req.supplierId = int(supplier_id or 0)
req.spuId = spu_id
req.skuId = int(sku_id or 0)
return self.call_rpc(
"shopMiddleUI", "listPayChannelV5", req, ListPayChannelRsp,
uid, guid, cookie, timeout=timeout,
)
def check_hy_protocol(
self, uid: int, guid: str, cookie: str, timeout: float = 15.0
):
from .shop_structs import CheckHyProtocolReq, ShopCodeRsp
req = CheckHyProtocolReq()
req.userId = self._build_shop_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", 4)
return self.call_rpc(
"shopMiddleUI", "checkHyProtocolV5", req, ShopCodeRsp,
uid, guid, cookie, timeout=timeout,
)
def check_user_buy_auth(
self, uid: int, guid: str, cookie: str, spu_id: str, sku_id: int,
timeout: float = 15.0,
):
from .shop_structs import CheckUserBuyAuthReq, ShopCodeRsp
req = CheckUserBuyAuthReq()
req.userId = self._build_shop_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", 4)
req.spuId = spu_id
req.skuId = int(sku_id or 0)
return self.call_rpc(
"shopMiddleUI", "checkUserBuyAuth", req, ShopCodeRsp,
uid, guid, cookie, timeout=timeout,
)
def query_user_order_list(
self,
uid,
+104
View File
@@ -639,6 +639,110 @@ class QueryUserOrderListRsp(TafStruct):
}
class ShopAppRequest(TafStruct):
"""商城前置 RPC 的公共请求字段。"""
def __init__(self):
self.userId = UserId()
self.shopAppInfo = ShopAppInfo()
def read_from(self, ins: TafInputStream):
self.userId = ins.read_struct(0, UserId) or self.userId
self.shopAppInfo = ins.read_struct(1, ShopAppInfo) or self.shopAppInfo
class ListPayChannelReq(ShopAppRequest):
def __init__(self):
super().__init__()
self.supplierId = 0
self.bizType = 5
self.gameCategoryId = 507
self.spuId = ""
self.skuId = 0
def write_to(self, os: TafOutputStream):
os.write_struct(0, self.userId)
os.write_struct(1, self.shopAppInfo)
os.write_int64(2, self.supplierId)
os.write_int32(3, self.bizType)
os.write_int32(4, self.gameCategoryId)
os.write_string(5, self.spuId)
os.write_int64(6, self.skuId)
class CheckHyProtocolReq(ShopAppRequest):
def __init__(self):
super().__init__()
self.protocolVersion = 1
def write_to(self, os: TafOutputStream):
os.write_struct(0, self.userId)
os.write_struct(1, self.shopAppInfo)
os.write_int32(2, self.protocolVersion)
class CheckUserBuyAuthReq(ShopAppRequest):
def __init__(self):
super().__init__()
self.spuId = ""
self.skuId = 0
self.checkType = 3
self.payChannel = ""
self.itemCount = 0
def write_to(self, os: TafOutputStream):
os.write_struct(0, self.userId)
os.write_struct(1, self.shopAppInfo)
os.write_string(2, self.spuId)
os.write_int64(3, self.skuId)
os.write_int32(4, self.checkType)
os.write_string(5, self.payChannel)
os.write_int32(6, self.itemCount)
class ListPayChannelRsp(TafStruct):
"""shopMiddleUI.listPayChannelV5 响应。"""
def __init__(self):
self.code = 0
self.message = ""
self.channels: list[str] = []
def read_from(self, ins: TafInputStream):
self.channels = ins.read_list(0)
self.code = ins.read_int32(1, default=self.code)
self.message = ins.read_string(2, default=self.message)
_skip_to_struct_end(ins)
def write_to(self, os: TafOutputStream):
os.write_list(0, self.channels)
os.write_int32(1, self.code)
os.write_string(2, self.message)
def to_dict(self) -> dict:
return {"code": self.code, "message": self.message, "channels": self.channels}
class ShopCodeRsp(TafStruct):
"""checkHyProtocolV5/checkUserBuyAuth 的状态响应。"""
def __init__(self):
self.code = 0
self.message = ""
def read_from(self, ins: TafInputStream):
self.code = ins.read_int32(0, default=self.code)
self.message = ins.read_string(1, default=self.message)
_skip_to_struct_end(ins)
def write_to(self, os: TafOutputStream):
os.write_int32(0, self.code)
os.write_string(1, self.message)
def to_dict(self) -> dict:
return {"code": self.code, "message": self.message}
class OrderDetailOrder(TafStruct):
"""orderDetailV5 中的订单摘要;保留支付轮询所需字段。"""
+40
View File
@@ -656,6 +656,46 @@ class HuyaWssClient:
"shopMiddleUI", "getGoodsInfoV5", req, GoodsInfoRsp, timeout=15.0
)
async def list_pay_channels(
self, uid: int, guid: str, cookie: str, spu_id: str, sku_id: int = 0,
supplier_id: int = 87401,
):
from .shop_structs import ListPayChannelReq, ListPayChannelRsp
req = ListPayChannelReq()
req.userId = self._build_biz_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", WSS_SHOP_SCENE)
req.supplierId = int(supplier_id or 0)
req.spuId = spu_id
req.skuId = int(sku_id or 0)
return await self.call_rpc(
"shopMiddleUI", "listPayChannelV5", req, ListPayChannelRsp, timeout=15.0
)
async def check_hy_protocol(self, uid: int, guid: str, cookie: str):
from .shop_structs import CheckHyProtocolReq, ShopCodeRsp
req = CheckHyProtocolReq()
req.userId = self._build_biz_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", WSS_SHOP_SCENE)
return await self.call_rpc(
"shopMiddleUI", "checkHyProtocolV5", req, ShopCodeRsp, timeout=15.0
)
async def check_user_buy_auth(
self, uid: int, guid: str, cookie: str, spu_id: str, sku_id: int,
):
from .shop_structs import CheckUserBuyAuthReq, ShopCodeRsp
req = CheckUserBuyAuthReq()
req.userId = self._build_biz_user(uid, cookie)
req.shopAppInfo = self._build_shop_app("yellowcarlist", WSS_SHOP_SCENE)
req.spuId = spu_id
req.skuId = int(sku_id or 0)
return await self.call_rpc(
"shopMiddleUI", "checkUserBuyAuth", req, ShopCodeRsp, timeout=15.0
)
async def query_user_order_list(
self,
uid: int,