fix(semi-auto): 换绑未生效原因与 7 天冷却提示

This commit is contained in:
2026-11-16 13:30:26 +08:00
parent 19367bdfdf
commit 5aa627a0ca
10 changed files with 781 additions and 93 deletions
@@ -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',