From 3a2147e94b0602c643647a60e4cecc3fcd848de3 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Fri, 7 Aug 2026 12:14:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20affiliate-dash=20=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E7=BB=91=E5=AE=9A=E5=BF=AB=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../claim/affiliate-dash-bind-state.test.ts | 45 +++++++++++++++++++ .../claim/kuaishou-cloud-claim-service.ts | 37 ++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts b/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts index f6c15579..e52efce2 100644 --- a/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts +++ b/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts @@ -4,6 +4,7 @@ import assert from 'node:assert/strict' import { canReuseAffiliateDashBindSnapshot, isAffiliateDashBindSnapshotStale, + shouldRefreshAffiliateDashBindStateForSnapshot, } from './kuaishou-cloud-claim-service.js' test('isAffiliateDashBindSnapshotStale detects bind uuid that belongs to old uid', () => { @@ -136,3 +137,47 @@ test('canReuseAffiliateDashBindSnapshot refuses mismatched bound account', () => false, ) }) + +test('shouldRefreshAffiliateDashBindStateForSnapshot keeps polling before submit', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'waiting_binding', + orderStatus: 'paid', + submitStatus: '', + }), + true, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops after submit starts', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'redeeming', + orderStatus: 'delivering', + submitStatus: 'delivering', + }), + false, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops after delivered', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'redeemed', + orderStatus: 'delivered', + submitStatus: 'delivered', + }), + false, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops for failed platform result', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'retry_pending', + orderStatus: 'ship_failed', + submitStatus: '', + }), + false, + ) +}) diff --git a/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts b/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts index 86506f1e..2550e953 100644 --- a/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts +++ b/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts @@ -232,7 +232,9 @@ export async function getKuaishouCloudClaimDetail(token: unknown): Promise