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

腾讯活动链接会过期,领取页不能一直用第一次的签名。过期后向 0666 重取同一提取码的新链接,不另发提货号。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-10-06 18:02:17 +08:00
co-authored by Cursor
parent f6e6d110a8
commit 9d981c253f
4 changed files with 177 additions and 42 deletions
@@ -8,6 +8,7 @@ import {
isAffiliateDashBindSnapshotStale,
isAffiliateDashSnapshotFresh,
isRockAffiliateDashSku,
isRockBindUrlStale,
shouldRefuseRockRebind,
shouldRefreshAffiliateDashBindStateForSnapshot,
} from './kuaishou-cloud-claim-service.js'
@@ -272,6 +273,40 @@ 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 () => {
const { readFile } = await import('node:fs/promises')
const src = await readFile(new URL('./kuaishou-cloud-claim-service.ts', import.meta.url), 'utf8')
@@ -282,6 +317,7 @@ test('claim detail skips affiliate-dash sync while the snapshot is fresh', async
assert.ok(detail.includes('flow.mock?.enabled'))
assert.ok(detail.includes('isAffiliateDashSnapshotFresh(flow.lastSyncedAt'))
assert.ok(detail.includes('bindFlow.lastBindSyncedAt'))
assert.ok(detail.includes('refreshRockBindUrlIfStale'))
assert.ok(
!detail.includes('snapshotOnly'),
'新鲜快照必须直接不调用同步;snapshotOnly 仍会 updateTask',