fix(semi-auto): 换绑未生效原因与 7 天冷却提示
This commit is contained in:
@@ -102,6 +102,11 @@ export type ConnectorBindingSession = {
|
||||
bindGameChannel: string
|
||||
hasExistingBinding?: boolean
|
||||
rebindRequested?: boolean
|
||||
rebindUnchanged?: boolean
|
||||
rebindCooldownDays?: number
|
||||
nextRebindAt?: string
|
||||
platformChangeBindDay?: number
|
||||
platformChangeBindTime?: number
|
||||
message: string
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ const LOGIN_QR_TTL_MS = 5 * 60 * 1000
|
||||
const SMS_LOGIN_TTL_MS = 5 * 60 * 1000
|
||||
const CREDENTIAL_TTL_MS = 24 * 60 * 60 * 1000
|
||||
const BINDING_QR_TTL_MS = 5 * 60 * 1000
|
||||
const REBIND_WINDOW_DAYS = 7
|
||||
const DAY_MS = 24 * 60 * 60 * 1000
|
||||
const BROWSER_TICKET_TTL_MS = 2 * 60 * 1000
|
||||
const MAX_SESSIONS = 500
|
||||
const NATIVE_TICKET_PREFIX = 'native-ticket-'
|
||||
@@ -73,6 +75,11 @@ type NativeBindState = {
|
||||
hasExistingBinding: boolean
|
||||
rebindRequested: boolean
|
||||
rebindScanned: boolean
|
||||
rebindUnchanged: boolean
|
||||
rebindCooldownDays: number
|
||||
nextRebindAt: string
|
||||
changeBindTime: number
|
||||
changeBindDay: number
|
||||
baselineRoleKey: string
|
||||
message: string
|
||||
}
|
||||
@@ -148,6 +155,11 @@ function defaultBindingState(): NativeBindState {
|
||||
hasExistingBinding: false,
|
||||
rebindRequested: false,
|
||||
rebindScanned: false,
|
||||
rebindUnchanged: false,
|
||||
rebindCooldownDays: 0,
|
||||
nextRebindAt: '',
|
||||
changeBindTime: 0,
|
||||
changeBindDay: 0,
|
||||
baselineRoleKey: '',
|
||||
message: '',
|
||||
}
|
||||
@@ -157,6 +169,78 @@ function iso(value: number): string {
|
||||
return new Date(value).toISOString()
|
||||
}
|
||||
|
||||
function rebindDateLabel(value: string): string {
|
||||
if (!value) return ''
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) return ''
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
}).format(date)
|
||||
}
|
||||
|
||||
export type RebindCooldownInput = {
|
||||
status?: number
|
||||
changeBindDay?: number
|
||||
accountData?: { changeBindTime?: number } | null
|
||||
}
|
||||
|
||||
/**
|
||||
* 虎牙活动限制:每 7 个自然日允许换绑 1 次。
|
||||
* changeBindTime 为上次绑定/换绑时间(秒级 Unix 时间戳),changeBindDay 作为兜底剩余天数。
|
||||
*/
|
||||
export function resolveRebindCooldown(
|
||||
response: RebindCooldownInput | null | undefined,
|
||||
now = Date.now(),
|
||||
): { days: number; nextRebindAt: string } {
|
||||
if (!response || (response.status !== undefined && response.status !== 200)) {
|
||||
return { days: 0, nextRebindAt: '' }
|
||||
}
|
||||
const changeBindTime = Number(response.accountData?.changeBindTime || 0)
|
||||
if (Number.isFinite(changeBindTime) && changeBindTime > 0) {
|
||||
const changedAtMs = changeBindTime > 1e12 ? changeBindTime : changeBindTime * 1000
|
||||
const nextRebindMs = changedAtMs + REBIND_WINDOW_DAYS * DAY_MS
|
||||
if (nextRebindMs > now) {
|
||||
return {
|
||||
days: Math.ceil((nextRebindMs - now) / DAY_MS),
|
||||
nextRebindAt: iso(nextRebindMs),
|
||||
}
|
||||
}
|
||||
}
|
||||
const changeBindDay = Number(response.changeBindDay || 0)
|
||||
if (Number.isFinite(changeBindDay) && changeBindDay > 0 && changeBindDay <= 30) {
|
||||
const days = Math.round(changeBindDay)
|
||||
return { days, nextRebindAt: iso(now + days * DAY_MS) }
|
||||
}
|
||||
return { days: 0, nextRebindAt: '' }
|
||||
}
|
||||
|
||||
function applyRebindMeta(
|
||||
session: NativeSession,
|
||||
response: HuyaBindResponse | null,
|
||||
now: number,
|
||||
): void {
|
||||
const cooldown = resolveRebindCooldown(response, now)
|
||||
session.binding.rebindCooldownDays = cooldown.days
|
||||
session.binding.nextRebindAt = cooldown.nextRebindAt
|
||||
session.binding.changeBindTime = Number(response?.accountData?.changeBindTime || 0)
|
||||
session.binding.changeBindDay = Number(response?.changeBindDay || 0)
|
||||
}
|
||||
|
||||
function rebindUnchangedMessage(
|
||||
roleName: string,
|
||||
cooldownDays: number,
|
||||
nextRebindAt: string,
|
||||
): string {
|
||||
const next = rebindDateLabel(nextRebindAt)
|
||||
if (cooldownDays > 0) {
|
||||
return `扫码后仍识别到原绑定角色「${roleName}」;本活动 7 天内只能换绑 1 次${next ? `,预计下次换绑:${next}` : ''}`
|
||||
}
|
||||
return `扫码后仍识别到原绑定角色「${roleName}」,请确认微信中选择的角色或重新换绑`
|
||||
}
|
||||
|
||||
function extractInt(value: unknown): number {
|
||||
const parsed = Number.parseInt(String(value ?? '').trim(), 10)
|
||||
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0
|
||||
@@ -674,10 +758,17 @@ export class HuyaNativeConnector {
|
||||
const role = parseRole(roleResponse)
|
||||
const hasExistingBinding = hasExistingHuyaBinding(roleResponse)
|
||||
session.binding.hasExistingBinding = hasExistingBinding
|
||||
applyRebindMeta(session, roleResponse, this.now())
|
||||
if (role.role && !options.forceRebind) {
|
||||
this.markRoleReady(session, role, hasExistingBinding && !session.binding.rebindRequested)
|
||||
if (session.binding.rebindRequested) {
|
||||
session.binding.message = '已识别待换绑角色,请确认换绑'
|
||||
session.binding.message = session.binding.rebindUnchanged
|
||||
? rebindUnchangedMessage(
|
||||
role.role,
|
||||
session.binding.rebindCooldownDays,
|
||||
session.binding.nextRebindAt,
|
||||
)
|
||||
: '已识别待换绑角色,请确认换绑'
|
||||
}
|
||||
return this.bindingView(session)
|
||||
}
|
||||
@@ -700,11 +791,20 @@ export class HuyaNativeConnector {
|
||||
errorCode: 'huya_livelink_param_failed',
|
||||
})
|
||||
}
|
||||
const profile = await rpc.getUserProfile({
|
||||
uid: session.uid,
|
||||
cookie: session.cookie,
|
||||
targetUid: session.uid,
|
||||
})
|
||||
let profile: Awaited<ReturnType<typeof rpc.getUserProfile>> = null
|
||||
try {
|
||||
profile = await rpc.getUserProfile({
|
||||
uid: session.uid,
|
||||
cookie: session.cookie,
|
||||
targetUid: session.uid,
|
||||
})
|
||||
} catch (error) {
|
||||
// 资料接口结构可能随虎牙升级变化,失败时回退登录会话里的昵称/头像,不能阻断换绑二维码。
|
||||
logWarn('huya/bind/profile', '获取虎牙账号资料失败,回退登录昵称', {
|
||||
uid: session.uid,
|
||||
error: errorMessage(error),
|
||||
})
|
||||
}
|
||||
const nickname = profile?.nick || profile?.passport || session.nickname
|
||||
session.nickname = nickname
|
||||
const avatar = profile?.avatar || ''
|
||||
@@ -732,6 +832,7 @@ export class HuyaNativeConnector {
|
||||
if (options.forceRebind) {
|
||||
session.binding.rebindRequested = true
|
||||
session.binding.rebindScanned = false
|
||||
session.binding.rebindUnchanged = false
|
||||
session.binding.baselineRoleKey = bindingRoleKey(role)
|
||||
}
|
||||
session.binding.status = 'qr_pending'
|
||||
@@ -790,24 +891,30 @@ export class HuyaNativeConnector {
|
||||
const role = parseRole(response)
|
||||
const hasExistingBinding = hasExistingHuyaBinding(response)
|
||||
session.binding.hasExistingBinding = hasExistingBinding
|
||||
applyRebindMeta(session, response, this.now())
|
||||
if (role.role) {
|
||||
const rebindRequested = session.binding.rebindRequested
|
||||
const roleKey = bindingRoleKey(role)
|
||||
const changedRole =
|
||||
!session.binding.baselineRoleKey || roleKey !== session.binding.baselineRoleKey
|
||||
if (rebindRequested && !changedRole) {
|
||||
if (qrCompleted) {
|
||||
session.binding.rebindRequested = false
|
||||
session.binding.rebindScanned = false
|
||||
session.binding.baselineRoleKey = ''
|
||||
if (qrCompleted || session.binding.rebindUnchanged) {
|
||||
// 扫码完成但虎牙仍返回原角色:保留 rebind 状态,明确告知未换绑及冷却原因,
|
||||
// 不能清空 rebindRequested,否则 confirmBinding 会误判为“使用已有绑定”。
|
||||
session.binding.rebindUnchanged = true
|
||||
this.markRoleReady(session, role, hasExistingBinding)
|
||||
session.binding.message = '扫码后仍识别到原绑定角色,请确认使用或重新换绑'
|
||||
session.binding.message = rebindUnchangedMessage(
|
||||
role.role,
|
||||
session.binding.rebindCooldownDays,
|
||||
session.binding.nextRebindAt,
|
||||
)
|
||||
} else {
|
||||
session.binding.status = 'scanned'
|
||||
session.binding.message = '已扫码,正在等待换绑角色生效'
|
||||
}
|
||||
return this.bindingView(session)
|
||||
}
|
||||
if (rebindRequested) session.binding.rebindUnchanged = false
|
||||
this.markRoleReady(session, role, hasExistingBinding && !rebindRequested)
|
||||
if (rebindRequested) {
|
||||
session.binding.message = '已识别换绑角色,请确认换绑'
|
||||
@@ -839,15 +946,24 @@ export class HuyaNativeConnector {
|
||||
})
|
||||
}
|
||||
const rebindRequested = session.binding.rebindRequested
|
||||
applyRebindMeta(session, response, this.now())
|
||||
if (
|
||||
rebindRequested &&
|
||||
session.binding.baselineRoleKey &&
|
||||
bindingRoleKey(role) === session.binding.baselineRoleKey
|
||||
) {
|
||||
throw createHttpError('换绑角色尚未生效,请稍后重试', {
|
||||
statusCode: 409,
|
||||
errorCode: 'huya_bind_rebind_not_ready',
|
||||
})
|
||||
const cooldownDays = session.binding.rebindCooldownDays
|
||||
const next = rebindDateLabel(session.binding.nextRebindAt)
|
||||
throw createHttpError(
|
||||
cooldownDays > 0
|
||||
? `换绑未生效:平台仍返回原绑定角色「${role.role}」;本活动 7 天内只能换绑 1 次${next ? `,预计下次换绑:${next}` : ''}`
|
||||
: `换绑未生效:平台仍返回原绑定角色「${role.role}」,请重新扫码选择正确角色`,
|
||||
{
|
||||
statusCode: 409,
|
||||
errorCode:
|
||||
cooldownDays > 0 ? 'huya_bind_rebind_cooldown' : 'huya_bind_rebind_not_ready',
|
||||
},
|
||||
)
|
||||
}
|
||||
const useExistingBinding = hasExistingHuyaBinding(response) && !rebindRequested
|
||||
if (!useExistingBinding) {
|
||||
@@ -869,6 +985,9 @@ export class HuyaNativeConnector {
|
||||
session.binding.hasExistingBinding = true
|
||||
session.binding.rebindRequested = false
|
||||
session.binding.rebindScanned = false
|
||||
session.binding.rebindUnchanged = false
|
||||
session.binding.rebindCooldownDays = 0
|
||||
session.binding.nextRebindAt = ''
|
||||
session.binding.baselineRoleKey = ''
|
||||
session.binding.message = useExistingBinding
|
||||
? '当前虎牙账号已有绑定角色,已确认直接使用'
|
||||
@@ -1156,6 +1275,11 @@ export class HuyaNativeConnector {
|
||||
bindGameChannel: binding.channel,
|
||||
hasExistingBinding: binding.hasExistingBinding,
|
||||
rebindRequested: binding.rebindRequested,
|
||||
rebindUnchanged: binding.rebindUnchanged,
|
||||
rebindCooldownDays: binding.rebindCooldownDays,
|
||||
nextRebindAt: binding.nextRebindAt,
|
||||
platformChangeBindDay: binding.changeBindDay,
|
||||
platformChangeBindTime: binding.changeBindTime,
|
||||
message: binding.message,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +401,27 @@ function parseLiveLinkResponse(reader: TafReader): HuyaLiveLinkResponse {
|
||||
}
|
||||
}
|
||||
|
||||
function isProfileIntType(dataType: TafTypeValue): boolean {
|
||||
return (
|
||||
dataType === TAF_TYPE.INT8 ||
|
||||
dataType === TAF_TYPE.INT16 ||
|
||||
dataType === TAF_TYPE.INT32 ||
|
||||
dataType === TAF_TYPE.INT64 ||
|
||||
dataType === TAF_TYPE.ZERO
|
||||
)
|
||||
}
|
||||
|
||||
function readProfileString(reader: TafReader, dataType: TafTypeValue): string {
|
||||
if (dataType === TAF_TYPE.STRING1 || dataType === TAF_TYPE.STRING4) {
|
||||
return reader.readStringValue(dataType)
|
||||
}
|
||||
|
||||
if (dataType === TAF_TYPE.ZERO) return ''
|
||||
|
||||
reader.skipValue(dataType)
|
||||
return ''
|
||||
}
|
||||
|
||||
function parseProfile(reader: TafReader): HuyaUserProfile {
|
||||
let uid = 0
|
||||
let nick = ''
|
||||
@@ -412,10 +433,20 @@ function parseProfile(reader: TafReader): HuyaUserProfile {
|
||||
break
|
||||
}
|
||||
reader.readHead()
|
||||
if (tag === 0) uid = reader.readIntValue(dataType)
|
||||
else if (tag === 1) nick = reader.readStringValue(dataType)
|
||||
else if (tag === 2) avatar = reader.readStringValue(dataType)
|
||||
else if (tag === 17) passport = reader.readStringValue(dataType)
|
||||
if (dataType === TAF_TYPE.STRUCT_BEGIN) {
|
||||
// 新版虎牙把资料包在 tag0 的嵌套结构里,直接解析内层结构。
|
||||
if (tag === 0) {
|
||||
return reader.readStructBody((nested) => parseProfile(nested))
|
||||
}
|
||||
reader.skipValue(dataType)
|
||||
continue
|
||||
}
|
||||
if (tag === 0) {
|
||||
if (isProfileIntType(dataType)) uid = reader.readIntValue(dataType)
|
||||
else reader.skipValue(dataType)
|
||||
} else if (tag === 1) nick = readProfileString(reader, dataType)
|
||||
else if (tag === 2) avatar = readProfileString(reader, dataType)
|
||||
else if (tag === 17) passport = readProfileString(reader, dataType)
|
||||
else reader.skipValue(dataType)
|
||||
}
|
||||
return { uid, nick, avatar, passport }
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { resolveRebindCooldown } from './huya-native-connector.js'
|
||||
|
||||
// 2026-11-16 12:12:24 +08:00,对应任务 34 的初次绑定时间。
|
||||
const NOW = Date.UTC(2026, 10, 16, 4, 12, 24)
|
||||
const DAY_MS = 24 * 60 * 60 * 1000
|
||||
|
||||
test('换绑冷却:changeBindTime 为初次绑定时间时,下次换绑为 7 天后', () => {
|
||||
const result = resolveRebindCooldown(
|
||||
{
|
||||
status: 200,
|
||||
changeBindDay: 0,
|
||||
accountData: { changeBindTime: Math.floor(NOW / 1000) },
|
||||
},
|
||||
NOW,
|
||||
)
|
||||
assert.equal(result.days, 7)
|
||||
assert.equal(result.nextRebindAt.slice(0, 10), '2026-11-23')
|
||||
})
|
||||
|
||||
test('换绑冷却:changeBindTime 已超过 7 天时不再限制', () => {
|
||||
const result = resolveRebindCooldown(
|
||||
{
|
||||
status: 200,
|
||||
changeBindDay: 0,
|
||||
accountData: { changeBindTime: Math.floor((NOW - 8 * DAY_MS) / 1000) },
|
||||
},
|
||||
NOW,
|
||||
)
|
||||
assert.equal(result.days, 0)
|
||||
assert.equal(result.nextRebindAt, '')
|
||||
})
|
||||
|
||||
test('换绑冷却:changeBindTime 缺失时用 changeBindDay 兜底', () => {
|
||||
const result = resolveRebindCooldown({ status: 200, changeBindDay: 3, accountData: {} }, NOW)
|
||||
assert.equal(result.days, 3)
|
||||
assert.equal(result.nextRebindAt.slice(0, 10), '2026-11-19')
|
||||
})
|
||||
|
||||
test('换绑冷却:字段为空时不限制', () => {
|
||||
const result = resolveRebindCooldown({ status: 200, changeBindDay: 0, accountData: {} }, NOW)
|
||||
assert.deepEqual(result, { days: 0, nextRebindAt: '' })
|
||||
})
|
||||
@@ -2,11 +2,16 @@ import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
|
||||
import { resolveBindingRoleId } from './binding-role-id.js'
|
||||
import { compareBindingRole, normalizeCustomerProfile } from './semi-auto-task-service.js'
|
||||
import {
|
||||
compareBindingRole,
|
||||
detectServerZone,
|
||||
normalizeCustomerProfile,
|
||||
} from './semi-auto-task-service.js'
|
||||
|
||||
const task = (id: string, name: string, huyaUid = '') => ({
|
||||
const task = (id: string, name: string, huyaUid = '', zone = '') => ({
|
||||
customer_game_id: id,
|
||||
customer_game_role: name,
|
||||
customer_game_server_zone: zone,
|
||||
huya_uid: huyaUid,
|
||||
})
|
||||
|
||||
@@ -53,7 +58,75 @@ describe('待确认角色 UID 取数(huyaUid)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('区服解析', () => {
|
||||
it('安卓 + 微信识别为安卓V区', () => {
|
||||
assert.equal(detectServerZone('安卓(android) · 微信'), '安卓V区')
|
||||
assert.equal(detectServerZone('微信用户 · 安卓(android) · 微信'), '安卓V区')
|
||||
})
|
||||
|
||||
it('苹果 + QQ识别为苹果Q区', () => {
|
||||
assert.equal(detectServerZone('苹果(iOS) · QQ'), '苹果Q区')
|
||||
})
|
||||
|
||||
it('无法识别时返回空串', () => {
|
||||
assert.equal(detectServerZone(''), '')
|
||||
assert.equal(detectServerZone('微信用户'), '')
|
||||
})
|
||||
})
|
||||
|
||||
describe('客户填写角色与平台识别角色比对', () => {
|
||||
it('区服、角色名称、角色 ID 都一致时允许确认', () => {
|
||||
const result = compareBindingRole(
|
||||
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '安卓V区'),
|
||||
{
|
||||
bindGameRole: '大鲨鱼伊塞53',
|
||||
bindGameRoleId: '1199608910400',
|
||||
bindGameChannel: '安卓(android) · 微信',
|
||||
},
|
||||
)
|
||||
assert.equal(result.verdict, 'match')
|
||||
assert.equal(result.customerZone, '安卓V区')
|
||||
assert.equal(result.boundZone, '安卓V区')
|
||||
assert.match(result.message, /区服/)
|
||||
})
|
||||
|
||||
it('角色 ID 一致但角色名称不一致时禁止确认', () => {
|
||||
const result = compareBindingRole(task('1199608910400', '123', '1199608910400', '安卓V区'), {
|
||||
bindGameRole: '大鲨鱼伊塞53',
|
||||
bindGameRoleId: '1199608910400',
|
||||
bindGameChannel: '安卓(android) · 微信',
|
||||
})
|
||||
assert.equal(result.verdict, 'mismatch')
|
||||
assert.match(result.message, /名称/)
|
||||
})
|
||||
|
||||
it('角色名称与 ID 一致但区服不一致时禁止确认', () => {
|
||||
const result = compareBindingRole(
|
||||
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '苹果Q区'),
|
||||
{
|
||||
bindGameRole: '大鲨鱼伊塞53',
|
||||
bindGameRoleId: '1199608910400',
|
||||
bindGameChannel: '安卓(android) · 微信',
|
||||
},
|
||||
)
|
||||
assert.equal(result.verdict, 'mismatch')
|
||||
assert.match(result.message, /区服/)
|
||||
assert.equal(result.boundZone, '安卓V区')
|
||||
})
|
||||
|
||||
it('渠道解析不出区服时跳过区服比对', () => {
|
||||
const result = compareBindingRole(
|
||||
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '苹果Q区'),
|
||||
{
|
||||
bindGameRole: '大鲨鱼伊塞53',
|
||||
bindGameRoleId: '1199608910400',
|
||||
bindGameChannel: '微信用户',
|
||||
},
|
||||
)
|
||||
assert.equal(result.verdict, 'match')
|
||||
assert.equal(result.boundZone, '')
|
||||
})
|
||||
|
||||
it('两侧角色 ID 一致时允许确认', () => {
|
||||
const result = compareBindingRole(task('1192083858', '巫师基尔斯84'), {
|
||||
bindGameRole: '巫师基尔斯84',
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
import {
|
||||
createHuyaBrowserTicket,
|
||||
createHuyaLoginSession,
|
||||
confirmHuyaBinding,
|
||||
exportHuyaSessionCredential,
|
||||
getHuyaBinding,
|
||||
getHuyaLoginSession,
|
||||
@@ -954,6 +955,11 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
|
||||
bindGameChannel: String(session.bindGameChannel || ''),
|
||||
hasExistingBinding: session.hasExistingBinding === true,
|
||||
rebindRequested: session.rebindRequested === true,
|
||||
rebindUnchanged: session.rebindUnchanged === true,
|
||||
rebindCooldownDays: Number(session.rebindCooldownDays || 0),
|
||||
nextRebindAt: String(session.nextRebindAt || ''),
|
||||
platformChangeBindDay: Number(session.platformChangeBindDay || 0),
|
||||
platformChangeBindTime: Number(session.platformChangeBindTime || 0),
|
||||
message: String(session.message || ''),
|
||||
}
|
||||
}
|
||||
@@ -962,8 +968,10 @@ export type BindingRoleComparison = {
|
||||
verdict: 'match' | 'mismatch' | 'unknown'
|
||||
customerRoleName: string
|
||||
customerRoleId: string
|
||||
customerZone: string
|
||||
boundRoleName: string
|
||||
boundRoleId: string
|
||||
boundZone: string
|
||||
message: string
|
||||
}
|
||||
|
||||
@@ -973,18 +981,53 @@ function normalizeRoleText(value: unknown): string {
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
function normalizeServerZone(value: unknown): string {
|
||||
const text = String(value ?? '').trim()
|
||||
|
||||
if (!text) return ''
|
||||
|
||||
return /区$/.test(text) ? text : `${text}区`
|
||||
}
|
||||
|
||||
/**
|
||||
* 从虎牙渠道串解析区服,例如「安卓(android) · 微信」→ 安卓V区。
|
||||
* 解析不出平台或登录方式时返回空串,调用方跳过区服比对。
|
||||
*/
|
||||
export function detectServerZone(channel: unknown): string {
|
||||
const text = String(channel ?? '')
|
||||
.replace(/\s+/g, '')
|
||||
.toLowerCase()
|
||||
|
||||
if (!text) return ''
|
||||
|
||||
const platform = /苹果|ios/.test(text) ? '苹果' : /安卓|android/.test(text) ? '安卓' : ''
|
||||
|
||||
if (!platform) return ''
|
||||
|
||||
const login = /qq|q区/.test(text) ? 'Q' : /微信|wechat|v区/.test(text) ? 'V' : ''
|
||||
|
||||
return login ? `${platform}${login}区` : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户填写角色与平台识别角色必须一致才允许确认绑定。
|
||||
*
|
||||
* 两侧都有角色 ID 时以 ID 为准(截图里的“两侧角色 ID 不一致”);
|
||||
* 任一侧缺 ID 时退回角色名比对;两边都取不到才判 unknown,转客服核对。
|
||||
* 区服、角色名、角色 ID 三项都要一致:
|
||||
* ① 两侧都有 ID 时 ID 必须相等;
|
||||
* ② 两侧都有角色名时名称必须相等(不能因为 ID 相同就放行改名);
|
||||
* ③ 平台渠道能解析出区服且客户有填时,区服必须相等。
|
||||
* 任一侧缺某字段时跳过该字段比对;三项都取不到才判 unknown,转客服核对。
|
||||
*/
|
||||
export function compareBindingRole(
|
||||
task: Pick<TaskRow, 'customer_game_id' | 'customer_game_role' | 'huya_uid'>,
|
||||
binding: { bindGameRole?: string; bindGameRoleId?: string },
|
||||
task: Pick<
|
||||
TaskRow,
|
||||
'customer_game_id' | 'customer_game_role' | 'customer_game_server_zone' | 'huya_uid'
|
||||
>,
|
||||
binding: { bindGameRole?: string; bindGameRoleId?: string; bindGameChannel?: string },
|
||||
): BindingRoleComparison {
|
||||
const customerRoleName = String(task.customer_game_role || '').trim()
|
||||
const customerRoleId = String(task.customer_game_id || '').trim()
|
||||
const customerZone = normalizeServerZone(task.customer_game_server_zone)
|
||||
const boundRoleName = String(binding.bindGameRole || '').trim()
|
||||
const rawBoundRoleId = String(binding.bindGameRoleId || '').trim()
|
||||
// 虎牙 gameRole.roleId 是 40 位加密串,客户填写的是数值游戏编号;
|
||||
@@ -995,17 +1038,46 @@ export function compareBindingRole(
|
||||
const boundRoleId = /^\d+$/.test(rawBoundRoleId)
|
||||
? rawBoundRoleId
|
||||
: numericHuyaUid || rawBoundRoleId
|
||||
const base = { customerRoleName, customerRoleId, boundRoleName, boundRoleId }
|
||||
if (customerRoleId && boundRoleId) {
|
||||
return customerRoleId === boundRoleId
|
||||
? { ...base, verdict: 'match', message: '两侧角色 ID 一致,可确认绑定' }
|
||||
: { ...base, verdict: 'mismatch', message: '两侧角色 ID 不一致,无法确认绑定' }
|
||||
const boundZone = detectServerZone(binding.bindGameChannel)
|
||||
const base = {
|
||||
customerRoleName,
|
||||
customerRoleId,
|
||||
customerZone,
|
||||
boundRoleName,
|
||||
boundRoleId,
|
||||
boundZone,
|
||||
}
|
||||
if (customerRoleName && boundRoleName) {
|
||||
return normalizeRoleText(customerRoleName) === normalizeRoleText(boundRoleName)
|
||||
? { ...base, verdict: 'match', message: '两侧角色名称一致,可确认绑定' }
|
||||
: { ...base, verdict: 'mismatch', message: '两侧角色名称不一致,无法确认绑定' }
|
||||
|
||||
if (customerRoleId && boundRoleId && customerRoleId !== boundRoleId) {
|
||||
return { ...base, verdict: 'mismatch', message: '两侧角色 ID 不一致,无法确认绑定' }
|
||||
}
|
||||
|
||||
if (
|
||||
customerRoleName &&
|
||||
boundRoleName &&
|
||||
normalizeRoleText(customerRoleName) !== normalizeRoleText(boundRoleName)
|
||||
) {
|
||||
return { ...base, verdict: 'mismatch', message: '两侧角色名称不一致,无法确认绑定' }
|
||||
}
|
||||
|
||||
if (customerZone && boundZone && customerZone !== boundZone) {
|
||||
return { ...base, verdict: 'mismatch', message: '两侧区服不一致,无法确认绑定' }
|
||||
}
|
||||
|
||||
const matchedFields = [
|
||||
customerRoleId && boundRoleId ? '角色 ID' : '',
|
||||
customerRoleName && boundRoleName ? '角色名称' : '',
|
||||
customerZone && boundZone ? '区服' : '',
|
||||
].filter(Boolean)
|
||||
|
||||
if (matchedFields.length > 0) {
|
||||
return {
|
||||
...base,
|
||||
verdict: 'match',
|
||||
message: `两侧${matchedFields.join('、')}一致,可确认绑定`,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...base,
|
||||
verdict: 'unknown',
|
||||
@@ -1065,6 +1137,12 @@ async function updateBindingTask(
|
||||
gameRoleId: mapped.bindGameRoleId,
|
||||
gameChannel: mapped.bindGameChannel,
|
||||
verdict: comparison.verdict,
|
||||
rebindRequested: mapped.rebindRequested,
|
||||
rebindUnchanged: mapped.rebindUnchanged,
|
||||
rebindCooldownDays: mapped.rebindCooldownDays,
|
||||
nextRebindAt: mapped.nextRebindAt,
|
||||
changeBindDay: mapped.platformChangeBindDay,
|
||||
changeBindTime: mapped.platformChangeBindTime,
|
||||
message: mapped.message,
|
||||
},
|
||||
})
|
||||
@@ -1080,6 +1158,11 @@ async function updateBindingTask(
|
||||
bindGameChannel: mapped.bindGameChannel,
|
||||
hasExistingBinding: mapped.hasExistingBinding,
|
||||
rebindRequested: mapped.rebindRequested,
|
||||
rebindUnchanged: mapped.rebindUnchanged,
|
||||
rebindCooldownDays: mapped.rebindCooldownDays,
|
||||
nextRebindAt: mapped.nextRebindAt,
|
||||
platformChangeBindDay: mapped.platformChangeBindDay,
|
||||
platformChangeBindTime: mapped.platformChangeBindTime,
|
||||
message: mapped.message,
|
||||
comparison,
|
||||
}
|
||||
@@ -1271,6 +1354,15 @@ export async function confirmPublicBinding(orderNoInput: unknown, taskIdInput: u
|
||||
})
|
||||
}
|
||||
const session = await getBindingForTask(task, task.connector_session_id)
|
||||
if (task.platform === 'huya' && session.rebindUnchanged === true) {
|
||||
throw createHttpError(session.message || '换绑未生效:平台仍返回原绑定角色,请重新扫码', {
|
||||
statusCode: 409,
|
||||
errorCode:
|
||||
Number(session.rebindCooldownDays || 0) > 0
|
||||
? 'semi_auto_binding_rebind_cooldown'
|
||||
: 'semi_auto_binding_rebind_unchanged',
|
||||
})
|
||||
}
|
||||
const comparison = compareBindingRole(task, session)
|
||||
if (comparison.verdict === 'mismatch') {
|
||||
throw createHttpError(comparison.message, {
|
||||
@@ -1278,7 +1370,12 @@ export async function confirmPublicBinding(orderNoInput: unknown, taskIdInput: u
|
||||
errorCode: 'semi_auto_binding_role_mismatch',
|
||||
})
|
||||
}
|
||||
const binding = await updateBindingTask(task, session, 'customer')
|
||||
// 必须调用 Connector 完成确认,否则会话仍是 role_ready,数据库也会停在待确认。
|
||||
const confirmedSession =
|
||||
task.platform === 'huya'
|
||||
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode)
|
||||
: session
|
||||
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
||||
const updated = await loadTask(task.id)
|
||||
return { task: mapTask(updated), binding }
|
||||
}
|
||||
|
||||
@@ -727,6 +727,24 @@ export default function AdminSemiAutoTasksPage() {
|
||||
{formatAdminDateTime(event.createdAt)} · {event.actorType}
|
||||
{event.actorId ? ` ${event.actorId}` : ''}
|
||||
</Text>
|
||||
{event.eventType === 'binding_status_changed' && event.detail?.message ? (
|
||||
<Text
|
||||
type={
|
||||
event.detail.rebindUnchanged === true ||
|
||||
Number(event.detail.rebindCooldownDays || 0) > 0
|
||||
? 'warning'
|
||||
: 'secondary'
|
||||
}
|
||||
>
|
||||
{String(event.detail.message)}
|
||||
{Number(event.detail.rebindCooldownDays || 0) > 0 &&
|
||||
event.detail.nextRebindAt
|
||||
? ` · 下次可换绑 ${formatAdminDateTime(
|
||||
String(event.detail.nextRebindAt),
|
||||
)}`
|
||||
: ''}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
}))}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
CheckCircleFilled,
|
||||
ExclamationCircleOutlined,
|
||||
LoadingOutlined,
|
||||
QrcodeOutlined,
|
||||
ReloadOutlined,
|
||||
@@ -303,6 +304,8 @@ export default function CustomerFulfillmentPage() {
|
||||
useEffect(() => {
|
||||
if (!selectedTask || selectedTask.bindingStatus !== 'role_ready') return
|
||||
if (!bindingInfo?.comparison) return
|
||||
// 换绑后仍是原角色时只展示失败原因,不能自动弹出确认框。
|
||||
if (bindingInfo.rebindUnchanged) return
|
||||
const key = `${selectedTask.id}:${bindingInfo.bindGameRoleId || ''}`
|
||||
if (autoOpenedRoleRef.current === key) return
|
||||
autoOpenedRoleRef.current = key
|
||||
@@ -494,13 +497,44 @@ export default function CustomerFulfillmentPage() {
|
||||
setBindingLoading(true)
|
||||
try {
|
||||
const response = await pollCustomerBinding(orderNo, selectedTask.id)
|
||||
setTasks((current) =>
|
||||
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
||||
)
|
||||
if (response.data.binding) setBindingInfo(response.data.binding)
|
||||
if (openConfirm || response.data.task.bindingStatus === 'role_ready') {
|
||||
const nextTask = response.data.task
|
||||
const nextBinding = response.data.binding
|
||||
setTasks((current) => current.map((task) => (task.id === nextTask.id ? nextTask : task)))
|
||||
if (nextBinding) setBindingInfo(nextBinding)
|
||||
if (nextTask.bindingStatus === 'role_ready') {
|
||||
if (nextBinding?.rebindUnchanged) {
|
||||
setBindingConfirmOpen(false)
|
||||
message.warning(nextBinding.message || '换绑未生效,请查看下方原因')
|
||||
return
|
||||
}
|
||||
setBindingConfirmOpen(true)
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'confirmed') {
|
||||
setBindingConfirmOpen(false)
|
||||
message.success('绑定已确认,等待客服处理')
|
||||
return
|
||||
}
|
||||
// 弹窗内点「刷新」:角色不再是待确认状态时收起弹窗,避免展示过期比对。
|
||||
if (openConfirm) setBindingConfirmOpen(false)
|
||||
const detail = nextBinding?.message || ''
|
||||
if (nextTask.bindingStatus === 'scanned') {
|
||||
message.info(detail || '已扫码,正在等待虎牙平台换绑生效,请稍后再点击刷新')
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'qr_pending') {
|
||||
message.warning('还没有检测到扫码记录,请使用微信扫码完成绑定后再点击')
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'expired') {
|
||||
message.warning('绑定二维码已过期,请点击「刷新二维码」重新获取')
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'failed') {
|
||||
message.error(detail || '识别绑定角色失败,请点击「刷新二维码」重试')
|
||||
return
|
||||
}
|
||||
message.info(detail || '绑定状态还没有更新,请稍后再试')
|
||||
} catch (error) {
|
||||
if (isHuyaSessionExpired(error)) {
|
||||
setBindingSessionExpired(true)
|
||||
@@ -595,7 +629,8 @@ export default function CustomerFulfillmentPage() {
|
||||
selectedTask &&
|
||||
selectedTask.platform === 'huya' &&
|
||||
selectedTask.loginStatus === 'authenticated' &&
|
||||
selectedTask.bindingStatus !== 'confirmed',
|
||||
selectedTask.executionStatus !== 'completed' &&
|
||||
selectedTask.executionStatus !== 'cancelled',
|
||||
)
|
||||
const bindingQrVisible = ['not_started', 'qr_pending', 'scanned'].includes(
|
||||
selectedTask?.bindingStatus || '',
|
||||
@@ -610,6 +645,11 @@ export default function CustomerFulfillmentPage() {
|
||||
return /^\d+$/.test(huyaUid) ? huyaUid : comparisonId
|
||||
})()
|
||||
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
||||
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
||||
const rebindCooldownDays = Number(bindingInfo?.rebindCooldownDays || 0)
|
||||
const nextRebindText = bindingInfo?.nextRebindAt
|
||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||
: ''
|
||||
const showProfileForm = showBindingStage && profileEditing
|
||||
const bindingCustomerReady = Boolean(
|
||||
bindingComparison?.customerRoleId || bindingComparison?.customerRoleName,
|
||||
@@ -949,59 +989,76 @@ export default function CustomerFulfillmentPage() {
|
||||
) : null}
|
||||
|
||||
{!bindingSessionExpired ? (
|
||||
!bindingRoleId ? (
|
||||
<div className="customer-binding-alert is-warning">
|
||||
未获取到已绑定的角色ID,请重新扫码绑定
|
||||
</div>
|
||||
) : (
|
||||
rebindUnchanged ? (
|
||||
<div className="customer-binding-alert is-warning">换绑未生效,请查看下方原因</div>
|
||||
) : selectedTask?.bindingStatus === 'role_ready' ? (
|
||||
<div className="customer-binding-alert is-info">已识别绑定角色,请核对后确认</div>
|
||||
) : selectedTask?.bindingStatus === 'confirmed' || bindingRoleId ? (
|
||||
<div className="customer-binding-alert is-info">
|
||||
登录成功,请继续扫码绑定游戏角色
|
||||
</div>
|
||||
) : (
|
||||
<div className="customer-binding-alert is-warning">
|
||||
未获取到已绑定的角色ID,请重新扫码绑定
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{showProfileForm && !bindingSessionExpired ? (
|
||||
<div className="customer-auth-profile" id="customer-profile-form">
|
||||
<p>修改资料后会重新核对平台识别角色。</p>
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
<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="区服(必填)"
|
||||
placeholder="请选择区服"
|
||||
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
|
||||
/>
|
||||
<label className="customer-collect-label">
|
||||
游戏编号 <span>*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="customer-collect-input"
|
||||
value={profileRoleId}
|
||||
onChange={(event) => setProfileRoleId(event.target.value)}
|
||||
placeholder="游戏编号 / 角色 ID(必填,纯数字)"
|
||||
placeholder="请输入游戏编号"
|
||||
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="角色名(必填)"
|
||||
placeholder="请输入角色名"
|
||||
maxLength={100}
|
||||
/>
|
||||
<Button
|
||||
type="primary"
|
||||
block
|
||||
size="large"
|
||||
className="customer-collect-submit"
|
||||
loading={profileSaving}
|
||||
onClick={() => void handleSaveProfile()}
|
||||
>
|
||||
保存角色资料
|
||||
提交资料
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{bindingQrVisible && !bindingSessionExpired ? (
|
||||
<div className="customer-binding-qr-card">
|
||||
<h3>游戏角色绑定二维码</h3>
|
||||
{bindingQrImage || bindingInfo?.qrImage ? (
|
||||
{bindingInfo?.qrImage || bindingQrImage ? (
|
||||
<Image
|
||||
src={bindingQrImage || bindingInfo?.qrImage || ''}
|
||||
src={bindingInfo?.qrImage || bindingQrImage || ''}
|
||||
alt="游戏角色绑定二维码"
|
||||
width={260}
|
||||
preview={false}
|
||||
@@ -1013,10 +1070,20 @@ export default function CustomerFulfillmentPage() {
|
||||
</div>
|
||||
)}
|
||||
<p className="customer-binding-qr-hint">请使用微信APP扫码进行游戏角色绑定</p>
|
||||
<p className="customer-binding-qr-tip">手机端可长按二维码或截图保存图片再识别</p>
|
||||
<p className="customer-binding-qr-tip">
|
||||
{selectedTask?.bindingStatus === 'scanned'
|
||||
? '请在微信中完成角色绑定确认,再点击下方按钮进入下一步'
|
||||
: '扫码后请在微信确认框中核对目标角色;本活动 7 天内只能换绑 1 次'}
|
||||
</p>
|
||||
{rebindCooldownDays > 0 ? (
|
||||
<p className="customer-binding-qr-tip">
|
||||
平台提示:预计下次可换绑
|
||||
{nextRebindText ? ` ${nextRebindText}` : '需等待 7 天'};本次扫码可能不会生效。
|
||||
</p>
|
||||
) : null}
|
||||
<p className="customer-binding-qr-countdown">
|
||||
{selectedTask?.bindingStatus === 'scanned'
|
||||
? '已扫码,等待角色生效'
|
||||
? bindingInfo?.message || '已扫码,等待角色生效'
|
||||
: `建议 ${formatCountdown(bindingSecondsLeft)} 内完成扫码`}
|
||||
</p>
|
||||
<div className="customer-binding-qr-actions">
|
||||
@@ -1031,6 +1098,7 @@ export default function CustomerFulfillmentPage() {
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-next"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
已扫码绑定,点击进入下一步
|
||||
@@ -1070,15 +1138,41 @@ export default function CustomerFulfillmentPage() {
|
||||
|
||||
{selectedTask?.bindingStatus === 'role_ready' && !bindingSessionExpired ? (
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
|
||||
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel]
|
||||
.filter(Boolean)
|
||||
.join(' · ')}
|
||||
/>
|
||||
{!bindingRoleId ? (
|
||||
{rebindUnchanged ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="换绑未生效"
|
||||
description={
|
||||
<Space direction="vertical" size={2}>
|
||||
<span>
|
||||
扫码已完成,但平台仍返回原绑定角色:
|
||||
{bindingRoleName || '未识别到角色'}
|
||||
</span>
|
||||
{rebindCooldownDays > 0 ? (
|
||||
<span>
|
||||
原因:本活动 7 天内只能换绑 1 次
|
||||
{nextRebindText ? `,预计下次可换绑:${nextRebindText}` : ''}。
|
||||
</span>
|
||||
) : (
|
||||
<span>
|
||||
请在微信确认框中核对目标角色后重新换绑;如持续失败请联系客服。
|
||||
</span>
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
|
||||
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel]
|
||||
.filter(Boolean)
|
||||
.join(' · ')}
|
||||
/>
|
||||
)}
|
||||
{!bindingPendingUid && !rebindUnchanged ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
@@ -1086,29 +1180,76 @@ export default function CustomerFulfillmentPage() {
|
||||
description="没有角色 ID 时无法自动核对,请联系客服人工核实后再确认。"
|
||||
/>
|
||||
) : null}
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
loading={bindingLoading}
|
||||
onClick={() => setBindingConfirmOpen(true)}
|
||||
>
|
||||
确认绑定角色
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
角色不对,重新扫码换绑
|
||||
</Button>
|
||||
</Space>
|
||||
{rebindUnchanged ? (
|
||||
<div className="customer-binding-role-actions">
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
重新扫码换绑
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
刷新绑定状态
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="customer-binding-role-actions">
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
loading={bindingLoading}
|
||||
onClick={() => setBindingConfirmOpen(true)}
|
||||
>
|
||||
确认绑定角色
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
角色不对,重新扫码换绑
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Space>
|
||||
) : null}
|
||||
|
||||
{selectedTask?.bindingStatus === 'confirmed' ? (
|
||||
<div className="customer-binding-verify">
|
||||
<p>绑定状态需要平台人工核实,请联系客服处理</p>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-login-alt"
|
||||
loading={bindingLoading}
|
||||
onClick={() => {
|
||||
setBindingLoading(true)
|
||||
void load(true).finally(() => setBindingLoading(false))
|
||||
}}
|
||||
>
|
||||
刷新绑定状态
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{selectedTask?.loginStatus === 'authenticated' &&
|
||||
(isWeibo || selectedTask.bindingStatus === 'confirmed') &&
|
||||
{isWeibo &&
|
||||
selectedTask?.loginStatus === 'authenticated' &&
|
||||
selectedTask.executionStatus !== 'completed' ? (
|
||||
<div className="customer-auth-state is-waiting">
|
||||
<div className="customer-auth-state-icon">
|
||||
@@ -1127,7 +1268,9 @@ export default function CustomerFulfillmentPage() {
|
||||
) : null}
|
||||
|
||||
<Modal
|
||||
open={bindingConfirmOpen && selectedTask?.bindingStatus === 'role_ready'}
|
||||
open={
|
||||
bindingConfirmOpen && selectedTask?.bindingStatus === 'role_ready' && !rebindUnchanged
|
||||
}
|
||||
title="确认绑定角色"
|
||||
onCancel={() => {
|
||||
if (!bindingLoading) setBindingConfirmOpen(false)
|
||||
@@ -1152,7 +1295,9 @@ export default function CustomerFulfillmentPage() {
|
||||
</Button>
|
||||
</div>
|
||||
{bindingComparison?.verdict === 'mismatch' ? (
|
||||
<p className="customer-binding-modal-error">两侧角色ID不一致,无法确认绑定</p>
|
||||
<p className="customer-binding-modal-error">
|
||||
{bindingComparison?.message || '两侧角色信息不一致,无法确认绑定'}
|
||||
</p>
|
||||
) : bindingComparison?.verdict === 'unknown' ? (
|
||||
<p className="customer-binding-modal-warning">两侧角色信息不完整,请联系客服核实</p>
|
||||
) : null}
|
||||
|
||||
@@ -1855,7 +1855,7 @@
|
||||
}
|
||||
|
||||
.customer-auth-page .ant-btn-primary {
|
||||
color: #111827;
|
||||
color: #fff;
|
||||
border-color: var(--auth-accent);
|
||||
background: var(--auth-accent);
|
||||
font-weight: 700;
|
||||
@@ -1863,7 +1863,7 @@
|
||||
}
|
||||
|
||||
.customer-auth-page .ant-btn-primary:hover {
|
||||
color: #111827 !important;
|
||||
color: #fff !important;
|
||||
border-color: var(--auth-accent-hover) !important;
|
||||
background: var(--auth-accent-hover) !important;
|
||||
}
|
||||
@@ -2087,7 +2087,13 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.customer-auth-profile,
|
||||
.customer-auth-profile {
|
||||
padding: 16px;
|
||||
border: 1px solid #3a4150;
|
||||
border-radius: 12px;
|
||||
background: #212733;
|
||||
}
|
||||
|
||||
.customer-auth-profile-summary {
|
||||
padding: 14px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
@@ -2096,12 +2102,22 @@
|
||||
}
|
||||
|
||||
.customer-auth-profile > p {
|
||||
margin: 0 0 10px;
|
||||
color: var(--auth-muted);
|
||||
margin: 0 0 12px;
|
||||
color: #9aa3b2;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.customer-profile-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.customer-profile-form .customer-collect-label {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.customer-auth-profile-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -2322,7 +2338,8 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.customer-collect-page .customer-collect-submit.ant-btn {
|
||||
.customer-collect-page .customer-collect-submit.ant-btn,
|
||||
.customer-auth-profile .customer-collect-submit.ant-btn {
|
||||
height: 56px;
|
||||
margin-top: 14px;
|
||||
border-radius: 14px;
|
||||
@@ -2343,7 +2360,9 @@
|
||||
}
|
||||
|
||||
.customer-collect-page .customer-collect-submit.ant-btn:hover,
|
||||
.customer-collect-page .customer-collect-submit.ant-btn:focus-visible {
|
||||
.customer-collect-page .customer-collect-submit.ant-btn:focus-visible,
|
||||
.customer-auth-profile .customer-collect-submit.ant-btn:hover,
|
||||
.customer-auth-profile .customer-collect-submit.ant-btn:focus-visible {
|
||||
background: #1d4ed8 !important;
|
||||
border-color: #1d4ed8 !important;
|
||||
color: #fff !important;
|
||||
@@ -2479,6 +2498,114 @@
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
/* antd Alert 在绑定阶段统一走深色卡片,避免浅色块破坏整体深色风格 */
|
||||
.customer-binding-stage .ant-alert {
|
||||
align-items: flex-start;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #3a4150;
|
||||
border-radius: 12px;
|
||||
background: #212733;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert .ant-alert-message {
|
||||
color: #e2e8f0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert .ant-alert-description {
|
||||
color: #cbd5e1;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-warning {
|
||||
border-color: #78350f;
|
||||
background: rgba(120, 53, 15, 0.22);
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-warning .ant-alert-icon,
|
||||
.customer-binding-stage .ant-alert-warning .ant-alert-message {
|
||||
color: #fbbf24;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-warning .ant-alert-description {
|
||||
color: #fcd34d;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-error {
|
||||
border-color: #7f1d1d;
|
||||
background: rgba(127, 29, 29, 0.24);
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-error .ant-alert-icon,
|
||||
.customer-binding-stage .ant-alert-error .ant-alert-message {
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-error .ant-alert-description {
|
||||
color: #fecaca;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-success {
|
||||
border-color: #065f46;
|
||||
background: rgba(6, 78, 59, 0.28);
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-success .ant-alert-icon,
|
||||
.customer-binding-stage .ant-alert-success .ant-alert-message {
|
||||
color: #6ee7b7;
|
||||
}
|
||||
|
||||
.customer-binding-stage .ant-alert-success .ant-alert-description {
|
||||
color: #a7f3d0;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions .customer-binding-confirm.ant-btn {
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
background: #2563eb !important;
|
||||
border-color: #2563eb !important;
|
||||
color: #fff !important;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions .customer-binding-confirm.ant-btn:hover,
|
||||
.customer-binding-role-actions .customer-binding-confirm.ant-btn:focus-visible {
|
||||
background: #1d4ed8 !important;
|
||||
border-color: #1d4ed8 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions .customer-binding-rebind.ant-btn {
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
background: transparent !important;
|
||||
border-color: #3a4150 !important;
|
||||
color: #cbd5e1 !important;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions .customer-binding-rebind.ant-btn .anticon {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.customer-binding-role-actions .customer-binding-rebind.ant-btn:hover,
|
||||
.customer-binding-role-actions .customer-binding-rebind.ant-btn:focus-visible {
|
||||
background: rgba(245, 158, 11, 0.08) !important;
|
||||
border-color: #b45309 !important;
|
||||
color: #fbbf24 !important;
|
||||
}
|
||||
|
||||
.customer-binding-info {
|
||||
padding: 16px;
|
||||
border: 1px solid #3a4150;
|
||||
@@ -2543,6 +2670,24 @@
|
||||
background: rgba(30, 58, 138, 0.3);
|
||||
}
|
||||
|
||||
.customer-binding-verify {
|
||||
padding: 18px;
|
||||
border: 1px solid #3a4150;
|
||||
border-radius: 12px;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.customer-binding-verify p {
|
||||
margin: 0;
|
||||
color: #e5e7eb;
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.customer-binding-qr-card {
|
||||
padding: 18px;
|
||||
border-radius: 12px;
|
||||
|
||||
@@ -57,6 +57,11 @@ export type CustomerBindingInfo = {
|
||||
bindGameChannel: string
|
||||
hasExistingBinding: boolean
|
||||
rebindRequested: boolean
|
||||
rebindUnchanged: boolean
|
||||
rebindCooldownDays: number
|
||||
nextRebindAt: string
|
||||
platformChangeBindDay?: number
|
||||
platformChangeBindTime?: number
|
||||
message: string
|
||||
comparison: CustomerBindingComparison
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user