修复(履约确认): 扫码角色消失不再误报客户冷却
- confirm 找不到已识别角色时归为 role_changed - 客户页/工作台允许刷新二维码重新扫码 - 保留账号,避免角色变化被当成换绑冷却 - 补充角色消失分类测试
This commit is contained in:
@@ -38,6 +38,10 @@ from web.backend.services.automation.jobs import (
|
|||||||
platform_fulfillment_lease_reaper as reaper,
|
platform_fulfillment_lease_reaper as reaper,
|
||||||
)
|
)
|
||||||
from web.backend.services.platform_fulfillment import account_selector, service, views
|
from web.backend.services.platform_fulfillment import account_selector, service, views
|
||||||
|
from web.backend.services.platform_fulfillment.binding_status import (
|
||||||
|
_binding_failure_issue,
|
||||||
|
_binding_failure_raw_message,
|
||||||
|
)
|
||||||
from web.backend.services.platform_fulfillment.order_sync import _apply_customer_profile
|
from web.backend.services.platform_fulfillment.order_sync import _apply_customer_profile
|
||||||
|
|
||||||
NOW = datetime.now(UTC).replace(microsecond=0)
|
NOW = datetime.now(UTC).replace(microsecond=0)
|
||||||
@@ -3387,6 +3391,25 @@ class TestBindingAndCompletion(_Base):
|
|||||||
|
|
||||||
assert detail["customerProfile"]["channelMatched"] is True
|
assert detail["customerProfile"]["channelMatched"] is True
|
||||||
|
|
||||||
|
def test_confirm_role_disappeared_is_not_customer_cooldown(self):
|
||||||
|
result = {
|
||||||
|
"bind_phase": "confirm_failed",
|
||||||
|
"expected_role_name": "再说就一坨儿",
|
||||||
|
"bind_candidates": [
|
||||||
|
{"act_alias": "cjm", "role_name": ""},
|
||||||
|
{"act_alias": "20260120QYOOB", "role_name": "小无恩"},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
task = DouyuTask(
|
||||||
|
message="待确认角色已变化,未找到: 再说就一坨儿",
|
||||||
|
result=result,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert _binding_failure_issue(task, result) == "role_changed"
|
||||||
|
assert "扫码角色已失效" in _binding_failure_raw_message(
|
||||||
|
"role_changed", result
|
||||||
|
)
|
||||||
|
|
||||||
def test_customer_profile_requires_home_image(self):
|
def test_customer_profile_requires_home_image(self):
|
||||||
task = self._allocated()
|
task = self._allocated()
|
||||||
with pytest.raises(HTTPException) as exc_info:
|
with pytest.raises(HTTPException) as exc_info:
|
||||||
|
|||||||
@@ -620,7 +620,7 @@ def prepare_manual_allocation(
|
|||||||
task.execution_status == "manual_required"
|
task.execution_status == "manual_required"
|
||||||
and not task.account_id
|
and not task.account_id
|
||||||
and not task.lease_id
|
and not task.lease_id
|
||||||
and task.issue_code in {"binding_failed", "lease_expired"}
|
and task.issue_code in {"binding_failed", "lease_expired", "role_changed"}
|
||||||
):
|
):
|
||||||
# 绑定失败账号已释放后,人工触发一次重新选号;
|
# 绑定失败账号已释放后,人工触发一次重新选号;
|
||||||
# 客户资料保留,分配成功后 auto allocator 会继续启动绑定。
|
# 客户资料保留,分配成功后 auto allocator 会继续启动绑定。
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ def _customer_task_message_for(issue_code: str) -> str:
|
|||||||
"points_short": "账号正在补充积分,请稍后重试",
|
"points_short": "账号正在补充积分,请稍后重试",
|
||||||
"commodity_limit_reached": "当前商品暂时无法兑换,请联系客服",
|
"commodity_limit_reached": "当前商品暂时无法兑换,请联系客服",
|
||||||
"binding_failed": "暂未识别到绑定角色,请继续使用当前二维码完成扫码",
|
"binding_failed": "暂未识别到绑定角色,请继续使用当前二维码完成扫码",
|
||||||
|
"role_changed": "扫码角色已失效,请刷新二维码后重新扫码",
|
||||||
"account_role_cooldown": "当前斗鱼账号未到换绑时间,请截图本页面并联系客服处理",
|
"account_role_cooldown": "当前斗鱼账号未到换绑时间,请截图本页面并联系客服处理",
|
||||||
"customer_role_cooldown": "该游戏角色仍在换绑冷却期,请截图本页面并联系客服处理",
|
"customer_role_cooldown": "该游戏角色仍在换绑冷却期,请截图本页面并联系客服处理",
|
||||||
"customer_role_bound_elsewhere": "该游戏角色 7 天内已绑定其他斗鱼账号,请使用原账号或等待",
|
"customer_role_bound_elsewhere": "该游戏角色 7 天内已绑定其他斗鱼账号,请使用原账号或等待",
|
||||||
@@ -38,6 +39,32 @@ def _customer_task_message(task: PlatformFulfillmentTask) -> str:
|
|||||||
return _customer_task_message_for(task.issue_code)
|
return _customer_task_message_for(task.issue_code)
|
||||||
|
|
||||||
|
|
||||||
|
def _is_role_changed_failure(
|
||||||
|
phase: str,
|
||||||
|
message: str,
|
||||||
|
confirm_error: str,
|
||||||
|
result: dict[str, Any],
|
||||||
|
) -> bool:
|
||||||
|
"""确认时角色凭空消失,不等于客户角色处于换绑冷却。"""
|
||||||
|
if phase != "confirm_failed":
|
||||||
|
return False
|
||||||
|
text = f"{message} {confirm_error}"
|
||||||
|
if "未找到" in text or "角色已变化" in text or "待确认角色已变化" in text:
|
||||||
|
return True
|
||||||
|
expected = str(result.get("expected_role_name") or "").strip()
|
||||||
|
candidates = result.get("bind_candidates")
|
||||||
|
if expected and isinstance(candidates, list):
|
||||||
|
roles = {
|
||||||
|
str(item.get("role_name") or "").strip().casefold()
|
||||||
|
for item in candidates
|
||||||
|
if isinstance(item, dict)
|
||||||
|
}
|
||||||
|
roles.discard("")
|
||||||
|
if roles and expected.casefold() not in roles:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _binding_failure_raw_message(
|
def _binding_failure_raw_message(
|
||||||
issue_code: str,
|
issue_code: str,
|
||||||
result: dict[str, Any],
|
result: dict[str, Any],
|
||||||
@@ -51,6 +78,9 @@ def _binding_failure_raw_message(
|
|||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
role_name = str(result.get("role_name") or "")
|
role_name = str(result.get("role_name") or "")
|
||||||
|
if issue_code == "role_changed":
|
||||||
|
expected = str(result.get("expected_role_name") or role_name or "-")
|
||||||
|
return f"扫码角色已失效(原角色: {expected}),请刷新二维码重新扫码"
|
||||||
if issue_code == "account_role_cooldown":
|
if issue_code == "account_role_cooldown":
|
||||||
role_label = before_bound_role or role_name or "当前角色"
|
role_label = before_bound_role or role_name or "当前角色"
|
||||||
return (
|
return (
|
||||||
@@ -70,6 +100,13 @@ def _binding_failure_issue(bind_task: DouyuTask, result: dict[str, Any]) -> str:
|
|||||||
message = str(bind_task.message or "")
|
message = str(bind_task.message or "")
|
||||||
confirm_error = str(result.get("confirm_error") or "")
|
confirm_error = str(result.get("confirm_error") or "")
|
||||||
confirm_code = result.get("confirm_error_code")
|
confirm_code = result.get("confirm_error_code")
|
||||||
|
if _is_role_changed_failure(
|
||||||
|
phase,
|
||||||
|
message,
|
||||||
|
f"{confirm_error} {result.get('bind_phase') or ''}",
|
||||||
|
result,
|
||||||
|
):
|
||||||
|
return "role_changed"
|
||||||
# 原始接口文案是分类的第一事实源。历史任务可能已经写入了错误的
|
# 原始接口文案是分类的第一事实源。历史任务可能已经写入了错误的
|
||||||
# derived issue_code,不能在刷新时继续让错误派生值覆盖原始响应。
|
# derived issue_code,不能在刷新时继续让错误派生值覆盖原始响应。
|
||||||
cooldown_kind = classify_bind_cooldown(None, confirm_error)
|
cooldown_kind = classify_bind_cooldown(None, confirm_error)
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ async def customer_start_binding(
|
|||||||
if not task.account_id or not task.lease_id:
|
if not task.account_id or not task.lease_id:
|
||||||
if (
|
if (
|
||||||
task.execution_status == "manual_required"
|
task.execution_status == "manual_required"
|
||||||
and task.issue_code in {"binding_failed", "lease_expired"}
|
and task.issue_code in {"binding_failed", "lease_expired", "role_changed"}
|
||||||
):
|
):
|
||||||
from .allocation import prepare_manual_allocation
|
from .allocation import prepare_manual_allocation
|
||||||
|
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ function canReallocateAndBind(task: PlatformFulfillmentTask) {
|
|||||||
!task.account &&
|
!task.account &&
|
||||||
task.customerProfile &&
|
task.customerProfile &&
|
||||||
task.executionStatus === 'manual_required' &&
|
task.executionStatus === 'manual_required' &&
|
||||||
['binding_failed', 'lease_expired'].includes(task.issueCode),
|
['binding_failed', 'lease_expired', 'role_changed'].includes(task.issueCode),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user