From 848f65319f575456068a600022ef20211f65074c Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 5 Aug 2026 22:06:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=B8=8D?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../claim/kuaishou-cloud-claim-service.ts | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) 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 b508fdf1..992943db 100644 --- a/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts +++ b/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts @@ -372,7 +372,10 @@ export async function submitClaimUid( } if (executorKey === 'affiliate_dash') { - updatedTask = (await bindAffiliateDashClaimForTask(updatedTask, expectedUid)) || updatedTask + updatedTask = + (await bindAffiliateDashClaimForTask(updatedTask, expectedUid, { + keepExistingBindOnUidUpdate: shouldKeepAffiliateDashBindOnUidUpdate(), + })) || updatedTask } return getKuaishouCloudClaimDetail(token) @@ -548,7 +551,11 @@ export async function submitAffiliateDashClaim( * 提交 UID 后触发 affiliate-dash 绑定(bind),把 bind_uuid / 二维码写回上下文, * task → waiting_binding(link_generated → waiting_binding 合法)。 */ -async function bindAffiliateDashClaimForTask(task: TaskRow, gameAccount: string) { +async function bindAffiliateDashClaimForTask( + task: TaskRow, + gameAccount: string, + options: { keepExistingBindOnUidUpdate?: boolean } = {}, +) { const taskContext = parseTaskContextValue(task) const flow = normalizeAffiliateDashFlow(taskContext.affiliateDash) if (!flow.orderNo || !gameAccount) { @@ -556,6 +563,42 @@ async function bindAffiliateDashClaimForTask(task: TaskRow, gameAccount: string) } const now = nowIso() + const shouldReuseExistingBind = Boolean( + options.keepExistingBindOnUidUpdate && + flow.bindUuid && + flow.bound && + flow.boundAccount && + normalizeUid(flow.boundAccount) === normalizeUid(gameAccount), + ) + if (shouldReuseExistingBind) { + const nextFlow = { + ...flow, + gameAccount, + expectedGameAccount: gameAccount, + bindMismatch: false, + } + const updatedTask = await updateTask(task.id, { + task_status: TASK_STATUS.WAITING_BINDING, + context_json: JSON.stringify({ + ...taskContext, + affiliateDash: nextFlow, + }), + updated_at: now, + }) + await createTaskEvent( + task.id, + 'affiliate_dash_bind_reused_for_uid_update', + { + orderNo: flow.orderNo, + bindUuid: flow.bindUuid, + gameAccount, + boundAccount: flow.boundAccount, + }, + now, + ) + return updatedTask || task + } + const bindResult = await bindAffiliateDashDelivery({ orderNo: flow.orderNo, gameAccount, @@ -648,6 +691,11 @@ async function refreshAffiliateDashBindState(task: TaskRow): Promise