fix(claim): 后台改对扫码 UID 后领取页跟上,绑定失败仍记住扫到的号

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-10-06 17:47:01 +08:00
co-authored by Cursor
parent 2a0eea40e9
commit f6343e58c1
2 changed files with 61 additions and 12 deletions
@@ -647,28 +647,62 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
orderNo: flow.orderNo, orderNo: flow.orderNo,
bindUuid: flow.bindUuid, bindUuid: flow.bindUuid,
}) })
const boundAccount = result.bound ? result.gameAccount || flow.boundAccount : '' const scannedAccount = String(result.gameAccount || '').trim()
const upstreamExpected = String(result.expectedGameAccount || '').trim()
// 后台把期望 UID 改成扫码账号并解除阻断后,领取页跟上这个 UID,买家不用再改一次。
const confirmedAccount =
result.bound &&
scannedAccount &&
upstreamExpected &&
normalizeUid(upstreamExpected) === normalizeUid(scannedAccount)
? scannedAccount
: ''
const nextExpected = confirmedAccount || expectedGameAccount
// 绑定失败也要留下扫到的 UID。买家改成这个号时继续用原提货链接,不能把号放回公共库存。
const boundAccount = result.bound
? scannedAccount || flow.boundAccount
: result.mismatch
? scannedAccount || flow.boundAccount
: ''
const localMismatch = Boolean( const localMismatch = Boolean(
boundAccount && boundAccount &&
expectedGameAccount && nextExpected &&
normalizeUid(boundAccount) !== normalizeUid(expectedGameAccount), normalizeUid(boundAccount) !== normalizeUid(nextExpected),
) )
const now = nowIso() const now = nowIso()
const claimIdentity = readClaimIdentity(taskContext.claimIdentity)
const nextClaimIdentity = confirmedAccount
? {
...claimIdentity,
expectedUid: confirmedAccount,
submittedAt:
normalizeUid(claimIdentity.expectedUid) === normalizeUid(confirmedAccount) &&
claimIdentity.submittedAt
? claimIdentity.submittedAt
: now,
source:
normalizeUid(claimIdentity.expectedUid) === normalizeUid(confirmedAccount)
? claimIdentity.source || 'claim_page'
: 'rock_expected_uid_corrected',
}
: claimIdentity
const nextFlow = { const nextFlow = {
...flow, ...flow,
bindUuid: result.bindUuid || flow.bindUuid, bindUuid: result.bindUuid || flow.bindUuid,
bindUrl: result.bindUrl || flow.bindUrl, bindUrl: result.bindUrl || flow.bindUrl,
qrUrl: result.qrUrl || flow.qrUrl, qrUrl: result.qrUrl || flow.qrUrl,
gameAccount: expectedGameAccount || flow.gameAccount, gameAccount: nextExpected || flow.gameAccount,
expectedGameAccount: expectedGameAccount || flow.expectedGameAccount, expectedGameAccount: nextExpected || flow.expectedGameAccount,
bound: result.bound, bound: result.bound,
boundAccount, boundAccount,
roleName: result.bound roleName:
? String(result.roleName || flow.roleName || '').trim() result.bound || result.mismatch
: flow.roleName, ? String(result.roleName || flow.roleName || '').trim()
gameChannel: result.bound : flow.roleName,
? String(result.gameChannel || flow.gameChannel || '').trim() gameChannel:
: flow.gameChannel, result.bound || result.mismatch
? String(result.gameChannel || flow.gameChannel || '').trim()
: flow.gameChannel,
bindMismatch: Boolean(result.mismatch) || localMismatch, bindMismatch: Boolean(result.mismatch) || localMismatch,
lastBindSyncedAt: now, lastBindSyncedAt: now,
} }
@@ -677,6 +711,7 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
(await updateTask(task.id, { (await updateTask(task.id, {
context_json: JSON.stringify({ context_json: JSON.stringify({
...taskContext, ...taskContext,
claimIdentity: nextClaimIdentity,
affiliateDash: nextFlow, affiliateDash: nextFlow,
}), }),
updated_at: now, updated_at: now,
@@ -687,6 +722,18 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
} }
} }
function readClaimIdentity(value: unknown) {
const source =
value && typeof value === 'object' && !Array.isArray(value)
? (value as { expectedUid?: unknown; submittedAt?: unknown; source?: unknown })
: {}
return {
expectedUid: String(source.expectedUid || ''),
submittedAt: source.submittedAt ? String(source.submittedAt) : '',
source: String(source.source || ''),
}
}
function normalizeUid(value: unknown) { function normalizeUid(value: unknown) {
return String(value || '') return String(value || '')
.trim() .trim()
@@ -69,7 +69,9 @@ export function AffiliateDashClaimPanel({
? '账号已在平台授权,确认无误后提交发货(无需再次扫码)' ? '账号已在平台授权,确认无误后提交发货(无需再次扫码)'
: '账号绑定成功,确认无误后提交发货' : '账号绑定成功,确认无误后提交发货'
: rockTokenLocked : rockTokenLocked
? '提货链接已绑定失败,不能更换新的提货号,请联系客服处理' ? boundAccount
? `已扫到账号 ${boundAccount},请把 UID 改成这个号。仍使用当前提货链接,不能换成别的号`
: '提货链接已绑定失败,不能更换新的提货号,请联系客服处理'
: bindMismatch : bindMismatch
? '绑定账号与填写 UID 不一致,请核对 UID 后用正确账号重新绑定' ? '绑定账号与填写 UID 不一致,请核对 UID 后用正确账号重新绑定'
: bound : bound