diff --git a/docs/斗鱼/DOUYU_PROTOCOL_OVERVIEW.md b/docs/斗鱼/DOUYU_PROTOCOL_OVERVIEW.md index bceb72d..7eb0675 100644 --- a/docs/斗鱼/DOUYU_PROTOCOL_OVERVIEW.md +++ b/docs/斗鱼/DOUYU_PROTOCOL_OVERVIEW.md @@ -392,7 +392,8 @@ alias 上的旧角色,不能把 `cjm` 的新角色写入账号库。 - `bindAct=0` 是 pending,可以在发新二维码前已经存在; - `bindAct=1` 是 bound,即使同时返回 `needBindAct=1` 也不是 pending; - 不要把 `needBindAct=1` 单独当成本轮扫码结果; -- `actBind=-200001` 是当前斗鱼账号冷却,不是客户游戏角色冷却; +- `actBind=-200001` 必须结合文案区分:含“该平台账号未到可换绑时间”是当前 + 斗鱼账号冷却,含“该账号未到可换绑时间”是客户游戏账号冷却; - `actBind` 失败后必须保留旧绑定,不能写入新扫码角色; - 不要在页面层重新实现 `bindAct/needBindAct` 判断; - 不要把原始 `bind_summary` 当业务文案,它只用于排障。 diff --git a/tests/test_douyu_binding_state.py b/tests/test_douyu_binding_state.py index 4182034..0009870 100644 --- a/tests/test_douyu_binding_state.py +++ b/tests/test_douyu_binding_state.py @@ -18,6 +18,7 @@ from web.backend.services.account_binding import ( binding_snapshot, derive_from_bind_info, is_pending_binding_role, + is_platform_account_bind_cooldown, is_role_change_cooling, pending_binding_role_from_result, role_change_available_at, @@ -616,6 +617,14 @@ def test_confirm_bind_preserves_platform_cooldown_error_code(monkeypatch): assert exc_info.value.payload == payload +def test_bind_cooldown_messages_distinguish_platform_and_customer_accounts(): + customer_message = "该账号未到可换绑时间,请使用其他账号" + platform_message = "该平台账号未到可换绑时间,请使用其他平台账号" + + assert is_platform_account_bind_cooldown(-200001, customer_message) is False + assert is_platform_account_bind_cooldown(-200001, platform_message) is True + + def test_get_bind_qr_uses_role_param_url_for_mini_qrcode(monkeypatch): client = DouyuActivityClient("acf_ccn=ctn") monkeypatch.setattr( diff --git a/tests/test_platform_fulfillment.py b/tests/test_platform_fulfillment.py index 139671e..d16aabe 100644 --- a/tests/test_platform_fulfillment.py +++ b/tests/test_platform_fulfillment.py @@ -2512,6 +2512,8 @@ class TestBindingAndCompletion(_Base): "role_name": "测试角色", "bind_ready_for_confirm": True, "bind_confirmed": False, + "confirm_error": "该账号未到可换绑时间,请使用其他账号", + "confirm_error_code": -200001, }, created_by=self.admin_id, ) diff --git a/web/backend/services/account_binding.py b/web/backend/services/account_binding.py index 69dd6ea..62ac598 100644 --- a/web/backend/services/account_binding.py +++ b/web/backend/services/account_binding.py @@ -291,17 +291,21 @@ def is_platform_account_bind_cooldown( ) -> bool: """是否为斗鱼平台账号自身的换绑冷却。 - 2026-11-22 换绑失败 HAR 中 ``actBind`` 返回 ``-200001``: - “该平台账号未到可换绑时间,请使用其他平台账号”。它限制的是当前斗鱼号, - 不是用户扫码选择的腾讯游戏角色;提示和人工处理都必须区分两者。 + 两种冷却都是 ``-200001``,必须继续用文案区分: + + - “该平台账号未到可换绑时间,请使用其他平台账号”:斗鱼账号冷却; + - “该账号未到可换绑时间,请使用其他账号”:客户游戏账号冷却。 """ try: normalized_code = int(error_code) except (TypeError, ValueError): normalized_code = None - return normalized_code == -200001 or "该平台账号未到可换绑时间" in ( - message or "" - ) + text = str(message or "") + if "该平台账号未到可换绑时间" in text: + return True + if "该账号未到可换绑时间" in text or "请使用其他账号" in text: + return False + return normalized_code == -200001 def binding_pending_decision(