Revert "feat(claim): Rock 同一提货号过期后自动换新二维码"

This reverts commit 9d981c253f.
This commit is contained in:
yml2213
2026-10-06 18:08:20 +08:00
parent 9d981c253f
commit 98dc675b88
4 changed files with 42 additions and 177 deletions
@@ -8,7 +8,6 @@ import {
isAffiliateDashBindSnapshotStale, isAffiliateDashBindSnapshotStale,
isAffiliateDashSnapshotFresh, isAffiliateDashSnapshotFresh,
isRockAffiliateDashSku, isRockAffiliateDashSku,
isRockBindUrlStale,
shouldRefuseRockRebind, shouldRefuseRockRebind,
shouldRefreshAffiliateDashBindStateForSnapshot, shouldRefreshAffiliateDashBindStateForSnapshot,
} from './kuaishou-cloud-claim-service.js' } from './kuaishou-cloud-claim-service.js'
@@ -273,40 +272,6 @@ test('order snapshot stays fresh for 45s and bind snapshot only for 15s', () =>
) )
}) })
test('isRockBindUrlStale only refreshes an unpaid rock qr on the same token', () => {
const now = Date.parse('2026-10-06T09:57:00.000Z')
const oldTs = Math.floor(Date.parse('2026-10-06T09:10:14.000Z') / 1000)
const freshTs = Math.floor(Date.parse('2026-10-06T09:55:00.000Z') / 1000)
const stale = {
sku: 'rock_black_tshirt',
orderNo: 'FO20261006170653afd37ce7e19',
bindUrl: `https://gp.qq.com/cp/a20241128mobile/index.html?userId=1&timestamp=${oldTs}&nonce=a`,
bound: false,
bindMismatch: false,
}
assert.equal(isRockBindUrlStale(stale, now), true)
assert.equal(
isRockBindUrlStale(
{
...stale,
bindUrl: `https://gp.qq.com/cp/a20241128mobile/index.html?timestamp=${freshTs}&nonce=b`,
},
now,
),
false,
)
assert.equal(isRockBindUrlStale({ ...stale, bound: true }, now), false)
assert.equal(isRockBindUrlStale({ ...stale, bindMismatch: true }, now), false)
assert.equal(isRockBindUrlStale({ ...stale, sku: 'lewan_black' }, now), false)
assert.equal(
isRockBindUrlStale(
{ ...stale, rockBindUrlCheckedAt: new Date(now - 10_000).toISOString() },
now,
),
false,
)
})
test('claim detail skips affiliate-dash sync while the snapshot is fresh', async () => { test('claim detail skips affiliate-dash sync while the snapshot is fresh', async () => {
const { readFile } = await import('node:fs/promises') const { readFile } = await import('node:fs/promises')
const src = await readFile(new URL('./kuaishou-cloud-claim-service.ts', import.meta.url), 'utf8') const src = await readFile(new URL('./kuaishou-cloud-claim-service.ts', import.meta.url), 'utf8')
@@ -317,7 +282,6 @@ test('claim detail skips affiliate-dash sync while the snapshot is fresh', async
assert.ok(detail.includes('flow.mock?.enabled')) assert.ok(detail.includes('flow.mock?.enabled'))
assert.ok(detail.includes('isAffiliateDashSnapshotFresh(flow.lastSyncedAt')) assert.ok(detail.includes('isAffiliateDashSnapshotFresh(flow.lastSyncedAt'))
assert.ok(detail.includes('bindFlow.lastBindSyncedAt')) assert.ok(detail.includes('bindFlow.lastBindSyncedAt'))
assert.ok(detail.includes('refreshRockBindUrlIfStale'))
assert.ok( assert.ok(
!detail.includes('snapshotOnly'), !detail.includes('snapshotOnly'),
'新鲜快照必须直接不调用同步;snapshotOnly 仍会 updateTask', '新鲜快照必须直接不调用同步;snapshotOnly 仍会 updateTask',
@@ -86,7 +86,6 @@ export async function getKuaishouCloudClaimDetail(token: unknown): Promise<Claim
task = (await refreshAffiliateDashBindState(task)) || task task = (await refreshAffiliateDashBindState(task)) || task
} }
} }
task = (await refreshRockBindUrlIfStale(task)) || task
} }
return buildClaimDetailPayload({ return buildClaimDetailPayload({
@@ -229,7 +228,7 @@ async function submitAffiliateDashClaimUid(
return getKuaishouCloudClaimDetail(token) return getKuaishouCloudClaimDetail(token)
} }
if (canReuseAffiliateDashBindSnapshot(flow, expectedUid) && !isRockBindUrlStale(flow)) { if (canReuseAffiliateDashBindSnapshot(flow, expectedUid)) {
const nextFlow = { const nextFlow = {
...flow, ...flow,
gameAccount: expectedUid, gameAccount: expectedUid,
@@ -483,42 +482,6 @@ function resolveAffiliateDashRecordedBindUid(flow: AffiliateDashFlowSnapshot) {
export const ROCK_CLAIM_TOKEN_LOCKED_MESSAGE = export const ROCK_CLAIM_TOKEN_LOCKED_MESSAGE =
'该订单提货链接已绑定失败,不能更换新的提货号,请联系客服处理' '该订单提货链接已绑定失败,不能更换新的提货号,请联系客服处理'
/** 腾讯活动链接按生成时间签名,超时后同一提货号要重新取一条新二维码。 */
export const ROCK_BIND_URL_MAX_AGE_MS = 8 * 60 * 1000
export function rockBindUrlIssuedAtMs(bindUrl: unknown): number | null {
const match = /[?&]timestamp=(\d{10,13})(?:&|$)/.exec(String(bindUrl || ''))
if (!match) {
return null
}
const value = Number(match[1])
if (!Number.isFinite(value)) {
return null
}
return value < 1e12 ? value * 1000 : value
}
/** Rock 扫码前的二维码过期后要刷新链接,不能因此再领一个提货号。 */
export function isRockBindUrlStale(flowLike: unknown, now = Date.now()): boolean {
const flow = normalizeAffiliateDashFlow(flowLike)
if (!isRockAffiliateDashSku(flow.sku) || !flow.orderNo || !flow.bindUrl) {
return false
}
if (flow.bound || flow.bindMismatch || flow.mock?.enabled) {
return false
}
const checkedAt = Date.parse(String(flow.rockBindUrlCheckedAt || ''))
if (Number.isFinite(checkedAt) && now - checkedAt < 60_000) {
return false
}
const issuedAt = rockBindUrlIssuedAtMs(flow.bindUrl)
if (issuedAt == null) {
const syncedAt = Date.parse(String(flow.lastBindSyncedAt || ''))
return !Number.isFinite(syncedAt) || now - syncedAt >= ROCK_BIND_URL_MAX_AGE_MS
}
return now - issuedAt >= ROCK_BIND_URL_MAX_AGE_MS
}
export function isRockAffiliateDashSku(sku: unknown) { export function isRockAffiliateDashSku(sku: unknown) {
return String(sku || '') return String(sku || '')
.trim() .trim()
@@ -757,51 +720,6 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise<TaskRow | n
} }
} }
async function refreshRockBindUrlIfStale(task: TaskRow): Promise<TaskRow | null> {
const taskContext = parseTaskContextValue(task)
const flow = normalizeAffiliateDashFlow(taskContext.affiliateDash)
if (!isRockBindUrlStale(flow)) {
return task
}
const expectedUid = resolveAffiliateDashExpectedGameAccount(task, flow)
if (!expectedUid) {
return task
}
const now = nowIso()
const persist = (patch: { bindUuid?: string; bindUrl?: string; qrUrl?: string }) =>
updateTask(task.id, {
context_json: JSON.stringify({
...taskContext,
affiliateDash: {
...flow,
bindUuid: patch.bindUuid || flow.bindUuid,
bindUrl: patch.bindUrl || flow.bindUrl,
qrUrl: patch.qrUrl || flow.qrUrl,
rockBindUrlCheckedAt: now,
},
}),
updated_at: now,
})
try {
const bindResult = await bindAffiliateDashDelivery({
orderNo: flow.orderNo,
gameAccount: expectedUid,
})
const nextBindUrl = String(bindResult.bindUrl || '').trim()
return (
(await persist({
bindUuid: bindResult.bindUuid || flow.bindUuid,
bindUrl: nextBindUrl || flow.bindUrl,
qrUrl: bindResult.qrUrl || flow.qrUrl,
})) || task
)
} catch {
return (await persist({})) || task
}
}
function readClaimIdentity(value: unknown) { function readClaimIdentity(value: unknown) {
const source = const source =
value && typeof value === 'object' && !Array.isArray(value) value && typeof value === 'object' && !Array.isArray(value)
@@ -332,8 +332,6 @@ export type AffiliateDashFlow = {
lastSyncedAt: unknown lastSyncedAt: unknown
/** 最近一次成功拉取 bind-result 的时间。与订单状态的 lastSyncedAt 分开计。 */ /** 最近一次成功拉取 bind-result 的时间。与订单状态的 lastSyncedAt 分开计。 */
lastBindSyncedAt: unknown lastBindSyncedAt: unknown
/** 最近一次向 0666 重取同一提货号二维码的时间,用来避免过期链接每轮都打上游。 */
rockBindUrlCheckedAt: unknown
raw: unknown raw: unknown
/** dev-mock 标记:enabled 时所有 affiliate-dash 平台调用短路(建单/绑定/提交/同步均不请求外部) */ /** dev-mock 标记:enabled 时所有 affiliate-dash 平台调用短路(建单/绑定/提交/同步均不请求外部) */
mock: { enabled: boolean; orderNo: string; createdAt: string } | null mock: { enabled: boolean; orderNo: string; createdAt: string } | null
@@ -376,7 +374,6 @@ export function normalizeAffiliateDashFlow(value: unknown): AffiliateDashFlow {
consumeStatus: String(source.consumeStatus || 'pending').trim(), consumeStatus: String(source.consumeStatus || 'pending').trim(),
lastSyncedAt: source.lastSyncedAt || null, lastSyncedAt: source.lastSyncedAt || null,
lastBindSyncedAt: source.lastBindSyncedAt || null, lastBindSyncedAt: source.lastBindSyncedAt || null,
rockBindUrlCheckedAt: source.rockBindUrlCheckedAt || null,
raw, raw,
mock: mock:
source.mock && typeof source.mock === 'object' source.mock && typeof source.mock === 'object'
@@ -169,64 +169,50 @@ export function AffiliateDashClaimPanel({
) : null} ) : null}
{!canSubmit ? ( {!canSubmit ? (
<> <div
<div className="claim-bind-area"
className="claim-bind-area" style={{
marginBottom: 16,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 20,
}}
>
<span
style={{ style={{
marginBottom: 16, color: '#ff4d4f',
display: 'flex', writingMode: 'vertical-rl',
alignItems: 'center', textOrientation: 'upright',
justifyContent: 'center', fontSize: 17,
gap: 20, fontWeight: 600,
letterSpacing: 8,
}} }}
> >
<span Q区用Q扫
style={{ </span>
color: '#ff4d4f', {hasBindQr ? (
writingMode: 'vertical-rl', <img
textOrientation: 'upright', src={qrCodeDataUrl}
fontSize: 17, alt="绑定二维码"
fontWeight: 600, style={{ width: 220, height: 220, borderRadius: 8 }}
letterSpacing: 8, />
}} ) : (
> <Typography.Text type="secondary">绑定二维码生成中,请稍候自动刷新…</Typography.Text>
Q区用Q扫 )}
</span> <span
{hasBindQr ? ( style={{
<img color: '#ff4d4f',
src={qrCodeDataUrl} writingMode: 'vertical-rl',
alt="绑定二维码" textOrientation: 'upright',
style={{ width: 220, height: 220, borderRadius: 8 }} fontSize: 17,
/> fontWeight: 600,
) : ( letterSpacing: 8,
<Typography.Text type="secondary">绑定二维码生成中,请稍候自动刷新…</Typography.Text> }}
)} >
<span V区用V扫
style={{ </span>
color: '#ff4d4f', </div>
writingMode: 'vertical-rl',
textOrientation: 'upright',
fontSize: 17,
fontWeight: 600,
letterSpacing: 8,
}}
>
V区用V扫
</span>
</div>
{hasBindQr &&
String(affiliateDash.sku || '')
.toLowerCase()
.startsWith('rock_') &&
!rockTokenLocked ? (
<Typography.Text
type="secondary"
style={{ display: 'block', margin: '-8px 0 16px', textAlign: 'center' }}
>
二维码会过期,页面会自动换成新的,请扫当前这一张
</Typography.Text>
) : null}
</>
) : ( ) : (
<> <>
<Button <Button