调整(虎牙绑定): 改完资料自动回查平台,一致即可确认;冷却只认平台返回
- 客户保存资料后,服务端再向虎牙**只读**查询一次绑定事实并落库,随后重算决策: 新资料与平台当前角色或待确认角色一致时直接回到可确认状态, 不再要求「改完资料必须重新扫一次码」;仍不一致时才需要重新扫码。 回查失败不阻断资料保存(只记日志),避免平台抖动让客户白填一次资料。 - 换绑冷却维持「只认平台返回」:平台给 changeBindTime 就用它算剩余天数, 没给就只说「平台未返回下次可换绑时间」,不推算、不硬编码 7 天。 - 补 3 条回归断言:保存资料后必须走只读回查、回查失败留日志、 重新出码只看 allowedActions。 - 权威文档同步「改完资料只读复核」口径。
This commit is contained in:
@@ -278,10 +278,34 @@ export async function savePublicTaskProfile(
|
||||
'customer',
|
||||
'customer_profile_saved',
|
||||
)
|
||||
// 资料改动后重新从虎牙只读查询一次绑定事实:
|
||||
// 平台侧 inner act 记着客户上次扫码选中的角色,只要新资料与它一致就应直接可确认,
|
||||
// 不该逼客户重新扫一遍。这里只读平台,不生成二维码、不写平台。
|
||||
updated = await refreshHuyaBindingFactsAfterProfileEdit(updated)
|
||||
}
|
||||
return { task: mapTask(updated) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 资料变更后的只读回查:拉一次平台绑定快照并落库,再重算绑定决策。
|
||||
* 失败不阻断资料保存(平台抖动不应让客户白填一次资料),但必须留日志。
|
||||
*/
|
||||
async function refreshHuyaBindingFactsAfterProfileEdit(task: TaskRow): Promise<TaskRow> {
|
||||
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') return task
|
||||
if (!task.connector_session_id || task.login_status !== 'authenticated') return task
|
||||
try {
|
||||
const session = await getBindingForTask(task, task.connector_session_id)
|
||||
await updateBindingTask(task, session, 'customer')
|
||||
return await refreshHuyaBindingDecisionForTask(task.id, 'customer', 'customer_profile_saved')
|
||||
} catch (error) {
|
||||
logWarn('semi-auto', '资料保存后回查虎牙绑定事实失败', {
|
||||
taskId: task.id,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
return task
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户上传游戏主页截图:文件先独立落库,保存资料时再用 objectKey 校验归属并写入任务。
|
||||
* 与服务端其它上传一致,必须走 file_assets 台账,不信任前端传入的 URL。
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, it } from 'node:test'
|
||||
|
||||
const root = dirname(fileURLToPath(import.meta.url))
|
||||
const customerService = readFileSync(join(root, 'semi-auto-customer-service.ts'), 'utf8')
|
||||
|
||||
describe('改完资料后重新从平台核对一次绑定事实', () => {
|
||||
it('保存资料后调用只读回查,而不是要求客户重新扫码', () => {
|
||||
const saveStart = customerService.indexOf('export async function savePublicTaskProfile(')
|
||||
const saveEnd = customerService.indexOf(
|
||||
'export async function uploadPublicTaskHomepageScreenshot(',
|
||||
)
|
||||
const saveBody = customerService.slice(saveStart, saveEnd)
|
||||
assert.ok(saveBody.includes('refreshHuyaBindingFactsAfterProfileEdit('))
|
||||
// 回查只允许读平台并落库事实,不得在这里生成二维码或写平台。
|
||||
assert.ok(!saveBody.includes('startHuyaBinding('))
|
||||
assert.ok(!saveBody.includes('confirmHuyaBinding('))
|
||||
})
|
||||
|
||||
it('回查失败不阻断资料保存,但要留日志', () => {
|
||||
const helperStart = customerService.indexOf(
|
||||
'async function refreshHuyaBindingFactsAfterProfileEdit(',
|
||||
)
|
||||
assert.ok(helperStart > 0)
|
||||
const helperBody = customerService.slice(helperStart, helperStart + 1400)
|
||||
assert.ok(helperBody.includes('getBindingForTask('))
|
||||
assert.ok(helperBody.includes('updateBindingTask('))
|
||||
assert.ok(helperBody.includes('logWarn('))
|
||||
})
|
||||
|
||||
it('重新出码只看 allowedActions,不再用 primaryAction 单点判定', () => {
|
||||
const start = customerService.indexOf('export async function startPublicBinding(')
|
||||
const body = customerService.slice(start, start + 5200)
|
||||
assert.ok(body.includes("decision.allowedActions.includes('refresh_first_binding_qr')"))
|
||||
assert.ok(body.includes("decision.allowedActions.includes('start_rebind')"))
|
||||
assert.ok(
|
||||
!body.includes(
|
||||
"['start_first_binding', 'refresh_first_binding_qr'].includes(\n decision.primaryAction",
|
||||
),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user