补齐行业凭证发码回调券码
This commit is contained in:
@@ -129,6 +129,14 @@ function fireSendCallback(input: {
|
|||||||
token: input.token,
|
token: input.token,
|
||||||
...(input.eticketType ? { eticketType: input.eticketType } : {}),
|
...(input.eticketType ? { eticketType: input.eticketType } : {}),
|
||||||
...(input.ext ? { ext: input.ext } : {}),
|
...(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) => {
|
}).catch((err) => {
|
||||||
logWarn('[kuaishou-industry/send-code]', '发码回调异步执行异常', {
|
logWarn('[kuaishou-industry/send-code]', '发码回调异步执行异常', {
|
||||||
oid: input.oid,
|
oid: input.oid,
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import assert from 'node:assert/strict'
|
|||||||
|
|
||||||
import { generateKuaishouIndustryVoucherCode } from '../../../repositories/kuaishou-industry-voucher-repo.js'
|
import { generateKuaishouIndustryVoucherCode } from '../../../repositories/kuaishou-industry-voucher-repo.js'
|
||||||
import { buildKuaishouIndustryVoucherContext } from './voucher-binding-service.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', () => {
|
test('generateKuaishouIndustryVoucherCode creates non-numeric stable voucher code', () => {
|
||||||
let requestedSize = 0
|
let requestedSize = 0
|
||||||
@@ -59,6 +62,19 @@ test('resolveKuaishouIndustryVoucherValidity prefers actual certificate time ran
|
|||||||
assert.equal(validity.validEndTime, 5000)
|
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', () => {
|
test('buildKuaishouIndustryVoucherContext maps consumed voucher state', () => {
|
||||||
const context = buildKuaishouIndustryVoucherContext(
|
const context = buildKuaishouIndustryVoucherContext(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export function buildKuaishouIndustryEticketFromVoucher(
|
|||||||
) {
|
) {
|
||||||
return buildIndustryEticketItem({
|
return buildIndustryEticketItem({
|
||||||
id: String(voucher.voucher_code || ''),
|
id: String(voucher.voucher_code || ''),
|
||||||
|
code: String(voucher.voucher_code || ''),
|
||||||
status: normalizeVoucherStatus(voucher.status),
|
status: normalizeVoucherStatus(voucher.status),
|
||||||
num: 1,
|
num: 1,
|
||||||
validStartTime: Number(voucher.valid_start_time || 0) || 0,
|
validStartTime: Number(voucher.valid_start_time || 0) || 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user