From 24a1ade83fdebdc183dfeb9caafdac4cdc3f26ad Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 8 Jul 2026 12:09:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E8=A1=8C=E4=B8=9A=E5=87=AD?= =?UTF-8?q?=E8=AF=81=E5=8F=91=E7=A0=81=E5=9B=9E=E8=B0=83=E5=88=B8=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kuaishou-industry/send-code-service.ts | 8 ++++++++ .../kuaishou-industry/voucher-service.test.ts | 18 +++++++++++++++++- .../kuaishou-industry/voucher-service.ts | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/services/platforms/kuaishou-industry/send-code-service.ts b/apps/backend/src/services/platforms/kuaishou-industry/send-code-service.ts index 158086be..76bd9677 100644 --- a/apps/backend/src/services/platforms/kuaishou-industry/send-code-service.ts +++ b/apps/backend/src/services/platforms/kuaishou-industry/send-code-service.ts @@ -129,6 +129,14 @@ function fireSendCallback(input: { token: input.token, ...(input.eticketType ? { eticketType: input.eticketType } : {}), ...(input.ext ? { ext: input.ext } : {}), + }).then((result) => { + if (!result.success) { + logWarn('[kuaishou-industry/send-code]', '发码回调异步执行失败', { + oid: input.oid, + error: result.error || '', + response: result.response || null, + }) + } }).catch((err) => { logWarn('[kuaishou-industry/send-code]', '发码回调异步执行异常', { oid: input.oid, diff --git a/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.test.ts b/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.test.ts index cdba2896..dc7a9ca6 100644 --- a/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.test.ts +++ b/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.test.ts @@ -3,7 +3,10 @@ import assert from 'node:assert/strict' import { generateKuaishouIndustryVoucherCode } from '../../../repositories/kuaishou-industry-voucher-repo.js' import { buildKuaishouIndustryVoucherContext } from './voucher-binding-service.js' -import { resolveKuaishouIndustryVoucherValidity } from './voucher-service.js' +import { + buildKuaishouIndustryEticketFromVoucher, + resolveKuaishouIndustryVoucherValidity, +} from './voucher-service.js' test('generateKuaishouIndustryVoucherCode creates non-numeric stable voucher code', () => { let requestedSize = 0 @@ -59,6 +62,19 @@ test('resolveKuaishouIndustryVoucherValidity prefers actual certificate time ran assert.equal(validity.validEndTime, 5000) }) +test('buildKuaishouIndustryEticketFromVoucher mirrors voucher code into id and code', () => { + const eticket = buildKuaishouIndustryEticketFromVoucher({ + voucher_code: 'KSV15K821FDHPMTX1ST', + status: 'UNUSED', + valid_start_time: 1783427213868, + valid_end_time: 1786019213868, + } as any, 'GAME_OPEN_TICKET_CONSUME') + + assert.equal(eticket.id, 'KSV15K821FDHPMTX1ST') + assert.equal(eticket.code, 'KSV15K821FDHPMTX1ST') + assert.equal(eticket.eticketType, 'GAME_OPEN_TICKET_CONSUME') +}) + test('buildKuaishouIndustryVoucherContext maps consumed voucher state', () => { const context = buildKuaishouIndustryVoucherContext( { diff --git a/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.ts b/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.ts index 5ecb22e6..05d797e5 100644 --- a/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.ts +++ b/apps/backend/src/services/platforms/kuaishou-industry/voucher-service.ts @@ -51,6 +51,7 @@ export function buildKuaishouIndustryEticketFromVoucher( ) { return buildIndustryEticketItem({ id: String(voucher.voucher_code || ''), + code: String(voucher.voucher_code || ''), status: normalizeVoucherStatus(voucher.status), num: 1, validStartTime: Number(voucher.valid_start_time || 0) || 0,