fix(huya): 开通商品只保留真正可购买的 spu,并清理历史死商品行
真机 2026-10-15(HAR 10.15-精英徽章两个-1 + 逐个 spu 探测):面板里的「精英徽章 hy-5872824」是积分中心「赠送指定礼物得积分」那排的礼物 spu —— getGoodsInfoV5 仍返回 200+价格,但 listPayChannelV5 返回 401「您的设备环境暂不支持购买该商品」,所以下单必报「当前支付渠道不可用」(与数量无关)。真能买的是 hy-8343549 精英徽章 ¥1 / hy-8343551 精英令 ¥10。 - 内置候选换成可购买的 4 个:hy-8328015 宝典 / hy-8327356 币 / hy-8343549 徽章 / hy-8343551 令 - 刷新商品增加「能买到」闸门:详情 200 后再校验 listPayChannelV5,非 200 或渠道为空即剔除并记录服务端原话 - 下单流程渠道失败时透出服务端消息,只有渠道真不在可用列表才说「当前支付渠道不可用(可用:…)」 - 商品列表只认「最近一次刷新」那一套:原先按账号并集返回,别的账号旧刷新留下的礼物 spu 会和最新一套叠成 7 个选项 - 刷新时清理历史死行:本账号旧行 + 全局默认行(account_id 为空)+ 其它账号里已不在候选中的 spu 行 - 测试:401 商品被剔除、渠道失败透传、列表只认最近一套、刷新清理别处死行
This commit is contained in:
@@ -70,12 +70,18 @@ class _Client:
|
||||
orders=None,
|
||||
auth_code: int = 200,
|
||||
auth_message: str = "",
|
||||
channel_code: int = 200,
|
||||
channel_message: str = "",
|
||||
channels=("Zfb",),
|
||||
):
|
||||
self.create_code = create_code
|
||||
self.create_message = create_message
|
||||
self.orders = orders or []
|
||||
self.auth_code = auth_code
|
||||
self.auth_message = auth_message
|
||||
self.channel_code = channel_code
|
||||
self.channel_message = channel_message
|
||||
self.channels = list(channels)
|
||||
self.pay_order_ids: list[int] = []
|
||||
self.order_list_calls = 0
|
||||
self.create_calls = 0
|
||||
@@ -97,7 +103,9 @@ class _Client:
|
||||
return resp
|
||||
|
||||
def list_pay_channels(self, **kwargs):
|
||||
return SimpleNamespace(code=200, message="", channels=["Zfb"])
|
||||
return SimpleNamespace(
|
||||
code=self.channel_code, message=self.channel_message, channels=self.channels
|
||||
)
|
||||
|
||||
def check_hy_protocol(self, **kwargs):
|
||||
return SimpleNamespace(code=200, message="")
|
||||
@@ -245,6 +253,40 @@ def test_auth_no_response_fails_without_touching_orders():
|
||||
assert client.order_list_calls == 0
|
||||
|
||||
|
||||
def test_unbuyable_goods_surfaces_channel_message():
|
||||
"""能看不能买的商品(listPayChannelV5 401):把服务端原话透出来。
|
||||
|
||||
真机 2026-10-15:hy-5872824「精英徽章」是积分中心的礼物 spu,getGoodsInfoV5
|
||||
返回 200 + ¥1,但支付渠道接口返回 401「您的设备环境暂不支持购买该商品」。
|
||||
以前一律报「当前支付渠道不可用」,看不出是商品不能买。
|
||||
"""
|
||||
client = _Client(
|
||||
create_code=200,
|
||||
channel_code=401,
|
||||
channel_message="您的设备环境暂不支持购买该商品",
|
||||
channels=(),
|
||||
)
|
||||
|
||||
outcome = _run(client)
|
||||
|
||||
assert outcome.ok is False
|
||||
assert outcome.message == "您的设备环境暂不支持购买该商品"
|
||||
# 渠道校验没过就不该下单、更不该起支付
|
||||
assert client.create_calls == 0
|
||||
assert client.pay_order_ids == []
|
||||
|
||||
|
||||
def test_unavailable_pay_channel_lists_what_is_available():
|
||||
client = _Client(create_code=200, channels=("Weixin",))
|
||||
|
||||
outcome = _run(client) # 默认走 Zfb
|
||||
|
||||
assert outcome.ok is False
|
||||
assert "当前支付渠道不可用" in outcome.message
|
||||
assert "Weixin" in outcome.message
|
||||
assert client.create_calls == 0
|
||||
|
||||
|
||||
def test_paid_order_is_not_reused():
|
||||
client = _Client(
|
||||
create_code=703, create_message=BUY_LIMIT_MESSAGE, orders=[PAID_ELITE_ORDER]
|
||||
|
||||
Reference in New Issue
Block a user