修复(虎牙绑定): 扫错角色可重新扫码、绑定失败留证、确认后引导截图联系客服
按业务口径重审「资料 → 登录 → 读角色 → 绑定」全链路,修复 3 个 P0 与 4 处口径问题: P0 重新扫码空转 - startPublicBinding 改为按 allowedActions 判定能否重新出码,不再只看 primaryAction。 此前 first_bind_role_mismatch(primaryAction=contact_support)点「刷新绑定二维码」 后端直接早退:二维码不重生成、旧 pending 不清,客户扫错角色后卡死。 P0 扫错角色被判成人工核实 - 换绑 pending 与目标资料不一致时不再返回 manual_review,改为 rebind_required (start_rebind + edit_profile + contact_support),客户可自愈。 - first_bind_role_mismatch 保留(后端仍会产出),客户页重新渲染该状态, 确认按钮不再吞掉「重新扫码」「上一步修改资料」两个退回入口。 - requiresSupport 只在 manual_review 为真;canGenerateBindingQr 改为从 allowedActions 推导。 - 新增前端守卫测试:后端会产出的每个 flowState 在客户页都必须有可操作落点。 P0 确认后没有下一步引导 - confirmed 区块改为「绑定已确认」+「请截图本页,把订单号和这张截图发给客服」, 展示并可复制订单号,保留刷新按钮。 失败留证 - Connector 拒绝时 bind_confirm_message 带平台返回码;确认写接口抛异常也落 bind_confirm_message + last_error,不再只停在 submitting 等超时。 - rebind_platform_message 不再被「本次无消息」覆盖成空串;DTO 暴露 bindConfirmState / bindConfirmMessage,客户页按去重顺序展示真实失败原因。 - 加密 role token 不再写入任务事件(仅保留 hasRoleToken 布尔标记)。 换绑冷却 - 平台未返回 changeBindTime 时不再推算「从现在起 N 天」; 页面只在剩余天数 > 0 时展示「剩余约 N 天」,否则提示平台未返回。 - 冷却态补「刷新绑定状态」入口与「冷却结束后再回来点重新扫码换绑」指引。 文档同步虎牙绑定的可自愈动作、确认后截图引导、冷却与失败留证口径。
This commit is contained in:
@@ -260,6 +260,43 @@ test('平台已受理但角色未生效时进入等待态,超时后允许重
|
||||
assert.equal(failed.primaryAction, 'start_rebind')
|
||||
})
|
||||
|
||||
test('首次绑定扫错角色时客户可以重新扫码或修改资料,不丢给客服', () => {
|
||||
const wrong = role({
|
||||
isBindAccount: false,
|
||||
isBindRole: false,
|
||||
roleName: '别的角色',
|
||||
roleToken: 'ffffffffffffffffffffffffffffffffffffffff',
|
||||
})
|
||||
const decision = resolveHuyaBindingDecision(input({ pending: wrong, bindingStatus: 'scanned' }))
|
||||
assert.equal(decision.flowState, 'first_bind_role_mismatch')
|
||||
assert.equal(decision.allowedActions.includes('refresh_first_binding_qr'), true)
|
||||
assert.equal(decision.allowedActions.includes('edit_profile'), true)
|
||||
assert.equal(decision.canGenerateBindingQr, true)
|
||||
// 两侧信息可枚举,属于客户可自愈,不应标记成「需客服核实」。
|
||||
assert.equal(decision.requiresSupport, false)
|
||||
})
|
||||
|
||||
test('换绑时扫错角色同样给重新扫码与修改资料', () => {
|
||||
const wrong = role({
|
||||
roleName: '别的角色',
|
||||
roleToken: 'ffffffffffffffffffffffffffffffffffffffff',
|
||||
})
|
||||
const decision = resolveHuyaBindingDecision(
|
||||
input({ current: role(), pending: wrong, bindingStatus: 'scanned', rebindRequested: true }),
|
||||
)
|
||||
assert.equal(decision.flowState, 'rebind_required')
|
||||
assert.equal(decision.allowedActions.includes('start_rebind'), true)
|
||||
assert.equal(decision.allowedActions.includes('edit_profile'), true)
|
||||
})
|
||||
|
||||
test('扫码阶段也允许回头修改资料', () => {
|
||||
const decision = resolveHuyaBindingDecision(
|
||||
input({ bindingStatus: 'qr_pending', hasBindingQr: true }),
|
||||
)
|
||||
assert.equal(decision.flowState, 'first_bind_qr_pending')
|
||||
assert.equal(decision.allowedActions.includes('edit_profile'), true)
|
||||
})
|
||||
|
||||
test('绑定标志不一致时统一进入客服人工核实', () => {
|
||||
const decision = resolveHuyaBindingDecision(
|
||||
input({
|
||||
|
||||
@@ -304,12 +304,8 @@ export function resolveHuyaRebindCooldownResponse(
|
||||
nextRebindAt: availability.availableAt,
|
||||
}
|
||||
}
|
||||
if (!changeBindTime && availability.windowDays > 0) {
|
||||
return {
|
||||
days: availability.windowDays,
|
||||
nextRebindAt: iso(nowMs + availability.windowDays * DAY_MS),
|
||||
}
|
||||
}
|
||||
// 平台没返回 `changeBindTime` 时不得自行推算「从现在起 N 天」,
|
||||
// 那会把「没有冷却信息」显示成「冷却剩余 N 天」。只保留窗口天数(每 N 天可换绑 1 次)。
|
||||
return { days: 0, nextRebindAt: '' }
|
||||
}
|
||||
|
||||
@@ -382,17 +378,18 @@ function decision(
|
||||
'rebind_role_ready',
|
||||
'current_role_confirmable',
|
||||
].includes(state.flowState)
|
||||
const canGenerateBindingQr = [
|
||||
'initial_bind_required',
|
||||
'first_bind_qr_pending',
|
||||
'first_bind_failed',
|
||||
'rebind_required',
|
||||
'rebind_qr_pending',
|
||||
'rebind_rejected',
|
||||
'rebind_effect_failed',
|
||||
'expired',
|
||||
].includes(state.flowState)
|
||||
const requiresSupport = ['manual_review', 'first_bind_role_mismatch'].includes(state.flowState)
|
||||
// 「能不能重新出码」只看这个状态是否给了出码动作,避免与 allowedActions 漂移。
|
||||
const canGenerateBindingQr = state.allowedActions.some((action) =>
|
||||
[
|
||||
'start_first_binding',
|
||||
'refresh_first_binding_qr',
|
||||
'start_rebind',
|
||||
'refresh_rebind_qr',
|
||||
].includes(action),
|
||||
)
|
||||
// 只有「平台事实不自洽、无法自动核对」才需要人工介入;
|
||||
// 角色名/区服可枚举但填错属于客户可自愈,不再标成需客服。
|
||||
const requiresSupport = state.flowState === 'manual_review'
|
||||
return {
|
||||
accountRoleState: base.accountRoleState,
|
||||
targetRoleMatch: base.targetRoleMatch,
|
||||
@@ -623,11 +620,14 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
|
||||
message: '已识别本次待确认角色,核对后提交平台换绑',
|
||||
})
|
||||
}
|
||||
// 扫错角色(pending 与目标资料不一致)属于客户可以自愈的情况:
|
||||
// 必须同时给「重新扫码换绑」和「上一步修改资料」,不能丢给客服。
|
||||
return decision(input, base, {
|
||||
flowState: 'manual_review',
|
||||
primaryAction: 'contact_support',
|
||||
allowedActions: actions('refresh_binding_status', 'edit_profile', 'contact_support'),
|
||||
message: base.pendingComparison?.message || '待确认角色与目标资料不一致',
|
||||
flowState: 'rebind_required',
|
||||
primaryAction: 'start_rebind',
|
||||
allowedActions: actions('start_rebind', 'edit_profile', 'contact_support'),
|
||||
message:
|
||||
base.pendingComparison?.message || '待确认角色与目标资料不一致,请重新扫码或修改资料',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -639,7 +639,12 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
|
||||
return decision(input, base, {
|
||||
flowState: 'rebind_qr_pending',
|
||||
primaryAction: 'refresh_rebind_qr',
|
||||
allowedActions: actions('refresh_rebind_qr', 'refresh_binding_status', 'contact_support'),
|
||||
allowedActions: actions(
|
||||
'refresh_rebind_qr',
|
||||
'refresh_binding_status',
|
||||
'edit_profile',
|
||||
'contact_support',
|
||||
),
|
||||
message: '请扫码并在虎牙中选择目标角色',
|
||||
})
|
||||
}
|
||||
@@ -690,6 +695,7 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
|
||||
allowedActions: actions(
|
||||
'refresh_first_binding_qr',
|
||||
'refresh_binding_status',
|
||||
'edit_profile',
|
||||
'contact_support',
|
||||
),
|
||||
message: '请扫码并在虎牙中选择目标游戏角色',
|
||||
|
||||
@@ -1330,7 +1330,10 @@ export class HuyaNativeConnector {
|
||||
})
|
||||
if (!confirmed || confirmed.status !== 200) {
|
||||
binding.bindConfirmState = 'rejected'
|
||||
binding.bindConfirmMessage = confirmed?.msg || '虎牙未接受本次绑定'
|
||||
// 失败信息必须带平台返回码,客服排障时不用再去报文里捞。
|
||||
binding.bindConfirmMessage = confirmed
|
||||
? `${confirmed.msg || '虎牙未接受本次绑定'}(返回码 ${confirmed.status})`
|
||||
: '虎牙未接受本次绑定(无响应)'
|
||||
binding.status = 'failed'
|
||||
binding.message = `虎牙未接受本次绑定:${binding.bindConfirmMessage}`
|
||||
return this.bindingView(session)
|
||||
|
||||
@@ -44,10 +44,12 @@ test('换绑冷却:changeBindTime 已超过 7 天时不再限制', () => {
|
||||
assert.equal(result.nextRebindAt, '')
|
||||
})
|
||||
|
||||
test('换绑冷却:changeBindTime 缺失时用 changeBindDay 兜底', () => {
|
||||
test('换绑冷却:平台未返回 changeBindTime 时不推算剩余天数', () => {
|
||||
// changeBindTime 是平台给的下次可换绑时间;缺失时不得自行编造「从现在起 N 天」,
|
||||
// 否则会把「没有冷却信息」显示成「冷却剩余 N 天」。
|
||||
const result = resolveRebindCooldown({ status: 200, changeBindDay: 3, accountData: {} }, NOW)
|
||||
assert.equal(result.days, 3)
|
||||
assert.equal(result.nextRebindAt.slice(0, 10), '2026-11-19')
|
||||
assert.equal(result.days, 0)
|
||||
assert.equal(result.nextRebindAt, '')
|
||||
})
|
||||
|
||||
test('换绑冷却:字段为空时不限制', () => {
|
||||
|
||||
@@ -636,12 +636,19 @@ export async function startPublicBinding(
|
||||
})
|
||||
}
|
||||
|
||||
const wantsFirstBinding = ['start_first_binding', 'refresh_first_binding_qr'].includes(
|
||||
decision.primaryAction,
|
||||
)
|
||||
const wantsRebind =
|
||||
(input.intent === 'rebind' || input.forceRebind === true) &&
|
||||
['start_rebind', 'refresh_rebind_qr'].includes(decision.primaryAction)
|
||||
// 是否允许重新出码只看 allowedActions:`primaryAction` 是「当前最该做的下一步」,
|
||||
// 不等于「客户唯一能做的事」。此前按 primaryAction 判定,导致
|
||||
// `first_bind_role_mismatch`(primaryAction=contact_support)点「刷新绑定二维码」完全空转,
|
||||
// 客户扫错角色后无法重新扫码。
|
||||
const canStartFirstBinding =
|
||||
decision.allowedActions.includes('start_first_binding') ||
|
||||
decision.allowedActions.includes('refresh_first_binding_qr')
|
||||
const canStartRebind =
|
||||
decision.allowedActions.includes('start_rebind') ||
|
||||
decision.allowedActions.includes('refresh_rebind_qr')
|
||||
// 首次绑定允许自动出码(页面进入第一步就要码);换绑必须由客户显式点「重新扫码换绑」触发。
|
||||
const wantsFirstBinding = canStartFirstBinding
|
||||
const wantsRebind = (input.intent === 'rebind' || input.forceRebind === true) && canStartRebind
|
||||
if (!wantsFirstBinding && !wantsRebind) {
|
||||
return {
|
||||
task: mapTask(inspectedTask),
|
||||
@@ -866,8 +873,9 @@ async function markHuyaBindingConfirmationSubmitting(input: {
|
||||
eventType: 'huya_binding_confirm_submitted',
|
||||
detail: {
|
||||
roleName: input.expectedRoleName,
|
||||
roleToken: input.expectedRoleToken,
|
||||
roleChannel: input.expectedRoleChannel,
|
||||
// 加密 role token 不写事件,只在任务列里用于前后两次查询的一致性判断。
|
||||
hasRoleToken: Boolean(input.expectedRoleToken),
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -983,14 +991,36 @@ export async function confirmPublicBinding(
|
||||
return { task: mapTask(updated), binding }
|
||||
}
|
||||
}
|
||||
const confirmedSession =
|
||||
task.platform === 'huya'
|
||||
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode, {
|
||||
expectedRoleName: String(options.expectedRoleName || '').trim(),
|
||||
expectedRoleToken: String(options.expectedRoleToken || '').trim(),
|
||||
expectedRoleChannel: String(options.expectedRoleChannel || '').trim(),
|
||||
})
|
||||
: session
|
||||
let confirmedSession: ConnectorBindingSession
|
||||
try {
|
||||
confirmedSession =
|
||||
task.platform === 'huya'
|
||||
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode, {
|
||||
expectedRoleName,
|
||||
expectedRoleToken,
|
||||
expectedRoleChannel,
|
||||
})
|
||||
: session
|
||||
} catch (error) {
|
||||
// 写平台异常(网络/超时/5xx)也必须留下原因,否则后台只剩一句「提交超时」。
|
||||
const message = error instanceof Error ? error.message : '确认绑定请求失败'
|
||||
await withTransaction(async (client) => {
|
||||
const current = await loadTaskForUpdateWithClient(client, task.id)
|
||||
await convergeSemiAutoTaskState(client, current.id, {
|
||||
reason: 'huya_binding_confirm_failed',
|
||||
actor: 'customer',
|
||||
patch: {
|
||||
bindConfirmMessage: message,
|
||||
lastError: `确认绑定失败:${message}`,
|
||||
},
|
||||
event: {
|
||||
eventType: 'huya_binding_confirm_failed',
|
||||
detail: { message },
|
||||
},
|
||||
})
|
||||
})
|
||||
throw error
|
||||
}
|
||||
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
||||
const updated = await loadTask(task.id)
|
||||
return { task: mapTask(updated), binding }
|
||||
|
||||
@@ -561,6 +561,9 @@ export function mapTask(task: TaskRow) {
|
||||
targetRoleMatch: bindingDecision?.targetRoleMatch || task.target_role_match,
|
||||
rebindBlockScope: bindingDecision?.rebindBlockScope || task.rebind_block_scope,
|
||||
rebindPlatformMessage: task.rebind_platform_message,
|
||||
// 平台确认结果与失败原因:客户页要展示「为什么失败」,后台也要能直接看到平台返回码。
|
||||
bindConfirmState: task.bind_confirm_state,
|
||||
bindConfirmMessage: task.bind_confirm_message,
|
||||
customerGameRoleId: task.customer_game_id || '',
|
||||
customerGameRoleName: task.customer_game_role || '',
|
||||
customerServerZone: task.customer_server_zone || '',
|
||||
@@ -1692,7 +1695,8 @@ export async function updateBindingTaskWithClient(
|
||||
rebindBlockScope: bindingDecision?.rebindBlockScope || '',
|
||||
}
|
||||
: {}),
|
||||
rebindPlatformMessage: mapped.rebindConfirmMessage,
|
||||
// 平台失败原因不能被「本次没有消息」覆盖成空串,否则客服再也看不到上一次失败原因。
|
||||
rebindPlatformMessage: mapped.rebindConfirmMessage || current.rebind_platform_message,
|
||||
rebindRequested: mapped.rebindRequested,
|
||||
bindConfirmState: mapped.bindConfirmState,
|
||||
bindConfirmMessage: mapped.bindConfirmMessage,
|
||||
@@ -1719,11 +1723,12 @@ export async function updateBindingTaskWithClient(
|
||||
...(options.eventDetail || {}),
|
||||
gameAccount: mapped.bindGameAccount,
|
||||
gameRole: mapped.bindGameRole,
|
||||
gameRoleToken: mapped.bindGameRoleToken,
|
||||
// role token 是 40 位加密标识,只落库列,不进事件时间线。
|
||||
hasGameRoleToken: Boolean(mapped.bindGameRoleToken),
|
||||
gameChannel: mapped.bindGameChannel,
|
||||
pendingGameAccount: mapped.pendingBindGameAccount,
|
||||
pendingGameRole: mapped.pendingBindGameRole,
|
||||
pendingGameRoleToken: mapped.pendingBindGameRoleToken,
|
||||
hasPendingGameRoleToken: Boolean(mapped.pendingBindGameRoleToken),
|
||||
pendingPlatformGameRoleUid: mapped.pendingPlatformGameRoleUid,
|
||||
pendingGameChannel: mapped.pendingBindGameChannel,
|
||||
roleIdentitySource: mapped.roleIdentitySource,
|
||||
|
||||
Reference in New Issue
Block a user