feat(douyu): 兑换图片默认隐藏 + 供应商直充默认上限800

- 兑换图片仅显示本页面本次发起过兑换的账号,历史截图默认不展示
- douyu_config 增加 gold_api_max_amount,默认800
- 配置弹窗可修改,输入框按上限 clamp,执行器下单前再校验
- 新增迁移0130,补充配置/超限测试
This commit is contained in:
yml
2026-11-24 20:00:31 +08:00
parent 77a881bdf8
commit 7a5d3ae9c8
12 changed files with 158 additions and 4 deletions
+29
View File
@@ -242,6 +242,30 @@ class TestDouyuGoldRechargeChannel:
assert "pay_url" not in task_result
assert "sign" not in task_result["supplier_order"]
@patch("web.backend.services.douyu_runner_gold.FishFinRechargeClient")
def test_supplier_channel_rejects_amount_over_configured_max(self, client_class):
config = {
"gold_recharge_channel": "supplier_api",
"gold_api_product_id": "gold-product",
"gold_api_account_template_name": "斗鱼昵称",
"gold_api_max_amount": 800,
}
self.task.result = {"payload": {"amount": 801}}
self.session.commit()
self.runner._execute_create_gold_qr(
self.session,
self.task,
self.account,
"acf_uid=10001",
config,
)
client_class.assert_not_called()
self.session.refresh(self.task)
assert self.task.status == "failed"
assert "800" in self.task.message
@patch("web.backend.services.douyu_runner_gold.FishFinRechargeClient")
def test_supplier_channel_rejects_account_without_nickname(self, client_class):
self.account.nickname = ""
@@ -355,6 +379,11 @@ class TestDouyuGoldRechargeChannel:
dumped = res.model_dump()
assert dumped["gold_recharge_channel"] == "supplier_api"
assert dumped["peace_enabled"] is True
assert dumped["gold_api_max_amount"] == 800
req_max = DouyuConfigUpdate(gold_api_max_amount=500)
res_max = update_config(req_max, db=self.session, current=admin_user)
assert res_max.model_dump()["gold_api_max_amount"] == 500
# 2. 切换回 wechat_qr
req2 = DouyuConfigUpdate(
+1 -1
View File
@@ -45,7 +45,7 @@ TESTS_DIR = Path(__file__).resolve().parent
PROJECT_ROOT = TESTS_DIR.parent
VERSIONS_DIR = PROJECT_ROOT / "web" / "backend" / "migrations" / "versions"
HEAD_REVISION = "20261124_0129"
HEAD_REVISION = "20261124_0130"
# 迁移新增、但不声明在模型里的复合查询索引。
EXTRA_INDEXES = (