feat: 完善履约路由、订单服务与自动核销

This commit is contained in:
yml2213
2026-11-05 14:59:58 +08:00
parent 517d763f17
commit 1df88cc639
54 changed files with 3166 additions and 318 deletions
@@ -15,6 +15,7 @@ import {
runProductNormalizeJob,
runSalesFactsJob,
} from './finance-pipeline-jobs.js'
import { runVoucherConsumeDispatchJob } from '../fulfillment/voucher-consume-queue-service.js'
const timers = new Map<string, NodeJS.Timeout>()
const jobStates = new Map<string, JsonObject>()
@@ -88,7 +89,7 @@ function rescheduleJob(job: JsonObject) {
if (!jobId) return
const latestJob = getScheduledJobById(jobId)
if (!latestJob || latestJob.enabled !== true) return
const intervalMs = Math.max(10, Number(latestJob.intervalSeconds || 20)) * 1000
const intervalMs = Math.max(1, Number(latestJob.intervalSeconds || 20)) * 1000
scheduleJob(latestJob, intervalMs)
}
@@ -234,6 +235,11 @@ function dispatchJob(job: JsonObject) {
if (job.type === 'order_service_auto_publish') {
return runOrderServiceAutoPublishJobs(job)
}
if (job.type === 'voucher_consume_dispatch') {
return runVoucherConsumeDispatchJob(
job.config && typeof job.config === 'object' ? (job.config as Record<string, unknown>) : {},
)
}
throw createHttpError(`不支持的定时任务类型:${job.type}`, {
statusCode: 400,