修复(半自动履约): 稳定任务排序并拆分虎牙角色UID

This commit is contained in:
yml
2026-11-20 15:44:59 +08:00
parent 3b7d133dc9
commit e17d1ac8ab
23 changed files with 643 additions and 239 deletions
@@ -20,6 +20,7 @@ type AuditRow = {
platform_role_uid: string platform_role_uid: string
pending_role_name: string pending_role_name: string
pending_role_token: string pending_role_token: string
pending_platform_role_uid: string
customer_role_uid: string customer_role_uid: string
legacy_bind_game_role_id: string legacy_bind_game_role_id: string
role_identity_source: string role_identity_source: string
@@ -45,6 +46,7 @@ async function main() {
task.platform_game_role_uid, task.platform_game_role_uid,
task.pending_bind_game_role AS pending_role_name, task.pending_bind_game_role AS pending_role_name,
task.pending_bind_game_role_token AS pending_role_token, task.pending_bind_game_role_token AS pending_role_token,
task.pending_platform_game_role_uid AS pending_platform_role_uid,
task.customer_game_role_id AS customer_role_uid, task.customer_game_role_id AS customer_role_uid,
task.legacy_bind_game_role_id, task.legacy_bind_game_role_id,
task.role_identity_source, task.role_identity_source,
@@ -110,13 +112,16 @@ async function main() {
(row.latest_inner_role_token && !/^[0-9a-f]{40}$/i.test(row.latest_inner_role_token)), (row.latest_inner_role_token && !/^[0-9a-f]{40}$/i.test(row.latest_inner_role_token)),
) )
const invalidPlatformRoleUids = rows.filter( const invalidPlatformRoleUids = rows.filter(
(row) => row.platform_role_uid && !/^\d+$/.test(row.platform_role_uid), (row) =>
(row.platform_role_uid && !/^\d+$/.test(row.platform_role_uid)) ||
(row.pending_platform_role_uid && !/^\d+$/.test(row.pending_platform_role_uid)),
) )
const platformRoleUidReusedFromAccountUid = rows.filter( const platformRoleUidReusedFromAccountUid = rows.filter(
(row) => (row) =>
Boolean(row.account_uid) && Boolean(row.account_uid) &&
Boolean(row.platform_role_uid) && ((Boolean(row.platform_role_uid) && row.platform_role_uid === row.account_uid) ||
row.platform_role_uid === row.account_uid, (Boolean(row.pending_platform_role_uid) &&
row.pending_platform_role_uid === row.account_uid)),
) )
console.log( console.log(
@@ -158,6 +163,7 @@ async function main() {
taskId: row.task_id, taskId: row.task_id,
orderNo: row.order_no, orderNo: row.order_no,
platformRoleUid: row.platform_role_uid, platformRoleUid: row.platform_role_uid,
pendingPlatformRoleUid: row.pending_platform_role_uid,
})), })),
platformRoleUidReusedFromAccountUidTasks: platformRoleUidReusedFromAccountUid.map( platformRoleUidReusedFromAccountUidTasks: platformRoleUidReusedFromAccountUid.map(
(row) => ({ (row) => ({
@@ -0,0 +1,26 @@
-- 179_semi_auto_huya_pending_role_uid.sql
--
-- 待确认角色与当前绑定角色分别保存平台明确返回的数值游戏角色 UID。
-- 虎牙 gameRole.roleId 是加密 token,不得写入该字段。
ALTER TABLE semi_auto_tasks
ADD COLUMN IF NOT EXISTS pending_platform_game_role_uid TEXT NOT NULL DEFAULT '';
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'chk_semi_auto_tasks_pending_platform_role_uid'
) THEN
ALTER TABLE semi_auto_tasks
ADD CONSTRAINT chk_semi_auto_tasks_pending_platform_role_uid
CHECK (
pending_platform_game_role_uid = ''
OR pending_platform_game_role_uid ~ '^[0-9]+$'
);
END IF;
END $$;
COMMENT ON COLUMN semi_auto_tasks.pending_platform_game_role_uid IS
'扫码后、确认绑定前平台明确返回的数值游戏角色 UID;加密 role token 不得写入';
@@ -5,6 +5,7 @@ import {
classifyHuyaRebindFailure, classifyHuyaRebindFailure,
resolveHuyaBindingDecision, resolveHuyaBindingDecision,
resolveHuyaRoleRebindAvailability, resolveHuyaRoleRebindAvailability,
roleSnapshotsFromLegacyFields,
type HuyaBindingDecisionInput, type HuyaBindingDecisionInput,
type HuyaRoleSnapshot, type HuyaRoleSnapshot,
} from './huya-binding-policy.js' } from './huya-binding-policy.js'
@@ -336,3 +337,27 @@ test('冷却计算和目标匹配器保持唯一实现', () => {
assert.equal(classifyHuyaRebindFailure('该游戏角色仍在换绑冷却期'), 'target_role') assert.equal(classifyHuyaRebindFailure('该游戏角色仍在换绑冷却期'), 'target_role')
assert.equal(classifyHuyaRebindFailure('当前绑定账号暂不可换绑'), 'account') assert.equal(classifyHuyaRebindFailure('当前绑定账号暂不可换绑'), 'account')
}) })
test('数据库角色快照分别保留加密 token 与平台角色 UID', () => {
const snapshots = roleSnapshotsFromLegacyFields({
bindGameRole: TARGET.roleName,
bindGameRoleToken: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
platformGameRoleUid: TARGET.roleId,
bindGameChannel: '安卓(android) · QQ',
isBindAccount: true,
isBindRole: true,
changeBindTime: 0,
changeBindDay: 0,
pendingBindGameRole: TARGET.roleName,
pendingBindGameRoleToken: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
pendingPlatformGameRoleUid: '1192083859',
pendingBindGameChannel: '安卓(android) · QQ',
pendingChangeBindTime: 0,
pendingChangeBindDay: 0,
})
assert.equal(snapshots.current?.roleToken, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
assert.equal(snapshots.current?.platformRoleUid, TARGET.roleId)
assert.equal(snapshots.pending?.roleToken, 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
assert.equal(snapshots.pending?.platformRoleUid, '1192083859')
})
@@ -14,6 +14,7 @@ export type HuyaRoleSnapshot = {
isBindRole: boolean isBindRole: boolean
roleName: string roleName: string
roleToken: string roleToken: string
platformRoleUid?: string
channel: string channel: string
changeBindTime: number changeBindTime: number
changeBindDay: number changeBindDay: number
@@ -144,7 +145,7 @@ function comparisonBase(customer: HuyaCustomerRoleSnapshot, role: HuyaRoleSnapsh
const customerZone = resolveServerZone(customer.serverZone) const customerZone = resolveServerZone(customer.serverZone)
const roleName = readString(role?.roleName) const roleName = readString(role?.roleName)
const roleToken = readString(role?.roleToken) const roleToken = readString(role?.roleToken)
const platformRoleUid = isNumericBindingRoleId(roleToken) ? roleToken : '' const platformRoleUid = readString(role?.platformRoleUid)
const boundZone = resolveServerZone(role?.channel) const boundZone = resolveServerZone(role?.channel)
return { return {
customerRoleName, customerRoleName,
@@ -567,7 +568,7 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
'contact_support', 'contact_support',
), ),
rebindBlockScope: 'account', rebindBlockScope: 'account',
message: `当前虎牙登录账号暂不可换绑,预计 ${base.accountAvailability.availableAt || '稍后'} 恢复`, message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑',
}) })
} }
@@ -577,7 +578,7 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
primaryAction: 'wait_target_role_rebind', primaryAction: 'wait_target_role_rebind',
allowedActions: actions('wait_target_role_rebind', 'edit_profile', 'contact_support'), allowedActions: actions('wait_target_role_rebind', 'edit_profile', 'contact_support'),
rebindBlockScope: 'target_role', rebindBlockScope: 'target_role',
message: `目标游戏角色仍在换绑冷却期,预计 ${base.targetAvailability.availableAt || '稍后'} 恢复`, message: '目标游戏角色仍在换绑冷却期,暂不可换绑',
}) })
} }
@@ -717,6 +718,7 @@ export function isHuyaBindingConfirmedForCompletion(input: HuyaBindingDecisionIn
export function roleSnapshotsFromLegacyFields(input: { export function roleSnapshotsFromLegacyFields(input: {
bindGameRole: string bindGameRole: string
bindGameRoleToken: string bindGameRoleToken: string
platformGameRoleUid?: string
bindGameChannel: string bindGameChannel: string
isBindAccount: boolean isBindAccount: boolean
isBindRole: boolean isBindRole: boolean
@@ -724,6 +726,7 @@ export function roleSnapshotsFromLegacyFields(input: {
changeBindDay: number changeBindDay: number
pendingBindGameRole: string pendingBindGameRole: string
pendingBindGameRoleToken: string pendingBindGameRoleToken: string
pendingPlatformGameRoleUid?: string
pendingBindGameChannel: string pendingBindGameChannel: string
pendingChangeBindTime: number pendingChangeBindTime: number
pendingChangeBindDay: number pendingChangeBindDay: number
@@ -737,6 +740,7 @@ export function roleSnapshotsFromLegacyFields(input: {
isBindRole: input.isBindRole, isBindRole: input.isBindRole,
roleName: currentRole, roleName: currentRole,
roleToken: readString(input.bindGameRoleToken), roleToken: readString(input.bindGameRoleToken),
platformRoleUid: readString(input.platformGameRoleUid),
channel: readString(input.bindGameChannel), channel: readString(input.bindGameChannel),
changeBindTime: Number(input.changeBindTime || 0), changeBindTime: Number(input.changeBindTime || 0),
changeBindDay: Number(input.changeBindDay || 0), changeBindDay: Number(input.changeBindDay || 0),
@@ -748,6 +752,7 @@ export function roleSnapshotsFromLegacyFields(input: {
isBindRole: false, isBindRole: false,
roleName: pendingRole, roleName: pendingRole,
roleToken: readString(input.pendingBindGameRoleToken), roleToken: readString(input.pendingBindGameRoleToken),
platformRoleUid: readString(input.pendingPlatformGameRoleUid),
channel: readString(input.pendingBindGameChannel), channel: readString(input.pendingBindGameChannel),
changeBindTime: Number(input.pendingChangeBindTime || 0), changeBindTime: Number(input.pendingChangeBindTime || 0),
changeBindDay: Number(input.pendingChangeBindDay || 0), changeBindDay: Number(input.pendingChangeBindDay || 0),
@@ -34,3 +34,15 @@ test('外部 Connector 状态快照复用统一绑定写入和确认门禁', ()
assert.match(customerService, /getHuyaBindingSnapshot\(/) assert.match(customerService, /getHuyaBindingSnapshot\(/)
assert.match(customerService, /if \(!decision\.canConfirmBinding\)/) assert.match(customerService, /if \(!decision\.canConfirmBinding\)/)
}) })
test('后台半自动任务列表使用创建顺序,页面刷新不会按状态或更新时间重排', () => {
const adminService = source('semi-auto-admin-service.ts')
const listStart = adminService.indexOf('export async function listAdminSemiAutoTasks')
const listEnd = adminService.indexOf('export async function getAdminSemiAutoTask')
assert.ok(listStart > 0)
assert.ok(listEnd > listStart)
const listBody = adminService.slice(listStart, listEnd)
assert.match(listBody, /ORDER BY task\.created_at DESC, task\.id DESC/)
assert.doesNotMatch(listBody, /CASE task\.execution_status/)
assert.doesNotMatch(listBody, /task\.updated_at DESC/)
})
@@ -113,6 +113,7 @@ export type ConnectorBindingSession = {
pendingBindGameAccount?: string pendingBindGameAccount?: string
pendingBindGameRole?: string pendingBindGameRole?: string
pendingBindGameRoleToken?: string pendingBindGameRoleToken?: string
pendingPlatformGameRoleUid?: string
pendingBindGameChannel?: string pendingBindGameChannel?: string
pendingChangeBindTime?: number pendingChangeBindTime?: number
pendingChangeBindDay?: number pendingChangeBindDay?: number
@@ -21,6 +21,8 @@ function bindResponse(input: {
isBindRole?: number isBindRole?: number
platform?: string platform?: string
area?: string area?: string
gameSerial?: string
extendInfo?: string
}): HuyaBindResponse { }): HuyaBindResponse {
return { return {
status: 200, status: 200,
@@ -47,8 +49,8 @@ function bindResponse(input: {
areaName: input.area || 'QQ', areaName: input.area || 'QQ',
platName: input.platform || '安卓(android)', platName: input.platform || '安卓(android)',
partitionName: '', partitionName: '',
gameSerial: '', gameSerial: input.gameSerial || '',
extendInfo: '', extendInfo: input.extendInfo || '',
}, },
changeBindTime: 1795536000, changeBindTime: 1795536000,
}, },
@@ -193,3 +195,69 @@ test('未绑定时即使外层残留同名角色,也仍以内层角色作为
assert.equal(snapshot.current, null) assert.equal(snapshot.current, null)
assert.equal(snapshot.pending?.role, '残留角色') assert.equal(snapshot.pending?.role, '残留角色')
}) })
test('平台明确返回 gameSerial 或扩展角色 UID 时才映射为独立角色 UID', async () => {
const response = bindResponse({
roleName: '角色 UID 测试',
gameSerial: '3112327877',
})
const rpc = {
async checkUserBindGameAccount() {
return response
},
}
const snapshot = await queryHuyaBindingSnapshot(rpc as never, {
uid: 1,
cookie: 'yyuid=1',
protocol: PROTOCOL,
})
assert.equal(snapshot.current?.roleUid, '3112327877')
})
test('加密 roleId 即使内容为纯数字也不能冒充平台角色 UID', async () => {
const response = bindResponse({
roleName: 'roleId 不是 UID',
roleId: '3112327877',
})
const rpc = {
async checkUserBindGameAccount() {
return response
},
}
const snapshot = await queryHuyaBindingSnapshot(rpc as never, {
uid: 1,
cookie: 'yyuid=1',
protocol: PROTOCOL,
})
assert.equal(snapshot.current?.roleId, '3112327877')
assert.equal(snapshot.current?.roleUid, '')
})
test('extendInfo 中明确的数值角色 UID 可映射到待确认角色', async () => {
const responses = [
bindResponse({
roleName: '',
roleId: '',
accountNick: '',
isBindAccount: 0,
isBindRole: 0,
}),
bindResponse({
roleName: '待确认 UID 角色',
roleId: 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
extendInfo: JSON.stringify({ roleUid: '3112327878' }),
}),
]
const rpc = {
async checkUserBindGameAccount() {
return responses.shift() || null
},
}
const snapshot = await queryHuyaBindingSnapshot(rpc as never, {
uid: 1,
cookie: 'yyuid=1',
protocol: PROTOCOL,
})
assert.equal(snapshot.pending?.role, '待确认 UID 角色')
assert.equal(snapshot.pending?.roleUid, '3112327878')
})
@@ -75,6 +75,8 @@ type NativeBindState = {
role: string role: string
/** 虎牙返回的加密角色标识,绝不能回退成虎牙账号 UID。 */ /** 虎牙返回的加密角色标识,绝不能回退成虎牙账号 UID。 */
roleId: string roleId: string
/** 平台明确返回的独立游戏角色 UID;加密 roleId 不算。 */
roleUid: string
channel: string channel: string
isBindAccount: boolean isBindAccount: boolean
isBindRole: boolean isBindRole: boolean
@@ -84,6 +86,7 @@ type NativeBindState = {
pendingAccount: string pendingAccount: string
pendingRole: string pendingRole: string
pendingRoleId: string pendingRoleId: string
pendingRoleUid: string
pendingChannel: string pendingChannel: string
pendingChangeBindTime: number pendingChangeBindTime: number
pendingChangeBindDay: number pendingChangeBindDay: number
@@ -177,6 +180,7 @@ function defaultBindingState(): NativeBindState {
account: '', account: '',
role: '', role: '',
roleId: '', roleId: '',
roleUid: '',
channel: '', channel: '',
isBindAccount: false, isBindAccount: false,
isBindRole: false, isBindRole: false,
@@ -186,6 +190,7 @@ function defaultBindingState(): NativeBindState {
pendingAccount: '', pendingAccount: '',
pendingRole: '', pendingRole: '',
pendingRoleId: '', pendingRoleId: '',
pendingRoleUid: '',
pendingChannel: '', pendingChannel: '',
pendingChangeBindTime: 0, pendingChangeBindTime: 0,
pendingChangeBindDay: 0, pendingChangeBindDay: 0,
@@ -354,6 +359,7 @@ function parseRole(response: HuyaBindResponse | null): {
account: string account: string
role: string role: string
roleId: string roleId: string
roleUid: string
channel: string channel: string
isBindAccount: boolean isBindAccount: boolean
isBindRole: boolean isBindRole: boolean
@@ -365,6 +371,7 @@ function parseRole(response: HuyaBindResponse | null): {
account: '', account: '',
role: '', role: '',
roleId: '', roleId: '',
roleUid: '',
channel: '', channel: '',
isBindAccount: false, isBindAccount: false,
isBindRole: false, isBindRole: false,
@@ -377,10 +384,12 @@ function parseRole(response: HuyaBindResponse | null): {
const role = data.gameRole.roleName const role = data.gameRole.roleName
const channel = [data.gameRole.platName, data.gameRole.areaName].filter(Boolean).join(' · ') const channel = [data.gameRole.platName, data.gameRole.areaName].filter(Boolean).join(' · ')
const roleId = String(data.gameRole.roleId || '').trim() const roleId = String(data.gameRole.roleId || '').trim()
const roleUid = extractHuyaRoleUid(data)
return { return {
account, account,
role, role,
roleId, roleId,
roleUid,
channel, channel,
isBindAccount: Boolean(data.isBindAccount), isBindAccount: Boolean(data.isBindAccount),
isBindRole: Boolean(data.isBindRole), isBindRole: Boolean(data.isBindRole),
@@ -389,6 +398,24 @@ function parseRole(response: HuyaBindResponse | null): {
} }
} }
function extractHuyaRoleUid(data: HuyaGameAccountData): string {
const candidates = [data.gameRole.gameSerial]
const extendInfo = readString(data.gameRole.extendInfo)
if (extendInfo) {
try {
const parsed = JSON.parse(extendInfo) as Record<string, unknown>
candidates.push(
String(
parsed.roleUid ?? parsed.gameRoleUid ?? parsed.role_id ?? parsed.rid ?? parsed.uid ?? '',
),
)
} catch {
// 虎牙扩展字段不是稳定 JSON,解析失败时只使用明确的结构化字段。
}
}
return candidates.map((item) => readString(item)).find((item) => /^\d+$/.test(item)) || ''
}
function bindingRoleKey(role: { role: string; roleId?: string; channel: string }): string { function bindingRoleKey(role: { role: string; roleId?: string; channel: string }): string {
return [role.role, String(role.roleId || '').toLowerCase(), role.channel].join('\u0000') return [role.role, String(role.roleId || '').toLowerCase(), role.channel].join('\u0000')
} }
@@ -1292,6 +1319,7 @@ export class HuyaNativeConnector {
if (!pending) { if (!pending) {
this.finalizeConfirmedBinding(session, { this.finalizeConfirmedBinding(session, {
...target, ...target,
roleUid: binding.roleUid,
isBindAccount: true, isBindAccount: true,
isBindRole: true, isBindRole: true,
changeBindTime: binding.changeBindTime, changeBindTime: binding.changeBindTime,
@@ -1546,6 +1574,7 @@ export class HuyaNativeConnector {
session.binding.account = role.account session.binding.account = role.account
session.binding.role = role.role session.binding.role = role.role
session.binding.roleId = role.roleId || '' session.binding.roleId = role.roleId || ''
session.binding.roleUid = role.roleUid || ''
session.binding.channel = role.channel session.binding.channel = role.channel
session.binding.isBindAccount = role.isBindAccount session.binding.isBindAccount = role.isBindAccount
session.binding.isBindRole = role.isBindRole session.binding.isBindRole = role.isBindRole
@@ -1558,6 +1587,7 @@ export class HuyaNativeConnector {
session.binding.pendingAccount = role.account session.binding.pendingAccount = role.account
session.binding.pendingRole = role.role session.binding.pendingRole = role.role
session.binding.pendingRoleId = role.roleId || '' session.binding.pendingRoleId = role.roleId || ''
session.binding.pendingRoleUid = role.roleUid || ''
session.binding.pendingChannel = role.channel session.binding.pendingChannel = role.channel
session.binding.pendingChangeBindTime = role.changeBindTime session.binding.pendingChangeBindTime = role.changeBindTime
session.binding.pendingChangeBindDay = role.changeBindDay session.binding.pendingChangeBindDay = role.changeBindDay
@@ -1568,6 +1598,7 @@ export class HuyaNativeConnector {
session.binding.pendingAccount = '' session.binding.pendingAccount = ''
session.binding.pendingRole = '' session.binding.pendingRole = ''
session.binding.pendingRoleId = '' session.binding.pendingRoleId = ''
session.binding.pendingRoleUid = ''
session.binding.pendingChannel = '' session.binding.pendingChannel = ''
session.binding.pendingChangeBindTime = 0 session.binding.pendingChangeBindTime = 0
session.binding.pendingChangeBindDay = 0 session.binding.pendingChangeBindDay = 0
@@ -1668,7 +1699,7 @@ export class HuyaNativeConnector {
private bindingView(session: NativeSession): ConnectorBindingSession { private bindingView(session: NativeSession): ConnectorBindingSession {
const binding = session.binding const binding = session.binding
const roleIdVerified = /^\d+$/.test(binding.roleId) const roleIdVerified = /^\d+$/.test(binding.roleUid)
const requiresSupport = binding.hasExistingBinding === true && !binding.role const requiresSupport = binding.hasExistingBinding === true && !binding.role
return { return {
sessionId: session.sessionId, sessionId: session.sessionId,
@@ -1680,7 +1711,7 @@ export class HuyaNativeConnector {
bindGameRole: binding.role, bindGameRole: binding.role,
bindGameRoleId: binding.roleId, bindGameRoleId: binding.roleId,
bindGameRoleToken: binding.roleId, bindGameRoleToken: binding.roleId,
platformGameRoleUid: /^\d+$/.test(binding.roleId) ? binding.roleId : '', platformGameRoleUid: binding.roleUid,
bindGameChannel: binding.channel, bindGameChannel: binding.channel,
currentRole: binding.role currentRole: binding.role
? { ? {
@@ -1688,6 +1719,7 @@ export class HuyaNativeConnector {
isBindRole: binding.isBindRole, isBindRole: binding.isBindRole,
roleName: binding.role, roleName: binding.role,
roleToken: binding.roleId, roleToken: binding.roleId,
platformRoleUid: binding.roleUid,
channel: binding.channel, channel: binding.channel,
changeBindTime: binding.changeBindTime, changeBindTime: binding.changeBindTime,
changeBindDay: binding.changeBindDay, changeBindDay: binding.changeBindDay,
@@ -1699,6 +1731,7 @@ export class HuyaNativeConnector {
isBindRole: false, isBindRole: false,
roleName: binding.pendingRole, roleName: binding.pendingRole,
roleToken: binding.pendingRoleId, roleToken: binding.pendingRoleId,
platformRoleUid: binding.pendingRoleUid,
channel: binding.pendingChannel, channel: binding.pendingChannel,
changeBindTime: binding.pendingChangeBindTime, changeBindTime: binding.pendingChangeBindTime,
changeBindDay: binding.pendingChangeBindDay, changeBindDay: binding.pendingChangeBindDay,
@@ -1707,6 +1740,7 @@ export class HuyaNativeConnector {
pendingBindGameAccount: binding.pendingAccount, pendingBindGameAccount: binding.pendingAccount,
pendingBindGameRole: binding.pendingRole, pendingBindGameRole: binding.pendingRole,
pendingBindGameRoleToken: binding.pendingRoleId, pendingBindGameRoleToken: binding.pendingRoleId,
pendingPlatformGameRoleUid: binding.pendingRoleUid,
pendingBindGameChannel: binding.pendingChannel, pendingBindGameChannel: binding.pendingChannel,
pendingChangeBindTime: binding.pendingChangeBindTime, pendingChangeBindTime: binding.pendingChangeBindTime,
pendingChangeBindDay: binding.pendingChangeBindDay, pendingChangeBindDay: binding.pendingChangeBindDay,
@@ -1715,7 +1749,11 @@ export class HuyaNativeConnector {
: binding.role : binding.role
? 'huya_outer_current' ? 'huya_outer_current'
: '', : '',
verificationBasis: binding.role ? 'role_name_zone' : '', verificationBasis: binding.roleUid
? 'platform_numeric_uid'
: binding.role
? 'role_name_zone'
: '',
roleIdVerified, roleIdVerified,
requiresSupport, requiresSupport,
hasExistingBinding: binding.hasExistingBinding, hasExistingBinding: binding.hasExistingBinding,
@@ -107,16 +107,7 @@ export async function listAdminSemiAutoTasks(input: Record<string, unknown> = {}
const result = await query<TaskRow>( const result = await query<TaskRow>(
`${TASK_SELECT} `${TASK_SELECT}
WHERE ${where} WHERE ${where}
ORDER BY ORDER BY task.created_at DESC, task.id DESC
CASE task.execution_status
WHEN 'waiting_operator' THEN 0
WHEN 'waiting_customer' THEN 1
WHEN 'processing' THEN 2
WHEN 'failed' THEN 3
ELSE 4
END,
task.updated_at DESC,
task.id DESC
LIMIT $${listParams.length - 1} OFFSET $${listParams.length}`, LIMIT $${listParams.length - 1} OFFSET $${listParams.length}`,
listParams, listParams,
) )
@@ -539,6 +530,9 @@ export async function applySemiAutoTaskStateSnapshot(
const pendingBindGameRoleToken = String( const pendingBindGameRoleToken = String(
input.pendingBindGameRoleToken ?? input.pending_bind_game_role_token ?? '', input.pendingBindGameRoleToken ?? input.pending_bind_game_role_token ?? '',
).trim() ).trim()
const pendingPlatformGameRoleUid = String(
input.pendingPlatformGameRoleUid ?? input.pending_platform_game_role_uid ?? '',
).trim()
const pendingBindGameChannel = String( const pendingBindGameChannel = String(
input.pendingBindGameChannel ?? input.pending_bind_game_channel ?? '', input.pendingBindGameChannel ?? input.pending_bind_game_channel ?? '',
).trim() ).trim()
@@ -566,6 +560,12 @@ export async function applySemiAutoTaskStateSnapshot(
errorCode: 'semi_auto_snapshot_platform_role_uid_invalid', errorCode: 'semi_auto_snapshot_platform_role_uid_invalid',
}) })
} }
if (pendingPlatformGameRoleUid && !/^\d+$/.test(pendingPlatformGameRoleUid)) {
throw createHttpError('待确认平台游戏角色 UID 格式无效', {
statusCode: 400,
errorCode: 'semi_auto_snapshot_pending_platform_role_uid_invalid',
})
}
const effectiveHuyaUid = uid || task.huya_uid const effectiveHuyaUid = uid || task.huya_uid
if (platformGameRoleUid && effectiveHuyaUid && platformGameRoleUid === effectiveHuyaUid) { if (platformGameRoleUid && effectiveHuyaUid && platformGameRoleUid === effectiveHuyaUid) {
throw createHttpError('平台游戏角色 UID 不能复用虎牙账号 UID', { throw createHttpError('平台游戏角色 UID 不能复用虎牙账号 UID', {
@@ -573,6 +573,16 @@ export async function applySemiAutoTaskStateSnapshot(
errorCode: 'semi_auto_snapshot_platform_role_uid_reused', errorCode: 'semi_auto_snapshot_platform_role_uid_reused',
}) })
} }
if (
pendingPlatformGameRoleUid &&
effectiveHuyaUid &&
pendingPlatformGameRoleUid === effectiveHuyaUid
) {
throw createHttpError('待确认平台游戏角色 UID 不能复用虎牙账号 UID', {
statusCode: 400,
errorCode: 'semi_auto_snapshot_pending_platform_role_uid_reused',
})
}
if (!ROLE_IDENTITY_SOURCES.has(roleIdentitySource)) { if (!ROLE_IDENTITY_SOURCES.has(roleIdentitySource)) {
throw createHttpError('角色身份来源无效', { throw createHttpError('角色身份来源无效', {
statusCode: 400, statusCode: 400,
@@ -627,7 +637,8 @@ export async function applySemiAutoTaskStateSnapshot(
isBindAccount: isBindAccount ?? Boolean(bindGameRole), isBindAccount: isBindAccount ?? Boolean(bindGameRole),
isBindRole: isBindRole ?? Boolean(bindGameRole), isBindRole: isBindRole ?? Boolean(bindGameRole),
roleName: bindGameRole, roleName: bindGameRole,
roleToken: platformGameRoleUid || bindGameRoleToken, roleToken: bindGameRoleToken,
platformRoleUid: platformGameRoleUid,
channel: bindGameChannel, channel: bindGameChannel,
changeBindTime: accountChangeBindTime, changeBindTime: accountChangeBindTime,
changeBindDay: accountChangeBindDay, changeBindDay: accountChangeBindDay,
@@ -639,6 +650,7 @@ export async function applySemiAutoTaskStateSnapshot(
isBindRole: false, isBindRole: false,
roleName: pendingBindGameRole, roleName: pendingBindGameRole,
roleToken: pendingBindGameRoleToken, roleToken: pendingBindGameRoleToken,
platformRoleUid: pendingPlatformGameRoleUid,
channel: pendingBindGameChannel, channel: pendingBindGameChannel,
changeBindTime: pendingChangeBindTime, changeBindTime: pendingChangeBindTime,
changeBindDay: pendingChangeBindDay, changeBindDay: pendingChangeBindDay,
@@ -661,6 +673,7 @@ export async function applySemiAutoTaskStateSnapshot(
pendingBindGameAccount, pendingBindGameAccount,
pendingBindGameRole, pendingBindGameRole,
pendingBindGameRoleToken, pendingBindGameRoleToken,
pendingPlatformGameRoleUid,
pendingBindGameChannel, pendingBindGameChannel,
pendingChangeBindTime, pendingChangeBindTime,
pendingChangeBindDay, pendingChangeBindDay,
@@ -133,8 +133,8 @@ export function normalizeCustomerProfile(input: CustomerProfileInput = {}) {
} }
/** /**
* 半自动订单没有 work_orders,客户资料只能在授权页 /c/<订单号>(虎牙)或 /d/<订单号>(微博)收集。 * 半自动订单没有 work_orders,客户资料在授权页 /c/<订单号>(虎牙)或 /d/<订单号>(微博)收集。
* 保存后立即参与“客户填写角色 vs 平台识别角色”的比对。 * 虎牙先保存目标角色资料,再登录账号;保存后立即参与平台角色比对。
*/ */
export async function savePublicTaskProfile( export async function savePublicTaskProfile(
orderNoInput: unknown, orderNoInput: unknown,
@@ -163,13 +163,6 @@ export async function savePublicTaskProfile(
errorCode: 'semi_auto_profile_locked', errorCode: 'semi_auto_profile_locked',
}) })
} }
// 客户页流程固定为「登录 → 填写资料 → 绑定角色」;未登录不允许提前写资料。
if (task.login_status !== 'authenticated') {
throw createHttpError('请先完成虎牙登录后再填写资料', {
statusCode: 409,
errorCode: 'semi_auto_login_required',
})
}
const profile = normalizeCustomerProfile(payload) const profile = normalizeCustomerProfile(payload)
await withTransaction(async (client) => { await withTransaction(async (client) => {
const current = await loadTaskForUpdateWithClient(client, task.id) const current = await loadTaskForUpdateWithClient(client, task.id)
@@ -185,12 +178,6 @@ export async function savePublicTaskProfile(
errorCode: 'semi_auto_profile_locked', errorCode: 'semi_auto_profile_locked',
}) })
} }
if (current.login_status !== 'authenticated') {
throw createHttpError('请先完成虎牙登录后再填写资料', {
statusCode: 409,
errorCode: 'semi_auto_login_required',
})
}
await client.query( await client.query(
` `
UPDATE semi_auto_tasks UPDATE semi_auto_tasks
@@ -420,6 +407,7 @@ export async function startPublicLogin(orderNoInput: unknown, taskIdInput: unkno
pending_bind_game_account = '', pending_bind_game_account = '',
pending_bind_game_role = '', pending_bind_game_role = '',
pending_bind_game_role_token = '', pending_bind_game_role_token = '',
pending_platform_game_role_uid = '',
pending_bind_game_channel = '', pending_bind_game_channel = '',
pending_bind_game_change_bind_time = 0, pending_bind_game_change_bind_time = 0,
pending_bind_game_change_bind_day = 0, pending_bind_game_change_bind_day = 0,
@@ -676,6 +664,7 @@ export async function resetPublicBinding(orderNoInput: unknown, taskIdInput: unk
pending_bind_game_account = '', pending_bind_game_account = '',
pending_bind_game_role = '', pending_bind_game_role = '',
pending_bind_game_role_token = '', pending_bind_game_role_token = '',
pending_platform_game_role_uid = '',
pending_bind_game_channel = '', pending_bind_game_channel = '',
pending_bind_game_change_bind_time = 0, pending_bind_game_change_bind_time = 0,
pending_bind_game_change_bind_day = 0, pending_bind_game_change_bind_day = 0,
@@ -1007,6 +996,7 @@ export async function sendPublicHuyaSmsCode(
pending_bind_game_account = '', pending_bind_game_account = '',
pending_bind_game_role = '', pending_bind_game_role = '',
pending_bind_game_role_token = '', pending_bind_game_role_token = '',
pending_platform_game_role_uid = '',
pending_bind_game_channel = '', pending_bind_game_channel = '',
pending_bind_game_change_bind_time = 0, pending_bind_game_change_bind_time = 0,
pending_bind_game_change_bind_day = 0, pending_bind_game_change_bind_day = 0,
@@ -132,6 +132,7 @@ export type TaskRow = {
pending_bind_game_account: string pending_bind_game_account: string
pending_bind_game_role: string pending_bind_game_role: string
pending_bind_game_role_token: string pending_bind_game_role_token: string
pending_platform_game_role_uid: string
pending_bind_game_channel: string pending_bind_game_channel: string
pending_bind_game_change_bind_time: number pending_bind_game_change_bind_time: number
pending_bind_game_change_bind_day: number pending_bind_game_change_bind_day: number
@@ -272,6 +273,7 @@ function huyaRoleSnapshots(task: TaskRow): {
return roleSnapshotsFromLegacyFields({ return roleSnapshotsFromLegacyFields({
bindGameRole: task.bind_game_role, bindGameRole: task.bind_game_role,
bindGameRoleToken: task.bind_game_role_token, bindGameRoleToken: task.bind_game_role_token,
platformGameRoleUid: task.platform_game_role_uid,
bindGameChannel: task.bind_game_channel, bindGameChannel: task.bind_game_channel,
isBindAccount: task.is_bind_account, isBindAccount: task.is_bind_account,
isBindRole: task.is_bind_role, isBindRole: task.is_bind_role,
@@ -279,6 +281,7 @@ function huyaRoleSnapshots(task: TaskRow): {
changeBindDay: task.account_change_bind_day, changeBindDay: task.account_change_bind_day,
pendingBindGameRole: task.pending_bind_game_role, pendingBindGameRole: task.pending_bind_game_role,
pendingBindGameRoleToken: task.pending_bind_game_role_token, pendingBindGameRoleToken: task.pending_bind_game_role_token,
pendingPlatformGameRoleUid: task.pending_platform_game_role_uid,
pendingBindGameChannel: task.pending_bind_game_channel, pendingBindGameChannel: task.pending_bind_game_channel,
pendingChangeBindTime: task.pending_bind_game_change_bind_time, pendingChangeBindTime: task.pending_bind_game_change_bind_time,
pendingChangeBindDay: task.pending_bind_game_change_bind_day, pendingChangeBindDay: task.pending_bind_game_change_bind_day,
@@ -429,15 +432,15 @@ export function displayStatus(task: TaskRow, decision = resolveTaskHuyaBindingDe
if (task.execution_status === 'processing') { if (task.execution_status === 'processing') {
return status('processing', '处理中', 'operator', '客服继续履约') return status('processing', '处理中', 'operator', '客服继续履约')
} }
if (bindingPolicy.requiresCustomerProfile && !hasCustomerProfile(task)) {
return status(
'waiting_profile',
'待客户填写资料',
'customer',
'客户填写区服、游戏角色 UID 和角色名',
)
}
if (task.login_status === 'authenticated') { if (task.login_status === 'authenticated') {
if (bindingPolicy.requiresCustomerProfile && !hasCustomerProfile(task)) {
return status(
'waiting_profile',
'待客户填写资料',
'customer',
'客户填写区服、游戏角色 UID 和角色名',
)
}
if (task.platform === 'huya' && decision) { if (task.platform === 'huya' && decision) {
switch (decision.flowState) { switch (decision.flowState) {
case 'confirmed': case 'confirmed':
@@ -556,6 +559,7 @@ export function mapTask(task: TaskRow) {
pendingBindGameAccount: task.pending_bind_game_account, pendingBindGameAccount: task.pending_bind_game_account,
pendingBindGameRole: task.pending_bind_game_role, pendingBindGameRole: task.pending_bind_game_role,
pendingBindGameRoleToken: task.pending_bind_game_role_token, pendingBindGameRoleToken: task.pending_bind_game_role_token,
pendingPlatformGameRoleUid: task.pending_platform_game_role_uid,
pendingBindGameChannel: task.pending_bind_game_channel, pendingBindGameChannel: task.pending_bind_game_channel,
roleIdentitySource: task.role_identity_source, roleIdentitySource: task.role_identity_source,
verificationBasis: task.verification_basis, verificationBasis: task.verification_basis,
@@ -850,6 +854,7 @@ export async function resetTaskForCustomerLogin(
pending_bind_game_account = '', pending_bind_game_account = '',
pending_bind_game_role = '', pending_bind_game_role = '',
pending_bind_game_role_token = '', pending_bind_game_role_token = '',
pending_platform_game_role_uid = '',
pending_bind_game_channel = '', pending_bind_game_channel = '',
pending_bind_game_change_bind_time = 0, pending_bind_game_change_bind_time = 0,
pending_bind_game_change_bind_day = 0, pending_bind_game_change_bind_day = 0,
@@ -1374,7 +1379,8 @@ export function compareBindingRole(
isBindAccount: true, isBindAccount: true,
isBindRole: true, isBindRole: true,
roleName: binding.bindGameRole || '', roleName: binding.bindGameRole || '',
roleToken: platformRoleUid || roleToken, roleToken,
platformRoleUid,
channel: binding.bindGameChannel || '', channel: binding.bindGameChannel || '',
changeBindTime: 0, changeBindTime: 0,
changeBindDay: 0, changeBindDay: 0,
@@ -1402,7 +1408,8 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
isBindAccount: session.hasExistingBinding === true || Boolean(session.bindGameRole), isBindAccount: session.hasExistingBinding === true || Boolean(session.bindGameRole),
isBindRole: session.hasExistingBinding === true || Boolean(session.bindGameRole), isBindRole: session.hasExistingBinding === true || Boolean(session.bindGameRole),
roleName: String(session.bindGameRole || ''), roleName: String(session.bindGameRole || ''),
roleToken: platformGameRoleUid || String(session.bindGameRoleToken || legacyRoleId || ''), roleToken: String(session.bindGameRoleToken || legacyRoleId || ''),
platformRoleUid: platformGameRoleUid,
channel: String(session.bindGameChannel || ''), channel: String(session.bindGameChannel || ''),
changeBindTime: Number(session.platformChangeBindTime || 0), changeBindTime: Number(session.platformChangeBindTime || 0),
changeBindDay: Number(session.platformChangeBindDay || 0), changeBindDay: Number(session.platformChangeBindDay || 0),
@@ -1414,6 +1421,7 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
isBindRole: false, isBindRole: false,
roleName: String(session.pendingBindGameRole || ''), roleName: String(session.pendingBindGameRole || ''),
roleToken: String(session.pendingBindGameRoleToken || ''), roleToken: String(session.pendingBindGameRoleToken || ''),
platformRoleUid: String(session.pendingPlatformGameRoleUid || ''),
channel: String(session.pendingBindGameChannel || ''), channel: String(session.pendingBindGameChannel || ''),
changeBindTime: Number(session.pendingChangeBindTime || 0), changeBindTime: Number(session.pendingChangeBindTime || 0),
changeBindDay: Number(session.pendingChangeBindDay || 0), changeBindDay: Number(session.pendingChangeBindDay || 0),
@@ -1448,6 +1456,7 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
pendingBindGameAccount: String(session.pendingBindGameAccount || ''), pendingBindGameAccount: String(session.pendingBindGameAccount || ''),
pendingBindGameRole: String(session.pendingBindGameRole || ''), pendingBindGameRole: String(session.pendingBindGameRole || ''),
pendingBindGameRoleToken: String(session.pendingBindGameRoleToken || ''), pendingBindGameRoleToken: String(session.pendingBindGameRoleToken || ''),
pendingPlatformGameRoleUid: String(session.pendingPlatformGameRoleUid || ''),
pendingBindGameChannel: String(session.pendingBindGameChannel || ''), pendingBindGameChannel: String(session.pendingBindGameChannel || ''),
pendingBindGameChangeBindTime: Number(session.pendingChangeBindTime || 0), pendingBindGameChangeBindTime: Number(session.pendingChangeBindTime || 0),
pendingBindGameChangeBindDay: Number(session.pendingChangeBindDay || 0), pendingBindGameChangeBindDay: Number(session.pendingChangeBindDay || 0),
@@ -1486,13 +1495,13 @@ function currentRoleMatchesPending(
const currentZone = resolveServerZone(current.channel) const currentZone = resolveServerZone(current.channel)
const pendingZone = resolveServerZone(pending.channel) const pendingZone = resolveServerZone(pending.channel)
if (!currentZone || currentZone !== pendingZone) return false if (!currentZone || currentZone !== pendingZone) return false
const currentToken = String(current.roleToken || '') const currentIdentity = String(current.platformRoleUid || current.roleToken || '')
.trim() .trim()
.toLowerCase() .toLowerCase()
const pendingToken = String(pending.roleToken || '') const pendingIdentity = String(pending.platformRoleUid || pending.roleToken || '')
.trim() .trim()
.toLowerCase() .toLowerCase()
return Boolean(currentToken && pendingToken && currentToken === pendingToken) return Boolean(currentIdentity && pendingIdentity && currentIdentity === pendingIdentity)
} }
/** /**
@@ -1523,6 +1532,7 @@ function stabilizePersistedHuyaBindingSession(
pendingBindGameAccount: '', pendingBindGameAccount: '',
pendingBindGameRole: '', pendingBindGameRole: '',
pendingBindGameRoleToken: '', pendingBindGameRoleToken: '',
pendingPlatformGameRoleUid: '',
pendingBindGameChannel: '', pendingBindGameChannel: '',
pendingChangeBindTime: 0, pendingChangeBindTime: 0,
pendingChangeBindDay: 0, pendingChangeBindDay: 0,
@@ -1541,6 +1551,10 @@ function stabilizePersistedHuyaBindingSession(
pendingBindGameRole: session.pendingBindGameRole || pending?.roleName || '', pendingBindGameRole: session.pendingBindGameRole || pending?.roleName || '',
pendingBindGameRoleToken: pendingBindGameRoleToken:
session.pendingBindGameRoleToken || pending?.roleToken || task.pending_bind_game_role_token, session.pendingBindGameRoleToken || pending?.roleToken || task.pending_bind_game_role_token,
pendingPlatformGameRoleUid:
session.pendingPlatformGameRoleUid ||
pending?.platformRoleUid ||
task.pending_platform_game_role_uid,
pendingBindGameChannel: pendingBindGameChannel:
session.pendingBindGameChannel || pending?.channel || task.pending_bind_game_channel, session.pendingBindGameChannel || pending?.channel || task.pending_bind_game_channel,
pendingChangeBindTime: pendingChangeBindTime:
@@ -1616,6 +1630,7 @@ export async function updateBindingTaskWithClient(
: current.account_change_bind_day, : current.account_change_bind_day,
pending_bind_game_role: mapped.pendingBindGameRole, pending_bind_game_role: mapped.pendingBindGameRole,
pending_bind_game_role_token: mapped.pendingBindGameRoleToken, pending_bind_game_role_token: mapped.pendingBindGameRoleToken,
pending_platform_game_role_uid: mapped.pendingPlatformGameRoleUid,
pending_bind_game_channel: mapped.pendingBindGameChannel, pending_bind_game_channel: mapped.pendingBindGameChannel,
pending_bind_game_change_bind_time: mapped.pendingBindGameChangeBindTime, pending_bind_game_change_bind_time: mapped.pendingBindGameChangeBindTime,
pending_bind_game_change_bind_day: mapped.pendingBindGameChangeBindDay, pending_bind_game_change_bind_day: mapped.pendingBindGameChangeBindDay,
@@ -1652,6 +1667,7 @@ export async function updateBindingTaskWithClient(
pending_bind_game_account = $9, pending_bind_game_account = $9,
pending_bind_game_role = $10, pending_bind_game_role = $10,
pending_bind_game_role_token = $11, pending_bind_game_role_token = $11,
pending_platform_game_role_uid = $35,
pending_bind_game_channel = $12, pending_bind_game_channel = $12,
pending_bind_game_change_bind_time = $13, pending_bind_game_change_bind_time = $13,
pending_bind_game_change_bind_day = $14, pending_bind_game_change_bind_day = $14,
@@ -1725,6 +1741,7 @@ export async function updateBindingTaskWithClient(
accountFactsObserved, accountFactsObserved,
bindingConfirmed, bindingConfirmed,
current.platform === 'huya', current.platform === 'huya',
mapped.pendingPlatformGameRoleUid,
], ],
) )
const bindingChanged = const bindingChanged =
@@ -1753,6 +1770,7 @@ export async function updateBindingTaskWithClient(
pendingGameAccount: mapped.pendingBindGameAccount, pendingGameAccount: mapped.pendingBindGameAccount,
pendingGameRole: mapped.pendingBindGameRole, pendingGameRole: mapped.pendingBindGameRole,
pendingGameRoleToken: mapped.pendingBindGameRoleToken, pendingGameRoleToken: mapped.pendingBindGameRoleToken,
pendingPlatformGameRoleUid: mapped.pendingPlatformGameRoleUid,
pendingGameChannel: mapped.pendingBindGameChannel, pendingGameChannel: mapped.pendingBindGameChannel,
roleIdentitySource: mapped.roleIdentitySource, roleIdentitySource: mapped.roleIdentitySource,
verificationBasis: mapped.verificationBasis, verificationBasis: mapped.verificationBasis,
@@ -1806,6 +1824,7 @@ export async function updateBindingTask(
pendingBindGameAccount: mapped.pendingBindGameAccount, pendingBindGameAccount: mapped.pendingBindGameAccount,
pendingBindGameRole: mapped.pendingBindGameRole, pendingBindGameRole: mapped.pendingBindGameRole,
pendingBindGameRoleToken: mapped.pendingBindGameRoleToken, pendingBindGameRoleToken: mapped.pendingBindGameRoleToken,
pendingPlatformGameRoleUid: mapped.pendingPlatformGameRoleUid,
pendingBindGameChannel: mapped.pendingBindGameChannel, pendingBindGameChannel: mapped.pendingBindGameChannel,
platformGameRoleUid: mapped.platformGameRoleUid, platformGameRoleUid: mapped.platformGameRoleUid,
pendingChangeBindTime: mapped.pendingBindGameChangeBindTime, pendingChangeBindTime: mapped.pendingBindGameChangeBindTime,
@@ -124,16 +124,15 @@ test(
assert.equal(tasks[0]?.semiAutoConfig.pageTitle, '虎牙授权测试') assert.equal(tasks[0]?.semiAutoConfig.pageTitle, '虎牙授权测试')
const taskId = Number(tasks[0]?.id || 0) const taskId = Number(tasks[0]?.id || 0)
// 客户页流程固定为「登录 → 填写资料 → 绑定角色」:未登录不能提前写资料或开始绑定。 // 客户页流程固定为「填写资料 → 登录 → 绑定角色」:资料可先保存,绑定仍要求登录。
await expectErrorCode( const savedProfile = await savePublicTaskProfile(orderNo, taskId, {
() => roleName: '集成测试角色',
savePublicTaskProfile(orderNo, taskId, { roleId: '1192083858',
roleName: '集成测试角色', serverZone: '安卓V区',
roleId: '1192083858', })
serverZone: '安卓V区', assert.equal(savedProfile.task.customerGameRoleName, '集成测试角色')
}), assert.equal(savedProfile.task.customerGameRoleId, '1192083858')
'semi_auto_login_required', assert.equal(savedProfile.task.customerServerZone, '安卓V区')
)
await expectErrorCode(() => startPublicBinding(orderNo, taskId), 'semi_auto_login_required') await expectErrorCode(() => startPublicBinding(orderNo, taskId), 'semi_auto_login_required')
const credential = await query<{ id: number }>( const credential = await query<{ id: number }>(
` `
@@ -166,31 +165,7 @@ test(
) )
const authenticatedList = await listAdminSemiAutoTasks({ keyword: orderNo }) const authenticatedList = await listAdminSemiAutoTasks({ keyword: orderNo })
assert.equal(authenticatedList.items[0]?.loginStatus, 'authenticated') assert.equal(authenticatedList.items[0]?.loginStatus, 'authenticated')
assert.equal(authenticatedList.items[0]?.displayStatus.label, '待客户填写资料') assert.equal(authenticatedList.items[0]?.displayStatus.label, '等待客户绑定角色')
// 资料未填时不能开始绑定;也不能把待确认角色直接提交为平台绑定。
await expectErrorCode(() => startPublicBinding(orderNo, taskId), 'semi_auto_profile_required')
await query("UPDATE semi_auto_tasks SET binding_status = 'role_ready' WHERE id = $1", [
taskId,
])
await expectErrorCode(
() => confirmPublicBinding(orderNo, taskId),
'semi_auto_profile_required',
)
await query("UPDATE semi_auto_tasks SET binding_status = 'not_started' WHERE id = $1", [
taskId,
])
const savedProfile = await savePublicTaskProfile(orderNo, taskId, {
roleName: '集成测试角色',
roleId: '1192083858',
serverZone: '安卓V区',
})
assert.equal(savedProfile.task.customerGameRoleName, '集成测试角色')
assert.equal(savedProfile.task.customerGameRoleId, '1192083858')
assert.equal(savedProfile.task.customerServerZone, '安卓V区')
const profileReadyList = await listAdminSemiAutoTasks({ keyword: orderNo })
assert.equal(profileReadyList.items[0]?.displayStatus.label, '等待客户绑定角色')
const exported = await exportAdminSemiAutoCredential(taskId) const exported = await exportAdminSemiAutoCredential(taskId)
assert.equal(exported.credentialId, credentialId) assert.equal(exported.credentialId, credentialId)
assert.equal(exported.platform, 'huya') assert.equal(exported.platform, 'huya')
@@ -915,6 +890,71 @@ test(
}, },
) )
test(
'半自动后台列表按任务创建顺序稳定分页,状态刷新不会导致行跳位',
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
async () => {
process.env.DATABASE_URL = TEST_DATABASE_URL
process.env.ENABLE_DEV_MOCK = '1'
const { closeDb, query } = await import('../../db/client.js')
const { createSemiAutoMock } = await import('../dev-mock/dev-mock-service.js')
const { listAdminSemiAutoTasks } = await import('./semi-auto-task-service.js')
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
const keyword = `IT-SEMI-AUTO-STABLE-${suffix}`
const created: Array<{ orderId: number; configId: number; taskId: number }> = []
try {
for (const label of ['A', 'B']) {
const result = await createSemiAutoMock({
orderNo: `${keyword}-${label}`,
skuName: `半自动稳定排序-${suffix}-${label}`,
quantity: 1,
connectorMode: 'embedded',
})
created.push({
orderId: result.orderId,
configId: result.configId,
taskId: result.taskId,
})
}
const first = created[0]!
const second = created[1]!
await query(
`
UPDATE semi_auto_tasks
SET created_at = NOW() - INTERVAL '2 minutes',
updated_at = NOW() + INTERVAL '2 minutes',
execution_status = 'waiting_operator'
WHERE id = $1
`,
[first.taskId],
)
await query(
`
UPDATE semi_auto_tasks
SET created_at = NOW() - INTERVAL '1 minute',
updated_at = NOW() - INTERVAL '1 minute',
execution_status = 'waiting_customer'
WHERE id = $1
`,
[second.taskId],
)
const result = await listAdminSemiAutoTasks({ keyword, page: 1, pageSize: 20 })
assert.deepEqual(
result.items.map((item) => item.id),
[second.taskId, first.taskId],
)
} finally {
for (const item of created.reverse()) {
await query('DELETE FROM orders WHERE id = $1', [item.orderId])
await query('DELETE FROM manual_fulfillment_configs WHERE id = $1', [item.configId])
}
delete process.env.ENABLE_DEV_MOCK
await closeDb()
}
},
)
test( test(
'微博账号 CK 以账号级 Cookie JSON 保存并可加载', '微博账号 CK 以账号级 Cookie JSON 保存并可加载',
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false }, { skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
@@ -1325,7 +1365,7 @@ test(
) )
test( test(
'客户手动触发虎牙短信登录后保存 CK 并进入填写资料步骤', '客户先保存虎牙角色资料,再完成短信登录并保存 CK',
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false }, { skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
async () => { async () => {
process.env.DATABASE_URL = TEST_DATABASE_URL process.env.DATABASE_URL = TEST_DATABASE_URL
@@ -1354,6 +1394,14 @@ test(
orderId = result.orderId orderId = result.orderId
configId = result.configId configId = result.configId
const saved = await savePublicTaskProfile(orderNo, result.taskId, {
roleName: 'Mock虎牙角色',
roleId: '1192083858',
serverZone: '安卓V区',
})
assert.equal(saved.task.loginStatus, 'waiting_login')
assert.equal(saved.task.displayStatus.label, '等待客户授权')
const sent = await sendPublicHuyaSmsCode(orderNo, result.taskId, '13800138000') const sent = await sendPublicHuyaSmsCode(orderNo, result.taskId, '13800138000')
assert.equal(sent.ok, true) assert.equal(sent.ok, true)
const waiting = await query<{ const waiting = await query<{
@@ -1375,21 +1423,15 @@ test(
}) })
const tasks = await listPublicSemiAutoTasks(orderNo) const tasks = await listPublicSemiAutoTasks(orderNo)
assert.equal(tasks[0]?.loginStatus, 'authenticated') assert.equal(tasks[0]?.loginStatus, 'authenticated')
// 虎牙登录成功后仍需客户填写资料,不能直接进入等待客服。 // 虎牙登录成功只代表取得 CK,仍需完成角色绑定,不能直接进入等待客服。
assert.equal(tasks[0]?.executionStatus, 'waiting_customer') assert.equal(tasks[0]?.executionStatus, 'waiting_customer')
assert.equal(tasks[0]?.displayStatus.label, '待客户填写资料') assert.equal(tasks[0]?.displayStatus.label, '等待客户绑定角色')
assert.equal(tasks[0]?.customerGameRoleName, 'Mock虎牙角色')
assert.equal(tasks[0]?.customerGameRoleId, '1192083858')
assert.equal(tasks[0]?.credentialSource, 'sms') assert.equal(tasks[0]?.credentialSource, 'sms')
assert.ok(tasks[0]?.huyaUid) assert.ok(tasks[0]?.huyaUid)
assert.equal(tasks[0]?.platformNickname, 'Mock虎牙用户') assert.equal(tasks[0]?.platformNickname, 'Mock虎牙用户')
const saved = await savePublicTaskProfile(orderNo, result.taskId, {
roleName: 'Mock虎牙角色',
roleId: '1192083858',
serverZone: '安卓V区',
})
assert.equal(saved.task.executionStatus, 'waiting_customer')
assert.equal(saved.task.displayStatus.label, '等待客户绑定角色')
const stored = await query<{ const stored = await query<{
id: number id: number
credential_source: string credential_source: string
@@ -737,9 +737,6 @@ function resolveEventSummary(event: SemiAutoTaskHistoryEvent) {
if (text(detail.pendingGameRole)) { if (text(detail.pendingGameRole)) {
parts.push(`待确认角色:${text(detail.pendingGameRole)}`) parts.push(`待确认角色:${text(detail.pendingGameRole)}`)
} }
if (text(detail.gameRoleToken) || text(detail.pendingGameRoleToken)) {
parts.push('虎牙平台已返回加密角色标识')
}
if (detail.rebindUnchanged === true) parts.push('平台仍返回原绑定角色') if (detail.rebindUnchanged === true) parts.push('平台仍返回原绑定角色')
const message = text(detail.message) || text(detail.rebindConfirmMessage) const message = text(detail.message) || text(detail.rebindConfirmMessage)
if (message) parts.push(message) if (message) parts.push(message)
@@ -48,6 +48,7 @@ import type { SemiAutoTask } from '@/types/admin/semi-auto'
import type { UploadedFile } from '@/types/worker-platform' import type { UploadedFile } from '@/types/worker-platform'
import { formatAdminDateTime } from '@/utils/admin-time' import { formatAdminDateTime } from '@/utils/admin-time'
import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link' import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link'
import { formatHuyaBindingDecisionMessage } from '@/utils/semi-auto-binding-decision'
import { resolvePostInjectionUrl } from '@/utils/semi-auto-injection' import { resolvePostInjectionUrl } from '@/utils/semi-auto-injection'
import { canCompleteSemiAutoTask, canInjectSemiAutoBrowser } from '@/utils/semi-auto-task-readiness' import { canCompleteSemiAutoTask, canInjectSemiAutoBrowser } from '@/utils/semi-auto-task-readiness'
@@ -513,12 +514,8 @@ export default function AdminSemiAutoTasksPage() {
task.bindingStatus task.bindingStatus
}`} }`}
</Text> </Text>
{task.bindGameRole || task.bindGameRoleToken ? ( {task.bindGameRole ? (
<Text type="secondary"> <Text type="secondary">{`当前角色:${task.bindGameRole}`}</Text>
{`当前角色:${task.bindGameRole || '-'}${
task.bindGameRoleToken ? '(平台加密标识已识别)' : ''
}`}
</Text>
) : null} ) : null}
{task.pendingBindGameRole ? ( {task.pendingBindGameRole ? (
<Text type="secondary">{`待确认角色:${task.pendingBindGameRole}`}</Text> <Text type="secondary">{`待确认角色:${task.pendingBindGameRole}`}</Text>
@@ -813,13 +810,16 @@ export default function AdminSemiAutoTasksPage() {
<Descriptions.Item label="待确认角色"> <Descriptions.Item label="待确认角色">
{detail.task.pendingBindGameRole || '-'} {detail.task.pendingBindGameRole || '-'}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="平台角色标识"> {detail.task.platformGameRoleUid ? (
{detail.task.platformGameRoleUid <Descriptions.Item label="平台角色 UID">
? `游戏角色 UID ${detail.task.platformGameRoleUid}` {detail.task.platformGameRoleUid}
: detail.task.bindGameRoleToken || detail.task.pendingBindGameRoleToken </Descriptions.Item>
? '已识别的虎牙加密角色标识' ) : null}
: '-'} {detail.task.pendingPlatformGameRoleUid ? (
</Descriptions.Item> <Descriptions.Item label="待确认角色 UID">
{detail.task.pendingPlatformGameRoleUid}
</Descriptions.Item>
) : null}
<Descriptions.Item label="平台绑定渠道"> <Descriptions.Item label="平台绑定渠道">
{[ {[
detail.task.bindGameChannel, detail.task.bindGameChannel,
@@ -862,7 +862,9 @@ export default function AdminSemiAutoTasksPage() {
<Descriptions.Item label="绑定判定" span={2}> <Descriptions.Item label="绑定判定" span={2}>
<Space direction="vertical" size={2}> <Space direction="vertical" size={2}>
<Text strong>{BINDING_FLOW_LABELS[detail.task.bindingFlowState] || '-'}</Text> <Text strong>{BINDING_FLOW_LABELS[detail.task.bindingFlowState] || '-'}</Text>
<Text type="secondary">{detail.task.bindingDecision?.message || '-'}</Text> <Text type="secondary">
{formatHuyaBindingDecisionMessage(detail.task.bindingDecision) || '-'}
</Text>
{detail.task.bindingDecision?.rebindBlockScope ? ( {detail.task.bindingDecision?.rebindBlockScope ? (
<Text type="warning"> <Text type="warning">
阻塞作用域: 阻塞作用域:
@@ -42,6 +42,7 @@ import {
resolveCustomerPlatformRedirect, resolveCustomerPlatformRedirect,
type CustomerFulfillmentPlatform, type CustomerFulfillmentPlatform,
} from '@/utils/customer-fulfillment-link' } from '@/utils/customer-fulfillment-link'
import { formatHuyaBindingDecisionMessage } from '@/utils/semi-auto-binding-decision'
import { runWeiboYidunChallenge } from '@/utils/weibo-yidun' import { runWeiboYidunChallenge } from '@/utils/weibo-yidun'
import HuyaChallengeModal from './HuyaChallengeModal' import HuyaChallengeModal from './HuyaChallengeModal'
@@ -115,7 +116,7 @@ export default function CustomerFulfillmentPage({
), ),
) )
const isWeibo = selectedTask?.platform === 'weibo' const isWeibo = selectedTask?.platform === 'weibo'
// 虎牙流程:登录 → 填写资料(区服/游戏角色 UID/角色名)→ 绑定角色。 // 虎牙流程:填写资料(区服/游戏角色 UID/角色名)→ 登录 → 绑定角色。
// 资料齐全前不生成绑定二维码,避免客户在资料缺失时先绑错角色。 // 资料齐全前不生成绑定二维码,避免客户在资料缺失时先绑错角色。
const profileComplete = Boolean( const profileComplete = Boolean(
String(selectedTask?.customerServerZone || '').trim() && String(selectedTask?.customerServerZone || '').trim() &&
@@ -884,8 +885,8 @@ export default function CustomerFulfillmentPage({
} }
/** /**
* 返回第二步修改资料: * 返回第一步修改资料:
* 立即切回资料表单(步骤条高亮第 2 步、隐藏绑定/换绑结果),同时调后端清空虎牙 * 立即切回资料表单(步骤条高亮第 1 步、隐藏绑定/换绑结果),同时调后端清空虎牙
* 绑定与换绑失败状态;登录状态和已填资料保留,客户提交资料后重新走绑定流程。 * 绑定与换绑失败状态;登录状态和已填资料保留,客户提交资料后重新走绑定流程。
*/ */
async function openProfileEditor() { async function openProfileEditor() {
@@ -893,7 +894,7 @@ export default function CustomerFulfillmentPage({
if (resettingBindingRef.current) return if (resettingBindingRef.current) return
setBindingConfirmOpen(false) setBindingConfirmOpen(false)
setProfileEditing(true) setProfileEditing(true)
// 资料步骤会隐藏绑定二维码与比对区,等 React 完成切换后再回到第二步顶部。 // 资料步骤会隐藏绑定二维码与比对区,等 React 完成切换后再回到第一步顶部。
window.setTimeout(() => { window.setTimeout(() => {
document document
.getElementById('customer-binding-stage') .getElementById('customer-binding-stage')
@@ -953,7 +954,11 @@ export default function CustomerFulfillmentPage({
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)), current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
) )
setProfileEditing(false) setProfileEditing(false)
message.success('资料已保存,正在重新核对平台角色') message.success(
selectedTask.loginStatus === 'authenticated'
? '资料已保存,正在重新核对平台角色'
: '资料已保存,请继续登录虎牙账号',
)
} catch (error) { } catch (error) {
message.error(error instanceof Error ? error.message : '保存角色资料失败') message.error(error instanceof Error ? error.message : '保存角色资料失败')
} finally { } finally {
@@ -993,13 +998,19 @@ export default function CustomerFulfillmentPage({
const displayTitle = isWeibo ? '登录并绑定微博游戏角色' : '绑定游戏角色' const displayTitle = isWeibo ? '登录并绑定微博游戏角色' : '绑定游戏角色'
const loginQrVisible = const loginQrVisible =
Boolean(selectedTask) && ['qr_pending', 'scanned'].includes(selectedTask.loginStatus) Boolean(selectedTask) && ['qr_pending', 'scanned'].includes(selectedTask.loginStatus)
const showBindingStage = Boolean( const huyaFlowActive = Boolean(
selectedTask && selectedTask &&
selectedTask.platform === 'huya' && selectedTask.platform === 'huya' &&
selectedTask.loginStatus === 'authenticated' &&
selectedTask.executionStatus !== 'completed' && selectedTask.executionStatus !== 'completed' &&
selectedTask.executionStatus !== 'cancelled', selectedTask.executionStatus !== 'cancelled',
) )
const showHuyaProfileStage = Boolean(huyaFlowActive && (profileEditing || !profileComplete))
const showBindingStage = Boolean(
huyaFlowActive &&
selectedTask.loginStatus === 'authenticated' &&
profileComplete &&
!profileEditing,
)
const showWeiboBindingStage = Boolean( const showWeiboBindingStage = Boolean(
selectedTask && selectedTask &&
selectedTask.platform === 'weibo' && selectedTask.platform === 'weibo' &&
@@ -1042,17 +1053,20 @@ export default function CustomerFulfillmentPage({
const currentRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || '' const currentRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
const pendingRoleName = const pendingRoleName =
bindingInfo?.pendingBindGameRole || selectedTask?.pendingBindGameRole || '' bindingInfo?.pendingBindGameRole || selectedTask?.pendingBindGameRole || ''
const pendingRoleToken =
bindingInfo?.pendingBindGameRoleToken || selectedTask?.pendingBindGameRoleToken || ''
const bindingRoleName = pendingRoleName || currentRoleName const bindingRoleName = pendingRoleName || currentRoleName
const accountUid = String(selectedTask?.huyaUid || '').trim() const accountUid = String(selectedTask?.huyaUid || '').trim()
const boundRoleIdKind = bindingComparison?.boundRoleIdKind || 'missing' const platformRoleUid = String(
const boundRoleReference = bindingInfo?.platformGameRoleUid || selectedTask?.platformGameRoleUid || '',
boundRoleIdKind === 'game_role_uid' ).trim()
? `游戏角色 UID ${bindingComparison?.boundRoleId || '未知'}` const pendingPlatformRoleUid = String(
: boundRoleIdKind === 'huya_role_token' bindingInfo?.pendingPlatformGameRoleUid || selectedTask?.pendingPlatformGameRoleUid || '',
? '平台已返回加密角色标识(不与游戏角色 UID 混用)' ).trim()
: '平台未返回可核对角色标识' const targetRoleUid = String(
bindingComparison?.customerRoleId || selectedTask?.customerGameRoleId || '',
).trim()
const platformRoleUidReference = platformRoleUid
? `平台角色 UID ${platformRoleUid}`
: '平台未返回绑定角色 UID,当前仅按角色名与区服核验'
const rebindUnchanged = bindingInfo?.rebindUnchanged === true const rebindUnchanged = bindingInfo?.rebindUnchanged === true
// 换绑被虎牙拒绝或未生效时展示失败原因;若客户已把资料改成与平台当前角色一致, // 换绑被虎牙拒绝或未生效时展示失败原因;若客户已把资料改成与平台当前角色一致,
// 比对为 match,则回到正常提交流程,不再显示换绑失败。 // 比对为 match,则回到正常提交流程,不再显示换绑失败。
@@ -1078,10 +1092,10 @@ export default function CustomerFulfillmentPage({
if (bindingSessionExpired) return null if (bindingSessionExpired) return null
if (bindingDecision) { if (bindingDecision) {
if (bindingDecision.flowState === 'rebind_blocked_account') { if (bindingDecision.flowState === 'rebind_blocked_account') {
return { tone: 'is-warning', text: bindingDecision.message } return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
} }
if (bindingDecision.flowState === 'rebind_blocked_target_role') { if (bindingDecision.flowState === 'rebind_blocked_target_role') {
return { tone: 'is-warning', text: bindingDecision.message } return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
} }
if (bindingDecision.flowState === 'rebind_effect_pending') { if (bindingDecision.flowState === 'rebind_effect_pending') {
return { tone: 'is-info', text: bindingDecision.message } return { tone: 'is-info', text: bindingDecision.message }
@@ -1134,9 +1148,6 @@ export default function CustomerFulfillmentPage({
const nextRebindText = bindingInfo?.nextRebindAt const nextRebindText = bindingInfo?.nextRebindAt
? formatAdminDateTime(bindingInfo.nextRebindAt) ? formatAdminDateTime(bindingInfo.nextRebindAt)
: '' : ''
// 登录后资料不全时自动展开资料表单;资料齐全后才展示绑定二维码。
const showProfileForm = showBindingStage && (profileEditing || !profileComplete)
const renderLoginForm = (options: { const renderLoginForm = (options: {
platformLabel: string platformLabel: string
mobilePlaceholder: string mobilePlaceholder: string
@@ -1205,6 +1216,68 @@ export default function CustomerFulfillmentPage({
codePlaceholder: '6 位验证码', codePlaceholder: '6 位验证码',
submitText: '登录', submitText: '登录',
}) })
const huyaProfileForm = showHuyaProfileStage ? (
<div className="customer-auth-profile" id="customer-profile-form">
<p>
{profileComplete
? '修改目标角色资料后会重新核对虎牙账号当前绑定角色;角色名与区服一致后才能确认绑定。'
: '第一步:请填写区服、游戏角色 UID 和角色名。游戏角色 UID 与稍后登录的虎牙账号 UID 不是同一个编号。'}
</p>
<div className="customer-profile-form">
<label className="customer-collect-label">
区服 <span>*</span>
</label>
<Select
className="customer-collect-select"
classNames={SERVER_ZONE_SELECT_CLASS_NAMES}
value={profileServerZone || undefined}
onChange={(value) => setProfileServerZone(String(value))}
placeholder="请选择区服"
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
/>
<label className="customer-collect-label">
游戏角色 UID <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleId}
onChange={(event) => setProfileRoleId(event.target.value)}
placeholder="请输入游戏角色 UID"
maxLength={64}
inputMode="numeric"
/>
<label className="customer-collect-label">
角色名 <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleName}
onChange={(event) => setProfileRoleName(event.target.value)}
placeholder="请输入角色名"
maxLength={100}
/>
<Button
block
size="large"
className="customer-collect-submit"
loading={profileSaving}
onClick={() => void handleSaveProfile()}
>
保存资料并继续登录
</Button>
{profileComplete && selectedTask?.loginStatus === 'authenticated' ? (
<Button
block
size="large"
className="customer-login-alt"
onClick={() => setProfileEditing(false)}
>
返回绑定角色
</Button>
) : null}
</div>
</div>
) : null
if (loading) { if (loading) {
return ( return (
@@ -1282,9 +1355,9 @@ export default function CustomerFulfillmentPage({
{selectedTask?.platform === 'huya' ? ( {selectedTask?.platform === 'huya' ? (
<CustomerHuyaSteps <CustomerHuyaSteps
current={ current={
selectedTask.loginStatus !== 'authenticated' profileEditing || !profileComplete
? 1 ? 1
: profileEditing || !profileComplete : selectedTask.loginStatus !== 'authenticated'
? 2 ? 2
: huyaBindingConfirmed : huyaBindingConfirmed
? 4 ? 4
@@ -1293,10 +1366,15 @@ export default function CustomerFulfillmentPage({
/> />
) : null} ) : null}
{selectedTask?.loginStatus === 'waiting_login' || {huyaProfileForm ? (
selectedTask?.loginStatus === 'failed' || <section className="customer-auth-section">{huyaProfileForm}</section>
selectedTask?.loginStatus === 'expired' || ) : null}
(loginQrVisible && loginMode === 'sms') ? (
{(isWeibo || profileComplete) &&
(selectedTask?.loginStatus === 'waiting_login' ||
selectedTask?.loginStatus === 'failed' ||
selectedTask?.loginStatus === 'expired' ||
(loginQrVisible && loginMode === 'sms')) ? (
<section className="customer-auth-section"> <section className="customer-auth-section">
{isWeibo {isWeibo
? renderLoginForm({ ? renderLoginForm({
@@ -1319,7 +1397,7 @@ export default function CustomerFulfillmentPage({
</section> </section>
) : null} ) : null}
{loginQrVisible && loginMode === 'qr' ? ( {(isWeibo || profileComplete) && loginQrVisible && loginMode === 'qr' ? (
<section className="customer-auth-section"> <section className="customer-auth-section">
<div className="customer-auth-section-heading"> <div className="customer-auth-section-heading">
<span className="customer-auth-section-icon"> <span className="customer-auth-section-icon">
@@ -1511,13 +1589,20 @@ export default function CustomerFulfillmentPage({
<span>当前绑定角色</span> <span>当前绑定角色</span>
<strong>{currentRoleName || '未识别到角色'}</strong> <strong>{currentRoleName || '未识别到角色'}</strong>
</div> </div>
<div>
<span>目标角色 UID</span>
<strong>{targetRoleUid || '未填写'}</strong>
</div>
{pendingRoleName ? ( {pendingRoleName ? (
<div> <div>
<span>本次待确认角色</span> <span>本次待确认角色</span>
<strong> <strong>{pendingRoleName}</strong>
{pendingRoleName} </div>
{pendingRoleToken ? '(平台加密标识已识别)' : ''} ) : null}
</strong> {pendingPlatformRoleUid ? (
<div>
<span>待确认角色 UID</span>
<strong>{pendingPlatformRoleUid}</strong>
</div> </div>
) : null} ) : null}
</div> </div>
@@ -1549,69 +1634,6 @@ export default function CustomerFulfillmentPage({
</div> </div>
) : null} ) : null}
{showProfileForm && !bindingSessionExpired ? (
<div className="customer-auth-profile" id="customer-profile-form">
<p>
{profileComplete
? '第二步:修改资料后会用最新资料重新核对平台角色;角色名与区服一致后才能确认绑定。'
: '第二步:请填写区服、游戏角色 UID 和角色名。游戏角色 UID 与上方虎牙登录账号 UID 不是同一个编号。'}
</p>
<div className="customer-profile-form">
<label className="customer-collect-label">
区服 <span>*</span>
</label>
<Select
className="customer-collect-select"
classNames={SERVER_ZONE_SELECT_CLASS_NAMES}
value={profileServerZone || undefined}
onChange={(value) => setProfileServerZone(String(value))}
placeholder="请选择区服"
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
/>
<label className="customer-collect-label">
游戏角色 UID <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleId}
onChange={(event) => setProfileRoleId(event.target.value)}
placeholder="请输入游戏角色 UID"
maxLength={64}
inputMode="numeric"
/>
<label className="customer-collect-label">
角色名 <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleName}
onChange={(event) => setProfileRoleName(event.target.value)}
placeholder="请输入角色名"
maxLength={100}
/>
<Button
block
size="large"
className="customer-collect-submit"
loading={profileSaving}
onClick={() => void handleSaveProfile()}
>
提交资料
</Button>
{profileComplete ? (
<Button
block
size="large"
className="customer-login-alt"
onClick={() => setProfileEditing(false)}
>
返回绑定角色
</Button>
) : null}
</div>
</div>
) : null}
{bindingQrVisible && !bindingSessionExpired && !profileEditing ? ( {bindingQrVisible && !bindingSessionExpired && !profileEditing ? (
<div className="customer-binding-qr-card"> <div className="customer-binding-qr-card">
<h3>游戏角色绑定二维码</h3> <h3>游戏角色绑定二维码</h3>
@@ -1791,12 +1813,16 @@ export default function CustomerFulfillmentPage({
<Space direction="vertical" size={2}> <Space direction="vertical" size={2}>
<span> <span>
平台角色:{bindingComparison.boundZone || '区服未知'} ·{' '} 平台角色:{bindingComparison.boundZone || '区服未知'} ·{' '}
{bindingComparison.boundRoleName || '角色未知'} · {boundRoleReference} {bindingComparison.boundRoleName || '角色未知'}
</span> </span>
{platformRoleUid ? <span>平台角色 UID:{platformRoleUid}</span> : null}
{pendingPlatformRoleUid ? (
<span>待确认角色 UID:{pendingPlatformRoleUid}</span>
) : null}
<span> <span>
已填资料:{bindingComparison.customerZone || '区服未填'} ·{' '} 已填资料:{bindingComparison.customerZone || '区服未填'} ·{' '}
{bindingComparison.customerRoleName || '角色未填'}(ID{' '} {bindingComparison.customerRoleName || '角色未填'}(UID{' '}
{bindingComparison.customerRoleId || '未填'}) {targetRoleUid || '未填'})
</span> </span>
<span> <span>
角色名称与区服一致后才能确认绑定;请重新扫码换绑,或上一步修改资料。 角色名称与区服一致后才能确认绑定;请重新扫码换绑,或上一步修改资料。
@@ -1818,7 +1844,11 @@ export default function CustomerFulfillmentPage({
type="success" type="success"
showIcon showIcon
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'} message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel] description={[
bindingInfo?.bindGameAccount,
bindingInfo?.bindGameChannel,
targetRoleUid ? `目标角色 UID ${targetRoleUid}` : '',
]
.filter(Boolean) .filter(Boolean)
.join(' · ')} .join(' · ')}
/> />
@@ -2004,7 +2034,7 @@ export default function CustomerFulfillmentPage({
</Button> </Button>
</div> </div>
<strong>{bindingComparison?.boundRoleName || '未识别到角色'}</strong> <strong>{bindingComparison?.boundRoleName || '未识别到角色'}</strong>
<em>{boundRoleReference}</em> <em>{platformRoleUidReference}</em>
</div> </div>
</div> </div>
</Space> </Space>
@@ -2103,9 +2133,9 @@ function CustomerOrderCard({ task }: { task: CustomerSemiAutoTask }) {
) )
} }
const HUYA_FLOW_STEPS = ['登录虎牙账号', '填写游戏资料', '绑定游戏角色'] const HUYA_FLOW_STEPS = ['填写游戏资料', '登录虎牙账号', '绑定游戏角色']
/** 虎牙三步进度:登录 → 填写资料 → 绑定角色。current=4 表示三步都已走完。 */ /** 虎牙三步进度:填写资料 → 登录 → 绑定角色。current=4 表示三步都已走完。 */
function CustomerHuyaSteps({ current }: { current: number }) { function CustomerHuyaSteps({ current }: { current: number }) {
return ( return (
<ol className="customer-huya-steps" aria-label="虎牙履约步骤"> <ol className="customer-huya-steps" aria-label="虎牙履约步骤">
@@ -59,6 +59,7 @@ export type SemiAutoTask = {
pendingBindGameAccount: string pendingBindGameAccount: string
pendingBindGameRole: string pendingBindGameRole: string
pendingBindGameRoleToken: string pendingBindGameRoleToken: string
pendingPlatformGameRoleUid: string
pendingBindGameChannel: string pendingBindGameChannel: string
roleIdentitySource: string roleIdentitySource: string
verificationBasis: string verificationBasis: string
@@ -49,6 +49,7 @@ export type CustomerSemiAutoTask = {
pendingBindGameAccount: string pendingBindGameAccount: string
pendingBindGameRole: string pendingBindGameRole: string
pendingBindGameRoleToken: string pendingBindGameRoleToken: string
pendingPlatformGameRoleUid: string
pendingBindGameChannel: string pendingBindGameChannel: string
roleIdentitySource: string roleIdentitySource: string
verificationBasis: string verificationBasis: string
@@ -88,6 +89,8 @@ export type CustomerBindingInfo = {
pendingBindGameRole?: string pendingBindGameRole?: string
pendingBindGameRoleToken?: string pendingBindGameRoleToken?: string
pendingBindGameChannel?: string pendingBindGameChannel?: string
platformGameRoleUid?: string
pendingPlatformGameRoleUid?: string
pendingChangeBindTime?: number pendingChangeBindTime?: number
pendingChangeBindDay?: number pendingChangeBindDay?: number
roleIdentitySource?: 'huya_outer_current' | 'huya_inner_pending' | '' roleIdentitySource?: 'huya_outer_current' | 'huya_inner_pending' | ''
@@ -0,0 +1,28 @@
import type { HuyaBindingDecision } from '../types/semi-auto-binding'
function formatDecisionTime(value: string) {
const date = new Date(value)
if (Number.isNaN(date.getTime())) return value
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}
export function formatHuyaBindingDecisionMessage(decision: HuyaBindingDecision | null | undefined) {
const message = String(decision?.message || '').trim()
if (!decision || !message) return message
const availableAt =
decision.rebindBlockScope === 'account'
? decision.accountRebindAvailableAt
: decision.rebindBlockScope === 'target_role'
? decision.targetRoleRebindAvailableAt
: ''
if (!availableAt) return message
return `${message};预计 ${formatDecisionTime(availableAt)} 后可换绑`
}
@@ -35,10 +35,21 @@ test('保存资料后只由单一自动绑定流程推进,不再并发轮询',
assert.ok(saveStart > 0) assert.ok(saveStart > 0)
const saveBody = source.slice(saveStart, saveStart + 1800) const saveBody = source.slice(saveStart, saveStart + 1800)
assert.ok(!saveBody.includes('pollCustomerBinding(')) assert.ok(!saveBody.includes('pollCustomerBinding('))
assert.ok(source.includes("message.success('资料已保存,正在重新核对平台角色')")) assert.ok(source.includes("'资料已保存,正在重新核对平台角色'"))
assert.ok(source.includes("'资料已保存,请继续登录虎牙账号'"))
assert.ok(source.includes("!['query_binding', 'start_first_binding'].includes")) assert.ok(source.includes("!['query_binding', 'start_first_binding'].includes"))
}) })
test('虎牙客户页固定先填写资料,再登录并绑定角色', () => {
const stepsStart = source.indexOf('const HUYA_FLOW_STEPS')
const stepsSource = source.slice(stepsStart, stepsStart + 260)
assert.ok(stepsSource.includes("'填写游戏资料'"))
assert.ok(stepsSource.includes("'登录虎牙账号'"))
assert.ok(stepsSource.includes("'绑定游戏角色'"))
assert.ok(source.includes('showHuyaProfileStage'))
assert.ok(source.includes('(isWeibo || profileComplete) &&'))
})
test('登录和绑定专用同步阶段暂停整单轮询', () => { test('登录和绑定专用同步阶段暂停整单轮询', () => {
assert.ok(source.includes('const dedicatedLoginPoll =')) assert.ok(source.includes('const dedicatedLoginPoll ='))
assert.ok(source.includes('const dedicatedBindingPoll =')) assert.ok(source.includes('const dedicatedBindingPoll ='))
@@ -66,9 +77,11 @@ test('角色名和区服一致才出现确认绑定,不一致时展示原因',
test('二维码区明确区分虎牙账号 UID 与游戏角色 UID', () => { test('二维码区明确区分虎牙账号 UID 与游戏角色 UID', () => {
assert.ok(source.includes('扫码后系统会核对待确认角色的名称与区服')) assert.ok(source.includes('扫码后系统会核对待确认角色的名称与区服'))
assert.ok(source.includes('不会用虎牙账号 UID')) assert.ok(source.includes('不会用虎牙账号 UID'))
assert.ok(source.includes('游戏角色 UID 与上方虎牙登录账号 UID 不是同一个编号')) assert.ok(source.includes('游戏角色 UID 与稍后登录的虎牙账号 UID 不是同一个编号'))
assert.ok(source.includes('本次待确认角色')) assert.ok(source.includes('本次待确认角色'))
assert.ok(source.includes('虎牙账号 UID')) assert.ok(source.includes('虎牙账号 UID'))
assert.ok(!source.includes('平台已返回加密角色标识'))
assert.ok(!source.includes('平台加密标识已识别'))
assert.ok(!source.includes('const bindingPendingUid')) assert.ok(!source.includes('const bindingPendingUid'))
assert.ok(!source.includes('const huyaUid = String(selectedTask?.huyaUid')) assert.ok(!source.includes('const huyaUid = String(selectedTask?.huyaUid'))
}) })
@@ -36,10 +36,10 @@ test('取消直接使用原角色的快捷确认路径', () => {
assert.ok(!source.includes('modal.confirm')) assert.ok(!source.includes('modal.confirm'))
}) })
test('点击上一步修改资料会回到第二步并隐藏绑定区', () => { test('点击上一步修改资料会回到第一步并隐藏绑定区', () => {
// 步骤条把编辑资料视为第二步,即使资料原本已完整。 // 步骤条把编辑资料视为第一步,即使资料原本已完整。
assert.ok(source.includes(': profileEditing || !profileComplete')) assert.ok(source.includes('profileEditing || !profileComplete'))
assert.ok(source.includes("'第二步:请填写区服、游戏角色 UID 和角色名")) assert.ok(source.includes("'第一步:请填写区服、游戏角色 UID 和角色名"))
assert.ok(source.includes('返回绑定角色')) assert.ok(source.includes('返回绑定角色'))
// 资料步骤隐藏二维码、失败提示和比对操作,避免与第二步混在一起。 // 资料步骤隐藏二维码、失败提示和比对操作,避免与第二步混在一起。
assert.ok(source.includes('!profileEditing')) assert.ok(source.includes('!profileEditing'))
@@ -0,0 +1,75 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import type { HuyaBindingDecision } from '../src/types/semi-auto-binding.ts'
import { formatHuyaBindingDecisionMessage } from '../src/utils/semi-auto-binding-decision.ts'
function decision(input: Partial<HuyaBindingDecision>): HuyaBindingDecision {
return {
accountRoleState: 'bound',
targetRoleMatch: 'mismatch',
flowState: 'rebind_blocked_account',
primaryAction: 'wait_account_rebind',
allowedActions: [],
rebindBlockScope: 'account',
accountRebindAvailableAt: '',
targetRoleRebindAvailableAt: '',
canGenerateBindingQr: false,
canConfirmBinding: false,
canCompleteTask: false,
requiresCustomerConfirmation: false,
requiresSupport: false,
comparison: {
verdict: 'mismatch',
customerRoleName: '',
customerRoleId: '',
customerZone: '',
boundRoleName: '',
boundRoleId: '',
boundRoleIdKind: 'missing',
boundZone: '',
verificationBasis: 'role_name_zone',
message: '',
missing: [],
mismatched: [],
},
currentRoleComparison: null,
pendingRoleComparison: null,
message: '',
...input,
}
}
test('虎牙账号换绑冷却提示使用页面格式化时间,不直接显示 ISO', () => {
const input = decision({
message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑',
accountRebindAvailableAt: '2026-11-21T16:00:00.000Z',
})
const text = formatHuyaBindingDecisionMessage(input)
assert.match(text, /当前虎牙登录账号仍在换绑冷却期/)
assert.match(text, /预计 \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 后可换绑/)
assert.doesNotMatch(text, /2026-11-21T16:00:00\.000Z/)
})
test('目标角色冷却提示只读取目标角色可换绑时间', () => {
const input = decision({
flowState: 'rebind_blocked_target_role',
rebindBlockScope: 'target_role',
message: '目标游戏角色仍在换绑冷却期,暂不可换绑',
accountRebindAvailableAt: '2026-11-20T16:00:00.000Z',
targetRoleRebindAvailableAt: '2026-11-23T16:00:00.000Z',
})
const text = formatHuyaBindingDecisionMessage(input)
assert.match(text, /目标游戏角色仍在换绑冷却期/)
assert.match(text, /预计 \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 后可换绑/)
assert.doesNotMatch(text, /2026-11-20/)
})
test('没有明确冷却时间时不补造时间', () => {
const text = formatHuyaBindingDecisionMessage(
decision({ message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑' }),
)
assert.equal(text, '当前虎牙登录账号仍在换绑冷却期,暂不可换绑')
})
@@ -65,3 +65,8 @@ test('虎牙默认只声明角色名与区服一致,不把客户角色 UID 冒
assert.ok(adminPage.includes('角色名与区服一致,可提交平台绑定')) assert.ok(adminPage.includes('角色名与区服一致,可提交平台绑定'))
assert.ok(adminPage.includes('角色名、区服和平台角色 UID 一致,可提交平台绑定')) assert.ok(adminPage.includes('角色名、区服和平台角色 UID 一致,可提交平台绑定'))
}) })
test('后台不再展示虎牙加密角色标识', () => {
assert.ok(!adminPage.includes('平台加密标识已识别'))
assert.ok(!adminPage.includes('已识别的虎牙加密角色标识'))
})
@@ -12,7 +12,7 @@ updated_at: 2026-11-20
> 状态:**唯一权威文档**。 > 状态:**唯一权威文档**。
> 最后校准:2026-11-20。 > 最后校准:2026-11-20。
> 生产基线:迁移 `175`(2026-11-19 核对)。 > 生产基线:迁移 `175`(2026-11-19 核对)。
> 开发基线:迁移 `178`(仅本地,尚未部署生产)。 > 开发基线:迁移 `179`(仅本地,尚未部署生产)。
> >
> 从本文件生效起,订单、内部 SKU、履约渠道、履约载体、标准商品、成本和财务相关实现, > 从本文件生效起,订单、内部 SKU、履约渠道、履约载体、标准商品、成本和财务相关实现,
> 只能以本文件为业务口径。其他旧分析只作为历史资料,不再具备设计或验收效力。 > 只能以本文件为业务口径。其他旧分析只作为历史资料,不再具备设计或验收效力。
@@ -317,16 +317,17 @@ manual fulfillment
- 半自动任务必须绑定 `order_item_id`、`fulfillments.id` 和人工履约配置,不得伪造接单平台工单。 - 半自动任务必须绑定 `order_item_id`、`fulfillments.id` 和人工履约配置,不得伪造接单平台工单。
- 半自动任务必须在 manual 渠道判定、人工配置保存/重匹配或 Carrier 补配成功后按订单项主动物化, - 半自动任务必须在 manual 渠道判定、人工配置保存/重匹配或 Carrier 补配成功后按订单项主动物化,
不能依赖客户先打开 `/c/<订单号>` 或客服先打开半自动任务列表。后台和客户页的幂等回填仅作为兜底。 不能依赖客户先打开 `/c/<订单号>` 或客服先打开半自动任务列表。后台和客户页的幂等回填仅作为兜底。
- 虎牙客户页流程固定为「登录 → 填写资料 → 绑定角色 → 客服处理」: - 虎牙客户页流程固定为「填写资料 → 登录虎牙账号 → 绑定角色 → 客服处理」:
① 资料三项(区服、游戏角色 UID、角色名)只能在登录成功后保存,未填全时不得生成绑定二维码, ① 资料三项(区服、游戏角色 UID、角色名)必须先保存,未填全时不得展示虎牙登录或生成绑定二维码,
页面状态显示「待客户填写资料」; 页面状态显示「待客户填写资料」;
② 虎牙账号 UID(`huya_uid`)只用于 WUP/RPC 请求身份,与客户填写的游戏角色 UID 没有任何对应关系, ② 虎牙账号 UID(`huya_uid`)只用于 WUP/RPC 请求身份,与客户填写的游戏角色 UID 没有任何对应关系,
禁止互相回退或比较; 禁止互相回退或比较;
③ 虎牙 `gameRole.roleId` 是 40 位加密 opaque token,只保存为平台角色标识,用于判断虎牙前后两次 ③ 虎牙 `gameRole.roleId` 是 40 位加密 opaque token,只可在 Connector 内部用于判断前后两次查询
查询是否仍是同一角色,不得展示成游戏角色 UID,也不得与账号 UID 或客户游戏角色 UID 比较; 是否仍是同一角色;客户页、管理端和历史摘要不得展示该标识,也不得把它当角色 UID;
④ 当前虎牙接口未稳定返回独立数值游戏角色 UID。自动放行依据固定为角色名与区服: ④ 平台返回 `gameSerial` 或 `gameRole.extendInfo` 中明确的数值角色 UID 时,必须分别保存到
`compareBindingRole` 仅在 `roleName + serverZone` 一致时返回 `match`;客户游戏角色 UID 只留档, `platform_game_role_uid` / `pending_platform_game_role_uid` 并纳入角色比对;当前实际响应可能
除非平台未来明确返回独立数值角色 UID,否则不参与自动比对; 不返回独立数值 UID,此时页面只能展示客户填写的目标角色 UID,并明确平台未提供绑定角色 UID,
不得由加密 token、账号 UID 或客户 UID 互相回填;
⑤ 客户确认前必须通过 outer/inner 双路查询得到本次 pending 角色;确认绑定必须先呈现 pending 角色, ⑤ 客户确认前必须通过 outer/inner 双路查询得到本次 pending 角色;确认绑定必须先呈现 pending 角色,
客户明确提交后才调用 `confirmBindActAccount`,写后回查 current 角色与 pending 一致才能进入 客户明确提交后才调用 `confirmBindActAccount`,写后回查 current 角色与 pending 一致才能进入
`binding_status = confirmed`。确认请求必须携带页面已核对的角色名、role token 与渠道快照, `binding_status = confirmed`。确认请求必须携带页面已核对的角色名、role token 与渠道快照,
@@ -338,7 +339,7 @@ manual fulfillment
平台未返回角色名或比对缺项时,只提供「复制订单号联系客服」和「刷新状态」。 平台未返回角色名或比对缺项时,只提供「复制订单号联系客服」和「刷新状态」。
- 客户点「上一步修改资料」时清空当前绑定与换绑失败状态:`binding_status` 回到 `not_started`, - 客户点「上一步修改资料」时清空当前绑定与换绑失败状态:`binding_status` 回到 `not_started`,
清空 `bind_game_*`、`bound_at`、`last_error` 与换绑失败痕迹(`rebindUnchanged`/`rebindConfirmState` 等), 清空 `bind_game_*`、`bound_at`、`last_error` 与换绑失败痕迹(`rebindUnchanged`/`rebindConfirmState` 等),
但保留登录状态、`credential_id`、`connector_session_id` 和客户已填资料三项。页面回到第二步并保留资料可编辑, 但保留登录状态、`credential_id`、`connector_session_id` 和客户已填资料三项。页面回到第一步并保留资料可编辑,
客户重新「提交资料」后重新识别平台角色、重新生成绑定二维码,不能复用旧的换绑失败状态。 客户重新「提交资料」后重新识别平台角色、重新生成绑定二维码,不能复用旧的换绑失败状态。
- 登录状态和执行状态保存于 `semi_auto_tasks`,不得写入 `material_json` 作为正式状态。 - 登录状态和执行状态保存于 `semi_auto_tasks`,不得写入 `material_json` 作为正式状态。
`binding_status`、`bind_game_*`、`bind_game_role_token`、pending 角色、`bound_at` 和客户资料三项 `binding_status`、`bind_game_*`、`bind_game_role_token`、pending 角色、`bound_at` 和客户资料三项
@@ -744,13 +745,14 @@ has_active_cost
客户页 `/c/<平台订单号>` 统一展示: 客户页 `/c/<平台订单号>` 统一展示:
```text ```text
登录 → 查询或填写角色资料 → 绑定角色 → 客服处理 → 完成 填写或确认订单角色资料 → 登录平台账号 → 绑定角色 → 客服处理 → 完成
``` ```
- 虎牙三步进度固定为「登录虎牙账号 → 填写游戏资料 → 绑定游戏角色」,当前步骤高亮,已完成为勾选。 - 虎牙三步进度固定为「填写游戏资料 → 登录虎牙账号 → 绑定游戏角色」,当前步骤高亮,已完成为勾选。
- 登录成功后才展示资料表单;资料三项(区服 / 游戏角色 UID / 角色名)未填全时不展示绑定二维码。 - 资料三项(区服 / 游戏角色 UID / 角色名)未填全时不展示虎牙登录和绑定二维码;资料保存后才引导登录。
- 绑定角色页分别展示虎牙账号 UID、当前平台角色、本次待确认角色与客户资料;角色名和区服一致才允许确认绑定, - 绑定角色页分别展示虎牙账号 UID、当前平台角色、本次待确认角色与客户资料;角色名和区服一致才允许确认绑定,
客户游戏角色 UID 不与虎牙账号 UID 或平台加密 role token 比对; 客户游戏角色 UID 不与虎牙账号 UID 或平台加密 role token 比对;平台返回独立数值角色 UID 时同时展示
当前角色与待确认角色 UID,未返回时只能展示客户填写的目标角色 UID,不得把加密 role token 显示成 UID;
不一致时固定显示「重新扫码换绑」「上一步修改资料」,换绑后仍不一致时以修改资料为主。 不一致时固定显示「重新扫码换绑」「上一步修改资料」,换绑后仍不一致时以修改资料为主。
- 微博登录成功后直接展示微信/QQ 绑定入口;平台返回已绑定角色时直接进入等待客服, - 微博登录成功后直接展示微信/QQ 绑定入口;平台返回已绑定角色时直接进入等待客服,
未绑定时展示扫码二维码,扫码后重新读取平台角色,角色名发生变化才视为换绑成功。 未绑定时展示扫码二维码,扫码后重新读取平台角色,角色名发生变化才视为换绑成功。
@@ -1176,7 +1178,7 @@ docs/archive/
## 十三、当前下一步 ## 十三、当前下一步
截至 2026-11-20,生产基线为 `175`,当前开发基线为 `178`。迁移 `152` 保护订单来源快照, 截至 2026-11-20,生产基线为 `175`,当前开发基线为 `179`。迁移 `152` 保护订单来源快照,
迁移 `158–160` 收口寄卖登记人同步、寄卖平台与自动匹配设置; 迁移 `158–160` 收口寄卖登记人同步、寄卖平台与自动匹配设置;
迁移 `161` 一次建立人工渠道半自动任务、内置 Connector 默认值、账号级 Cookie JSON 凭证、 迁移 `161` 一次建立人工渠道半自动任务、内置 Connector 默认值、账号级 Cookie JSON 凭证、
任务凭证引用和最终约束;迁移 `162` 建立履约待办四桶只读投影、补载体专用索引和新单优先扫描口径。 任务凭证引用和最终约束;迁移 `162` 建立履约待办四桶只读投影、补载体专用索引和新单优先扫描口径。
@@ -1203,9 +1205,11 @@ pending 角色快照、`role_identity_source` 与 `verification_basis`。
区服无法解析或角色名/区服不一致时退出客服待办,进入客户补资料或换绑流程;无取消任务的唯一索引 区服无法解析或角色名/区服不一致时退出客服待办,进入客户补资料或换绑流程;无取消任务的唯一索引
允许旧任务保留审计、新配置创建新的活动任务。确认绑定写平台前先持久化 `submitting`,重启或超时后 允许旧任务保留审计、新配置创建新的活动任务。确认绑定写平台前先持久化 `submitting`,重启或超时后
只按数据库 pending 与平台 current 回查收敛,不得重复提交平台写操作。 只按数据库 pending 与平台 current 回查收敛,不得重复提交平台写操作。
迁移 `179` 将当前角色与待确认角色的平台数值 UID 分开持久化,禁止把待确认角色 UID 写入当前角色字段;
加密 role token 与数值角色 UID 是两个独立字段,任何情况下都不得互相回填。
迁移 `169` 增加客户游戏角色资料三项(`customer_game_role_name` / `customer_game_role_id` / 迁移 `169` 增加客户游戏角色资料三项(`customer_game_role_name` / `customer_game_role_id` /
`customer_game_server_zone`),并允许从工单素材回退合并;客户页流程收敛为 `customer_game_server_zone`),并允许从工单素材回退合并;客户页流程收敛为
「登录 → 填写资料 → 绑定角色」,资料未填全不得生成绑定二维码。 「填写资料 → 登录 → 绑定角色」,资料未填全不得展示登录或绑定二维码。
迁移 `170` 增加半自动全链路报文日志,客户页、管理端和外部 Connector 共用同一追踪口径; 迁移 `170` 增加半自动全链路报文日志,客户页、管理端和外部 Connector 共用同一追踪口径;
虎牙角色自动比对改为角色名与区服;账号 UID、加密 role token、客户游戏角色 UID 三类身份禁止混用。 虎牙角色自动比对改为角色名与区服;账号 UID、加密 role token、客户游戏角色 UID 三类身份禁止混用。
只读审计命令为 `npm run audit:huya-binding-identity -- --strict`。历史 `legacy_*` 留档只用于追溯, 只读审计命令为 `npm run audit:huya-binding-identity -- --strict`。历史 `legacy_*` 留档只用于追溯,
@@ -1228,7 +1232,8 @@ pending 角色快照、`role_identity_source` 与 `verification_basis`。
6. 半自动平台负责客户登录、账号 CK 获取和游戏角色绑定;微博支持手机号登录、易盾二次验证、 6. 半自动平台负责客户登录、账号 CK 获取和游戏角色绑定;微博支持手机号登录、易盾二次验证、
完整域名 Cookie 保存、会话恢复、游戏角色查询和微信/QQ 扫码绑定;虎牙支持客户手动触发的 完整域名 Cookie 保存、会话恢复、游戏角色查询和微信/QQ 扫码绑定;虎牙支持客户手动触发的
短信验证码登录和扫码登录。 短信验证码登录和扫码登录。
虎牙客户登录后必须先填写区服 / 游戏角色 UID / 角色名,再进入绑定;虎牙账号 UID 只用于登录请求, 虎牙客户必须先填写区服 / 游戏角色 UID / 角色名,再登录账号并进入绑定;虎牙账号 UID 只用于登录请求,
游戏角色 UID 只作为客户资料留档。角色名与区服一致后,客户确认本次 pending 角色才可提交平台绑定; 客户游戏角色 UID 作为订单目标资料,平台明确返回独立数值角色 UID 时必须另行保存并参与比对。
不一致时只能重新扫码换绑或返回上一步修改资料,不提供直接使用原角色的快捷确认。 角色名与区服一致后,客户确认本次 pending 角色才可提交平台绑定;不一致时只能重新扫码换绑或返回
上一步修改资料,不提供直接使用原角色的快捷确认。
7. 观察期结束后,再单独发布兼容表、旧脚本别名和 `legacy_*` 字段的删除迁移。 7. 观察期结束后,再单独发布兼容表、旧脚本别名和 `legacy_*` 字段的删除迁移。