feat(半自动履约): 补齐微博游戏角色绑定流程

This commit is contained in:
yml
2026-11-18 15:45:13 +08:00
parent f76b9c452d
commit 623a4ffa05
21 changed files with 1366 additions and 156 deletions
@@ -5,6 +5,12 @@ import { publishRealtimeEvent } from '../realtime/realtime-event-service.js'
import { nowIso } from '../../utils/time.js'
import { createHttpError } from '../../utils/http.js'
import { logWarn } from '../../utils/logger.js'
import {
buildServerZone,
compareBindingIdentity,
resolveServerZone,
} from '../account-binding/binding-identity.js'
import { getAccountBindingPolicy } from '../account-binding/platform-policy.js'
type DouyuTaskRow = {
id: number
@@ -358,33 +364,32 @@ async function loadTask(taskId: number) {
return task
}
function normalizeText(value: unknown) {
return String(value || '')
.replace(/\s+/g, '')
.toLowerCase()
}
export function compareCustomerRole(task: DouyuTaskRow, live: LiveBindingState) {
const comparison = compareBindingIdentity({
requiredFields: getAccountBindingPolicy('douyu').requiredFields,
customer: {
roleName: task.customer_role_name,
serverZone: buildServerZone(task.customer_system, task.customer_platform),
},
platform: {
roleName: live.roleName,
serverZone: resolveServerZone(`${live.areaName} ${live.platName}`),
},
})
const roleMatched =
Boolean(task.customer_role_name && live.roleName) &&
normalizeText(task.customer_role_name) === normalizeText(live.roleName)
const liveParts = new Set([normalizeText(live.areaName), normalizeText(live.platName)])
const expected: string[] = []
if (task.customer_platform === 'wechat') expected.push('微信')
if (task.customer_platform === 'qq') expected.push('qq', '手q')
if (task.customer_system === 'ios') expected.push('苹果', 'ios')
if (task.customer_system === 'android') expected.push('安卓', 'android')
const channelMatched = expected.every((item) =>
[...liveParts].some((part) => part.includes(item) || item.includes(part)),
)
!comparison.missing.includes('roleName') && !comparison.mismatched.includes('roleName')
const channelMatched =
!comparison.missing.includes('serverZone') && !comparison.mismatched.includes('serverZone')
return {
matched: roleMatched && channelMatched,
matched: comparison.verdict === 'match',
roleMatched,
channelMatched,
message:
roleMatched && channelMatched
comparison.verdict === 'match'
? '客户资料与平台识别角色一致'
: '客户资料与平台识别角色不一致,请修改资料或联系客服',
: comparison.verdict === 'unknown'
? '客户资料或平台角色信息不完整,请修改资料或联系客服'
: '客户资料与平台识别角色不一致,请修改资料或联系客服',
}
}