refactor(fulfillment): 拆分履约服务并修正换绑冷却分类

This commit is contained in:
yml
2026-11-23 13:56:32 +08:00
parent 04e9b1d4c3
commit 05a7a56c4e
19 changed files with 4760 additions and 3951 deletions
+38 -10
View File
@@ -34,7 +34,7 @@ from __future__ import annotations
from collections.abc import Sequence
from datetime import UTC, datetime, timedelta
from typing import Any
from typing import Any, Literal
from ..models import Account
@@ -285,27 +285,55 @@ def role_change_available_at(
return None
def is_platform_account_bind_cooldown(
BindCooldownKind = Literal["platform", "customer"]
def classify_bind_cooldown(
error_code: Any = None,
message: str = "",
) -> bool:
"""是否为斗鱼平台账号自身的换绑冷却。
) -> BindCooldownKind | None:
"""区分斗鱼平台账号和客户游戏角色的换绑冷却。
两种冷却都是 ``-200001``,必须继续用文案区分:
- “该平台账号未到可换绑时间,请使用其他平台账号”:斗鱼账号冷却;
- “该账号未到可换绑时间,请使用其他账号”:客户游戏账号冷却。
兼容本系统历史版本生成的展示文案,避免旧任务刷新后继续误判。
``-200001`` 但没有可识别文案时沿用历史兜底,按斗鱼账号冷却处理。
"""
try:
normalized_code = int(error_code)
except (TypeError, ValueError):
normalized_code = None
text = str(message or "")
if "该平台账号未到可换绑时间" in text:
return True
if "该账号未到可换绑时间" in text or "请使用其他账号" in text:
return False
return normalized_code == -200001
text = "".join(str(message or "").split())
platform_markers = (
"该平台账号未到可换绑时间",
"请使用其他平台账号",
"斗鱼账号当前绑定角色",
"斗鱼账号当前角色",
)
customer_markers = (
"该账号未到可换绑时间",
"请使用其他账号",
"待绑定游戏账号",
"该游戏角色仍在换绑冷却期",
)
if any(marker in text for marker in platform_markers):
return "platform"
if any(marker in text for marker in customer_markers):
return "customer"
if normalized_code == -200001:
return "platform"
return None
def is_platform_account_bind_cooldown(
error_code: Any = None,
message: str = "",
) -> bool:
"""是否为斗鱼平台账号自身的换绑冷却。"""
return classify_bind_cooldown(error_code, message) == "platform"
def binding_pending_decision(