补齐行业凭证发码回调券码

This commit is contained in:
yml2213
2026-07-08 12:09:15 +08:00
parent 2380e28bcc
commit 24a1ade83f
3 changed files with 26 additions and 1 deletions
@@ -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,
@@ -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(
{
@@ -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,