修复(履约绑定): 匹配客户目标时展示 cjm 待确认角色

This commit is contained in:
yml
2026-11-26 01:40:49 +08:00
parent 473d9c7ecf
commit d62d56d98d
4 changed files with 99 additions and 21 deletions
+43
View File
@@ -730,6 +730,49 @@ def test_result_rejects_legacy_role_when_action_alias_still_has_role():
assert pending_binding_role_from_result(result) == "" assert pending_binding_role_from_result(result) == ""
def test_result_accepts_legacy_role_matching_customer_target():
candidates = [
_role_candidate(LEGACY_ALIAS, "情绪稳妥"),
_role_candidate(ACT_ALIAS, "呆혹", bound_act=True),
]
result = {
"role_name": "情绪稳妥",
"act_alias": LEGACY_ALIAS,
"action_act_aliases": [ACT_ALIAS],
"baseline_role_name": "呆혹",
"baseline_is_bound_act": True,
"expected_role_name": "情绪稳妥",
"bind_ready_for_confirm": True,
"bind_confirmed": False,
"bind_candidates": [
{
"act_alias": LEGACY_ALIAS,
"role_name": "情绪稳妥",
"is_bound_act": False,
},
{
"act_alias": ACT_ALIAS,
"role_name": "呆혹",
"is_bound_act": True,
},
],
}
assert pending_binding_role_from_result(result) == "情绪稳妥"
decisions = _RolePicker()._binding_candidate_decisions(
candidates,
baseline_role_name="呆혹",
baseline_is_bound_act=True,
actionable_aliases=[ACT_ALIAS],
expected_role_name="情绪稳妥",
)
legacy_decision = next(
item for item in decisions if item["alias"] == LEGACY_ALIAS
)
assert legacy_decision["confirmable"] is True
assert legacy_decision["reason"] == "role_changed"
def test_expected_role_never_falls_back_to_old_activity_role(): def test_expected_role_never_falls_back_to_old_activity_role():
old_role = "狗鼻子弗尼亚bd" old_role = "狗鼻子弗尼亚bd"
new_role = "我是火星人2222" new_role = "我是火星人2222"
+8 -2
View File
@@ -559,16 +559,22 @@ def pending_binding_role_from_result(result: dict[str, Any] | None) -> str:
in action_alias_set in action_alias_set
and str(item.get("role_name") or "").strip() and str(item.get("role_name") or "").strip()
] ]
expected_role_name = str(result.get("expected_role_name") or "").strip()
expected_matches = bool(
expected_role_name
and role_name.casefold() == expected_role_name.casefold()
)
if ( if (
action_alias_set action_alias_set
and selected_alias and selected_alias
and selected_alias not in action_alias_set and selected_alias not in action_alias_set
and action_evidence and action_evidence
and not expected_matches
): ):
# legacy(cjm) 可能返回同一斗鱼账号历史绑过的另一个游戏角色。 # legacy(cjm) 可能返回同一斗鱼账号历史绑过的另一个游戏角色。
# 动作 alias 仍有明确角色时,legacy 的 role_name 不能成为本单 pending。 # 动作 alias 仍有明确角色时,只有与客户目标一致的 legacy 角色可以进入
# pending;不匹配的历史角色不能覆盖本单。
return "" return ""
expected_role_name = str(result.get("expected_role_name") or "").strip()
if is_pending_binding_role( if is_pending_binding_role(
result, result,
baseline_role_name=baseline, baseline_role_name=baseline,
+26 -3
View File
@@ -382,7 +382,16 @@ class BindMixin:
for info, decision in zip(candidates, decisions, strict=True): for info, decision in zip(candidates, decisions, strict=True):
alias = str(info.get("act_alias") or "").strip() alias = str(info.get("act_alias") or "").strip()
role_name = str(info.get("role_name") or "").strip() role_name = str(info.get("role_name") or "").strip()
if alias not in alias_set and role_name not in action_roles: expected_matches = bool(
expected_role_name
and role_name.casefold()
== expected_role_name.strip().casefold()
)
if (
alias not in alias_set
and role_name not in action_roles
and not expected_matches
):
decision.update( decision.update(
{ {
"confirmable": False, "confirmable": False,
@@ -714,7 +723,14 @@ class BindMixin:
if not role_name or role_name.casefold() == baseline: if not role_name or role_name.casefold() == baseline:
continue continue
alias = str(info.get("act_alias") or "").strip() alias = str(info.get("act_alias") or "").strip()
if action_alias_has_role and alias not in alias_set: expected_matches = bool(
expected and role_name.casefold() == expected
)
if (
action_alias_has_role
and alias not in alias_set
and not expected_matches
):
continue continue
if expected and role_name.casefold() != expected: if expected and role_name.casefold() != expected:
continue continue
@@ -730,7 +746,14 @@ class BindMixin:
for info in ordered: for info in ordered:
role_name = str(info.get("role_name") or "").strip() role_name = str(info.get("role_name") or "").strip()
alias = str(info.get("act_alias") or "").strip() alias = str(info.get("act_alias") or "").strip()
if action_alias_has_role and alias not in alias_set: expected_matches = bool(
expected and role_name.casefold() == expected
)
if (
action_alias_has_role
and alias not in alias_set
and not expected_matches
):
continue continue
if expected and role_name.casefold() != expected: if expected and role_name.casefold() != expected:
continue continue
@@ -1398,22 +1398,28 @@ export default function PlatformFulfillmentPage() {
title: '用户角色绑定', title: '用户角色绑定',
key: 'binding', key: 'binding',
width: 180, width: 180,
render: (_, task) => ( render: (_, task) => {
<Space direction="vertical" size={2}> const roleName =
<Tag color={bindingStatusColor(task.bindingStatus)}> task.bindTask?.roleName?.trim() ||
{bindingStatusLabel(task.bindingStatus)} task.customerProfile?.roleName?.trim() ||
</Tag> '-';
{task.account && task.bindingStatus === 'failed' ? ( return (
<Tag color="orange">账号保留中</Tag> <Space direction="vertical" size={2}>
) : null} <Tag color={bindingStatusColor(task.bindingStatus)}>
<Text>{task.bindTask?.roleName || (task.bindTask?.bindPhase === 'role_ready' ? '角色待确认' : '-')}</Text> {bindingStatusLabel(task.bindingStatus)}
{task.bindingStatus === 'bound' ? ( </Tag>
<Text type="secondary" style={{ fontSize: 12 }}> {task.account && task.bindingStatus === 'failed' ? (
换绑时间:{formatTime(task.account?.roleChangeAvailableAt) || '无冷却'} <Tag color="orange">账号保留中</Tag>
</Text> ) : null}
) : null} <Text ellipsis title={roleName}>{roleName}</Text>
</Space> {task.bindingStatus === 'bound' ? (
), <Text type="secondary" style={{ fontSize: 12 }}>
换绑时间:{formatTime(task.account?.roleChangeAvailableAt) || '无冷却'}
</Text>
) : null}
</Space>
);
},
}, },
{ {
title: '游戏主页', title: '游戏主页',