feat(huya): 开通支付码复用未支付旧单 + 二维码改用支付宝收银台直达地址

- 限购商品(精英宝典 buy_limit=1)挂着未支付旧单时,真正先失败的是购买权限
  校验 checkUserBuyAuth(真机 703「已超过该商品的购买上限,下单失败~」),
  createOrderV5 根本不会执行;现在 checkUserBuyAuth 与 createOrderV5 两处失败
  都会回退 find_reusable_order,拿同一商品的未支付旧单继续 payOrderSubmitV5。
- 新增支付宝收银台直达地址解析(resolve_pay_entry_url):跟随网关 302 后的
  excashier.alipay.com/standard/auth.htm?payOrderId=…(93 字符,原始网关地址
  1616 字符)写入结果 pay_cashier_url;解析失败回落本站短链
  /api/huya/pay/<task_id>?k=<hmac>,后端跑在 localhost 时客户也扫得开。
- 前端 QRCode 显式 color="#000" bgColor="#fff":antd v6 暗色主题默认
  color=token.colorText、bgColor=transparent,白码落在白底容器里根本看不见。
- 支付成功后列表「二维码」列不再展示二维码(qrDoneLabel → 已支付/已开通)。

测试:pytest 767 passed / 6 skipped;typecheck、eslint、ruff 通过。
This commit is contained in:
yml2213
2026-10-15 19:28:26 +08:00
parent f61284e808
commit 0b9a01ab3f
9 changed files with 850 additions and 44 deletions
+14 -1
View File
@@ -16,6 +16,7 @@ from core.huya.frame_decoder import decode_struct_bytes
from core.huya.http_client import HuyaHttpClient
from core.huya.shop_structs import ShopRawRsp
from web.backend.models import HuyaAccount
from web.backend.services.huya_pay_link import pay_qr_path
from web.backend.services.huya_runner import HuyaBatchRunner
UID = 1199668595203
@@ -332,6 +333,7 @@ def test_create_recharge_order_confirms_elite_open_after_payment(db, monkeypatch
supplier_name="和平精英官方小店",
promotion={},
promotion_info="本单无返利",
reused_order={},
)
shop_client = _StubClient(redeem=_redeem(REDEEM_OPENED_HEX), season=True)
@@ -380,13 +382,20 @@ def test_create_recharge_order_confirms_elite_open_after_payment(db, monkeypatch
"web.backend.services.huya_runner_recharge.run_open_flow",
lambda *args, **kwargs: outcome,
)
# 二维码内容优先用支付宝收银台直达地址(真机:网关 302 后的落点)
monkeypatch.setattr(
"web.backend.services.huya_runner_recharge.resolve_pay_entry_url",
lambda _pay_url, **_kwargs: (
"https://excashier.alipay.com/standard/auth.htm?payOrderId=x.25"
),
)
account = HuyaAccount(uid=str(UID), cookie=COOKIE)
db.add(account)
db.commit()
runner._execute_create_recharge_order(
db,
None,
SimpleNamespace(id=587),
account,
{"uid": UID, "cookie": COOKIE},
{"room_pid": "1199650619883", "pay_channel": "Zfb", "sid": "2203"},
@@ -399,6 +408,10 @@ def test_create_recharge_order_confirms_elite_open_after_payment(db, monkeypatch
assert result["elite_open_time"] == 1792053457
assert result["elite_expire_time"] == 1798732799
assert result["post_payment_points"] == 280
# 二维码内容给前端两条短地址(原始支付地址 1626 字符,扫码扫不动)
assert result["pay_qr_path"] == pay_qr_path(587)
# 优先用支付宝收银台直达地址(公网域名,localhost 下客户也扫得开)
assert result["pay_cashier_url"].startswith("https://excashier.alipay.com/")
assert account.elite_opened is True
assert account.elite_expire_time == 1798732799
assert account.points == 280