feat(semi-auto): 虎牙客户页登录→资料→绑定流程与返回上一步重置
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
pollPublicBinding,
|
pollPublicBinding,
|
||||||
pollPublicLogin,
|
pollPublicLogin,
|
||||||
pollPublicWeiboQrLogin,
|
pollPublicWeiboQrLogin,
|
||||||
|
resetPublicBinding,
|
||||||
savePublicTaskProfile,
|
savePublicTaskProfile,
|
||||||
sendPublicHuyaSmsCode,
|
sendPublicHuyaSmsCode,
|
||||||
sendPublicWeiboSmsCode,
|
sendPublicWeiboSmsCode,
|
||||||
@@ -98,6 +99,16 @@ router.post(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/:orderNo/tasks/:taskId/binding/reset',
|
||||||
|
writeLimit,
|
||||||
|
createRouteHandler((req) => resetPublicBinding(req.params.orderNo, req.params.taskId), {
|
||||||
|
successMessage: '已返回修改资料',
|
||||||
|
errorMessage: '重置换绑状态失败',
|
||||||
|
scope: '[customer-fulfillment/:orderNo/tasks/:taskId/binding/reset]',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/:orderNo/tasks/:taskId/binding/start',
|
'/:orderNo/tasks/:taskId/binding/start',
|
||||||
writeLimit,
|
writeLimit,
|
||||||
|
|||||||
@@ -487,6 +487,23 @@ export async function confirmHuyaBinding(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户返回上一步修改资料:只重置绑定/换绑状态,不注销登录会话、不删除客户资料。
|
||||||
|
* 外部 Connector 通过独立 reset 端点实现;未提供时由调用方决定是否继续。
|
||||||
|
*/
|
||||||
|
export async function resetHuyaBinding(
|
||||||
|
sessionId: string,
|
||||||
|
mode: SemiAutoConnectorMode = defaultSemiAutoConnectorMode(),
|
||||||
|
): Promise<ConnectorBindingSession> {
|
||||||
|
if (mode === 'embedded') return huyaNativeConnector.resetBinding(sessionId)
|
||||||
|
if (mode === 'mock') return startHuyaBinding(sessionId, mode, {})
|
||||||
|
return callConnector<ConnectorBindingSession>(
|
||||||
|
`/api/internal/huya-semi-auto/sessions/${encodeURIComponent(sessionId)}/binding/reset`,
|
||||||
|
{ method: 'POST', body: {} },
|
||||||
|
mode,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码后由项目侧主动向虎牙提交换绑确认。
|
* 扫码后由项目侧主动向虎牙提交换绑确认。
|
||||||
* 外部 Connector 暂未提供独立端点时复用 confirm 端点(语义一致,幂等)。
|
* 外部 Connector 暂未提供独立端点时复用 confirm 端点(语义一致,幂等)。
|
||||||
|
|||||||
@@ -1152,6 +1152,20 @@ export class HuyaNativeConnector {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户点「上一步修改资料」:清空本次绑定/换绑状态,保留登录会话。
|
||||||
|
* 重新提交资料后会重新查询平台角色,按新资料重新比对,不会继承旧的换绑失败状态。
|
||||||
|
*/
|
||||||
|
async resetBinding(sessionId: string): Promise<ConnectorBindingSession> {
|
||||||
|
return this.withLock(sessionId, async () => {
|
||||||
|
const session = this.requireAuthenticatedSession(sessionId)
|
||||||
|
session.binding = defaultBindingState()
|
||||||
|
session.binding.account = session.nickname
|
||||||
|
session.binding.message = '已返回上一步修改资料,提交后会重新识别平台角色'
|
||||||
|
return this.bindingView(session)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户点「确认绑定」:只做本地状态流转,不调用虎牙接口。
|
* 客户点「确认绑定」:只做本地状态流转,不调用虎牙接口。
|
||||||
* 虎牙侧的绑定已由扫码(小程序/弹窗)完成,确认绑定只是核对三项后落库;
|
* 虎牙侧的绑定已由扫码(小程序/弹窗)完成,确认绑定只是核对三项后落库;
|
||||||
|
|||||||
@@ -44,20 +44,26 @@ describe('待确认角色 UID 取数(huyaUid)', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('虎牙加密串角色 ID 改用 huyaUid 参与比对', () => {
|
it('虎牙加密串角色 ID 改用 huyaUid 参与比对', () => {
|
||||||
const result = compareBindingRole(task('1199608910400', '大鲨鱼伊塞53', '1199608910400'), {
|
const result = compareBindingRole(
|
||||||
bindGameRole: '大鲨鱼伊塞53',
|
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '安卓V区'),
|
||||||
bindGameRoleId: '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea',
|
{
|
||||||
})
|
bindGameRole: '大鲨鱼伊塞53',
|
||||||
|
bindGameRoleId: '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea',
|
||||||
|
bindGameChannel: '安卓(android) · 微信',
|
||||||
|
},
|
||||||
|
)
|
||||||
assert.equal(result.verdict, 'match')
|
assert.equal(result.verdict, 'match')
|
||||||
assert.equal(result.boundRoleId, '1199608910400')
|
assert.equal(result.boundRoleId, '1199608910400')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('没有 huyaUid 时保留原始加密串,仍判不一致', () => {
|
it('没有 huyaUid 时无法核对加密角色 ID,判 unknown', () => {
|
||||||
const result = compareBindingRole(task('1199608910400', '大鲨鱼伊塞53'), {
|
const result = compareBindingRole(task('1199608910400', '大鲨鱼伊塞53', '', '安卓V区'), {
|
||||||
bindGameRole: '大鲨鱼伊塞53',
|
bindGameRole: '大鲨鱼伊塞53',
|
||||||
bindGameRoleId: '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea',
|
bindGameRoleId: '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea',
|
||||||
|
bindGameChannel: '安卓(android) · 微信',
|
||||||
})
|
})
|
||||||
assert.equal(result.verdict, 'mismatch')
|
assert.equal(result.verdict, 'unknown')
|
||||||
|
assert.match(result.message, /平台可核对角色ID/)
|
||||||
assert.equal(result.boundRoleId, '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea')
|
assert.equal(result.boundRoleId, '834ee3e75a1bfc9f65fb6b966bac7ef318e68ea')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -157,7 +163,7 @@ describe('客户填写角色与平台识别角色比对', () => {
|
|||||||
assert.equal(result.boundZone, '安卓V区')
|
assert.equal(result.boundZone, '安卓V区')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('渠道解析不出区服时跳过区服比对', () => {
|
it('渠道解析不出区服时判 unknown,不允许提交', () => {
|
||||||
const result = compareBindingRole(
|
const result = compareBindingRole(
|
||||||
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '苹果Q区'),
|
task('1199608910400', '大鲨鱼伊塞53', '1199608910400', '苹果Q区'),
|
||||||
{
|
{
|
||||||
@@ -166,41 +172,51 @@ describe('客户填写角色与平台识别角色比对', () => {
|
|||||||
bindGameChannel: '微信用户',
|
bindGameChannel: '微信用户',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert.equal(result.verdict, 'match')
|
assert.equal(result.verdict, 'unknown')
|
||||||
|
assert.match(result.message, /平台区服/)
|
||||||
assert.equal(result.boundZone, '')
|
assert.equal(result.boundZone, '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('两侧角色 ID 一致时允许确认', () => {
|
it('客户区服未填时判 unknown,不允许提交', () => {
|
||||||
const result = compareBindingRole(task('1192083858', '巫师基尔斯84'), {
|
const result = compareBindingRole(task('1199608910400', '大鲨鱼伊塞53', '1199608910400', ''), {
|
||||||
|
bindGameRole: '大鲨鱼伊塞53',
|
||||||
|
bindGameRoleId: '1199608910400',
|
||||||
|
bindGameChannel: '安卓(android) · 微信',
|
||||||
|
})
|
||||||
|
assert.equal(result.verdict, 'unknown')
|
||||||
|
assert.match(result.message, /客户区服/)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('三项一致时允许提交平台绑定', () => {
|
||||||
|
const result = compareBindingRole(task('1192083858', '巫师基尔斯84', '1192083858', '安卓Q区'), {
|
||||||
bindGameRole: '巫师基尔斯84',
|
bindGameRole: '巫师基尔斯84',
|
||||||
bindGameRoleId: '1192083858',
|
bindGameRoleId: '1192083858',
|
||||||
|
bindGameChannel: '安卓(android) · QQ',
|
||||||
})
|
})
|
||||||
assert.equal(result.verdict, 'match')
|
assert.equal(result.verdict, 'match')
|
||||||
assert.equal(result.customerRoleId, '1192083858')
|
assert.equal(result.customerRoleId, '1192083858')
|
||||||
assert.equal(result.boundRoleId, '1192083858')
|
assert.equal(result.boundRoleId, '1192083858')
|
||||||
|
assert.match(result.message, /可提交平台绑定/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('两侧角色 ID 不一致时禁止确认', () => {
|
it('两侧角色 ID 不一致时禁止提交', () => {
|
||||||
const result = compareBindingRole(task('1192083858', '巫师基尔斯84'), {
|
const result = compareBindingRole(task('1192083858', '巫师基尔斯84', '', '安卓V区'), {
|
||||||
bindGameRole: '我是火星人2222',
|
bindGameRole: '我是火星人2222',
|
||||||
bindGameRoleId: '166909256',
|
bindGameRoleId: '166909256',
|
||||||
|
bindGameChannel: '安卓(android) · 微信',
|
||||||
})
|
})
|
||||||
assert.equal(result.verdict, 'mismatch')
|
assert.equal(result.verdict, 'mismatch')
|
||||||
assert.match(result.message, /不一致/)
|
assert.match(result.message, /不一致/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('缺少角色 ID 时退回角色名称比对', () => {
|
it('任一侧缺少角色 ID 时判 unknown,不退化为只比角色名', () => {
|
||||||
const matched = compareBindingRole(task('', '巫师基尔斯84'), {
|
const result = compareBindingRole(task('', '巫师基尔斯84'), {
|
||||||
bindGameRole: '巫师基尔斯84',
|
bindGameRole: '巫师基尔斯84',
|
||||||
bindGameRoleId: '',
|
bindGameRoleId: '',
|
||||||
})
|
})
|
||||||
assert.equal(matched.verdict, 'match')
|
assert.equal(result.verdict, 'unknown')
|
||||||
|
assert.match(result.message, /客户游戏编号/)
|
||||||
const mismatched = compareBindingRole(task('', '巫师基尔斯84'), {
|
assert.match(result.message, /平台可核对角色ID/)
|
||||||
bindGameRole: '我是火星人2222',
|
|
||||||
bindGameRoleId: '',
|
|
||||||
})
|
|
||||||
assert.equal(mismatched.verdict, 'mismatch')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('两侧都没有可核对信息时标记为 unknown', () => {
|
it('两侧都没有可核对信息时标记为 unknown', () => {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
getHuyaBindingSnapshot,
|
getHuyaBindingSnapshot,
|
||||||
getHuyaLoginSession,
|
getHuyaLoginSession,
|
||||||
loginHuyaSms,
|
loginHuyaSms,
|
||||||
|
resetHuyaBinding,
|
||||||
revokeHuyaSession,
|
revokeHuyaSession,
|
||||||
sendHuyaSmsCode,
|
sendHuyaSmsCode,
|
||||||
startHuyaBinding,
|
startHuyaBinding,
|
||||||
@@ -178,6 +179,17 @@ function normalizeOrderNo(value: unknown): string {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 客户资料以 TASK_SELECT 合并后的字段为准:优先任务表,回退工单资料。 */
|
||||||
|
export function hasCustomerProfile(
|
||||||
|
task: Pick<TaskRow, 'customer_game_id' | 'customer_game_role' | 'customer_server_zone'>,
|
||||||
|
): boolean {
|
||||||
|
return Boolean(
|
||||||
|
String(task.customer_game_id || '').trim() &&
|
||||||
|
String(task.customer_game_role || '').trim() &&
|
||||||
|
String(task.customer_server_zone || '').trim(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function displayStatus(task: TaskRow) {
|
function displayStatus(task: TaskRow) {
|
||||||
if (task.execution_status === 'completed') return { key: 'completed', label: '已完成' }
|
if (task.execution_status === 'completed') return { key: 'completed', label: '已完成' }
|
||||||
if (task.execution_status === 'cancelled') return { key: 'cancelled', label: '已取消' }
|
if (task.execution_status === 'cancelled') return { key: 'cancelled', label: '已取消' }
|
||||||
@@ -192,6 +204,9 @@ function displayStatus(task: TaskRow) {
|
|||||||
if (task.platform === 'weibo' || task.binding_status === 'confirmed') {
|
if (task.platform === 'weibo' || task.binding_status === 'confirmed') {
|
||||||
return { key: 'waiting_operator', label: '等待客服处理' }
|
return { key: 'waiting_operator', label: '等待客服处理' }
|
||||||
}
|
}
|
||||||
|
if (task.platform === 'huya' && !hasCustomerProfile(task)) {
|
||||||
|
return { key: 'waiting_profile', label: '待客户填写资料' }
|
||||||
|
}
|
||||||
if (task.binding_status === 'role_ready') {
|
if (task.binding_status === 'role_ready') {
|
||||||
return { key: 'binding_confirm', label: '待确认绑定角色' }
|
return { key: 'binding_confirm', label: '待确认绑定角色' }
|
||||||
}
|
}
|
||||||
@@ -413,16 +428,13 @@ function assertHuyaTask(task: TaskRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 半自动订单没有工单,资料页 /c/<订单号>(虎牙)或 /d/<订单号>(微博)是唯一入口。
|
* 半自动订单没有工单时,客户资料在登录后由 /c/<订单号> 收集;
|
||||||
* 未提交区服 / 游戏编号 / 角色名时,不允许开始登录,避免后续无法比对角色。
|
* 任务表为空但工单素材已有资料时,TASK_SELECT 会合并回退字段。
|
||||||
|
* 进入绑定/确认/换绑前必须已有完整三项资料。
|
||||||
*/
|
*/
|
||||||
function assertCustomerProfileReady(task: TaskRow) {
|
function assertCustomerProfileReady(task: TaskRow) {
|
||||||
if (task.platform !== 'huya') return
|
if (task.platform !== 'huya') return
|
||||||
if (
|
if (!hasCustomerProfile(task)) {
|
||||||
!String(task.customer_game_server_zone || '').trim() ||
|
|
||||||
!String(task.customer_game_role_id || '').trim() ||
|
|
||||||
!String(task.customer_game_role_name || '').trim()
|
|
||||||
) {
|
|
||||||
throw createHttpError('请先提交游戏角色资料', {
|
throw createHttpError('请先提交游戏角色资料', {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
errorCode: 'semi_auto_profile_required',
|
errorCode: 'semi_auto_profile_required',
|
||||||
@@ -824,6 +836,13 @@ 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) => {
|
||||||
await client.query(
|
await client.query(
|
||||||
@@ -1003,7 +1022,7 @@ function normalizeServerZone(value: unknown): string {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 从虎牙渠道串解析区服,例如「安卓(android) · 微信」→ 安卓V区。
|
* 从虎牙渠道串解析区服,例如「安卓(android) · 微信」→ 安卓V区。
|
||||||
* 解析不出平台或登录方式时返回空串,调用方跳过区服比对。
|
* 解析不出平台或登录方式时返回空串,比对时按「平台区服缺失」处理(判 unknown)。
|
||||||
*/
|
*/
|
||||||
export function detectServerZone(channel: unknown): string {
|
export function detectServerZone(channel: unknown): string {
|
||||||
const text = String(channel ?? '')
|
const text = String(channel ?? '')
|
||||||
@@ -1022,13 +1041,14 @@ export function detectServerZone(channel: unknown): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户填写角色与平台识别角色必须一致才允许确认绑定。
|
* 客户填写角色与平台识别角色必须完全一致才允许提交平台绑定。
|
||||||
*
|
*
|
||||||
* 区服、角色名、角色 ID 三项都要一致:
|
* 区服、角色名、角色 ID 三项必须全部存在且一致:
|
||||||
* ① 两侧都有 ID 时 ID 必须相等;
|
* ① 客户游戏编号 = 虎牙账号 UID,与平台可核对角色 ID 相等;
|
||||||
* ② 两侧都有角色名时名称必须相等(不能因为 ID 相同就放行改名);
|
* ② 角色名按规范化文本相等(忽略空白与大小写差异不能放行改名);
|
||||||
* ③ 平台渠道能解析出区服且客户有填时,区服必须相等。
|
* ③ 平台渠道能解析出区服且与客户所填区服相等。
|
||||||
* 任一侧缺某字段时跳过该字段比对;三项都取不到才判 unknown,转客服核对。
|
* 任一侧缺任一项(含平台只给加密 roleId 且拿不到 UID)判 unknown,转客服核对;
|
||||||
|
* 任一项不等判 mismatch,不允许提交平台绑定。
|
||||||
*/
|
*/
|
||||||
export function compareBindingRole(
|
export function compareBindingRole(
|
||||||
task: Pick<
|
task: Pick<
|
||||||
@@ -1060,40 +1080,38 @@ export function compareBindingRole(
|
|||||||
boundZone,
|
boundZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customerRoleId && boundRoleId && customerRoleId !== boundRoleId) {
|
// 客户确认的口径:区服、角色名、角色 ID 三项必须全部存在且一致。
|
||||||
return { ...base, verdict: 'mismatch', message: '两侧角色 ID 不一致,无法确认绑定' }
|
const missing: string[] = []
|
||||||
}
|
if (!customerRoleId) missing.push('客户游戏编号')
|
||||||
|
if (!customerRoleName) missing.push('客户角色名')
|
||||||
if (
|
if (!customerZone) missing.push('客户区服')
|
||||||
customerRoleName &&
|
if (!boundRoleId || !isNumericBindingRoleId(boundRoleId)) missing.push('平台可核对角色ID')
|
||||||
boundRoleName &&
|
if (!boundRoleName) missing.push('平台角色名')
|
||||||
normalizeRoleText(customerRoleName) !== normalizeRoleText(boundRoleName)
|
if (!boundZone) missing.push('平台区服')
|
||||||
) {
|
if (missing.length > 0) {
|
||||||
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 {
|
return {
|
||||||
...base,
|
...base,
|
||||||
verdict: 'match',
|
verdict: 'unknown',
|
||||||
message: `两侧${matchedFields.join('、')}一致,可确认绑定`,
|
message: `缺少${missing.join('、')},无法核对绑定角色,请联系客服`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (customerRoleId !== boundRoleId) {
|
||||||
|
return { ...base, verdict: 'mismatch', message: '两侧角色 ID 不一致,无法提交平台绑定' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalizeRoleText(customerRoleName) !== normalizeRoleText(boundRoleName)) {
|
||||||
|
return { ...base, verdict: 'mismatch', message: '两侧角色名称不一致,无法提交平台绑定' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (customerZone !== boundZone) {
|
||||||
|
return { ...base, verdict: 'mismatch', message: '两侧区服不一致,无法提交平台绑定' }
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...base,
|
...base,
|
||||||
verdict: 'unknown',
|
verdict: 'match',
|
||||||
message: '未获取到可核对的两侧角色信息,请联系客服核对后再确认',
|
message: '两侧区服、角色名称、角色 ID 一致,可提交平台绑定',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1206,7 +1224,6 @@ export async function startPublicLogin(orderNoInput: unknown, taskIdInput: unkno
|
|||||||
const taskId = normalizeId(taskIdInput)
|
const taskId = normalizeId(taskIdInput)
|
||||||
await ensureSemiAutoTasksForOrder(orderNo)
|
await ensureSemiAutoTasksForOrder(orderNo)
|
||||||
const task = await loadTaskForOrder(orderNo, taskId)
|
const task = await loadTaskForOrder(orderNo, taskId)
|
||||||
assertCustomerProfileReady(task)
|
|
||||||
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
||||||
throw createHttpError('当前订单已结束,不能重新登录', {
|
throw createHttpError('当前订单已结束,不能重新登录', {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -1340,6 +1357,7 @@ export async function startPublicBinding(
|
|||||||
errorCode: 'semi_auto_login_required',
|
errorCode: 'semi_auto_login_required',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
assertCustomerProfileReady(task)
|
||||||
const session =
|
const session =
|
||||||
task.platform === 'weibo'
|
task.platform === 'weibo'
|
||||||
? await getWeiboBinding(task.connector_session_id, task.connector_mode)
|
? await getWeiboBinding(task.connector_session_id, task.connector_mode)
|
||||||
@@ -1351,6 +1369,81 @@ export async function startPublicBinding(
|
|||||||
return { task: mapTask(updated), binding }
|
return { task: mapTask(updated), binding }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户在失败/不一致页面点「上一步修改资料」:
|
||||||
|
* 清空绑定/换绑状态,保留登录会话和客户资料;重新提交资料后重新走绑定流程。
|
||||||
|
*/
|
||||||
|
export async function resetPublicBinding(orderNoInput: unknown, taskIdInput: unknown) {
|
||||||
|
const orderNo = normalizeOrderNo(orderNoInput)
|
||||||
|
const taskId = normalizeId(taskIdInput)
|
||||||
|
const task = await loadTaskForOrder(orderNo, taskId)
|
||||||
|
if (task.platform !== 'huya') {
|
||||||
|
throw createHttpError('当前平台不需要重置绑定状态', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'semi_auto_binding_reset_not_supported',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
||||||
|
throw createHttpError('当前订单已结束,不能返回修改资料', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'semi_auto_task_closed',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (task.binding_status === 'confirmed') {
|
||||||
|
throw createHttpError('绑定已确认,不能返回修改资料', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'semi_auto_profile_locked',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!task.connector_session_id || task.login_status !== 'authenticated') {
|
||||||
|
throw createHttpError('请先完成平台登录', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'semi_auto_login_required',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空 Connector 内存里的换绑失败状态;外部 Connector 尚未提供 reset 时,
|
||||||
|
// 本地状态仍重置,客户可继续修改资料,不能被旧的失败状态卡死。
|
||||||
|
try {
|
||||||
|
await resetHuyaBinding(task.connector_session_id, task.connector_mode)
|
||||||
|
} catch {
|
||||||
|
// 仅清理本地持久化状态;下一次绑定会重新查询平台角色。
|
||||||
|
}
|
||||||
|
|
||||||
|
await withTransaction(async (client) => {
|
||||||
|
await client.query(
|
||||||
|
`
|
||||||
|
UPDATE semi_auto_tasks
|
||||||
|
SET binding_status = 'not_started',
|
||||||
|
bind_game_role = '',
|
||||||
|
bind_game_role_id = '',
|
||||||
|
bind_game_channel = '',
|
||||||
|
binding_started_at = NULL,
|
||||||
|
bound_at = NULL,
|
||||||
|
execution_status = 'waiting_customer',
|
||||||
|
last_error = '',
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE id = $1
|
||||||
|
`,
|
||||||
|
[task.id],
|
||||||
|
)
|
||||||
|
await appendTaskEvent(client, task.id, {
|
||||||
|
eventType: 'binding_reset',
|
||||||
|
actorType: 'customer',
|
||||||
|
fromBindingStatus: task.binding_status,
|
||||||
|
toBindingStatus: 'not_started',
|
||||||
|
fromExecutionStatus: task.execution_status,
|
||||||
|
toExecutionStatus: 'waiting_customer',
|
||||||
|
detail: {
|
||||||
|
reason: 'customer_profile_edit',
|
||||||
|
customerProfileKept: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const updated = await loadTask(task.id)
|
||||||
|
return { task: mapTask(updated), binding: null }
|
||||||
|
}
|
||||||
|
|
||||||
export async function pollPublicBinding(orderNoInput: unknown, taskIdInput: unknown) {
|
export async function pollPublicBinding(orderNoInput: unknown, taskIdInput: unknown) {
|
||||||
const orderNo = normalizeOrderNo(orderNoInput)
|
const orderNo = normalizeOrderNo(orderNoInput)
|
||||||
const taskId = normalizeId(taskIdInput)
|
const taskId = normalizeId(taskIdInput)
|
||||||
@@ -1390,52 +1483,49 @@ export async function confirmPublicBinding(
|
|||||||
errorCode: 'semi_auto_binding_not_ready',
|
errorCode: 'semi_auto_binding_not_ready',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
assertCustomerProfileReady(task)
|
||||||
// 确认绑定是纯本地动作:虎牙侧只读内存快照,不再触发角色查询或换绑提交。
|
// 确认绑定是纯本地动作:虎牙侧只读内存快照,不再触发角色查询或换绑提交。
|
||||||
const session =
|
const session =
|
||||||
task.platform === 'huya'
|
task.platform === 'huya'
|
||||||
? await getHuyaBindingSnapshot(task.connector_session_id, task.connector_mode)
|
? await getHuyaBindingSnapshot(task.connector_session_id, task.connector_mode)
|
||||||
: await getBindingForTask(task, task.connector_session_id)
|
: await getBindingForTask(task, task.connector_session_id)
|
||||||
|
const comparison = compareBindingRole(task, session)
|
||||||
|
// 换绑被虎牙拒绝时平台仍返回原角色。若客户已把资料改成与原角色一致,
|
||||||
|
// 允许直接确认;否则要求重新扫码或返回上一步修改资料。
|
||||||
if (
|
if (
|
||||||
task.platform === 'huya' &&
|
task.platform === 'huya' &&
|
||||||
session.rebindUnchanged === true &&
|
session.rebindUnchanged === true &&
|
||||||
options.acceptExistingRole !== true
|
comparison.verdict !== 'match'
|
||||||
) {
|
) {
|
||||||
// 换绑被虎牙拒绝时不直接放行,要求客户二选一:重新扫码换绑 / 仍使用原角色。
|
|
||||||
const reason = String(session.rebindConfirmMessage || '').trim()
|
const reason = String(session.rebindConfirmMessage || '').trim()
|
||||||
throw createHttpError(
|
throw createHttpError(
|
||||||
`${
|
`${
|
||||||
reason ? `换绑未成功:${reason}。` : '换绑未生效:平台仍返回原绑定角色。'
|
reason ? `换绑未成功:${reason}。` : '换绑未生效:平台仍返回原绑定角色。'
|
||||||
}请重新扫码换绑,或确认继续使用原绑定角色「${session.bindGameRole || '原角色'}」`,
|
}请重新扫码换绑,或返回上一步修改资料,使资料与平台当前角色一致后再提交平台绑定`,
|
||||||
{
|
{
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
errorCode: 'semi_auto_binding_rebind_decision_required',
|
errorCode: 'semi_auto_binding_rebind_decision_required',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// 已绑定角色但没有可核对的数字角色 ID:不能只按角色名放行,必须人工核实(客户页会提示联系客服)。
|
// 三项必须全部存在且一致;信息不完整同样不能自动放行,必须转客服核实。
|
||||||
const boundRolePresent =
|
if (comparison.verdict !== 'match') {
|
||||||
Boolean(String(session.bindGameRole || '').trim()) || session.hasExistingBinding === true
|
|
||||||
if (
|
|
||||||
task.platform === 'huya' &&
|
|
||||||
boundRolePresent &&
|
|
||||||
!isNumericBindingRoleId(session.bindGameRoleId)
|
|
||||||
) {
|
|
||||||
throw createHttpError('平台未返回可核对的角色ID,请联系客服人工核实后再确认绑定', {
|
|
||||||
statusCode: 409,
|
|
||||||
errorCode: 'semi_auto_binding_role_id_missing',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const comparison = compareBindingRole(task, session)
|
|
||||||
if (comparison.verdict === 'mismatch') {
|
|
||||||
throw createHttpError(comparison.message, {
|
throw createHttpError(comparison.message, {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
errorCode: 'semi_auto_binding_role_mismatch',
|
errorCode:
|
||||||
|
comparison.verdict === 'mismatch'
|
||||||
|
? 'semi_auto_binding_role_mismatch'
|
||||||
|
: 'semi_auto_binding_role_unverifiable',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 必须调用 Connector 完成确认,否则会话仍是 role_ready,数据库也会停在待确认。
|
// 必须调用 Connector 完成确认,否则会话仍是 role_ready,数据库也会停在待确认。
|
||||||
const confirmedSession =
|
const confirmedSession =
|
||||||
task.platform === 'huya'
|
task.platform === 'huya'
|
||||||
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode, options)
|
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode, {
|
||||||
|
...(options.acceptExistingRole === true || session.rebindUnchanged === true
|
||||||
|
? { acceptExistingRole: true }
|
||||||
|
: {}),
|
||||||
|
})
|
||||||
: session
|
: session
|
||||||
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
||||||
const updated = await loadTask(task.id)
|
const updated = await loadTask(task.id)
|
||||||
@@ -1468,6 +1558,7 @@ export async function submitPublicRebind(orderNoInput: unknown, taskIdInput: unk
|
|||||||
errorCode: 'semi_auto_login_required',
|
errorCode: 'semi_auto_login_required',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
assertCustomerProfileReady(task)
|
||||||
const session = await submitHuyaRebind(task.connector_session_id, task.connector_mode)
|
const session = await submitHuyaRebind(task.connector_session_id, task.connector_mode)
|
||||||
const binding = await updateBindingTask(task, session, 'customer')
|
const binding = await updateBindingTask(task, session, 'customer')
|
||||||
const updated = await loadTask(task.id)
|
const updated = await loadTask(task.id)
|
||||||
@@ -1483,7 +1574,6 @@ export async function sendPublicHuyaSmsCode(
|
|||||||
const taskId = normalizeId(taskIdInput)
|
const taskId = normalizeId(taskIdInput)
|
||||||
const task = await loadTaskForOrder(orderNo, taskId)
|
const task = await loadTaskForOrder(orderNo, taskId)
|
||||||
assertHuyaTask(task)
|
assertHuyaTask(task)
|
||||||
assertCustomerProfileReady(task)
|
|
||||||
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
||||||
throw createHttpError('当前订单已结束,不能重新登录', {
|
throw createHttpError('当前订单已结束,不能重新登录', {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -1633,7 +1723,6 @@ export async function loginPublicHuyaSms(
|
|||||||
const taskId = normalizeId(taskIdInput)
|
const taskId = normalizeId(taskIdInput)
|
||||||
const task = await loadTaskForOrder(orderNo, taskId)
|
const task = await loadTaskForOrder(orderNo, taskId)
|
||||||
assertHuyaTask(task)
|
assertHuyaTask(task)
|
||||||
assertCustomerProfileReady(task)
|
|
||||||
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
||||||
throw createHttpError('当前订单已结束,不能重新登录', {
|
throw createHttpError('当前订单已结束,不能重新登录', {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -1937,6 +2026,12 @@ export async function getAdminSemiAutoTask(taskIdInput: unknown) {
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
task: mapTask(task),
|
task: mapTask(task),
|
||||||
|
// 管理端详情直接复用与客户页相同的三项比对口径,避免出现第二套判定。
|
||||||
|
comparison: compareBindingRole(task, {
|
||||||
|
bindGameRole: task.bind_game_role,
|
||||||
|
bindGameRoleId: task.bind_game_role_id,
|
||||||
|
bindGameChannel: task.bind_game_channel,
|
||||||
|
}),
|
||||||
events: events.rows.map((event) => ({
|
events: events.rows.map((event) => ({
|
||||||
id: Number(event.id),
|
id: Number(event.id),
|
||||||
eventType: event.event_type,
|
eventType: event.event_type,
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ import test from 'node:test'
|
|||||||
|
|
||||||
const TEST_DATABASE_URL = String(process.env.SEMI_AUTO_TASK_TEST_DATABASE_URL || '').trim()
|
const TEST_DATABASE_URL = String(process.env.SEMI_AUTO_TASK_TEST_DATABASE_URL || '').trim()
|
||||||
|
|
||||||
|
/** 断言领域服务抛出指定错误码,避免只匹配中文提示。 */
|
||||||
|
async function expectErrorCode(fn: () => Promise<unknown>, errorCode: string) {
|
||||||
|
await assert.rejects(fn, (error: { errorCode?: string }) => {
|
||||||
|
assert.equal(error.errorCode, errorCode)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'人工渠道半自动任务可由客户入口和后台列表幂等回填',
|
'人工渠道半自动任务可由客户入口和后台列表幂等回填',
|
||||||
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
|
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
|
||||||
@@ -16,11 +24,15 @@ test(
|
|||||||
process.env.DATABASE_URL = TEST_DATABASE_URL
|
process.env.DATABASE_URL = TEST_DATABASE_URL
|
||||||
const { closeDb, query, withTransaction } = await import('../../db/client.js')
|
const { closeDb, query, withTransaction } = await import('../../db/client.js')
|
||||||
const {
|
const {
|
||||||
|
confirmPublicBinding,
|
||||||
ensureSemiAutoTasksForOrder,
|
ensureSemiAutoTasksForOrder,
|
||||||
exportAdminSemiAutoCredential,
|
exportAdminSemiAutoCredential,
|
||||||
listAdminSemiAutoTasks,
|
listAdminSemiAutoTasks,
|
||||||
listPublicSemiAutoTasks,
|
listPublicSemiAutoTasks,
|
||||||
requestAdminSemiAutoCustomerReauth,
|
requestAdminSemiAutoCustomerReauth,
|
||||||
|
resetPublicBinding,
|
||||||
|
savePublicTaskProfile,
|
||||||
|
startPublicBinding,
|
||||||
} = await import('./semi-auto-task-service.js')
|
} = await import('./semi-auto-task-service.js')
|
||||||
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
|
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
|
||||||
const orderNo = `IT-SEMI-AUTO-${suffix}`
|
const orderNo = `IT-SEMI-AUTO-${suffix}`
|
||||||
@@ -110,6 +122,17 @@ 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(
|
||||||
|
() =>
|
||||||
|
savePublicTaskProfile(orderNo, taskId, {
|
||||||
|
roleName: '集成测试角色',
|
||||||
|
roleId: '1192083858',
|
||||||
|
serverZone: '安卓V区',
|
||||||
|
}),
|
||||||
|
'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 }>(
|
||||||
`
|
`
|
||||||
INSERT INTO semi_auto_credentials (
|
INSERT INTO semi_auto_credentials (
|
||||||
@@ -141,11 +164,110 @@ 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')
|
||||||
|
|
||||||
|
// 换绑失败后客户点「上一步修改资料」:清空绑定/换绑状态,保留登录与已填资料。
|
||||||
|
await query(
|
||||||
|
`
|
||||||
|
UPDATE semi_auto_tasks
|
||||||
|
SET binding_status = 'role_ready',
|
||||||
|
bind_game_role = '平台原角色',
|
||||||
|
bind_game_role_id = '99887766',
|
||||||
|
bind_game_channel = '微信',
|
||||||
|
binding_started_at = NOW(),
|
||||||
|
bound_at = NOW(),
|
||||||
|
last_error = '虎牙未接受本次换绑',
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE id = $1
|
||||||
|
`,
|
||||||
|
[taskId],
|
||||||
|
)
|
||||||
|
const reset = await resetPublicBinding(orderNo, taskId)
|
||||||
|
assert.equal(reset.task.bindingStatus, 'not_started')
|
||||||
|
assert.equal(reset.binding, null)
|
||||||
|
assert.equal(reset.task.customerGameRoleName, '集成测试角色')
|
||||||
|
assert.equal(reset.task.customerGameRoleId, '1192083858')
|
||||||
|
assert.equal(reset.task.customerServerZone, '安卓V区')
|
||||||
|
const resetRow = await query<{
|
||||||
|
binding_status: string
|
||||||
|
bind_game_role: string
|
||||||
|
bind_game_role_id: string
|
||||||
|
bind_game_channel: string
|
||||||
|
binding_started_at: string | null
|
||||||
|
bound_at: string | null
|
||||||
|
login_status: string
|
||||||
|
credential_id: number | null
|
||||||
|
connector_session_id: string
|
||||||
|
customer_game_role_name: string
|
||||||
|
customer_game_role_id: string
|
||||||
|
customer_game_server_zone: string
|
||||||
|
last_error: string
|
||||||
|
execution_status: string
|
||||||
|
}>(
|
||||||
|
`
|
||||||
|
SELECT binding_status, bind_game_role, bind_game_role_id, bind_game_channel,
|
||||||
|
binding_started_at, bound_at, login_status, credential_id,
|
||||||
|
connector_session_id, customer_game_role_name, customer_game_role_id,
|
||||||
|
customer_game_server_zone, last_error, execution_status
|
||||||
|
FROM semi_auto_tasks
|
||||||
|
WHERE id = $1
|
||||||
|
`,
|
||||||
|
[taskId],
|
||||||
|
)
|
||||||
|
const resetState = resetRow.rows[0]
|
||||||
|
assert.equal(resetState?.binding_status, 'not_started')
|
||||||
|
assert.equal(resetState?.bind_game_role, '')
|
||||||
|
assert.equal(resetState?.bind_game_role_id, '')
|
||||||
|
assert.equal(resetState?.bind_game_channel, '')
|
||||||
|
assert.equal(resetState?.binding_started_at, null)
|
||||||
|
assert.equal(resetState?.bound_at, null)
|
||||||
|
assert.equal(resetState?.last_error, '')
|
||||||
|
assert.equal(resetState?.execution_status, 'waiting_customer')
|
||||||
|
assert.equal(resetState?.login_status, 'authenticated')
|
||||||
|
assert.equal(Number(resetState?.credential_id), credentialId)
|
||||||
|
assert.equal(resetState?.connector_session_id, `it-huya-session-${suffix}`)
|
||||||
|
assert.equal(resetState?.customer_game_role_name, '集成测试角色')
|
||||||
|
assert.equal(resetState?.customer_game_role_id, '1192083858')
|
||||||
|
assert.equal(resetState?.customer_game_server_zone, '安卓V区')
|
||||||
|
const resetEvents = await query<{ detail_json: { reason?: string } | null }>(
|
||||||
|
`
|
||||||
|
SELECT detail_json
|
||||||
|
FROM semi_auto_task_events
|
||||||
|
WHERE task_id = $1 AND event_type = 'binding_reset'
|
||||||
|
ORDER BY id DESC
|
||||||
|
LIMIT 1
|
||||||
|
`,
|
||||||
|
[taskId],
|
||||||
|
)
|
||||||
|
assert.equal(resetEvents.rows[0]?.detail_json?.reason, 'customer_profile_edit')
|
||||||
|
|
||||||
const reauthorized = await requestAdminSemiAutoCustomerReauth(taskId, {
|
const reauthorized = await requestAdminSemiAutoCustomerReauth(taskId, {
|
||||||
userId: 1,
|
userId: 1,
|
||||||
role: 'support',
|
role: 'support',
|
||||||
@@ -599,7 +721,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
|
||||||
@@ -607,8 +729,12 @@ test(
|
|||||||
const { closeDb, query } = await import('../../db/client.js')
|
const { closeDb, query } = await import('../../db/client.js')
|
||||||
const { createSemiAutoMock } = await import('../dev-mock/dev-mock-service.js')
|
const { createSemiAutoMock } = await import('../dev-mock/dev-mock-service.js')
|
||||||
const { resetMockSessions } = await import('../dev-mock/mock-semi-auto-connector.js')
|
const { resetMockSessions } = await import('../dev-mock/mock-semi-auto-connector.js')
|
||||||
const { listPublicSemiAutoTasks, loginPublicHuyaSms, sendPublicHuyaSmsCode } =
|
const {
|
||||||
await import('./semi-auto-task-service.js')
|
listPublicSemiAutoTasks,
|
||||||
|
loginPublicHuyaSms,
|
||||||
|
savePublicTaskProfile,
|
||||||
|
sendPublicHuyaSmsCode,
|
||||||
|
} = await import('./semi-auto-task-service.js')
|
||||||
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
|
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
|
||||||
const orderNo = `IT-HUYA-SMS-${suffix}`
|
const orderNo = `IT-HUYA-SMS-${suffix}`
|
||||||
let orderId = 0
|
let orderId = 0
|
||||||
@@ -645,11 +771,21 @@ test(
|
|||||||
})
|
})
|
||||||
const tasks = await listPublicSemiAutoTasks(orderNo)
|
const tasks = await listPublicSemiAutoTasks(orderNo)
|
||||||
assert.equal(tasks[0]?.loginStatus, 'authenticated')
|
assert.equal(tasks[0]?.loginStatus, 'authenticated')
|
||||||
assert.equal(tasks[0]?.executionStatus, 'waiting_operator')
|
// 虎牙登录成功后仍需客户填写资料,不能直接进入等待客服。
|
||||||
|
assert.equal(tasks[0]?.executionStatus, 'waiting_customer')
|
||||||
|
assert.equal(tasks[0]?.displayStatus.label, '待客户填写资料')
|
||||||
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
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* 寄卖相关集成测试的收尾清理。
|
||||||
|
*
|
||||||
|
* 集成测试会造打手、分类、寄卖配置、提报、库存、工单、钱包流水。以前跑完不带清理,
|
||||||
|
* 数据会永久留在目标库里(2026-11-10 就是这样在共享联调库留下了 CTIMEOUT 假单)。
|
||||||
|
*
|
||||||
|
* 清理口径:所有识别字段都必须包含本次运行的 `suffix`。suffix 由测试自己生成
|
||||||
|
* (`Date.now().toString(36)` + 随机数),真实业务数据不会命中;配合
|
||||||
|
* `integration-db-guard` 的隔离库限制,误删风险极低。
|
||||||
|
*/
|
||||||
|
import { query } from '../db/client.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除本次集成测试造出的全部数据。
|
||||||
|
*
|
||||||
|
* 必须在测试的 `finally` 里调用,删除顺序遵循外键依赖(子表 -> 主表)。
|
||||||
|
*/
|
||||||
|
export async function cleanupIntegrationRun(suffix: string) {
|
||||||
|
const token = String(suffix || '').trim()
|
||||||
|
if (!token) throw new Error('cleanupIntegrationRun 需要 suffix')
|
||||||
|
const like = `%${token}%`
|
||||||
|
const params = [like]
|
||||||
|
|
||||||
|
const workOrderScope = `SELECT id FROM work_orders WHERE work_order_no LIKE $1`
|
||||||
|
const inventoryScope = `SELECT id FROM consignment_inventories WHERE inventory_no LIKE $1`
|
||||||
|
const submissionScope = `SELECT id FROM consignment_submissions WHERE submission_no LIKE $1`
|
||||||
|
const workerScope = `SELECT id FROM worker_users WHERE username LIKE $1`
|
||||||
|
const categoryScope = `SELECT id FROM work_categories WHERE category_key LIKE $1`
|
||||||
|
const profileScope = `SELECT id FROM consignment_profiles
|
||||||
|
WHERE category_id IN (${categoryScope}) OR name LIKE $1`
|
||||||
|
|
||||||
|
// 子记录:工单 / 库存维度
|
||||||
|
await query(`DELETE FROM work_order_events WHERE work_order_id IN (${workOrderScope})`, params)
|
||||||
|
await query(`DELETE FROM work_order_shares WHERE work_order_id IN (${workOrderScope})`, params)
|
||||||
|
await query(
|
||||||
|
`DELETE FROM consignment_inventory_allocations
|
||||||
|
WHERE work_order_id IN (${workOrderScope}) OR inventory_id IN (${inventoryScope})`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
await query(
|
||||||
|
`DELETE FROM consignment_sms_logs
|
||||||
|
WHERE work_order_id IN (${workOrderScope}) OR inventory_id IN (${inventoryScope})`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
await query(
|
||||||
|
`DELETE FROM consignment_match_logs
|
||||||
|
WHERE work_order_no LIKE $1 OR payload_json::text LIKE $1`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
|
||||||
|
// 钱包流水与打手会话
|
||||||
|
await query(`DELETE FROM worker_wallet_ledgers WHERE worker_id IN (${workerScope})`, params)
|
||||||
|
await query(`DELETE FROM worker_sessions WHERE worker_id IN (${workerScope})`, params)
|
||||||
|
|
||||||
|
// 主实体:先断开 库存 <-> 提报 的双向引用
|
||||||
|
await query(
|
||||||
|
`UPDATE consignment_inventories SET source_submission_id = NULL WHERE inventory_no LIKE $1`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
await query(
|
||||||
|
`UPDATE consignment_submissions SET result_inventory_id = NULL WHERE submission_no LIKE $1`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
await query(`DELETE FROM work_orders WHERE work_order_no LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM consignment_inventories WHERE inventory_no LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM consignment_submissions WHERE submission_no LIKE $1`, params)
|
||||||
|
|
||||||
|
// 配置、钱包、打手、分类
|
||||||
|
await query(
|
||||||
|
`DELETE FROM consignment_profile_versions WHERE profile_id IN (${profileScope})`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
await query(`DELETE FROM consignment_profiles WHERE id IN (${profileScope})`, params)
|
||||||
|
await query(`DELETE FROM worker_wallets WHERE worker_id IN (${workerScope})`, params)
|
||||||
|
await query(`DELETE FROM worker_users WHERE username LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM work_product_rules WHERE rule_key LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM consignment_contact_supporters WHERE name LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM admin_users WHERE username LIKE $1`, params)
|
||||||
|
await query(`DELETE FROM work_categories WHERE category_key LIKE $1`, params)
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
import {
|
||||||
|
isIsolatedIntegrationDatabaseName,
|
||||||
|
resolveIntegrationDatabaseOrThrow,
|
||||||
|
resolveIsolatedIntegrationDatabaseUrl,
|
||||||
|
} from './integration-db-guard.js'
|
||||||
|
|
||||||
|
test('隔离库命名:_ctest / _itest / _test 段才放行', () => {
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site_ctest'), true)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site_ctest_fresh'), true)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site_itest'), true)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site_test'), true)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('ctest'), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('共享库与系统库一律拒绝(防止再污染联调/生产)', () => {
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site'), false)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('postgres'), false)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('template1'), false)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName(''), false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('库存名只是包含 test 字样但没有独立段时不放行', () => {
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('order_site_contest'), false)
|
||||||
|
assert.equal(isIsolatedIntegrationDatabaseName('latest_orders'), false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('未设置环境变量时返回 null,调用方据此跳过测试', () => {
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
assert.equal(resolveIntegrationDatabaseOrThrow('ORDER_SITE_GUARD_TEST_URL'), null)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('两个连接串不一致时直接抛错', () => {
|
||||||
|
process.env.ORDER_SITE_GUARD_TEST_URL = 'postgres://u:p@127.0.0.1:5432/order_site_ctest'
|
||||||
|
process.env.DATABASE_URL = 'postgres://u:p@127.0.0.1:5432/order_site'
|
||||||
|
assert.throws(
|
||||||
|
() => resolveIntegrationDatabaseOrThrow('ORDER_SITE_GUARD_TEST_URL'),
|
||||||
|
/必须与 DATABASE_URL 完全一致/,
|
||||||
|
)
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
delete process.env.DATABASE_URL
|
||||||
|
})
|
||||||
|
|
||||||
|
test('指向共享库时即使两个变量一致也要拒绝', () => {
|
||||||
|
process.env.ORDER_SITE_GUARD_TEST_URL = 'postgres://u:p@192.168.10.9:5432/order_site'
|
||||||
|
process.env.DATABASE_URL = 'postgres://u:p@192.168.10.9:5432/order_site'
|
||||||
|
assert.throws(
|
||||||
|
() => resolveIntegrationDatabaseOrThrow('ORDER_SITE_GUARD_TEST_URL'),
|
||||||
|
/拒绝在非隔离库/,
|
||||||
|
)
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
delete process.env.DATABASE_URL
|
||||||
|
})
|
||||||
|
|
||||||
|
test('指向隔离库且两值一致时返回库名', () => {
|
||||||
|
process.env.ORDER_SITE_GUARD_TEST_URL = 'postgres://u:p@127.0.0.1:5432/order_site_ctest'
|
||||||
|
process.env.DATABASE_URL = 'postgres://u:p@127.0.0.1:5432/order_site_ctest'
|
||||||
|
assert.deepEqual(resolveIntegrationDatabaseOrThrow('ORDER_SITE_GUARD_TEST_URL'), {
|
||||||
|
databaseUrl: 'postgres://u:p@127.0.0.1:5432/order_site_ctest',
|
||||||
|
databaseName: 'order_site_ctest',
|
||||||
|
})
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
delete process.env.DATABASE_URL
|
||||||
|
})
|
||||||
|
|
||||||
|
test('只校验库名的版本:未设置返回空串,共享库抛错,隔离库原样返回', () => {
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
assert.equal(resolveIsolatedIntegrationDatabaseUrl('ORDER_SITE_GUARD_TEST_URL'), '')
|
||||||
|
|
||||||
|
process.env.ORDER_SITE_GUARD_TEST_URL = 'postgres://u:p@192.168.10.9:5432/order_site'
|
||||||
|
assert.throws(
|
||||||
|
() => resolveIsolatedIntegrationDatabaseUrl('ORDER_SITE_GUARD_TEST_URL'),
|
||||||
|
/拒绝在非隔离库/,
|
||||||
|
)
|
||||||
|
|
||||||
|
process.env.ORDER_SITE_GUARD_TEST_URL = 'postgres://u:p@127.0.0.1:5432/order_site_ctest'
|
||||||
|
assert.equal(
|
||||||
|
resolveIsolatedIntegrationDatabaseUrl('ORDER_SITE_GUARD_TEST_URL'),
|
||||||
|
'postgres://u:p@127.0.0.1:5432/order_site_ctest',
|
||||||
|
)
|
||||||
|
delete process.env.ORDER_SITE_GUARD_TEST_URL
|
||||||
|
})
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* 集成测试数据库守卫。
|
||||||
|
*
|
||||||
|
* 背景:2026-11-10 寄卖超时集成测试误跑在共享联调库 `order_site` 上,留下 7 条
|
||||||
|
* `CTIMEOUT-WO-*` 假工单和 8 个假打手,后台把它们当成真实订单展示。
|
||||||
|
*
|
||||||
|
* 原来的守卫只校验 `DATABASE_URL === CONSIGNMENT_MATCHING_TEST_DATABASE_URL`,
|
||||||
|
* 两边都被指到联调库时形同虚设。这里加两道硬约束:
|
||||||
|
* 1. 目标库名必须带隔离测试标记(`_ctest` / `_itest` / `_test`);
|
||||||
|
* 2. 显式拒绝 `order_site`、`postgres` 这类共享库。
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** 明确禁止运行集成测试的库名(生产/联调/系统库)。 */
|
||||||
|
const FORBIDDEN_DATABASE_NAMES = new Set([
|
||||||
|
'order_site',
|
||||||
|
'order_site_ctest_prod',
|
||||||
|
'postgres',
|
||||||
|
'template0',
|
||||||
|
'template1',
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 允许的隔离库命名:包含 _ctest / _itest / _test 段(可带 _fresh 等后缀)。 */
|
||||||
|
const ISOLATED_DATABASE_PATTERN = /(^|_)(ctest|itest|test)($|_)/i
|
||||||
|
|
||||||
|
export type IntegrationDatabaseCheck = {
|
||||||
|
databaseUrl: string
|
||||||
|
databaseName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function readDatabaseName(databaseUrl: string): string {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(new URL(databaseUrl).pathname.replace(/^\/+/, '')).trim()
|
||||||
|
} catch {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 判断库名是否为隔离测试库;导出便于单测覆盖命名规则。 */
|
||||||
|
export function isIsolatedIntegrationDatabaseName(name: string): boolean {
|
||||||
|
const normalized = String(name || '').trim()
|
||||||
|
if (!normalized) return false
|
||||||
|
if (FORBIDDEN_DATABASE_NAMES.has(normalized.toLowerCase())) return false
|
||||||
|
return ISOLATED_DATABASE_PATTERN.test(normalized)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并返回集成测试库地址。
|
||||||
|
*
|
||||||
|
* - 未设置 `envName` 对应变量时返回 null(调用方据此 skip);
|
||||||
|
* - 设置后要求与 `DATABASE_URL` 完全一致,且库名必须是隔离测试库,否则直接抛错中断测试。
|
||||||
|
*/
|
||||||
|
export function resolveIntegrationDatabaseOrThrow(
|
||||||
|
envName: string,
|
||||||
|
): IntegrationDatabaseCheck | null {
|
||||||
|
const databaseUrl = String(process.env[envName] || '').trim()
|
||||||
|
if (!databaseUrl) return null
|
||||||
|
|
||||||
|
const runtimeUrl = String(process.env.DATABASE_URL || '').trim()
|
||||||
|
if (runtimeUrl !== databaseUrl) {
|
||||||
|
throw new Error(
|
||||||
|
`${envName} 必须与 DATABASE_URL 完全一致,避免测试绕过连接配置连到别的库:\n` +
|
||||||
|
` ${envName}=${databaseUrl}\n DATABASE_URL=${runtimeUrl || '(未设置)'}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const databaseName = readDatabaseName(databaseUrl)
|
||||||
|
if (!isIsolatedIntegrationDatabaseName(databaseName)) {
|
||||||
|
throw new Error(
|
||||||
|
`拒绝在非隔离库 "${databaseName || databaseUrl}" 上运行集成测试。\n` +
|
||||||
|
'请使用专门的测试库(库名需包含 _ctest / _itest / _test,例如 order_site_ctest),' +
|
||||||
|
'否则测试会往共享环境写假工单、假打手。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { databaseUrl, databaseName }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只校验库名、不要求和 `DATABASE_URL` 一致的版本。
|
||||||
|
*
|
||||||
|
* 给「测试自己把 `process.env.DATABASE_URL` 改写成测试库」的那批集成测试用:
|
||||||
|
* 它们在模块顶层读不到最终连接串,但仍必须保证目标库是隔离库。
|
||||||
|
*
|
||||||
|
* 未设置环境变量时返回空串(调用方据此 skip);库名不合法时直接抛错。
|
||||||
|
*/
|
||||||
|
export function resolveIsolatedIntegrationDatabaseUrl(envName: string): string {
|
||||||
|
const databaseUrl = String(process.env[envName] || '').trim()
|
||||||
|
if (!databaseUrl) return ''
|
||||||
|
|
||||||
|
const databaseName = readDatabaseName(databaseUrl)
|
||||||
|
if (!isIsolatedIntegrationDatabaseName(databaseName)) {
|
||||||
|
throw new Error(
|
||||||
|
`拒绝在非隔离库 "${databaseName || databaseUrl}" 上运行集成测试(${envName})。\n` +
|
||||||
|
'请使用专门的测试库(库名需包含 _ctest / _itest / _test,例如 order_site_ctest),' +
|
||||||
|
'否则测试中途失败时会把假工单、假打手留在共享环境。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return databaseUrl
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||||
<meta name="theme-color" content="#f97316" />
|
<meta name="theme-color" content="#f97316" />
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Suspense, lazy, useEffect } from 'react'
|
import { Suspense, lazy, useEffect, useLayoutEffect } from 'react'
|
||||||
import { Spin } from 'antd'
|
import { Spin } from 'antd'
|
||||||
import {
|
import {
|
||||||
BrowserRouter,
|
BrowserRouter,
|
||||||
@@ -169,6 +169,21 @@ function OrderServiceApplication() {
|
|||||||
|
|
||||||
function CustomerFulfillmentApplication() {
|
function CustomerFulfillmentApplication() {
|
||||||
useClearStrayHash()
|
useClearStrayHash()
|
||||||
|
/**
|
||||||
|
* 客户履约页固定移动端:
|
||||||
|
* 全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden
|
||||||
|
* 裁掉横向溢出。应用内浏览器/分屏/系统显示放大时,实际视口可能小于 320px,
|
||||||
|
* 页面右侧(输入框、商品值、提示文案)会被直接裁掉。
|
||||||
|
* 这里只给客户履约路由挂移动端根类,覆盖最小宽度,不影响后台与打手端。
|
||||||
|
*/
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
document.documentElement.classList.add('customer-mobile-html')
|
||||||
|
document.body.classList.add('customer-mobile-body')
|
||||||
|
return () => {
|
||||||
|
document.documentElement.classList.remove('customer-mobile-html')
|
||||||
|
document.body.classList.remove('customer-mobile-body')
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
// 非标准子路径也按首段路径绑定平台,避免 /c/.../extra 这类地址绕过严格绑定。
|
// 非标准子路径也按首段路径绑定平台,避免 /c/.../extra 这类地址绕过严格绑定。
|
||||||
const prefix = window.location.pathname.split('/').filter(Boolean)[0]
|
const prefix = window.location.pathname.split('/').filter(Boolean)[0]
|
||||||
const wildcardPlatform = prefix === 'c' ? 'huya' : prefix === 'd' ? 'weibo' : undefined
|
const wildcardPlatform = prefix === 'c' ? 'huya' : prefix === 'd' ? 'weibo' : undefined
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import { resolvePostInjectionUrl } from '@/utils/semi-auto-injection'
|
|||||||
const { Text } = Typography
|
const { Text } = Typography
|
||||||
|
|
||||||
const STATUS_COLORS: Record<string, string> = {
|
const STATUS_COLORS: Record<string, string> = {
|
||||||
|
waiting_profile: 'gold',
|
||||||
waiting_customer: 'blue',
|
waiting_customer: 'blue',
|
||||||
waiting_login: 'blue',
|
waiting_login: 'blue',
|
||||||
login_scanned: 'cyan',
|
login_scanned: 'cyan',
|
||||||
@@ -773,19 +774,49 @@ export default function AdminSemiAutoTasksPage() {
|
|||||||
? '微博登录即授权'
|
? '微博登录即授权'
|
||||||
: BINDING_STATUS_LABELS[detail.task.bindingStatus] || detail.task.bindingStatus}
|
: BINDING_STATUS_LABELS[detail.task.bindingStatus] || detail.task.bindingStatus}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="绑定角色">
|
<Descriptions.Item label="平台绑定角色">
|
||||||
{detail.task.bindGameRole
|
{detail.task.bindGameRole || '-'}
|
||||||
? `${detail.task.bindGameRole}${detail.task.bindGameRoleId ? `(${detail.task.bindGameRoleId})` : '(无角色ID)'}`
|
</Descriptions.Item>
|
||||||
: '-'}
|
<Descriptions.Item label="平台角色ID">
|
||||||
|
{detail.task.bindGameRoleId || detail.task.huyaUid || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="平台绑定渠道">
|
||||||
|
{[
|
||||||
|
detail.task.bindGameChannel,
|
||||||
|
detail.comparison?.boundZone ? `识别区服 ${detail.comparison.boundZone}` : '',
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ') || '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="客户填写角色">
|
<Descriptions.Item label="客户填写角色">
|
||||||
{detail.task.customerGameRoleName
|
{detail.task.customerGameRoleName || '-'}
|
||||||
? `${detail.task.customerGameRoleName}${detail.task.customerGameRoleId ? `(${detail.task.customerGameRoleId})` : ''}`
|
|
||||||
: '-'}
|
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="区服">
|
<Descriptions.Item label="客户游戏编号">
|
||||||
|
{detail.task.customerGameRoleId || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="客户区服">
|
||||||
{detail.task.customerServerZone || '-'}
|
{detail.task.customerServerZone || '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="角色比对" span={2}>
|
||||||
|
<Space direction="vertical" size={2}>
|
||||||
|
<Tag
|
||||||
|
color={
|
||||||
|
detail.comparison?.verdict === 'match'
|
||||||
|
? 'green'
|
||||||
|
: detail.comparison?.verdict === 'mismatch'
|
||||||
|
? 'red'
|
||||||
|
: 'orange'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{detail.comparison?.verdict === 'match'
|
||||||
|
? '三项一致,可提交平台绑定'
|
||||||
|
: detail.comparison?.verdict === 'mismatch'
|
||||||
|
? '资料与平台角色不一致'
|
||||||
|
: '信息不完整,需人工核实'}
|
||||||
|
</Tag>
|
||||||
|
<Text type="secondary">{detail.comparison?.message || '-'}</Text>
|
||||||
|
</Space>
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="客服">
|
<Descriptions.Item label="客服">
|
||||||
{detail.task.assignedAdminName || '未领取'}
|
{detail.task.assignedAdminName || '未领取'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
pollCustomerBinding,
|
pollCustomerBinding,
|
||||||
pollCustomerLogin,
|
pollCustomerLogin,
|
||||||
pollCustomerWeiboQrLogin,
|
pollCustomerWeiboQrLogin,
|
||||||
|
resetCustomerBinding,
|
||||||
saveCustomerTaskProfile,
|
saveCustomerTaskProfile,
|
||||||
sendCustomerHuyaSmsCode,
|
sendCustomerHuyaSmsCode,
|
||||||
sendCustomerWeiboSmsCode,
|
sendCustomerWeiboSmsCode,
|
||||||
@@ -56,7 +57,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
}: {
|
}: {
|
||||||
expectedPlatform?: CustomerFulfillmentPlatform
|
expectedPlatform?: CustomerFulfillmentPlatform
|
||||||
}) {
|
}) {
|
||||||
const { message, modal } = App.useApp()
|
const { message } = App.useApp()
|
||||||
const { orderNo: routeOrderNo } = useParams<{ orderNo?: string }>()
|
const { orderNo: routeOrderNo } = useParams<{ orderNo?: string }>()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { search, hash } = useLocation()
|
const { search, hash } = useLocation()
|
||||||
@@ -86,8 +87,8 @@ export default function CustomerFulfillmentPage({
|
|||||||
const [profileServerZone, setProfileServerZone] = useState('')
|
const [profileServerZone, setProfileServerZone] = useState('')
|
||||||
const [profileSaving, setProfileSaving] = useState(false)
|
const [profileSaving, setProfileSaving] = useState(false)
|
||||||
const [profileEditing, setProfileEditing] = useState(false)
|
const [profileEditing, setProfileEditing] = useState(false)
|
||||||
const [rebindFailureDismissed, setRebindFailureDismissed] = useState(false)
|
|
||||||
const startingBindingRef = useRef(false)
|
const startingBindingRef = useRef(false)
|
||||||
|
const resettingBindingRef = useRef(false)
|
||||||
const hydratingBindingRef = useRef(false)
|
const hydratingBindingRef = useRef(false)
|
||||||
const autoOpenedRoleRef = useRef('')
|
const autoOpenedRoleRef = useRef('')
|
||||||
const redirectingRef = useRef(false)
|
const redirectingRef = useRef(false)
|
||||||
@@ -100,6 +101,13 @@ export default function CustomerFulfillmentPage({
|
|||||||
[selectedTaskId, tasks],
|
[selectedTaskId, tasks],
|
||||||
)
|
)
|
||||||
const isWeibo = selectedTask?.platform === 'weibo'
|
const isWeibo = selectedTask?.platform === 'weibo'
|
||||||
|
// 虎牙流程:登录 → 填写资料(区服/游戏编号/角色名)→ 绑定角色。
|
||||||
|
// 三项资料齐全前不生成绑定二维码,避免客户在资料缺失时先绑错角色。
|
||||||
|
const profileComplete = Boolean(
|
||||||
|
String(selectedTask?.customerServerZone || '').trim() &&
|
||||||
|
String(selectedTask?.customerGameRoleId || '').trim() &&
|
||||||
|
String(selectedTask?.customerGameRoleName || '').trim(),
|
||||||
|
)
|
||||||
|
|
||||||
const load = useCallback(
|
const load = useCallback(
|
||||||
async (silent = false) => {
|
async (silent = false) => {
|
||||||
@@ -171,7 +179,6 @@ export default function CustomerFulfillmentPage({
|
|||||||
autoOpenedRoleRef.current = ''
|
autoOpenedRoleRef.current = ''
|
||||||
setBindingSessionExpired(false)
|
setBindingSessionExpired(false)
|
||||||
setBindingLoadError('')
|
setBindingLoadError('')
|
||||||
setRebindFailureDismissed(false)
|
|
||||||
}, [selectedTask?.id])
|
}, [selectedTask?.id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -263,10 +270,12 @@ export default function CustomerFulfillmentPage({
|
|||||||
return () => window.clearInterval(timer)
|
return () => window.clearInterval(timer)
|
||||||
}, [orderNo, selectedTask?.id, selectedTask?.loginStatus, selectedTask?.platform])
|
}, [orderNo, selectedTask?.id, selectedTask?.loginStatus, selectedTask?.platform])
|
||||||
|
|
||||||
// 登录成功后自动进入绑定阶段;失败或过期时由客户点按钮重试,避免页面来回跳。
|
// 登录并填写完整资料后才自动进入绑定阶段;资料不全或客户正在返回修改资料时停留在资料步骤。
|
||||||
|
// 失败或过期时由客户点按钮重试,避免页面来回跳。
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedTask || !orderNo || selectedTask.platform !== 'huya') return
|
if (!selectedTask || !orderNo || selectedTask.platform !== 'huya') return
|
||||||
if (selectedTask.loginStatus !== 'authenticated') return
|
if (selectedTask.loginStatus !== 'authenticated') return
|
||||||
|
if (!profileComplete || profileEditing) return
|
||||||
if (selectedTask.bindingStatus === 'confirmed') return
|
if (selectedTask.bindingStatus === 'confirmed') return
|
||||||
if (selectedTask.bindingStatus !== 'not_started' || startingBindingRef.current) return
|
if (selectedTask.bindingStatus !== 'not_started' || startingBindingRef.current) return
|
||||||
startingBindingRef.current = true
|
startingBindingRef.current = true
|
||||||
@@ -293,6 +302,8 @@ export default function CustomerFulfillmentPage({
|
|||||||
}, [
|
}, [
|
||||||
message,
|
message,
|
||||||
orderNo,
|
orderNo,
|
||||||
|
profileComplete,
|
||||||
|
profileEditing,
|
||||||
selectedTask?.bindingStatus,
|
selectedTask?.bindingStatus,
|
||||||
selectedTask?.id,
|
selectedTask?.id,
|
||||||
selectedTask?.loginStatus,
|
selectedTask?.loginStatus,
|
||||||
@@ -374,7 +385,9 @@ export default function CustomerFulfillmentPage({
|
|||||||
if (!bindingInfo?.comparison) return
|
if (!bindingInfo?.comparison) return
|
||||||
// 换绑后仍是原角色时只展示失败原因,不能自动弹出确认框。
|
// 换绑后仍是原角色时只展示失败原因,不能自动弹出确认框。
|
||||||
if (bindingInfo.rebindUnchanged) return
|
if (bindingInfo.rebindUnchanged) return
|
||||||
// 识别到角色(含与资料不一致)都要弹出对比框,由客户选择修改资料或同步平台角色。
|
// 只有三项完全一致才自动弹出核对框,让客户直接提交平台绑定;
|
||||||
|
// 不一致时不弹框,由下方「重新扫码换绑 / 上一步修改资料」两个按钮处理。
|
||||||
|
if (bindingInfo.comparison.verdict !== 'match') return
|
||||||
const key = `${selectedTask.id}:${bindingInfo.bindGameRoleId || ''}`
|
const key = `${selectedTask.id}:${bindingInfo.bindGameRoleId || ''}`
|
||||||
if (autoOpenedRoleRef.current === key) return
|
if (autoOpenedRoleRef.current === key) return
|
||||||
autoOpenedRoleRef.current = key
|
autoOpenedRoleRef.current = key
|
||||||
@@ -509,7 +522,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
)
|
)
|
||||||
setLoginInfo(response.data.login)
|
setLoginInfo(response.data.login)
|
||||||
setHuyaChallenge(null)
|
setHuyaChallenge(null)
|
||||||
message.success(isWeibo ? '微博登录成功,等待客服处理' : '登录成功,请继续绑定游戏角色')
|
message.success(isWeibo ? '微博登录成功,等待客服处理' : '登录成功,请填写游戏角色资料')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorCode = (error as { errorCode?: string } | null)?.errorCode || ''
|
const errorCode = (error as { errorCode?: string } | null)?.errorCode || ''
|
||||||
if (errorCode === 'weibo_sms_mfa_required') {
|
if (errorCode === 'weibo_sms_mfa_required') {
|
||||||
@@ -597,13 +610,21 @@ export default function CustomerFulfillmentPage({
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 资料不一致同样打开对比框,客户可在弹窗内修改资料或同步平台角色。
|
// 只有三项完全一致才打开核对框;不一致由页面按钮引导换绑或修改资料。
|
||||||
setBindingConfirmOpen(true)
|
if (nextBinding?.comparison?.verdict === 'match') {
|
||||||
|
setBindingConfirmOpen(true)
|
||||||
|
} else {
|
||||||
|
setBindingConfirmOpen(false)
|
||||||
|
message.warning(
|
||||||
|
nextBinding?.comparison?.message ||
|
||||||
|
'平台角色与已填资料不一致,请重新扫码换绑或修改资料',
|
||||||
|
)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (nextTask.bindingStatus === 'confirmed') {
|
if (nextTask.bindingStatus === 'confirmed') {
|
||||||
setBindingConfirmOpen(false)
|
setBindingConfirmOpen(false)
|
||||||
message.success('绑定已确认,等待客服处理')
|
message.success('已提交平台绑定,等待客服处理')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 弹窗内点「刷新」:角色不再是待确认状态时收起弹窗,避免展示过期比对。
|
// 弹窗内点「刷新」:角色不再是待确认状态时收起弹窗,避免展示过期比对。
|
||||||
@@ -661,7 +682,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (nextTask.bindingStatus === 'role_ready') {
|
if (nextTask.bindingStatus === 'role_ready') {
|
||||||
message.success('换绑已生效,请核对角色后确认绑定')
|
message.success('换绑已生效,请核对角色后提交平台绑定')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
message.info('已向虎牙提交换绑,正在等待角色生效')
|
message.info('已向虎牙提交换绑,正在等待角色生效')
|
||||||
@@ -680,55 +701,17 @@ export default function CustomerFulfillmentPage({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSyncBindingProfile() {
|
async function handleConfirmBinding() {
|
||||||
if (!selectedTask) return
|
|
||||||
const comparison = bindingInfo?.comparison
|
|
||||||
if (!comparison) return
|
|
||||||
const roleName = comparison.boundRoleName
|
|
||||||
const roleId = comparison.boundRoleId
|
|
||||||
const serverZone = comparison.boundZone
|
|
||||||
if (!roleName || !roleId || !/^\d+$/.test(roleId) || !serverZone) {
|
|
||||||
message.warning('平台角色信息不完整,请点「修改资料」手动填写')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setProfileSaving(true)
|
|
||||||
try {
|
|
||||||
const response = await saveCustomerTaskProfile(orderNo, selectedTask.id, {
|
|
||||||
roleName,
|
|
||||||
roleId,
|
|
||||||
serverZone,
|
|
||||||
})
|
|
||||||
setTasks((current) =>
|
|
||||||
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
|
||||||
)
|
|
||||||
const bindingResponse = await pollCustomerBinding(orderNo, selectedTask.id)
|
|
||||||
if (bindingResponse.data.binding) setBindingInfo(bindingResponse.data.binding)
|
|
||||||
reopenBindingConfirm(bindingResponse.data.task, bindingResponse.data.binding)
|
|
||||||
message.success('资料已按平台角色同步,请核对后确认绑定')
|
|
||||||
} catch (error) {
|
|
||||||
message.error(error instanceof Error ? error.message : '同步角色资料失败')
|
|
||||||
} finally {
|
|
||||||
setProfileSaving(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleConfirmBinding(acceptExistingRole = false) {
|
|
||||||
if (!selectedTask) return
|
if (!selectedTask) return
|
||||||
setBindingLoading(true)
|
setBindingLoading(true)
|
||||||
try {
|
try {
|
||||||
const response = await confirmCustomerBinding(
|
const response = await confirmCustomerBinding(orderNo, selectedTask.id)
|
||||||
orderNo,
|
|
||||||
selectedTask.id,
|
|
||||||
acceptExistingRole ? { acceptExistingRole: true } : {},
|
|
||||||
)
|
|
||||||
setTasks((current) =>
|
setTasks((current) =>
|
||||||
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)),
|
||||||
)
|
)
|
||||||
setBindingInfo(response.data.binding)
|
setBindingInfo(response.data.binding)
|
||||||
setBindingConfirmOpen(false)
|
setBindingConfirmOpen(false)
|
||||||
message.success(
|
message.success('已提交平台绑定,等待客服处理')
|
||||||
acceptExistingRole ? '已按原绑定角色确认,等待客服处理' : '绑定已确认,等待客服处理',
|
|
||||||
)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isHuyaSessionExpired(error)) {
|
if (isHuyaSessionExpired(error)) {
|
||||||
setBindingSessionExpired(true)
|
setBindingSessionExpired(true)
|
||||||
@@ -736,48 +719,62 @@ export default function CustomerFulfillmentPage({
|
|||||||
message.warning('虎牙登录会话已过期,请重新登录')
|
message.warning('虎牙登录会话已过期,请重新登录')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
message.error(error instanceof Error ? error.message : '确认绑定失败')
|
message.error(error instanceof Error ? error.message : '提交平台绑定失败')
|
||||||
} finally {
|
} finally {
|
||||||
setBindingLoading(false)
|
setBindingLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 换绑被虎牙拒绝时的二次确认:客户可以选择继续使用原绑定角色。 */
|
/** 资料变更后重新打开核对弹窗:只有三项完全一致才让客户直接提交平台绑定。 */
|
||||||
function handleAcceptExistingRole() {
|
|
||||||
if (!selectedTask || bindingLoading) return
|
|
||||||
const reason = String(bindingInfo?.rebindConfirmMessage || '').trim()
|
|
||||||
modal.confirm({
|
|
||||||
title: '确认使用原角色?',
|
|
||||||
content: `本次换绑未成功${reason ? `(${reason})` : ''},平台仍返回原绑定角色「${
|
|
||||||
bindingRoleName || '当前角色'
|
|
||||||
}」。确认后本次换绑作废,直接使用该角色继续履约。`,
|
|
||||||
okText: '确认使用原角色',
|
|
||||||
cancelText: '先不确认',
|
|
||||||
onOk: () => handleConfirmBinding(true),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 资料变更后重新打开对比弹窗,让客户基于最新两侧信息再次核对。 */
|
|
||||||
function reopenBindingConfirm(
|
function reopenBindingConfirm(
|
||||||
nextTask: CustomerSemiAutoTask,
|
nextTask: CustomerSemiAutoTask,
|
||||||
nextBinding: CustomerBindingInfo | null | undefined,
|
nextBinding: CustomerBindingInfo | null | undefined,
|
||||||
) {
|
) {
|
||||||
if (nextTask.bindingStatus !== 'role_ready') return false
|
if (nextTask.bindingStatus !== 'role_ready') return false
|
||||||
if (!nextBinding?.comparison || nextBinding.rebindUnchanged) return false
|
if (!nextBinding?.comparison || nextBinding.rebindUnchanged) return false
|
||||||
|
if (nextBinding.comparison.verdict !== 'match') return false
|
||||||
autoOpenedRoleRef.current = `${nextTask.id}:${nextBinding.bindGameRoleId || ''}`
|
autoOpenedRoleRef.current = `${nextTask.id}:${nextBinding.bindGameRoleId || ''}`
|
||||||
setBindingConfirmOpen(true)
|
setBindingConfirmOpen(true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 从对比弹窗回到资料表单,保存成功后会自动重新打开对比。 */
|
/**
|
||||||
function openProfileEditor() {
|
* 返回第二步修改资料:
|
||||||
|
* 立即切回资料表单(步骤条高亮第 2 步、隐藏绑定/换绑结果),同时调后端清空虎牙
|
||||||
|
* 绑定与换绑失败状态;登录状态和已填资料保留,客户提交资料后重新走绑定流程。
|
||||||
|
*/
|
||||||
|
async function openProfileEditor() {
|
||||||
|
if (!selectedTask) return
|
||||||
|
if (resettingBindingRef.current) return
|
||||||
setBindingConfirmOpen(false)
|
setBindingConfirmOpen(false)
|
||||||
setProfileEditing(true)
|
setProfileEditing(true)
|
||||||
|
// 资料步骤会隐藏绑定二维码与比对区,等 React 完成切换后再回到第二步顶部。
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
document
|
document
|
||||||
.getElementById('customer-profile-form')
|
.getElementById('customer-binding-stage')
|
||||||
?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
}, 0)
|
}, 60)
|
||||||
|
if (selectedTask.platform !== 'huya' || selectedTask.bindingStatus === 'not_started') return
|
||||||
|
resettingBindingRef.current = true
|
||||||
|
try {
|
||||||
|
const response = await resetCustomerBinding(orderNo, selectedTask.id)
|
||||||
|
setTasks((current) =>
|
||||||
|
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
||||||
|
)
|
||||||
|
// 换绑失败原因(rebindUnchanged / rebindConfirmState 等)随绑定详情一并清掉。
|
||||||
|
setBindingInfo(response.data.binding)
|
||||||
|
setBindingLoadError('')
|
||||||
|
message.success('已返回上一步,请修改资料后重新提交')
|
||||||
|
} catch (error) {
|
||||||
|
if (isHuyaSessionExpired(error)) {
|
||||||
|
setBindingSessionExpired(true)
|
||||||
|
} else {
|
||||||
|
// 重置失败不阻断客户改资料,保存后会重新识别平台角色。
|
||||||
|
message.error(error instanceof Error ? error.message : '重置绑定状态失败,请稍后重试')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
resettingBindingRef.current = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSaveProfile() {
|
async function handleSaveProfile() {
|
||||||
@@ -790,6 +787,10 @@ export default function CustomerFulfillmentPage({
|
|||||||
message.warning('请选择区服')
|
message.warning('请选择区服')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!/^\d+$/.test(profileRoleId.trim())) {
|
||||||
|
message.warning('游戏编号只能是数字')
|
||||||
|
return
|
||||||
|
}
|
||||||
setProfileSaving(true)
|
setProfileSaving(true)
|
||||||
try {
|
try {
|
||||||
const response = await saveCustomerTaskProfile(orderNo, selectedTask.id, {
|
const response = await saveCustomerTaskProfile(orderNo, selectedTask.id, {
|
||||||
@@ -809,7 +810,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
} catch {
|
} catch {
|
||||||
// 绑定尚未开始时没有 binding,可忽略。
|
// 绑定尚未开始时没有 binding,可忽略。
|
||||||
}
|
}
|
||||||
message.success(reopened ? '角色资料已保存,请重新核对绑定角色' : '角色资料已保存')
|
message.success(reopened ? '资料已保存且与平台角色一致,请提交平台绑定' : '资料已保存')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error instanceof Error ? error.message : '保存角色资料失败')
|
message.error(error instanceof Error ? error.message : '保存角色资料失败')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -846,7 +847,6 @@ export default function CustomerFulfillmentPage({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = selectedTask?.semiAutoConfig || {}
|
|
||||||
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)
|
||||||
@@ -857,9 +857,9 @@ export default function CustomerFulfillmentPage({
|
|||||||
selectedTask.executionStatus !== 'completed' &&
|
selectedTask.executionStatus !== 'completed' &&
|
||||||
selectedTask.executionStatus !== 'cancelled',
|
selectedTask.executionStatus !== 'cancelled',
|
||||||
)
|
)
|
||||||
const bindingQrVisible = ['not_started', 'qr_pending', 'scanned'].includes(
|
const bindingQrVisible =
|
||||||
selectedTask?.bindingStatus || '',
|
profileComplete &&
|
||||||
)
|
['not_started', 'qr_pending', 'scanned'].includes(selectedTask?.bindingStatus || '')
|
||||||
const bindingComparison = bindingInfo?.comparison || null
|
const bindingComparison = bindingInfo?.comparison || null
|
||||||
const bindingRoleId = bindingInfo?.bindGameRoleId || selectedTask?.bindGameRoleId || ''
|
const bindingRoleId = bindingInfo?.bindGameRoleId || selectedTask?.bindGameRoleId || ''
|
||||||
// 虎牙 gameRole.roleId 是加密串,客户侧统一展示数值 UID(huyaUid)。
|
// 虎牙 gameRole.roleId 是加密串,客户侧统一展示数值 UID(huyaUid)。
|
||||||
@@ -871,8 +871,9 @@ export default function CustomerFulfillmentPage({
|
|||||||
})()
|
})()
|
||||||
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
||||||
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
||||||
// 换绑失败视图可返回「已识别角色 + 资料不一致」的核对界面;后端 rebindUnchanged 保持不变。
|
// 换绑被虎牙拒绝或未生效时展示失败原因;若客户已把资料改成与平台当前角色一致,
|
||||||
const showRebindFailure = rebindUnchanged && !rebindFailureDismissed
|
// 比对为 match,则回到正常提交流程,不再显示换绑失败。
|
||||||
|
const showRebindFailure = rebindUnchanged && bindingComparison?.verdict !== 'match'
|
||||||
const rebindConfirmState = bindingInfo?.rebindConfirmState || 'idle'
|
const rebindConfirmState = bindingInfo?.rebindConfirmState || 'idle'
|
||||||
const rebindRejected = rebindConfirmState === 'rejected'
|
const rebindRejected = rebindConfirmState === 'rejected'
|
||||||
const rebindAccepted = rebindConfirmState === 'accepted'
|
const rebindAccepted = rebindConfirmState === 'accepted'
|
||||||
@@ -886,12 +887,18 @@ export default function CustomerFulfillmentPage({
|
|||||||
(bindingInfo?.requiresSupport ??
|
(bindingInfo?.requiresSupport ??
|
||||||
(Boolean(bindingInfo?.bindGameRole || bindingRoleName) && !bindingRoleIdNumeric))
|
(Boolean(bindingInfo?.bindGameRole || bindingRoleName) && !bindingRoleIdNumeric))
|
||||||
// 绑定阶段顶部状态条:按 bindingStatus 显式映射,已确认/已过期/失败不再显示(各自有卡片)。
|
// 绑定阶段顶部状态条:按 bindingStatus 显式映射,已确认/已过期/失败不再显示(各自有卡片)。
|
||||||
|
const comparisonMismatch =
|
||||||
|
selectedTask?.bindingStatus === 'role_ready' && bindingComparison?.verdict === 'mismatch'
|
||||||
|
const comparisonUnknown =
|
||||||
|
selectedTask?.bindingStatus === 'role_ready' && bindingComparison?.verdict === 'unknown'
|
||||||
|
// 平台没给出可核对角色或比对缺项时,都只能转客服人工核实。
|
||||||
|
const bindingNeedsSupport = bindingRequiresSupport || comparisonUnknown
|
||||||
const bindingBanner = (() => {
|
const bindingBanner = (() => {
|
||||||
if (bindingSessionExpired) return null
|
if (bindingSessionExpired) return null
|
||||||
if (bindingRequiresSupport && selectedTask?.bindingStatus !== 'confirmed') {
|
if (bindingNeedsSupport && selectedTask?.bindingStatus !== 'confirmed') {
|
||||||
return {
|
return {
|
||||||
tone: 'is-warning',
|
tone: 'is-warning',
|
||||||
text: '已登录,但平台未返回可核对的角色ID,请联系客服人工核实',
|
text: '已登录,但两侧角色信息不完整,无法自动核对,请联系客服人工核实',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showRebindFailure) {
|
if (showRebindFailure) {
|
||||||
@@ -900,8 +907,12 @@ export default function CustomerFulfillmentPage({
|
|||||||
text: rebindRejected ? '虎牙未接受本次换绑,请查看下方原因' : '换绑未生效,请查看下方原因',
|
text: rebindRejected ? '虎牙未接受本次换绑,请查看下方原因' : '换绑未生效,请查看下方原因',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (comparisonMismatch) {
|
||||||
|
return { tone: 'is-warning', text: '平台角色与已填资料不一致,请重新扫码换绑或修改资料' }
|
||||||
|
}
|
||||||
if (selectedTask?.bindingStatus === 'role_ready') {
|
if (selectedTask?.bindingStatus === 'role_ready') {
|
||||||
return { tone: 'is-info', text: '已识别绑定角色,请核对后确认' }
|
if (!bindingComparison) return { tone: 'is-info', text: '正在核对平台角色,请稍候' }
|
||||||
|
return { tone: 'is-info', text: '平台角色与已填资料一致,请提交平台绑定' }
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
selectedTask?.bindingStatus === 'confirmed' ||
|
selectedTask?.bindingStatus === 'confirmed' ||
|
||||||
@@ -921,27 +932,8 @@ export default function CustomerFulfillmentPage({
|
|||||||
const nextRebindText = bindingInfo?.nextRebindAt
|
const nextRebindText = bindingInfo?.nextRebindAt
|
||||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||||
: ''
|
: ''
|
||||||
const comparisonMismatch =
|
// 登录后资料不全时自动展开资料表单;资料齐全后才展示绑定二维码。
|
||||||
selectedTask?.bindingStatus === 'role_ready' && bindingComparison?.verdict === 'mismatch'
|
const showProfileForm = showBindingStage && (profileEditing || !profileComplete)
|
||||||
const showProfileForm = showBindingStage && profileEditing
|
|
||||||
const bindingCustomerReady = Boolean(
|
|
||||||
bindingComparison?.customerRoleId || bindingComparison?.customerRoleName,
|
|
||||||
)
|
|
||||||
// 平台角色名、数字角色 ID、区服齐全时,才支持一键同步为平台角色。
|
|
||||||
const canSyncBindingProfile = Boolean(
|
|
||||||
bindingComparison?.boundRoleName &&
|
|
||||||
/^\d+$/.test(String(bindingComparison?.boundRoleId || '').trim()) &&
|
|
||||||
bindingComparison?.boundZone,
|
|
||||||
)
|
|
||||||
const needsProfileCollection = Boolean(
|
|
||||||
selectedTask &&
|
|
||||||
selectedTask.platform === 'huya' &&
|
|
||||||
selectedTask.executionStatus !== 'completed' &&
|
|
||||||
selectedTask.bindingStatus !== 'confirmed' &&
|
|
||||||
(!selectedTask.customerServerZone ||
|
|
||||||
!selectedTask.customerGameRoleId ||
|
|
||||||
!selectedTask.customerGameRoleName),
|
|
||||||
)
|
|
||||||
|
|
||||||
const renderLoginForm = (options: {
|
const renderLoginForm = (options: {
|
||||||
platformLabel: string
|
platformLabel: string
|
||||||
@@ -1060,17 +1052,6 @@ export default function CustomerFulfillmentPage({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsProfileCollection && selectedTask) {
|
|
||||||
return (
|
|
||||||
<CustomerCollectStep
|
|
||||||
task={selectedTask}
|
|
||||||
onSaved={(task) =>
|
|
||||||
setTasks((current) => current.map((item) => (item.id === task.id ? task : item)))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomerAuthFrame platform={selectedTask?.platform} title={displayTitle}>
|
<CustomerAuthFrame platform={selectedTask?.platform} title={displayTitle}>
|
||||||
<div className="customer-auth-content-stack">
|
<div className="customer-auth-content-stack">
|
||||||
@@ -1096,6 +1077,20 @@ export default function CustomerFulfillmentPage({
|
|||||||
|
|
||||||
<CustomerOrderCard task={selectedTask} />
|
<CustomerOrderCard task={selectedTask} />
|
||||||
|
|
||||||
|
{selectedTask?.platform === 'huya' ? (
|
||||||
|
<CustomerHuyaSteps
|
||||||
|
current={
|
||||||
|
selectedTask.loginStatus !== 'authenticated'
|
||||||
|
? 1
|
||||||
|
: profileEditing || !profileComplete
|
||||||
|
? 2
|
||||||
|
: selectedTask.bindingStatus === 'confirmed'
|
||||||
|
? 4
|
||||||
|
: 3
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{selectedTask?.loginStatus === 'waiting_login' ||
|
{selectedTask?.loginStatus === 'waiting_login' ||
|
||||||
selectedTask?.loginStatus === 'failed' ||
|
selectedTask?.loginStatus === 'failed' ||
|
||||||
selectedTask?.loginStatus === 'expired' ||
|
selectedTask?.loginStatus === 'expired' ||
|
||||||
@@ -1177,21 +1172,23 @@ export default function CustomerFulfillmentPage({
|
|||||||
|
|
||||||
{showBindingStage ? (
|
{showBindingStage ? (
|
||||||
<section id="customer-binding-stage" className="customer-binding-stage">
|
<section id="customer-binding-stage" className="customer-binding-stage">
|
||||||
<div className="customer-binding-info">
|
{profileComplete && !profileEditing ? (
|
||||||
<h3>
|
<div className="customer-binding-info">
|
||||||
绑定信息 <small>(已登录虎牙账号)</small>
|
<h3>
|
||||||
</h3>
|
绑定信息 <small>(已登录虎牙账号)</small>
|
||||||
<div>
|
</h3>
|
||||||
<span>登录账号</span>
|
<div>
|
||||||
<strong>
|
<span>登录账号</span>
|
||||||
{bindingInfo?.bindGameAccount || selectedTask.bindGameAccount || '未获取'}
|
<strong>
|
||||||
</strong>
|
{bindingInfo?.bindGameAccount || selectedTask.bindGameAccount || '未获取'}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>绑定角色</span>
|
||||||
|
<strong>{bindingRoleName || '未识别到角色'}</strong>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
) : null}
|
||||||
<span>绑定角色</span>
|
|
||||||
<strong>{bindingRoleName || '未识别到角色'}</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{bindingSessionExpired ? (
|
{bindingSessionExpired ? (
|
||||||
<div className="customer-binding-session-card">
|
<div className="customer-binding-session-card">
|
||||||
@@ -1211,7 +1208,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{bindingBanner ? (
|
{bindingBanner && !profileEditing ? (
|
||||||
<div className={`customer-binding-alert ${bindingBanner.tone}`}>
|
<div className={`customer-binding-alert ${bindingBanner.tone}`}>
|
||||||
{bindingBanner.text}
|
{bindingBanner.text}
|
||||||
</div>
|
</div>
|
||||||
@@ -1219,7 +1216,11 @@ export default function CustomerFulfillmentPage({
|
|||||||
|
|
||||||
{showProfileForm && !bindingSessionExpired ? (
|
{showProfileForm && !bindingSessionExpired ? (
|
||||||
<div className="customer-auth-profile" id="customer-profile-form">
|
<div className="customer-auth-profile" id="customer-profile-form">
|
||||||
<p>修改资料后会重新核对平台识别角色。</p>
|
<p>
|
||||||
|
{profileComplete
|
||||||
|
? '第二步:修改资料后会用最新资料重新核对平台角色,三项完全一致才能提交平台绑定。'
|
||||||
|
: '第二步:请填写游戏角色资料:区服、游戏编号(虎牙账号 UID)与角色名,提交后才能生成绑定二维码。'}
|
||||||
|
</p>
|
||||||
<div className="customer-profile-form">
|
<div className="customer-profile-form">
|
||||||
<label className="customer-collect-label">
|
<label className="customer-collect-label">
|
||||||
区服 <span>*</span>
|
区服 <span>*</span>
|
||||||
@@ -1262,11 +1263,21 @@ export default function CustomerFulfillmentPage({
|
|||||||
>
|
>
|
||||||
提交资料
|
提交资料
|
||||||
</Button>
|
</Button>
|
||||||
|
{profileComplete ? (
|
||||||
|
<Button
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
className="customer-login-alt"
|
||||||
|
onClick={() => setProfileEditing(false)}
|
||||||
|
>
|
||||||
|
返回绑定角色
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{bindingQrVisible && !bindingSessionExpired ? (
|
{bindingQrVisible && !bindingSessionExpired && !profileEditing ? (
|
||||||
<div className="customer-binding-qr-card">
|
<div className="customer-binding-qr-card">
|
||||||
<h3>游戏角色绑定二维码</h3>
|
<h3>游戏角色绑定二维码</h3>
|
||||||
{bindingInfo?.qrImage || bindingQrImage ? (
|
{bindingInfo?.qrImage || bindingQrImage ? (
|
||||||
@@ -1301,7 +1312,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
: '请使用微信APP扫码进行游戏角色绑定'}
|
: '请使用微信APP扫码进行游戏角色绑定'}
|
||||||
</p>
|
</p>
|
||||||
<p className="customer-binding-qr-hint">
|
<p className="customer-binding-qr-hint">
|
||||||
扫码后系统会核对平台角色与已填资料;不一致时可修改资料或同步平台角色。
|
扫码后系统会核对平台角色与已填资料;三项完全一致才能提交平台绑定。
|
||||||
</p>
|
</p>
|
||||||
<p className="customer-binding-qr-tip">
|
<p className="customer-binding-qr-tip">
|
||||||
{selectedTask?.bindingStatus === 'scanned'
|
{selectedTask?.bindingStatus === 'scanned'
|
||||||
@@ -1311,7 +1322,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
? '已向虎牙提交绑定,正在等待角色生效,请稍候刷新。'
|
? '已向虎牙提交绑定,正在等待角色生效,请稍候刷新。'
|
||||||
: bindingInfo?.rebindRequested
|
: bindingInfo?.rebindRequested
|
||||||
? '扫码后请在虎牙弹窗中选中目标角色;选好后点下方「已选好角色,提交换绑」。'
|
? '扫码后请在虎牙弹窗中选中目标角色;选好后点下方「已选好角色,提交换绑」。'
|
||||||
: '请在微信中完成角色绑定确认,再点击下方按钮进入下一步。'
|
: '请在微信中完成角色绑定确认,再点击下方按钮核对平台角色。'
|
||||||
: '扫码后请在微信确认框中核对目标角色。'}
|
: '扫码后请在微信确认框中核对目标角色。'}
|
||||||
</p>
|
</p>
|
||||||
{nextRebindText ? (
|
{nextRebindText ? (
|
||||||
@@ -1354,13 +1365,13 @@ export default function CustomerFulfillmentPage({
|
|||||||
>
|
>
|
||||||
{rebindAccepted || bindConfirmPending
|
{rebindAccepted || bindConfirmPending
|
||||||
? '刷新绑定状态'
|
? '刷新绑定状态'
|
||||||
: '已扫码绑定,点击进入下一步'}
|
: '已扫码绑定,点击核对平台角色'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectedTask?.bindingStatus === 'expired' ? (
|
{selectedTask?.bindingStatus === 'expired' && !profileEditing ? (
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
@@ -1374,7 +1385,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectedTask?.bindingStatus === 'failed' ? (
|
{selectedTask?.bindingStatus === 'failed' && !profileEditing ? (
|
||||||
<Alert
|
<Alert
|
||||||
type="error"
|
type="error"
|
||||||
showIcon
|
showIcon
|
||||||
@@ -1390,16 +1401,18 @@ export default function CustomerFulfillmentPage({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectedTask?.bindingStatus === 'role_ready' && !bindingSessionExpired ? (
|
{selectedTask?.bindingStatus === 'role_ready' &&
|
||||||
|
!bindingSessionExpired &&
|
||||||
|
!profileEditing ? (
|
||||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||||
{bindingRequiresSupport ? (
|
{bindingNeedsSupport ? (
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
message="请联系客服人工核实绑定角色"
|
message="请联系客服人工核实绑定角色"
|
||||||
description={`平台未返回可核对的角色ID,无法自动核对。请复制订单号 ${
|
description={`两侧角色信息不完整,无法自动核对。请复制订单号 ${
|
||||||
orderNo || selectedTask?.orderNo || ''
|
orderNo || selectedTask?.orderNo || ''
|
||||||
} 联系客服,核实完成前请不要确认绑定。`}
|
} 联系客服,核实完成前请不要提交平台绑定。`}
|
||||||
/>
|
/>
|
||||||
) : showRebindFailure ? (
|
) : showRebindFailure ? (
|
||||||
<Alert
|
<Alert
|
||||||
@@ -1427,24 +1440,11 @@ export default function CustomerFulfillmentPage({
|
|||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : comparisonMismatch && bindingComparison ? (
|
||||||
<Alert
|
|
||||||
type="success"
|
|
||||||
showIcon
|
|
||||||
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
|
|
||||||
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' · ')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{!bindingRequiresSupport &&
|
|
||||||
!showRebindFailure &&
|
|
||||||
comparisonMismatch &&
|
|
||||||
bindingComparison ? (
|
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
message="平台识别的角色与已填资料不一致"
|
message="平台角色与已填资料不一致"
|
||||||
description={
|
description={
|
||||||
<Space direction="vertical" size={2}>
|
<Space direction="vertical" size={2}>
|
||||||
<span>
|
<span>
|
||||||
@@ -1457,12 +1457,23 @@ export default function CustomerFulfillmentPage({
|
|||||||
{bindingComparison.customerRoleName || '角色未填'}(ID{' '}
|
{bindingComparison.customerRoleName || '角色未填'}(ID{' '}
|
||||||
{bindingComparison.customerRoleId || '未填'})
|
{bindingComparison.customerRoleId || '未填'})
|
||||||
</span>
|
</span>
|
||||||
<span>三项一致后才能提交确认;可一键同步平台角色。</span>
|
<span>
|
||||||
|
三项完全一致才能提交平台绑定;请重新扫码换绑,或上一步修改资料。
|
||||||
|
</span>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : (
|
||||||
{bindingRequiresSupport ? (
|
<Alert
|
||||||
|
type="success"
|
||||||
|
showIcon
|
||||||
|
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
|
||||||
|
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{bindingNeedsSupport ? (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
<Button
|
<Button
|
||||||
block
|
block
|
||||||
@@ -1486,86 +1497,53 @@ export default function CustomerFulfillmentPage({
|
|||||||
刷新状态
|
刷新状态
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : showRebindFailure ? (
|
) : showRebindFailure || comparisonMismatch ? (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
<Button
|
{comparisonMismatch && rebindAccepted ? (
|
||||||
block
|
<>
|
||||||
size="large"
|
<Button
|
||||||
className="customer-binding-confirm"
|
block
|
||||||
loading={bindingLoading}
|
size="large"
|
||||||
onClick={() => void handleSubmitRebind()}
|
className="customer-binding-confirm"
|
||||||
>
|
icon={<ExclamationCircleOutlined />}
|
||||||
重新提交换绑
|
onClick={() => void openProfileEditor()}
|
||||||
</Button>
|
>
|
||||||
<Button
|
上一步修改资料
|
||||||
block
|
</Button>
|
||||||
size="large"
|
<Button
|
||||||
className="customer-binding-rebind"
|
block
|
||||||
icon={<ReloadOutlined />}
|
size="large"
|
||||||
loading={bindingLoading}
|
className="customer-binding-rebind"
|
||||||
onClick={() => void handleRefreshBinding(true)}
|
icon={<ReloadOutlined />}
|
||||||
>
|
loading={bindingLoading}
|
||||||
重新扫码换绑
|
onClick={() => void handleRefreshBinding(true)}
|
||||||
</Button>
|
>
|
||||||
<Button
|
重新扫码换绑
|
||||||
block
|
</Button>
|
||||||
size="large"
|
</>
|
||||||
className="customer-binding-accept"
|
) : (
|
||||||
onClick={() => {
|
<>
|
||||||
setRebindFailureDismissed(true)
|
<Button
|
||||||
window.setTimeout(() => {
|
block
|
||||||
document
|
size="large"
|
||||||
.getElementById('customer-binding-stage')
|
className="customer-binding-confirm"
|
||||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
icon={showRebindFailure ? <ReloadOutlined /> : undefined}
|
||||||
}, 0)
|
loading={bindingLoading}
|
||||||
}}
|
onClick={() => void handleRefreshBinding(true)}
|
||||||
>
|
>
|
||||||
返回上一步
|
重新扫码换绑
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
<Button
|
||||||
) : comparisonMismatch ? (
|
block
|
||||||
<div className="customer-binding-role-actions">
|
size="large"
|
||||||
<Button
|
className="customer-binding-rebind"
|
||||||
block
|
icon={<ExclamationCircleOutlined />}
|
||||||
size="large"
|
onClick={() => void openProfileEditor()}
|
||||||
className="customer-binding-confirm"
|
>
|
||||||
loading={profileSaving}
|
上一步修改资料
|
||||||
onClick={() => void handleSyncBindingProfile()}
|
</Button>
|
||||||
>
|
</>
|
||||||
同步平台角色并继续
|
)}
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
block
|
|
||||||
size="large"
|
|
||||||
className="customer-binding-rebind"
|
|
||||||
icon={<ExclamationCircleOutlined />}
|
|
||||||
loading={bindingLoading}
|
|
||||||
onClick={() => void handleRefreshBinding(true)}
|
|
||||||
>
|
|
||||||
角色不对,重新扫码换绑
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
) : rebindUnchanged ? (
|
|
||||||
<div className="customer-binding-role-actions">
|
|
||||||
<Button
|
|
||||||
block
|
|
||||||
size="large"
|
|
||||||
className="customer-binding-confirm"
|
|
||||||
loading={bindingLoading}
|
|
||||||
onClick={() => handleAcceptExistingRole()}
|
|
||||||
>
|
|
||||||
确认使用原角色
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
block
|
|
||||||
size="large"
|
|
||||||
className="customer-binding-rebind"
|
|
||||||
icon={<ExclamationCircleOutlined />}
|
|
||||||
loading={bindingLoading}
|
|
||||||
onClick={() => void handleRefreshBinding(true)}
|
|
||||||
>
|
|
||||||
角色不对,重新扫码换绑
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
@@ -1574,26 +1552,17 @@ export default function CustomerFulfillmentPage({
|
|||||||
size="large"
|
size="large"
|
||||||
className="customer-binding-confirm"
|
className="customer-binding-confirm"
|
||||||
loading={bindingLoading}
|
loading={bindingLoading}
|
||||||
|
disabled={!bindingComparison}
|
||||||
onClick={() => setBindingConfirmOpen(true)}
|
onClick={() => setBindingConfirmOpen(true)}
|
||||||
>
|
>
|
||||||
确认绑定角色
|
{bindingComparison ? '提交平台绑定' : '正在核对平台角色...'}
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
block
|
|
||||||
size="large"
|
|
||||||
className="customer-binding-rebind"
|
|
||||||
icon={<ExclamationCircleOutlined />}
|
|
||||||
loading={bindingLoading}
|
|
||||||
onClick={() => void handleRefreshBinding(true)}
|
|
||||||
>
|
|
||||||
角色不对,重新扫码换绑
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectedTask?.bindingStatus === 'confirmed' ? (
|
{selectedTask?.bindingStatus === 'confirmed' && !profileEditing ? (
|
||||||
<div className="customer-binding-verify">
|
<div className="customer-binding-verify">
|
||||||
<p>绑定状态需要平台人工核实,请联系客服处理</p>
|
<p>绑定状态需要平台人工核实,请联系客服处理</p>
|
||||||
<Button
|
<Button
|
||||||
@@ -1637,44 +1606,44 @@ export default function CustomerFulfillmentPage({
|
|||||||
bindingConfirmOpen &&
|
bindingConfirmOpen &&
|
||||||
selectedTask?.bindingStatus === 'role_ready' &&
|
selectedTask?.bindingStatus === 'role_ready' &&
|
||||||
!rebindUnchanged &&
|
!rebindUnchanged &&
|
||||||
!bindingRequiresSupport
|
!bindingNeedsSupport &&
|
||||||
|
!profileEditing
|
||||||
}
|
}
|
||||||
title="确认绑定角色"
|
className="customer-binding-modal"
|
||||||
|
title="核对绑定角色"
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
if (!bindingLoading) setBindingConfirmOpen(false)
|
if (!bindingLoading) setBindingConfirmOpen(false)
|
||||||
}}
|
}}
|
||||||
footer={
|
footer={
|
||||||
<div className="customer-binding-modal-footer">
|
<div className="customer-binding-modal-footer">
|
||||||
<div className="customer-binding-modal-actions">
|
{bindingComparison?.verdict === 'match' ? (
|
||||||
<Button
|
<div className="customer-binding-modal-actions">
|
||||||
onClick={() => {
|
<Button
|
||||||
if (!bindingLoading) setBindingConfirmOpen(false)
|
onClick={() => {
|
||||||
}}
|
if (!bindingLoading) setBindingConfirmOpen(false)
|
||||||
>
|
}}
|
||||||
取消
|
>
|
||||||
</Button>
|
取消
|
||||||
<Button
|
</Button>
|
||||||
type="primary"
|
<Button
|
||||||
loading={bindingLoading}
|
type="primary"
|
||||||
disabled={!bindingCustomerReady || bindingComparison?.verdict === 'mismatch'}
|
loading={bindingLoading}
|
||||||
onClick={() => void handleConfirmBinding()}
|
onClick={() => void handleConfirmBinding()}
|
||||||
>
|
>
|
||||||
确认绑定
|
提交平台绑定
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
|
||||||
{bindingComparison?.verdict === 'mismatch' ? (
|
|
||||||
<div className="customer-binding-modal-actions is-mismatch">
|
|
||||||
<Button onClick={openProfileEditor}>修改资料</Button>
|
|
||||||
{canSyncBindingProfile ? (
|
|
||||||
<Button loading={profileSaving} onClick={() => void handleSyncBindingProfile()}>
|
|
||||||
同步平台角色
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : (
|
||||||
|
<div className="customer-binding-modal-actions is-mismatch">
|
||||||
|
<Button onClick={() => void openProfileEditor()}>上一步修改资料</Button>
|
||||||
|
<Button loading={bindingLoading} onClick={() => void handleRefreshBinding(true)}>
|
||||||
|
重新扫码换绑
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{bindingComparison?.verdict === 'mismatch' ? (
|
{bindingComparison?.verdict === 'mismatch' ? (
|
||||||
<p className="customer-binding-modal-error">
|
<p className="customer-binding-modal-error">
|
||||||
{bindingComparison?.message || '两侧角色信息不一致,无法确认绑定'}
|
{bindingComparison?.message || '两侧角色信息不一致,无法提交平台绑定'}
|
||||||
</p>
|
</p>
|
||||||
) : bindingComparison?.verdict === 'unknown' ? (
|
) : bindingComparison?.verdict === 'unknown' ? (
|
||||||
<p className="customer-binding-modal-warning">两侧角色信息不完整,请联系客服核实</p>
|
<p className="customer-binding-modal-warning">两侧角色信息不完整,请联系客服核实</p>
|
||||||
@@ -1684,12 +1653,14 @@ export default function CustomerFulfillmentPage({
|
|||||||
destroyOnClose
|
destroyOnClose
|
||||||
>
|
>
|
||||||
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||||
<p style={{ margin: 0 }}>检测到待确认的绑定角色,请核对两侧角色是否一致。</p>
|
<p style={{ margin: 0 }}>
|
||||||
|
请核对两侧区服、角色名称与角色 ID,三项完全一致才能提交平台绑定。
|
||||||
|
</p>
|
||||||
<div className="customer-binding-compare">
|
<div className="customer-binding-compare">
|
||||||
<div className="customer-binding-compare-side">
|
<div className="customer-binding-compare-side">
|
||||||
<div className="customer-binding-compare-head">
|
<div className="customer-binding-compare-head">
|
||||||
<span>您填写的角色</span>
|
<span>您填写的角色</span>
|
||||||
<Button type="link" size="small" onClick={openProfileEditor}>
|
<Button type="link" size="small" onClick={() => void openProfileEditor()}>
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -1698,7 +1669,7 @@ export default function CustomerFulfillmentPage({
|
|||||||
</div>
|
</div>
|
||||||
<div className="customer-binding-compare-side">
|
<div className="customer-binding-compare-side">
|
||||||
<div className="customer-binding-compare-head">
|
<div className="customer-binding-compare-head">
|
||||||
<span>待确认角色</span>
|
<span>平台识别角色</span>
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -1808,114 +1779,23 @@ function CustomerOrderCard({ task }: { task: CustomerSemiAutoTask }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function CustomerCollectStep(input: {
|
const HUYA_FLOW_STEPS = ['登录虎牙账号', '填写游戏资料', '绑定游戏角色']
|
||||||
task: CustomerSemiAutoTask
|
|
||||||
onSaved: (task: CustomerSemiAutoTask) => void
|
|
||||||
}) {
|
|
||||||
const { message } = App.useApp()
|
|
||||||
const [serverZone, setServerZone] = useState(input.task.customerServerZone || '')
|
|
||||||
const [roleId, setRoleId] = useState(input.task.customerGameRoleId || '')
|
|
||||||
const [roleName, setRoleName] = useState(input.task.customerGameRoleName || '')
|
|
||||||
const [saving, setSaving] = useState(false)
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
if (!serverZone.trim() || !roleId.trim() || !roleName.trim()) {
|
|
||||||
message.warning('请完整填写区服、游戏编号和角色名')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!SERVER_ZONE_OPTIONS.includes(serverZone.trim())) {
|
|
||||||
message.warning('请选择区服')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!/^\d+$/.test(roleId.trim())) {
|
|
||||||
message.warning('游戏编号只能是数字')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setSaving(true)
|
|
||||||
try {
|
|
||||||
const response = await saveCustomerTaskProfile(input.task.orderNo, input.task.id, {
|
|
||||||
roleName: roleName.trim(),
|
|
||||||
roleId: roleId.trim(),
|
|
||||||
serverZone: serverZone.trim(),
|
|
||||||
})
|
|
||||||
input.onSaved(response.data.task)
|
|
||||||
message.success('资料已提交')
|
|
||||||
} catch (error) {
|
|
||||||
message.error(error instanceof Error ? error.message : '提交资料失败')
|
|
||||||
} finally {
|
|
||||||
setSaving(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/** 虎牙三步进度:登录 → 填写资料 → 绑定角色。current=4 表示三步都已走完。 */
|
||||||
|
function CustomerHuyaSteps({ current }: { current: number }) {
|
||||||
return (
|
return (
|
||||||
<div className="customer-collect-page">
|
<ol className="customer-huya-steps" aria-label="虎牙履约步骤">
|
||||||
<div className="customer-collect-hero">
|
{HUYA_FLOW_STEPS.map((label, index) => {
|
||||||
<p className="customer-collect-warning">温馨提示:未成年人禁止下单</p>
|
const step = index + 1
|
||||||
</div>
|
const state = step < current ? 'is-done' : step === current ? 'is-active' : ''
|
||||||
<div className="customer-collect-body">
|
return (
|
||||||
<label className="customer-collect-label">
|
<li key={label} className={`customer-huya-step ${state}`.trim()}>
|
||||||
订单号 <span>*</span>
|
<span className="customer-huya-step-index">{step < current ? '✓' : step}</span>
|
||||||
</label>
|
<span className="customer-huya-step-label">{label}</span>
|
||||||
<div className="customer-collect-readonly">{input.task.orderNo}</div>
|
</li>
|
||||||
|
)
|
||||||
<div className="customer-collect-card">
|
})}
|
||||||
<div>
|
</ol>
|
||||||
<span>商品</span>
|
|
||||||
<strong>{input.task.productName || input.task.skuName}</strong>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span>游戏</span>
|
|
||||||
<strong>和平精英</strong>
|
|
||||||
</div>
|
|
||||||
<p>填完资料记得截图联系客服。</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label className="customer-collect-label">
|
|
||||||
区服 <span>*</span>
|
|
||||||
</label>
|
|
||||||
<Select
|
|
||||||
className="customer-collect-select"
|
|
||||||
classNames={SERVER_ZONE_SELECT_CLASS_NAMES}
|
|
||||||
value={serverZone || undefined}
|
|
||||||
onChange={(value) => setServerZone(String(value))}
|
|
||||||
placeholder="请选择区服"
|
|
||||||
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<label className="customer-collect-label">
|
|
||||||
游戏编号 <span>*</span>
|
|
||||||
</label>
|
|
||||||
<Input
|
|
||||||
className="customer-collect-input"
|
|
||||||
value={roleId}
|
|
||||||
onChange={(event) => setRoleId(event.target.value)}
|
|
||||||
placeholder="请输入游戏编号"
|
|
||||||
maxLength={64}
|
|
||||||
inputMode="numeric"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<label className="customer-collect-label">
|
|
||||||
角色名 <span>*</span>
|
|
||||||
</label>
|
|
||||||
<Input
|
|
||||||
className="customer-collect-input"
|
|
||||||
value={roleName}
|
|
||||||
onChange={(event) => setRoleName(event.target.value)}
|
|
||||||
placeholder="请输入角色名"
|
|
||||||
maxLength={100}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
block
|
|
||||||
size="large"
|
|
||||||
className="customer-collect-submit"
|
|
||||||
loading={saving}
|
|
||||||
onClick={() => void submit()}
|
|
||||||
>
|
|
||||||
提交资料
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export default function HuyaChallengeModal(input: Props) {
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={input.open}
|
open={input.open}
|
||||||
|
className="customer-huya-challenge-modal"
|
||||||
title="完成虎牙安全验证"
|
title="完成虎牙安全验证"
|
||||||
width={430}
|
width={430}
|
||||||
centered
|
centered
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ export function pollCustomerBinding(orderNo: string, taskId: number) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 返回上一步修改资料:清空绑定/换绑状态,保留登录会话与已填资料。 */
|
||||||
|
export function resetCustomerBinding(orderNo: string, taskId: number) {
|
||||||
|
return apiPost<{ task: CustomerSemiAutoTask; binding: CustomerBindingInfo | null }>(
|
||||||
|
`/api/v1/customer-fulfillment/${encodeURIComponent(orderNo)}/tasks/${taskId}/binding/reset`,
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function confirmCustomerBinding(
|
export function confirmCustomerBinding(
|
||||||
orderNo: string,
|
orderNo: string,
|
||||||
taskId: number,
|
taskId: number,
|
||||||
|
|||||||
@@ -1465,29 +1465,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-auth-hero {
|
.customer-auth-hero {
|
||||||
min-height: auto;
|
position: relative;
|
||||||
|
min-height: clamp(112px, 15vw, 136px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-end;
|
||||||
justify-content: center;
|
|
||||||
padding: 38px 16px 10px;
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 微博登录页顶部 KV:与资料页共用 inside-kv.jpg,叠加深色渐变保证标题可读。 */
|
|
||||||
.customer-auth-page.is-weibo .customer-auth-hero {
|
|
||||||
min-height: 134px;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
padding: 26px 20px 20px;
|
padding: 12px 20px 14px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: left;
|
||||||
background-color: #0b1220;
|
background-color: #0b1220;
|
||||||
background-image:
|
background-image:
|
||||||
linear-gradient(180deg, rgba(11, 18, 32, 0.12) 0%, rgba(11, 18, 32, 0.72) 72%, #232936 100%),
|
linear-gradient(180deg, rgba(11, 18, 32, 0.06) 0%, rgba(11, 18, 32, 0.62) 72%, #232936 100%),
|
||||||
url('/images/customer/inside-kv.jpg');
|
url('/images/customer/inside-kv.jpg');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center 38%;
|
background-position: center 38%;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 微博与虎牙客户页统一使用同一套顶部 KV,不再单独覆盖背景。 */
|
||||||
.customer-auth-page.is-weibo .customer-auth-brand {
|
.customer-auth-page.is-weibo .customer-auth-brand {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
@@ -1499,17 +1494,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.customer-auth-page.is-weibo .customer-auth-hero {
|
.customer-auth-hero {
|
||||||
min-height: 118px;
|
min-height: 112px;
|
||||||
padding: 20px 16px 14px;
|
padding: 12px 16px 14px;
|
||||||
background-position: center 42%;
|
background-position: center 42%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-auth-brand {
|
.customer-auth-brand {
|
||||||
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: flex-start;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
@@ -1535,7 +1531,8 @@
|
|||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0;
|
letter-spacing: 0;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
|
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
@@ -2184,19 +2181,19 @@
|
|||||||
/* 资料页顶部 KV:原图 https://game.gtimg.cn/images/gp/web201908/inside_kv.jpg(本地 1600×510 q82) */
|
/* 资料页顶部 KV:原图 https://game.gtimg.cn/images/gp/web201908/inside_kv.jpg(本地 1600×510 q82) */
|
||||||
.customer-collect-hero {
|
.customer-collect-hero {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: clamp(190px, 24vw, 240px);
|
min-height: clamp(132px, 18vw, 160px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0 20px 16px;
|
padding: 0 18px 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: #0b1220;
|
background-color: #0b1220;
|
||||||
background-image:
|
background-image:
|
||||||
linear-gradient(180deg, rgba(11, 18, 32, 0) 45%, rgba(11, 18, 32, 0.55) 72%, #0b1220 100%),
|
linear-gradient(180deg, rgba(11, 18, 32, 0) 38%, rgba(11, 18, 32, 0.55) 72%, #0b1220 100%),
|
||||||
url('/images/customer/inside-kv.jpg');
|
url('/images/customer/inside-kv.jpg');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center 38%;
|
background-position: center 40%;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2211,8 +2208,8 @@
|
|||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.customer-collect-hero {
|
.customer-collect-hero {
|
||||||
min-height: 180px;
|
min-height: 132px;
|
||||||
padding: 0 16px 14px;
|
padding: 0 16px 12px;
|
||||||
background-position: center 42%;
|
background-position: center 42%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2497,6 +2494,72 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-huya-steps {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 12px 16px 0;
|
||||||
|
padding: 12px 14px;
|
||||||
|
list-style: none;
|
||||||
|
border: 1px solid #3a4150;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #1b212c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step {
|
||||||
|
display: flex;
|
||||||
|
flex: 1 1 0;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
min-width: 0;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step-index {
|
||||||
|
display: inline-flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
border: 1px solid #3a4150;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
background: #212733;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step-label {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step.is-active {
|
||||||
|
color: #f8fafc;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step.is-active .customer-huya-step-index {
|
||||||
|
color: #fff;
|
||||||
|
border-color: #2563eb;
|
||||||
|
background: #2563eb;
|
||||||
|
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step.is-done {
|
||||||
|
color: #6ee7b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step.is-done .customer-huya-step-index {
|
||||||
|
color: #6ee7b7;
|
||||||
|
border-color: #065f46;
|
||||||
|
background: rgba(6, 78, 59, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
.customer-order-card {
|
.customer-order-card {
|
||||||
margin: 10px 16px 0;
|
margin: 10px 16px 0;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
@@ -3088,9 +3151,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-auth-hero {
|
.customer-auth-hero {
|
||||||
min-height: auto;
|
min-height: 112px;
|
||||||
padding: 38px 16px 10px;
|
padding: 12px 16px 14px;
|
||||||
background: none;
|
background-position: center 42%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-auth-brand h1 {
|
.customer-auth-brand h1 {
|
||||||
@@ -3111,6 +3174,23 @@
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-huya-steps {
|
||||||
|
gap: 6px;
|
||||||
|
margin: 10px 16px 0;
|
||||||
|
padding: 10px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step {
|
||||||
|
gap: 5px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-huya-step-index {
|
||||||
|
width: 19px;
|
||||||
|
height: 19px;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.customer-auth-facts {
|
.customer-auth-facts {
|
||||||
padding-inline: 20px;
|
padding-inline: 20px;
|
||||||
}
|
}
|
||||||
@@ -3231,3 +3311,244 @@
|
|||||||
line-height: 1.45;
|
line-height: 1.45;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
客户履约页(半自动)固定移动端 + 窄屏自适应
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden
|
||||||
|
裁掉横向溢出。应用内浏览器 / 分屏 / 系统显示放大时实际视口可能小于 320px,
|
||||||
|
页面右侧(输入框、商品值、提示文案)会被直接裁掉。
|
||||||
|
下面只作用于客户履约页(body.customer-mobile-body),不影响后台与打手端。
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
html.customer-mobile-html,
|
||||||
|
body.customer-mobile-body {
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body #root {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-page,
|
||||||
|
body.customer-mobile-body .customer-auth-page {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
min-height: 100dvh;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-hero {
|
||||||
|
width: min(480px, 100%);
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-body {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px clamp(12px, 4vw, 20px) calc(40px + env(safe-area-inset-bottom));
|
||||||
|
padding-left: max(clamp(12px, 4vw, 20px), env(safe-area-inset-left));
|
||||||
|
padding-right: max(clamp(12px, 4vw, 20px), env(safe-area-inset-right));
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-shell {
|
||||||
|
width: min(480px, 100%);
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-main {
|
||||||
|
padding-bottom: calc(24px + env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-content-stack,
|
||||||
|
body.customer-mobile-body .customer-auth-section,
|
||||||
|
body.customer-mobile-body .customer-auth-facts,
|
||||||
|
body.customer-mobile-body .customer-auth-facts > div,
|
||||||
|
body.customer-mobile-body .customer-auth-task-switcher,
|
||||||
|
body.customer-mobile-body .customer-login-form,
|
||||||
|
body.customer-mobile-body .customer-collect-card,
|
||||||
|
body.customer-mobile-body .customer-order-card {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card,
|
||||||
|
body.customer-mobile-body .customer-collect-readonly,
|
||||||
|
body.customer-mobile-body .customer-collect-input.ant-input,
|
||||||
|
body.customer-mobile-body .customer-collect-select.ant-select,
|
||||||
|
body.customer-mobile-body .customer-login-mobile.ant-input,
|
||||||
|
body.customer-mobile-body .customer-login-code-input.ant-input,
|
||||||
|
body.customer-mobile-body .customer-login-submit.ant-btn,
|
||||||
|
body.customer-mobile-body .customer-login-alt.ant-btn {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 订单卡片自带左右 16px 外边距,不能用 width:100% 再加边距 */
|
||||||
|
body.customer-mobile-body .customer-order-card {
|
||||||
|
width: auto;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card > div,
|
||||||
|
body.customer-mobile-body .customer-order-card > div {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card > div strong,
|
||||||
|
body.customer-mobile-body .customer-order-card > div strong {
|
||||||
|
flex: 1 1 10ch;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 状态胶囊保持自身宽度,不参与长值换行规则 */
|
||||||
|
body.customer-mobile-body .customer-order-card > div strong.customer-order-status {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
max-width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-readonly {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card > p {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-login-form,
|
||||||
|
body.customer-mobile-body .customer-login-mobile-row,
|
||||||
|
body.customer-mobile-body .customer-login-code-input.ant-input {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-role-card,
|
||||||
|
body.customer-mobile-body .customer-auth-button-stack {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 登录/绑定二维码:容器与图片都不超过可用宽度,避免 232/252/260px 固定宽溢出 */
|
||||||
|
body.customer-mobile-body .customer-auth-qr-image,
|
||||||
|
body.customer-mobile-body .customer-auth-qr-placeholder {
|
||||||
|
width: min(252px, 100%);
|
||||||
|
min-height: 0;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-qr-image .ant-image,
|
||||||
|
body.customer-mobile-body .customer-auth-qr-image img,
|
||||||
|
body.customer-mobile-body .customer-binding-qr-card .ant-image,
|
||||||
|
body.customer-mobile-body .customer-binding-qr-card img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 固定宽度弹窗(绑定确认 520 / 虎牙验证 430)在窄屏必须收到视口内 */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.customer-binding-modal,
|
||||||
|
.customer-huya-challenge-modal {
|
||||||
|
width: calc(100vw - 24px) !important;
|
||||||
|
max-width: 480px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-binding-modal .ant-modal-content,
|
||||||
|
.customer-huya-challenge-modal .ant-modal-content {
|
||||||
|
max-height: calc(100vh - 32px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 380px) {
|
||||||
|
body.customer-mobile-body .customer-binding-qr-actions,
|
||||||
|
body.customer-mobile-body .customer-binding-modal-actions {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 340px) {
|
||||||
|
body.customer-mobile-body .customer-collect-body {
|
||||||
|
padding-inline: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 标签 + 长值改为上下排列,值不再被挤到屏幕外 */
|
||||||
|
body.customer-mobile-body .customer-collect-card > div,
|
||||||
|
body.customer-mobile-body .customer-order-card > div {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card > div strong,
|
||||||
|
body.customer-mobile-body .customer-order-card > div strong {
|
||||||
|
flex: 0 1 auto;
|
||||||
|
max-width: 100%;
|
||||||
|
justify-self: start;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-order-card > div strong.customer-order-status {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-collect-card > p {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-login-mobile-row {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-login-code-button.ant-btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-task-switcher {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-task-switcher > span {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-facts {
|
||||||
|
padding-inline: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-facts > div {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
gap: 4px;
|
||||||
|
min-height: 0;
|
||||||
|
padding-block: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-facts > div > strong {
|
||||||
|
justify-self: start;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-state {
|
||||||
|
padding: 32px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.customer-mobile-body .customer-auth-privacy {
|
||||||
|
margin-inline: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,8 +76,21 @@ export type SemiAutoTaskListResult = {
|
|||||||
pagination: { page: number; pageSize: number; total: number }
|
pagination: { page: number; pageSize: number; total: number }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SemiAutoBindingComparison = {
|
||||||
|
verdict: 'match' | 'mismatch' | 'unknown'
|
||||||
|
customerRoleName: string
|
||||||
|
customerRoleId: string
|
||||||
|
customerZone: string
|
||||||
|
boundRoleName: string
|
||||||
|
boundRoleId: string
|
||||||
|
boundZone: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
export type SemiAutoTaskDetail = {
|
export type SemiAutoTaskDetail = {
|
||||||
task: SemiAutoTask
|
task: SemiAutoTask
|
||||||
|
/** 与客户页同源的区服 / 角色名 / 角色 ID 三项比对结果。 */
|
||||||
|
comparison: SemiAutoBindingComparison
|
||||||
events: SemiAutoTaskEvent[]
|
events: SemiAutoTaskEvent[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,48 +11,42 @@ const source = readFileSync(
|
|||||||
)
|
)
|
||||||
const styles = readFileSync(join(root, '../src/styles/client.css'), 'utf8')
|
const styles = readFileSync(join(root, '../src/styles/client.css'), 'utf8')
|
||||||
|
|
||||||
test('扫码识别角色后,资料不一致也打开对比弹窗', () => {
|
test('资料不一致时不自动弹核对框,由页面两个按钮处理', () => {
|
||||||
// 自动弹窗 effect 不再因 mismatch 提前 return。
|
assert.ok(source.includes("if (bindingInfo.comparison.verdict !== 'match') return"))
|
||||||
assert.ok(source.includes('识别到角色(含与资料不一致)都要弹出对比框'))
|
assert.ok(source.includes('不一致时不弹框'))
|
||||||
assert.ok(!source.includes("if (bindingInfo.comparison.verdict === 'mismatch') return"))
|
// 手动刷新时也只有三项一致才打开核对框。
|
||||||
// 手动刷新时 mismatch 同样打开弹窗,不再关闭并只弹提示。
|
assert.ok(source.includes("if (nextBinding?.comparison?.verdict === 'match') {"))
|
||||||
assert.ok(source.includes('资料不一致同样打开对比框'))
|
|
||||||
assert.ok(!source.includes('平台角色与已填资料不一致,请先同步资料'))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('对比弹窗在资料不一致时提供修改资料与同步平台角色入口', () => {
|
test('资料不一致时固定提供重新扫码换绑与上一步修改资料', () => {
|
||||||
assert.ok(source.includes('修改资料'))
|
assert.ok(source.includes('showRebindFailure || comparisonMismatch'))
|
||||||
assert.ok(source.includes('同步平台角色'))
|
assert.ok(source.includes('重新扫码换绑'))
|
||||||
assert.ok(source.includes('canSyncBindingProfile'))
|
assert.ok(source.includes('上一步修改资料'))
|
||||||
assert.ok(source.includes('onClick={openProfileEditor}'))
|
assert.ok(source.includes('onClick={() => void openProfileEditor()}'))
|
||||||
assert.ok(
|
// 取消同步平台角色与直接使用原角色的快捷路径。
|
||||||
source.includes(
|
assert.ok(!source.includes('同步平台角色'))
|
||||||
"disabled={!bindingCustomerReady || bindingComparison?.verdict === 'mismatch'}",
|
assert.ok(!source.includes('确认使用原角色'))
|
||||||
),
|
assert.ok(styles.includes('.customer-binding-role-actions'))
|
||||||
)
|
|
||||||
assert.ok(styles.includes('.customer-binding-modal-actions.is-mismatch'))
|
|
||||||
assert.ok(styles.includes('repeat(auto-fit, minmax(140px, 1fr))'))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('保存资料或同步平台角色后会重新打开对比弹窗', () => {
|
test('保存资料后只有三项一致才重新打开核对弹窗', () => {
|
||||||
assert.ok(source.includes('function reopenBindingConfirm('))
|
assert.ok(source.includes('function reopenBindingConfirm('))
|
||||||
assert.ok(source.includes("if (nextTask.bindingStatus !== 'role_ready') return false"))
|
assert.ok(source.includes("if (nextTask.bindingStatus !== 'role_ready') return false"))
|
||||||
|
assert.ok(source.includes("if (nextBinding.comparison.verdict !== 'match') return false"))
|
||||||
assert.ok(source.includes('reopened = reopenBindingConfirm('))
|
assert.ok(source.includes('reopened = reopenBindingConfirm('))
|
||||||
assert.ok(
|
assert.ok(source.includes('资料已保存且与平台角色一致,请提交平台绑定'))
|
||||||
source.includes(
|
|
||||||
'reopenBindingConfirm(bindingResponse.data.task, bindingResponse.data.binding)',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
assert.ok(source.includes('角色资料已保存,请重新核对绑定角色'))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('资料不一致时仍保持后端严格比对:确认按钮禁用并显示原因', () => {
|
test('三项一致才出现提交平台绑定,不一致时展示原因', () => {
|
||||||
assert.ok(source.includes('两侧角色信息不一致,无法确认绑定'))
|
assert.ok(source.includes('提交平台绑定'))
|
||||||
|
assert.ok(source.includes("bindingComparison?.verdict === 'match'"))
|
||||||
|
assert.ok(source.includes('两侧角色信息不一致,无法提交平台绑定'))
|
||||||
assert.ok(source.includes('customer-binding-modal-error'))
|
assert.ok(source.includes('customer-binding-modal-error'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('二维码区提示扫码后会核对平台角色与已填资料', () => {
|
test('二维码区提示扫码后会核对平台角色与已填资料', () => {
|
||||||
assert.ok(source.includes('扫码后系统会核对平台角色与已填资料'))
|
assert.ok(source.includes('扫码后系统会核对平台角色与已填资料'))
|
||||||
|
assert.ok(source.includes('三项完全一致才能提交平台绑定'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('换绑流程刷新二维码必须带 forceRebind,避免直接返回已有角色', () => {
|
test('换绑流程刷新二维码必须带 forceRebind,避免直接返回已有角色', () => {
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFile } from 'node:fs/promises'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
function source(relativePath: string) {
|
||||||
|
return new URL(`../src/${relativePath}`, import.meta.url)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 半自动履约客户页是公开 H5 页面,可能被应用内浏览器、分屏或系统显示放大打开。
|
||||||
|
* 全局 base.css 的 body { min-width:320px } + worker.css 的 overflow-x:hidden
|
||||||
|
* 会在实际视口小于 320px 时把页面右侧直接裁掉(输入框/商品值/提示文案)。
|
||||||
|
* 这里锁住客户页专属移动端根类和 480px 移动壳,防止以后被全局样式改回去。
|
||||||
|
*/
|
||||||
|
test('客户履约页必须覆盖 body 320px 最小宽度并使用 480px 移动端壳', async () => {
|
||||||
|
const [app, css] = await Promise.all([
|
||||||
|
readFile(source('App.tsx'), 'utf8'),
|
||||||
|
readFile(source('styles/client.css'), 'utf8'),
|
||||||
|
])
|
||||||
|
|
||||||
|
assert.match(app, /customer-mobile-html/)
|
||||||
|
assert.match(app, /customer-mobile-body/)
|
||||||
|
assert.match(
|
||||||
|
css,
|
||||||
|
/html\.customer-mobile-html,\s*body\.customer-mobile-body\s*\{[^}]*min-width:\s*0/s,
|
||||||
|
)
|
||||||
|
assert.match(
|
||||||
|
css,
|
||||||
|
/body\.customer-mobile-body \.customer-collect-body\s*\{[^}]*max-width:\s*480px/s,
|
||||||
|
)
|
||||||
|
assert.match(
|
||||||
|
css,
|
||||||
|
/body\.customer-mobile-body \.customer-auth-shell\s*\{[^}]*width:\s*min\(480px,\s*100%\)/s,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('客户履约页固定宽度弹窗必须收进手机视口', async () => {
|
||||||
|
const [page, huya, css] = await Promise.all([
|
||||||
|
readFile(source('pages/customer-fulfillment/CustomerFulfillmentPage.tsx'), 'utf8'),
|
||||||
|
readFile(source('pages/customer-fulfillment/HuyaChallengeModal.tsx'), 'utf8'),
|
||||||
|
readFile(source('styles/client.css'), 'utf8'),
|
||||||
|
])
|
||||||
|
|
||||||
|
assert.match(page, /className="customer-binding-modal"/)
|
||||||
|
assert.match(huya, /className="customer-huya-challenge-modal"/)
|
||||||
|
assert.match(
|
||||||
|
css,
|
||||||
|
/\.customer-binding-modal,\s*\.customer-huya-challenge-modal\s*\{[^}]*width:\s*calc\(100vw - 24px\)\s*!important/s,
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -12,20 +12,47 @@ const source = readFileSync(
|
|||||||
'utf8',
|
'utf8',
|
||||||
)
|
)
|
||||||
|
|
||||||
test('换绑失败页用「返回上一步」替换「仍使用原角色」', () => {
|
test('换绑失败页提供重新扫码换绑与上一步修改资料,不再直接使用原角色', () => {
|
||||||
assert.ok(source.includes('rebindFailureDismissed'))
|
assert.ok(source.includes('showRebindFailure || comparisonMismatch'))
|
||||||
assert.ok(source.includes('返回上一步'))
|
assert.ok(source.includes('重新扫码换绑'))
|
||||||
assert.ok(!source.includes('仍使用原角色'))
|
assert.ok(source.includes('上一步修改资料'))
|
||||||
|
assert.ok(!source.includes('确认使用原角色'))
|
||||||
|
assert.ok(!source.includes('handleAcceptExistingRole'))
|
||||||
|
assert.ok(!source.includes('rebindFailureDismissed'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('返回后展示资料不一致核对界面', () => {
|
test('换绑后仍不一致时以修改资料为主,同时保留重新扫码入口', () => {
|
||||||
assert.ok(source.includes('showRebindFailure'))
|
const panelStart = source.indexOf('showRebindFailure || comparisonMismatch')
|
||||||
assert.ok(source.includes('!showRebindFailure &&'))
|
assert.ok(panelStart > 0)
|
||||||
assert.ok(source.includes('同步平台角色并继续'))
|
const panel = source.slice(panelStart, panelStart + 1600)
|
||||||
|
assert.ok(panel.includes('重新扫码换绑'))
|
||||||
|
assert.ok(panel.includes('上一步修改资料'))
|
||||||
assert.ok(source.includes('id="customer-binding-stage"'))
|
assert.ok(source.includes('id="customer-binding-stage"'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('资料同步后提供确认使用原角色', () => {
|
test('取消直接使用原角色的快捷确认路径', () => {
|
||||||
assert.ok(source.includes('确认使用原角色'))
|
assert.ok(!source.includes('acceptExistingRole'))
|
||||||
assert.ok(source.includes('handleAcceptExistingRole'))
|
assert.ok(!source.includes('modal.confirm'))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('点击上一步修改资料会回到第二步并隐藏绑定区', () => {
|
||||||
|
// 步骤条把编辑资料视为第二步,即使资料原本已完整。
|
||||||
|
assert.ok(source.includes(': profileEditing || !profileComplete'))
|
||||||
|
assert.ok(source.includes("'第二步:请填写游戏角色资料"))
|
||||||
|
assert.ok(source.includes('返回绑定角色'))
|
||||||
|
// 资料步骤隐藏二维码、失败提示和比对操作,避免与第二步混在一起。
|
||||||
|
assert.ok(source.includes('!profileEditing'))
|
||||||
|
assert.ok(source.includes("getElementById('customer-binding-stage')"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('上一步修改资料会清空换绑状态并保留已填资料', () => {
|
||||||
|
// 进入资料编辑时同步调用重置接口,清掉虎牙未接受换绑等失败痕迹。
|
||||||
|
assert.ok(source.includes('async function openProfileEditor()'))
|
||||||
|
assert.ok(source.includes('await resetCustomerBinding(orderNo, selectedTask.id)'))
|
||||||
|
assert.ok(source.includes('setBindingInfo(response.data.binding)'))
|
||||||
|
assert.ok(source.includes("message.success('已返回上一步,请修改资料后重新提交')"))
|
||||||
|
// 已登录且有绑定结果时才重置,资料表单本身不受影响。
|
||||||
|
assert.ok(source.includes("selectedTask.bindingStatus === 'not_started'"))
|
||||||
|
// 重置失败不阻断客户修改资料。
|
||||||
|
assert.ok(source.includes('重置绑定状态失败,请稍后重试'))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,8 +51,12 @@ test('微博订单卡只展示订单号/商品/平台/状态,不含游戏和
|
|||||||
assert.ok(!weiboBranch.includes('游戏名称'))
|
assert.ok(!weiboBranch.includes('游戏名称'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('微博顶部使用 inside-kv 背景,虎牙保持纯色', () => {
|
test('客户登录/绑定页顶部统一显示 inside-kv 背景,不再按平台区分', () => {
|
||||||
assert.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
|
assert.match(
|
||||||
assert.ok(styles.includes("url('/images/customer/inside-kv.jpg')"))
|
styles,
|
||||||
|
/\.customer-auth-hero \{[^}]*url\('\/images\/customer\/inside-kv\.jpg'\)[^}]*\}/s,
|
||||||
|
)
|
||||||
|
assert.ok(!styles.includes('.customer-auth-page.is-weibo .customer-auth-hero'))
|
||||||
assert.ok(!styles.includes('.customer-auth-page.is-huya .customer-auth-hero'))
|
assert.ok(!styles.includes('.customer-auth-page.is-huya .customer-auth-hero'))
|
||||||
|
assert.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-brand'))
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user