fix(claim): 后台改对扫码 UID 后领取页跟上,绑定失败仍记住扫到的号
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -647,28 +647,62 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
|
||||
orderNo: flow.orderNo,
|
||||
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(
|
||||
boundAccount &&
|
||||
expectedGameAccount &&
|
||||
normalizeUid(boundAccount) !== normalizeUid(expectedGameAccount),
|
||||
nextExpected &&
|
||||
normalizeUid(boundAccount) !== normalizeUid(nextExpected),
|
||||
)
|
||||
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 = {
|
||||
...flow,
|
||||
bindUuid: result.bindUuid || flow.bindUuid,
|
||||
bindUrl: result.bindUrl || flow.bindUrl,
|
||||
qrUrl: result.qrUrl || flow.qrUrl,
|
||||
gameAccount: expectedGameAccount || flow.gameAccount,
|
||||
expectedGameAccount: expectedGameAccount || flow.expectedGameAccount,
|
||||
gameAccount: nextExpected || flow.gameAccount,
|
||||
expectedGameAccount: nextExpected || flow.expectedGameAccount,
|
||||
bound: result.bound,
|
||||
boundAccount,
|
||||
roleName: result.bound
|
||||
? String(result.roleName || flow.roleName || '').trim()
|
||||
: flow.roleName,
|
||||
gameChannel: result.bound
|
||||
? String(result.gameChannel || flow.gameChannel || '').trim()
|
||||
: flow.gameChannel,
|
||||
roleName:
|
||||
result.bound || result.mismatch
|
||||
? String(result.roleName || flow.roleName || '').trim()
|
||||
: flow.roleName,
|
||||
gameChannel:
|
||||
result.bound || result.mismatch
|
||||
? String(result.gameChannel || flow.gameChannel || '').trim()
|
||||
: flow.gameChannel,
|
||||
bindMismatch: Boolean(result.mismatch) || localMismatch,
|
||||
lastBindSyncedAt: now,
|
||||
}
|
||||
@@ -677,6 +711,7 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
|
||||
(await updateTask(task.id, {
|
||||
context_json: JSON.stringify({
|
||||
...taskContext,
|
||||
claimIdentity: nextClaimIdentity,
|
||||
affiliateDash: nextFlow,
|
||||
}),
|
||||
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) {
|
||||
return String(value || '')
|
||||
.trim()
|
||||
|
||||
@@ -69,7 +69,9 @@ export function AffiliateDashClaimPanel({
|
||||
? '账号已在平台授权,确认无误后提交发货(无需再次扫码)'
|
||||
: '账号绑定成功,确认无误后提交发货'
|
||||
: rockTokenLocked
|
||||
? '提货链接已绑定失败,不能更换新的提货号,请联系客服处理'
|
||||
? boundAccount
|
||||
? `已扫到账号 ${boundAccount},请把 UID 改成这个号。仍使用当前提货链接,不能换成别的号`
|
||||
: '提货链接已绑定失败,不能更换新的提货号,请联系客服处理'
|
||||
: bindMismatch
|
||||
? '绑定账号与填写 UID 不一致,请核对 UID 后用正确账号重新绑定'
|
||||
: bound
|
||||
|
||||
Reference in New Issue
Block a user