修复(履约绑定): 匹配客户目标时展示 cjm 待确认角色
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,7 +1398,12 @@ export default function PlatformFulfillmentPage() {
|
|||||||
title: '用户角色绑定',
|
title: '用户角色绑定',
|
||||||
key: 'binding',
|
key: 'binding',
|
||||||
width: 180,
|
width: 180,
|
||||||
render: (_, task) => (
|
render: (_, task) => {
|
||||||
|
const roleName =
|
||||||
|
task.bindTask?.roleName?.trim() ||
|
||||||
|
task.customerProfile?.roleName?.trim() ||
|
||||||
|
'-';
|
||||||
|
return (
|
||||||
<Space direction="vertical" size={2}>
|
<Space direction="vertical" size={2}>
|
||||||
<Tag color={bindingStatusColor(task.bindingStatus)}>
|
<Tag color={bindingStatusColor(task.bindingStatus)}>
|
||||||
{bindingStatusLabel(task.bindingStatus)}
|
{bindingStatusLabel(task.bindingStatus)}
|
||||||
@@ -1406,14 +1411,15 @@ export default function PlatformFulfillmentPage() {
|
|||||||
{task.account && task.bindingStatus === 'failed' ? (
|
{task.account && task.bindingStatus === 'failed' ? (
|
||||||
<Tag color="orange">账号保留中</Tag>
|
<Tag color="orange">账号保留中</Tag>
|
||||||
) : null}
|
) : null}
|
||||||
<Text>{task.bindTask?.roleName || (task.bindTask?.bindPhase === 'role_ready' ? '角色待确认' : '-')}</Text>
|
<Text ellipsis title={roleName}>{roleName}</Text>
|
||||||
{task.bindingStatus === 'bound' ? (
|
{task.bindingStatus === 'bound' ? (
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
换绑时间:{formatTime(task.account?.roleChangeAvailableAt) || '无冷却'}
|
换绑时间:{formatTime(task.account?.roleChangeAvailableAt) || '无冷却'}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '游戏主页',
|
title: '游戏主页',
|
||||||
|
|||||||
Reference in New Issue
Block a user