修复(半自动履约): 稳定任务排序并拆分虎牙角色UID
This commit is contained in:
@@ -20,6 +20,7 @@ type AuditRow = {
|
||||
platform_role_uid: string
|
||||
pending_role_name: string
|
||||
pending_role_token: string
|
||||
pending_platform_role_uid: string
|
||||
customer_role_uid: string
|
||||
legacy_bind_game_role_id: string
|
||||
role_identity_source: string
|
||||
@@ -45,6 +46,7 @@ async function main() {
|
||||
task.platform_game_role_uid,
|
||||
task.pending_bind_game_role AS pending_role_name,
|
||||
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.legacy_bind_game_role_id,
|
||||
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)),
|
||||
)
|
||||
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(
|
||||
(row) =>
|
||||
Boolean(row.account_uid) &&
|
||||
Boolean(row.platform_role_uid) &&
|
||||
row.platform_role_uid === row.account_uid,
|
||||
((Boolean(row.platform_role_uid) && row.platform_role_uid === row.account_uid) ||
|
||||
(Boolean(row.pending_platform_role_uid) &&
|
||||
row.pending_platform_role_uid === row.account_uid)),
|
||||
)
|
||||
|
||||
console.log(
|
||||
@@ -158,6 +163,7 @@ async function main() {
|
||||
taskId: row.task_id,
|
||||
orderNo: row.order_no,
|
||||
platformRoleUid: row.platform_role_uid,
|
||||
pendingPlatformRoleUid: row.pending_platform_role_uid,
|
||||
})),
|
||||
platformRoleUidReusedFromAccountUidTasks: platformRoleUidReusedFromAccountUid.map(
|
||||
(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,
|
||||
resolveHuyaBindingDecision,
|
||||
resolveHuyaRoleRebindAvailability,
|
||||
roleSnapshotsFromLegacyFields,
|
||||
type HuyaBindingDecisionInput,
|
||||
type HuyaRoleSnapshot,
|
||||
} from './huya-binding-policy.js'
|
||||
@@ -336,3 +337,27 @@ test('冷却计算和目标匹配器保持唯一实现', () => {
|
||||
assert.equal(classifyHuyaRebindFailure('该游戏角色仍在换绑冷却期'), 'target_role')
|
||||
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
|
||||
roleName: string
|
||||
roleToken: string
|
||||
platformRoleUid?: string
|
||||
channel: string
|
||||
changeBindTime: number
|
||||
changeBindDay: number
|
||||
@@ -144,7 +145,7 @@ function comparisonBase(customer: HuyaCustomerRoleSnapshot, role: HuyaRoleSnapsh
|
||||
const customerZone = resolveServerZone(customer.serverZone)
|
||||
const roleName = readString(role?.roleName)
|
||||
const roleToken = readString(role?.roleToken)
|
||||
const platformRoleUid = isNumericBindingRoleId(roleToken) ? roleToken : ''
|
||||
const platformRoleUid = readString(role?.platformRoleUid)
|
||||
const boundZone = resolveServerZone(role?.channel)
|
||||
return {
|
||||
customerRoleName,
|
||||
@@ -567,7 +568,7 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
|
||||
'contact_support',
|
||||
),
|
||||
rebindBlockScope: 'account',
|
||||
message: `当前虎牙登录账号暂不可换绑,预计 ${base.accountAvailability.availableAt || '稍后'} 恢复`,
|
||||
message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -577,7 +578,7 @@ export function resolveHuyaBindingDecision(input: HuyaBindingDecisionInput): Huy
|
||||
primaryAction: 'wait_target_role_rebind',
|
||||
allowedActions: actions('wait_target_role_rebind', 'edit_profile', 'contact_support'),
|
||||
rebindBlockScope: 'target_role',
|
||||
message: `目标游戏角色仍在换绑冷却期,预计 ${base.targetAvailability.availableAt || '稍后'} 恢复`,
|
||||
message: '目标游戏角色仍在换绑冷却期,暂不可换绑',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -717,6 +718,7 @@ export function isHuyaBindingConfirmedForCompletion(input: HuyaBindingDecisionIn
|
||||
export function roleSnapshotsFromLegacyFields(input: {
|
||||
bindGameRole: string
|
||||
bindGameRoleToken: string
|
||||
platformGameRoleUid?: string
|
||||
bindGameChannel: string
|
||||
isBindAccount: boolean
|
||||
isBindRole: boolean
|
||||
@@ -724,6 +726,7 @@ export function roleSnapshotsFromLegacyFields(input: {
|
||||
changeBindDay: number
|
||||
pendingBindGameRole: string
|
||||
pendingBindGameRoleToken: string
|
||||
pendingPlatformGameRoleUid?: string
|
||||
pendingBindGameChannel: string
|
||||
pendingChangeBindTime: number
|
||||
pendingChangeBindDay: number
|
||||
@@ -737,6 +740,7 @@ export function roleSnapshotsFromLegacyFields(input: {
|
||||
isBindRole: input.isBindRole,
|
||||
roleName: currentRole,
|
||||
roleToken: readString(input.bindGameRoleToken),
|
||||
platformRoleUid: readString(input.platformGameRoleUid),
|
||||
channel: readString(input.bindGameChannel),
|
||||
changeBindTime: Number(input.changeBindTime || 0),
|
||||
changeBindDay: Number(input.changeBindDay || 0),
|
||||
@@ -748,6 +752,7 @@ export function roleSnapshotsFromLegacyFields(input: {
|
||||
isBindRole: false,
|
||||
roleName: pendingRole,
|
||||
roleToken: readString(input.pendingBindGameRoleToken),
|
||||
platformRoleUid: readString(input.pendingPlatformGameRoleUid),
|
||||
channel: readString(input.pendingBindGameChannel),
|
||||
changeBindTime: Number(input.pendingChangeBindTime || 0),
|
||||
changeBindDay: Number(input.pendingChangeBindDay || 0),
|
||||
|
||||
@@ -34,3 +34,15 @@ test('外部 Connector 状态快照复用统一绑定写入和确认门禁', ()
|
||||
assert.match(customerService, /getHuyaBindingSnapshot\(/)
|
||||
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
|
||||
pendingBindGameRole?: string
|
||||
pendingBindGameRoleToken?: string
|
||||
pendingPlatformGameRoleUid?: string
|
||||
pendingBindGameChannel?: string
|
||||
pendingChangeBindTime?: number
|
||||
pendingChangeBindDay?: number
|
||||
|
||||
@@ -21,6 +21,8 @@ function bindResponse(input: {
|
||||
isBindRole?: number
|
||||
platform?: string
|
||||
area?: string
|
||||
gameSerial?: string
|
||||
extendInfo?: string
|
||||
}): HuyaBindResponse {
|
||||
return {
|
||||
status: 200,
|
||||
@@ -47,8 +49,8 @@ function bindResponse(input: {
|
||||
areaName: input.area || 'QQ',
|
||||
platName: input.platform || '安卓(android)',
|
||||
partitionName: '',
|
||||
gameSerial: '',
|
||||
extendInfo: '',
|
||||
gameSerial: input.gameSerial || '',
|
||||
extendInfo: input.extendInfo || '',
|
||||
},
|
||||
changeBindTime: 1795536000,
|
||||
},
|
||||
@@ -193,3 +195,69 @@ test('未绑定时即使外层残留同名角色,也仍以内层角色作为
|
||||
assert.equal(snapshot.current, null)
|
||||
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
|
||||
/** 虎牙返回的加密角色标识,绝不能回退成虎牙账号 UID。 */
|
||||
roleId: string
|
||||
/** 平台明确返回的独立游戏角色 UID;加密 roleId 不算。 */
|
||||
roleUid: string
|
||||
channel: string
|
||||
isBindAccount: boolean
|
||||
isBindRole: boolean
|
||||
@@ -84,6 +86,7 @@ type NativeBindState = {
|
||||
pendingAccount: string
|
||||
pendingRole: string
|
||||
pendingRoleId: string
|
||||
pendingRoleUid: string
|
||||
pendingChannel: string
|
||||
pendingChangeBindTime: number
|
||||
pendingChangeBindDay: number
|
||||
@@ -177,6 +180,7 @@ function defaultBindingState(): NativeBindState {
|
||||
account: '',
|
||||
role: '',
|
||||
roleId: '',
|
||||
roleUid: '',
|
||||
channel: '',
|
||||
isBindAccount: false,
|
||||
isBindRole: false,
|
||||
@@ -186,6 +190,7 @@ function defaultBindingState(): NativeBindState {
|
||||
pendingAccount: '',
|
||||
pendingRole: '',
|
||||
pendingRoleId: '',
|
||||
pendingRoleUid: '',
|
||||
pendingChannel: '',
|
||||
pendingChangeBindTime: 0,
|
||||
pendingChangeBindDay: 0,
|
||||
@@ -354,6 +359,7 @@ function parseRole(response: HuyaBindResponse | null): {
|
||||
account: string
|
||||
role: string
|
||||
roleId: string
|
||||
roleUid: string
|
||||
channel: string
|
||||
isBindAccount: boolean
|
||||
isBindRole: boolean
|
||||
@@ -365,6 +371,7 @@ function parseRole(response: HuyaBindResponse | null): {
|
||||
account: '',
|
||||
role: '',
|
||||
roleId: '',
|
||||
roleUid: '',
|
||||
channel: '',
|
||||
isBindAccount: false,
|
||||
isBindRole: false,
|
||||
@@ -377,10 +384,12 @@ function parseRole(response: HuyaBindResponse | null): {
|
||||
const role = data.gameRole.roleName
|
||||
const channel = [data.gameRole.platName, data.gameRole.areaName].filter(Boolean).join(' · ')
|
||||
const roleId = String(data.gameRole.roleId || '').trim()
|
||||
const roleUid = extractHuyaRoleUid(data)
|
||||
return {
|
||||
account,
|
||||
role,
|
||||
roleId,
|
||||
roleUid,
|
||||
channel,
|
||||
isBindAccount: Boolean(data.isBindAccount),
|
||||
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 {
|
||||
return [role.role, String(role.roleId || '').toLowerCase(), role.channel].join('\u0000')
|
||||
}
|
||||
@@ -1292,6 +1319,7 @@ export class HuyaNativeConnector {
|
||||
if (!pending) {
|
||||
this.finalizeConfirmedBinding(session, {
|
||||
...target,
|
||||
roleUid: binding.roleUid,
|
||||
isBindAccount: true,
|
||||
isBindRole: true,
|
||||
changeBindTime: binding.changeBindTime,
|
||||
@@ -1546,6 +1574,7 @@ export class HuyaNativeConnector {
|
||||
session.binding.account = role.account
|
||||
session.binding.role = role.role
|
||||
session.binding.roleId = role.roleId || ''
|
||||
session.binding.roleUid = role.roleUid || ''
|
||||
session.binding.channel = role.channel
|
||||
session.binding.isBindAccount = role.isBindAccount
|
||||
session.binding.isBindRole = role.isBindRole
|
||||
@@ -1558,6 +1587,7 @@ export class HuyaNativeConnector {
|
||||
session.binding.pendingAccount = role.account
|
||||
session.binding.pendingRole = role.role
|
||||
session.binding.pendingRoleId = role.roleId || ''
|
||||
session.binding.pendingRoleUid = role.roleUid || ''
|
||||
session.binding.pendingChannel = role.channel
|
||||
session.binding.pendingChangeBindTime = role.changeBindTime
|
||||
session.binding.pendingChangeBindDay = role.changeBindDay
|
||||
@@ -1568,6 +1598,7 @@ export class HuyaNativeConnector {
|
||||
session.binding.pendingAccount = ''
|
||||
session.binding.pendingRole = ''
|
||||
session.binding.pendingRoleId = ''
|
||||
session.binding.pendingRoleUid = ''
|
||||
session.binding.pendingChannel = ''
|
||||
session.binding.pendingChangeBindTime = 0
|
||||
session.binding.pendingChangeBindDay = 0
|
||||
@@ -1668,7 +1699,7 @@ export class HuyaNativeConnector {
|
||||
|
||||
private bindingView(session: NativeSession): ConnectorBindingSession {
|
||||
const binding = session.binding
|
||||
const roleIdVerified = /^\d+$/.test(binding.roleId)
|
||||
const roleIdVerified = /^\d+$/.test(binding.roleUid)
|
||||
const requiresSupport = binding.hasExistingBinding === true && !binding.role
|
||||
return {
|
||||
sessionId: session.sessionId,
|
||||
@@ -1680,7 +1711,7 @@ export class HuyaNativeConnector {
|
||||
bindGameRole: binding.role,
|
||||
bindGameRoleId: binding.roleId,
|
||||
bindGameRoleToken: binding.roleId,
|
||||
platformGameRoleUid: /^\d+$/.test(binding.roleId) ? binding.roleId : '',
|
||||
platformGameRoleUid: binding.roleUid,
|
||||
bindGameChannel: binding.channel,
|
||||
currentRole: binding.role
|
||||
? {
|
||||
@@ -1688,6 +1719,7 @@ export class HuyaNativeConnector {
|
||||
isBindRole: binding.isBindRole,
|
||||
roleName: binding.role,
|
||||
roleToken: binding.roleId,
|
||||
platformRoleUid: binding.roleUid,
|
||||
channel: binding.channel,
|
||||
changeBindTime: binding.changeBindTime,
|
||||
changeBindDay: binding.changeBindDay,
|
||||
@@ -1699,6 +1731,7 @@ export class HuyaNativeConnector {
|
||||
isBindRole: false,
|
||||
roleName: binding.pendingRole,
|
||||
roleToken: binding.pendingRoleId,
|
||||
platformRoleUid: binding.pendingRoleUid,
|
||||
channel: binding.pendingChannel,
|
||||
changeBindTime: binding.pendingChangeBindTime,
|
||||
changeBindDay: binding.pendingChangeBindDay,
|
||||
@@ -1707,6 +1740,7 @@ export class HuyaNativeConnector {
|
||||
pendingBindGameAccount: binding.pendingAccount,
|
||||
pendingBindGameRole: binding.pendingRole,
|
||||
pendingBindGameRoleToken: binding.pendingRoleId,
|
||||
pendingPlatformGameRoleUid: binding.pendingRoleUid,
|
||||
pendingBindGameChannel: binding.pendingChannel,
|
||||
pendingChangeBindTime: binding.pendingChangeBindTime,
|
||||
pendingChangeBindDay: binding.pendingChangeBindDay,
|
||||
@@ -1715,7 +1749,11 @@ export class HuyaNativeConnector {
|
||||
: binding.role
|
||||
? 'huya_outer_current'
|
||||
: '',
|
||||
verificationBasis: binding.role ? 'role_name_zone' : '',
|
||||
verificationBasis: binding.roleUid
|
||||
? 'platform_numeric_uid'
|
||||
: binding.role
|
||||
? 'role_name_zone'
|
||||
: '',
|
||||
roleIdVerified,
|
||||
requiresSupport,
|
||||
hasExistingBinding: binding.hasExistingBinding,
|
||||
|
||||
@@ -107,16 +107,7 @@ export async function listAdminSemiAutoTasks(input: Record<string, unknown> = {}
|
||||
const result = await query<TaskRow>(
|
||||
`${TASK_SELECT}
|
||||
WHERE ${where}
|
||||
ORDER BY
|
||||
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
|
||||
ORDER BY task.created_at DESC, task.id DESC
|
||||
LIMIT $${listParams.length - 1} OFFSET $${listParams.length}`,
|
||||
listParams,
|
||||
)
|
||||
@@ -539,6 +530,9 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
const pendingBindGameRoleToken = String(
|
||||
input.pendingBindGameRoleToken ?? input.pending_bind_game_role_token ?? '',
|
||||
).trim()
|
||||
const pendingPlatformGameRoleUid = String(
|
||||
input.pendingPlatformGameRoleUid ?? input.pending_platform_game_role_uid ?? '',
|
||||
).trim()
|
||||
const pendingBindGameChannel = String(
|
||||
input.pendingBindGameChannel ?? input.pending_bind_game_channel ?? '',
|
||||
).trim()
|
||||
@@ -566,6 +560,12 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
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
|
||||
if (platformGameRoleUid && effectiveHuyaUid && platformGameRoleUid === effectiveHuyaUid) {
|
||||
throw createHttpError('平台游戏角色 UID 不能复用虎牙账号 UID', {
|
||||
@@ -573,6 +573,16 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
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)) {
|
||||
throw createHttpError('角色身份来源无效', {
|
||||
statusCode: 400,
|
||||
@@ -627,7 +637,8 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
isBindAccount: isBindAccount ?? Boolean(bindGameRole),
|
||||
isBindRole: isBindRole ?? Boolean(bindGameRole),
|
||||
roleName: bindGameRole,
|
||||
roleToken: platformGameRoleUid || bindGameRoleToken,
|
||||
roleToken: bindGameRoleToken,
|
||||
platformRoleUid: platformGameRoleUid,
|
||||
channel: bindGameChannel,
|
||||
changeBindTime: accountChangeBindTime,
|
||||
changeBindDay: accountChangeBindDay,
|
||||
@@ -639,6 +650,7 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
isBindRole: false,
|
||||
roleName: pendingBindGameRole,
|
||||
roleToken: pendingBindGameRoleToken,
|
||||
platformRoleUid: pendingPlatformGameRoleUid,
|
||||
channel: pendingBindGameChannel,
|
||||
changeBindTime: pendingChangeBindTime,
|
||||
changeBindDay: pendingChangeBindDay,
|
||||
@@ -661,6 +673,7 @@ export async function applySemiAutoTaskStateSnapshot(
|
||||
pendingBindGameAccount,
|
||||
pendingBindGameRole,
|
||||
pendingBindGameRoleToken,
|
||||
pendingPlatformGameRoleUid,
|
||||
pendingBindGameChannel,
|
||||
pendingChangeBindTime,
|
||||
pendingChangeBindDay,
|
||||
|
||||
@@ -133,8 +133,8 @@ export function normalizeCustomerProfile(input: CustomerProfileInput = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 半自动订单没有 work_orders,客户资料只能在授权页 /c/<订单号>(虎牙)或 /d/<订单号>(微博)收集。
|
||||
* 保存后立即参与“客户填写角色 vs 平台识别角色”的比对。
|
||||
* 半自动订单没有 work_orders,客户资料在授权页 /c/<订单号>(虎牙)或 /d/<订单号>(微博)收集。
|
||||
* 虎牙先保存目标角色资料,再登录账号;保存后立即参与平台角色比对。
|
||||
*/
|
||||
export async function savePublicTaskProfile(
|
||||
orderNoInput: unknown,
|
||||
@@ -163,13 +163,6 @@ export async function savePublicTaskProfile(
|
||||
errorCode: 'semi_auto_profile_locked',
|
||||
})
|
||||
}
|
||||
// 客户页流程固定为「登录 → 填写资料 → 绑定角色」;未登录不允许提前写资料。
|
||||
if (task.login_status !== 'authenticated') {
|
||||
throw createHttpError('请先完成虎牙登录后再填写资料', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_login_required',
|
||||
})
|
||||
}
|
||||
const profile = normalizeCustomerProfile(payload)
|
||||
await withTransaction(async (client) => {
|
||||
const current = await loadTaskForUpdateWithClient(client, task.id)
|
||||
@@ -185,12 +178,6 @@ export async function savePublicTaskProfile(
|
||||
errorCode: 'semi_auto_profile_locked',
|
||||
})
|
||||
}
|
||||
if (current.login_status !== 'authenticated') {
|
||||
throw createHttpError('请先完成虎牙登录后再填写资料', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_login_required',
|
||||
})
|
||||
}
|
||||
await client.query(
|
||||
`
|
||||
UPDATE semi_auto_tasks
|
||||
@@ -420,6 +407,7 @@ export async function startPublicLogin(orderNoInput: unknown, taskIdInput: unkno
|
||||
pending_bind_game_account = '',
|
||||
pending_bind_game_role = '',
|
||||
pending_bind_game_role_token = '',
|
||||
pending_platform_game_role_uid = '',
|
||||
pending_bind_game_channel = '',
|
||||
pending_bind_game_change_bind_time = 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_role = '',
|
||||
pending_bind_game_role_token = '',
|
||||
pending_platform_game_role_uid = '',
|
||||
pending_bind_game_channel = '',
|
||||
pending_bind_game_change_bind_time = 0,
|
||||
pending_bind_game_change_bind_day = 0,
|
||||
@@ -1007,6 +996,7 @@ export async function sendPublicHuyaSmsCode(
|
||||
pending_bind_game_account = '',
|
||||
pending_bind_game_role = '',
|
||||
pending_bind_game_role_token = '',
|
||||
pending_platform_game_role_uid = '',
|
||||
pending_bind_game_channel = '',
|
||||
pending_bind_game_change_bind_time = 0,
|
||||
pending_bind_game_change_bind_day = 0,
|
||||
|
||||
@@ -132,6 +132,7 @@ export type TaskRow = {
|
||||
pending_bind_game_account: string
|
||||
pending_bind_game_role: string
|
||||
pending_bind_game_role_token: string
|
||||
pending_platform_game_role_uid: string
|
||||
pending_bind_game_channel: string
|
||||
pending_bind_game_change_bind_time: number
|
||||
pending_bind_game_change_bind_day: number
|
||||
@@ -272,6 +273,7 @@ function huyaRoleSnapshots(task: TaskRow): {
|
||||
return roleSnapshotsFromLegacyFields({
|
||||
bindGameRole: task.bind_game_role,
|
||||
bindGameRoleToken: task.bind_game_role_token,
|
||||
platformGameRoleUid: task.platform_game_role_uid,
|
||||
bindGameChannel: task.bind_game_channel,
|
||||
isBindAccount: task.is_bind_account,
|
||||
isBindRole: task.is_bind_role,
|
||||
@@ -279,6 +281,7 @@ function huyaRoleSnapshots(task: TaskRow): {
|
||||
changeBindDay: task.account_change_bind_day,
|
||||
pendingBindGameRole: task.pending_bind_game_role,
|
||||
pendingBindGameRoleToken: task.pending_bind_game_role_token,
|
||||
pendingPlatformGameRoleUid: task.pending_platform_game_role_uid,
|
||||
pendingBindGameChannel: task.pending_bind_game_channel,
|
||||
pendingChangeBindTime: task.pending_bind_game_change_bind_time,
|
||||
pendingChangeBindDay: task.pending_bind_game_change_bind_day,
|
||||
@@ -429,15 +432,15 @@ export function displayStatus(task: TaskRow, decision = resolveTaskHuyaBindingDe
|
||||
if (task.execution_status === 'processing') {
|
||||
return status('processing', '处理中', 'operator', '客服继续履约')
|
||||
}
|
||||
if (bindingPolicy.requiresCustomerProfile && !hasCustomerProfile(task)) {
|
||||
return status(
|
||||
'waiting_profile',
|
||||
'待客户填写资料',
|
||||
'customer',
|
||||
'客户填写区服、游戏角色 UID 和角色名',
|
||||
)
|
||||
}
|
||||
if (task.login_status === 'authenticated') {
|
||||
if (bindingPolicy.requiresCustomerProfile && !hasCustomerProfile(task)) {
|
||||
return status(
|
||||
'waiting_profile',
|
||||
'待客户填写资料',
|
||||
'customer',
|
||||
'客户填写区服、游戏角色 UID 和角色名',
|
||||
)
|
||||
}
|
||||
if (task.platform === 'huya' && decision) {
|
||||
switch (decision.flowState) {
|
||||
case 'confirmed':
|
||||
@@ -556,6 +559,7 @@ export function mapTask(task: TaskRow) {
|
||||
pendingBindGameAccount: task.pending_bind_game_account,
|
||||
pendingBindGameRole: task.pending_bind_game_role,
|
||||
pendingBindGameRoleToken: task.pending_bind_game_role_token,
|
||||
pendingPlatformGameRoleUid: task.pending_platform_game_role_uid,
|
||||
pendingBindGameChannel: task.pending_bind_game_channel,
|
||||
roleIdentitySource: task.role_identity_source,
|
||||
verificationBasis: task.verification_basis,
|
||||
@@ -850,6 +854,7 @@ export async function resetTaskForCustomerLogin(
|
||||
pending_bind_game_account = '',
|
||||
pending_bind_game_role = '',
|
||||
pending_bind_game_role_token = '',
|
||||
pending_platform_game_role_uid = '',
|
||||
pending_bind_game_channel = '',
|
||||
pending_bind_game_change_bind_time = 0,
|
||||
pending_bind_game_change_bind_day = 0,
|
||||
@@ -1374,7 +1379,8 @@ export function compareBindingRole(
|
||||
isBindAccount: true,
|
||||
isBindRole: true,
|
||||
roleName: binding.bindGameRole || '',
|
||||
roleToken: platformRoleUid || roleToken,
|
||||
roleToken,
|
||||
platformRoleUid,
|
||||
channel: binding.bindGameChannel || '',
|
||||
changeBindTime: 0,
|
||||
changeBindDay: 0,
|
||||
@@ -1402,7 +1408,8 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
|
||||
isBindAccount: session.hasExistingBinding === true || Boolean(session.bindGameRole),
|
||||
isBindRole: session.hasExistingBinding === true || Boolean(session.bindGameRole),
|
||||
roleName: String(session.bindGameRole || ''),
|
||||
roleToken: platformGameRoleUid || String(session.bindGameRoleToken || legacyRoleId || ''),
|
||||
roleToken: String(session.bindGameRoleToken || legacyRoleId || ''),
|
||||
platformRoleUid: platformGameRoleUid,
|
||||
channel: String(session.bindGameChannel || ''),
|
||||
changeBindTime: Number(session.platformChangeBindTime || 0),
|
||||
changeBindDay: Number(session.platformChangeBindDay || 0),
|
||||
@@ -1414,6 +1421,7 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
|
||||
isBindRole: false,
|
||||
roleName: String(session.pendingBindGameRole || ''),
|
||||
roleToken: String(session.pendingBindGameRoleToken || ''),
|
||||
platformRoleUid: String(session.pendingPlatformGameRoleUid || ''),
|
||||
channel: String(session.pendingBindGameChannel || ''),
|
||||
changeBindTime: Number(session.pendingChangeBindTime || 0),
|
||||
changeBindDay: Number(session.pendingChangeBindDay || 0),
|
||||
@@ -1448,6 +1456,7 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
|
||||
pendingBindGameAccount: String(session.pendingBindGameAccount || ''),
|
||||
pendingBindGameRole: String(session.pendingBindGameRole || ''),
|
||||
pendingBindGameRoleToken: String(session.pendingBindGameRoleToken || ''),
|
||||
pendingPlatformGameRoleUid: String(session.pendingPlatformGameRoleUid || ''),
|
||||
pendingBindGameChannel: String(session.pendingBindGameChannel || ''),
|
||||
pendingBindGameChangeBindTime: Number(session.pendingChangeBindTime || 0),
|
||||
pendingBindGameChangeBindDay: Number(session.pendingChangeBindDay || 0),
|
||||
@@ -1486,13 +1495,13 @@ function currentRoleMatchesPending(
|
||||
const currentZone = resolveServerZone(current.channel)
|
||||
const pendingZone = resolveServerZone(pending.channel)
|
||||
if (!currentZone || currentZone !== pendingZone) return false
|
||||
const currentToken = String(current.roleToken || '')
|
||||
const currentIdentity = String(current.platformRoleUid || current.roleToken || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
const pendingToken = String(pending.roleToken || '')
|
||||
const pendingIdentity = String(pending.platformRoleUid || pending.roleToken || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
return Boolean(currentToken && pendingToken && currentToken === pendingToken)
|
||||
return Boolean(currentIdentity && pendingIdentity && currentIdentity === pendingIdentity)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1523,6 +1532,7 @@ function stabilizePersistedHuyaBindingSession(
|
||||
pendingBindGameAccount: '',
|
||||
pendingBindGameRole: '',
|
||||
pendingBindGameRoleToken: '',
|
||||
pendingPlatformGameRoleUid: '',
|
||||
pendingBindGameChannel: '',
|
||||
pendingChangeBindTime: 0,
|
||||
pendingChangeBindDay: 0,
|
||||
@@ -1541,6 +1551,10 @@ function stabilizePersistedHuyaBindingSession(
|
||||
pendingBindGameRole: session.pendingBindGameRole || pending?.roleName || '',
|
||||
pendingBindGameRoleToken:
|
||||
session.pendingBindGameRoleToken || pending?.roleToken || task.pending_bind_game_role_token,
|
||||
pendingPlatformGameRoleUid:
|
||||
session.pendingPlatformGameRoleUid ||
|
||||
pending?.platformRoleUid ||
|
||||
task.pending_platform_game_role_uid,
|
||||
pendingBindGameChannel:
|
||||
session.pendingBindGameChannel || pending?.channel || task.pending_bind_game_channel,
|
||||
pendingChangeBindTime:
|
||||
@@ -1616,6 +1630,7 @@ export async function updateBindingTaskWithClient(
|
||||
: current.account_change_bind_day,
|
||||
pending_bind_game_role: mapped.pendingBindGameRole,
|
||||
pending_bind_game_role_token: mapped.pendingBindGameRoleToken,
|
||||
pending_platform_game_role_uid: mapped.pendingPlatformGameRoleUid,
|
||||
pending_bind_game_channel: mapped.pendingBindGameChannel,
|
||||
pending_bind_game_change_bind_time: mapped.pendingBindGameChangeBindTime,
|
||||
pending_bind_game_change_bind_day: mapped.pendingBindGameChangeBindDay,
|
||||
@@ -1652,6 +1667,7 @@ export async function updateBindingTaskWithClient(
|
||||
pending_bind_game_account = $9,
|
||||
pending_bind_game_role = $10,
|
||||
pending_bind_game_role_token = $11,
|
||||
pending_platform_game_role_uid = $35,
|
||||
pending_bind_game_channel = $12,
|
||||
pending_bind_game_change_bind_time = $13,
|
||||
pending_bind_game_change_bind_day = $14,
|
||||
@@ -1725,6 +1741,7 @@ export async function updateBindingTaskWithClient(
|
||||
accountFactsObserved,
|
||||
bindingConfirmed,
|
||||
current.platform === 'huya',
|
||||
mapped.pendingPlatformGameRoleUid,
|
||||
],
|
||||
)
|
||||
const bindingChanged =
|
||||
@@ -1753,6 +1770,7 @@ export async function updateBindingTaskWithClient(
|
||||
pendingGameAccount: mapped.pendingBindGameAccount,
|
||||
pendingGameRole: mapped.pendingBindGameRole,
|
||||
pendingGameRoleToken: mapped.pendingBindGameRoleToken,
|
||||
pendingPlatformGameRoleUid: mapped.pendingPlatformGameRoleUid,
|
||||
pendingGameChannel: mapped.pendingBindGameChannel,
|
||||
roleIdentitySource: mapped.roleIdentitySource,
|
||||
verificationBasis: mapped.verificationBasis,
|
||||
@@ -1806,6 +1824,7 @@ export async function updateBindingTask(
|
||||
pendingBindGameAccount: mapped.pendingBindGameAccount,
|
||||
pendingBindGameRole: mapped.pendingBindGameRole,
|
||||
pendingBindGameRoleToken: mapped.pendingBindGameRoleToken,
|
||||
pendingPlatformGameRoleUid: mapped.pendingPlatformGameRoleUid,
|
||||
pendingBindGameChannel: mapped.pendingBindGameChannel,
|
||||
platformGameRoleUid: mapped.platformGameRoleUid,
|
||||
pendingChangeBindTime: mapped.pendingBindGameChangeBindTime,
|
||||
|
||||
@@ -124,16 +124,15 @@ test(
|
||||
assert.equal(tasks[0]?.semiAutoConfig.pageTitle, '虎牙授权测试')
|
||||
|
||||
const taskId = Number(tasks[0]?.id || 0)
|
||||
// 客户页流程固定为「登录 → 填写资料 → 绑定角色」:未登录不能提前写资料或开始绑定。
|
||||
await expectErrorCode(
|
||||
() =>
|
||||
savePublicTaskProfile(orderNo, taskId, {
|
||||
roleName: '集成测试角色',
|
||||
roleId: '1192083858',
|
||||
serverZone: '安卓V区',
|
||||
}),
|
||||
'semi_auto_login_required',
|
||||
)
|
||||
// 客户页流程固定为「填写资料 → 登录 → 绑定角色」:资料可先保存,绑定仍要求登录。
|
||||
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区')
|
||||
await expectErrorCode(() => startPublicBinding(orderNo, taskId), 'semi_auto_login_required')
|
||||
const credential = await query<{ id: number }>(
|
||||
`
|
||||
@@ -166,31 +165,7 @@ test(
|
||||
)
|
||||
const authenticatedList = await listAdminSemiAutoTasks({ keyword: orderNo })
|
||||
assert.equal(authenticatedList.items[0]?.loginStatus, 'authenticated')
|
||||
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, '等待客户绑定角色')
|
||||
assert.equal(authenticatedList.items[0]?.displayStatus.label, '等待客户绑定角色')
|
||||
const exported = await exportAdminSemiAutoCredential(taskId)
|
||||
assert.equal(exported.credentialId, credentialId)
|
||||
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(
|
||||
'微博账号 CK 以账号级 Cookie JSON 保存并可加载',
|
||||
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
|
||||
@@ -1325,7 +1365,7 @@ test(
|
||||
)
|
||||
|
||||
test(
|
||||
'客户手动触发虎牙短信登录后保存 CK 并进入填写资料步骤',
|
||||
'客户先保存虎牙角色资料,再完成短信登录并保存 CK',
|
||||
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
|
||||
async () => {
|
||||
process.env.DATABASE_URL = TEST_DATABASE_URL
|
||||
@@ -1354,6 +1394,14 @@ test(
|
||||
orderId = result.orderId
|
||||
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')
|
||||
assert.equal(sent.ok, true)
|
||||
const waiting = await query<{
|
||||
@@ -1375,21 +1423,15 @@ test(
|
||||
})
|
||||
const tasks = await listPublicSemiAutoTasks(orderNo)
|
||||
assert.equal(tasks[0]?.loginStatus, 'authenticated')
|
||||
// 虎牙登录成功后仍需客户填写资料,不能直接进入等待客服。
|
||||
// 虎牙登录成功只代表取得 CK,仍需完成角色绑定,不能直接进入等待客服。
|
||||
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.ok(tasks[0]?.huyaUid)
|
||||
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<{
|
||||
id: number
|
||||
credential_source: string
|
||||
|
||||
Reference in New Issue
Block a user