fix(douyu): 同步履约状态并补齐角色资料重置流程

- 接收 order_site 客户资料重置标记,清理旧角色并恢复待填写状态
- 统一绑定失败、待人工和已分配状态的投影与页面文案
- 新增 allocated 状态迁移,避免已分配账号被折叠为准备账号
- 立即同步时同时刷新直播履约状态,主动校正历史状态差异
- 补充状态优先级、资料重置和已分配状态测试
This commit is contained in:
yml
2026-11-18 11:00:28 +08:00
parent 919fb2767b
commit 1bc4931508
8 changed files with 149 additions and 13 deletions
@@ -1,7 +1,11 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { applyLiveBindingStateSnapshot, compareCustomerRole } from './douyu-fulfillment-service.js'
import {
applyLiveBindingStateSnapshot,
compareCustomerRole,
statusForLive,
} from './douyu-fulfillment-service.js'
const task = {
customer_role_name: '狗鼻子弗尼亚bd',
@@ -38,6 +42,45 @@ test('斗鱼客户资料角色名不一致时禁止确认', () => {
assert.equal(result.roleMatched, false)
})
test('绑定失败优先于旧角色确认标记', () => {
const status = statusForLive({
executionStatus: 'manual_required',
bindingStatus: 'failed',
issueCode: 'customer_role_cooldown',
bindReadyForConfirm: true,
bindConfirmed: false,
qrUrl: 'https://example.com/old-qr',
accountReady: true,
} as never)
assert.equal(status, 'failed')
})
test('绑定失败代码优先于旧待确认状态', () => {
const status = statusForLive({
executionStatus: 'role_ready',
bindingStatus: 'role_ready',
issueCode: 'binding_failed',
bindReadyForConfirm: true,
bindConfirmed: false,
qrUrl: '',
accountReady: true,
} as never)
assert.equal(status, 'failed')
})
test('已分配账号保持 allocated,不折叠成准备账号', () => {
const status = statusForLive({
executionStatus: 'allocated',
bindingStatus: 'not_started',
issueCode: '',
bindReadyForConfirm: false,
bindConfirmed: false,
qrUrl: '',
accountReady: true,
} as never)
assert.equal(status, 'allocated')
})
test('直播账号状态推送忽略空数据和无效任务', async () => {
assert.deepEqual(await applyLiveBindingStateSnapshot({ items: [] }), {
received: 0,