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
@@ -19,6 +19,7 @@ const COST_SNAPSHOT_JOB_ID = 'cost-snapshot'
const SALES_FACTS_JOB_ID = 'sales-facts'
const LEDGER_POST_JOB_ID = 'ledger-post'
const ORDER_SERVICE_AUTO_PUBLISH_JOB_ID = 'order-service-auto-publish'
const VOUCHER_CONSUME_DISPATCH_JOB_ID = 'voucher-consume-dispatch'
export function getScheduledJobsFilePath() {
return SCHEDULED_JOBS_FILE_PATH
@@ -93,6 +94,7 @@ export function normalizeScheduledJobsConfig(rawValue: unknown) {
const hasOrderServiceAutoPublish = jobs.some(
(item) => item.id === ORDER_SERVICE_AUTO_PUBLISH_JOB_ID,
)
const hasVoucherConsumeDispatch = jobs.some((item) => item.id === VOUCHER_CONSUME_DISPATCH_JOB_ID)
if (!hasWorkOrderTimeout) {
jobs.push(createDefaultWorkOrderTimeoutJob())
@@ -116,6 +118,7 @@ export function normalizeScheduledJobsConfig(rawValue: unknown) {
if (!hasSalesFacts) jobs.push(createDefaultSalesFactsJob())
if (!hasLedgerPost) jobs.push(createDefaultLedgerPostJob())
if (!hasOrderServiceAutoPublish) jobs.push(createDefaultOrderServiceAutoPublishJob())
if (!hasVoucherConsumeDispatch) jobs.push(createDefaultVoucherConsumeDispatchJob())
return {
enabled: typeof source.enabled === 'boolean' ? source.enabled : true,
@@ -166,6 +169,9 @@ function normalizeScheduledJob(rawValue: unknown) {
if (type === 'order_service_auto_publish') {
return normalizeOrderServiceAutoPublishJob(rawValue)
}
if (type === 'voucher_consume_dispatch') {
return normalizeVoucherConsumeDispatchJob(rawValue)
}
return null
}
@@ -237,6 +243,7 @@ function createDefaultScheduledJobsConfig() {
createDefaultSalesFactsJob(),
createDefaultLedgerPostJob(),
createDefaultOrderServiceAutoPublishJob(),
createDefaultVoucherConsumeDispatchJob(),
],
}
}
@@ -322,6 +329,19 @@ function normalizeOrderServiceAutoPublishJob(rawValue: JsonObject) {
}
}
function normalizeVoucherConsumeDispatchJob(rawValue: JsonObject) {
const config = isPlainObject(rawValue.config) ? rawValue.config : {}
return {
id: VOUCHER_CONSUME_DISPATCH_JOB_ID,
type: 'voucher_consume_dispatch',
enabled: rawValue.enabled !== false,
intervalSeconds: normalizeRangeInteger(rawValue.intervalSeconds, 5, 1, 60),
config: {
batchSize: normalizeRangeInteger(config.batchSize, 20, 1, 200),
},
}
}
function normalizeLedgerPostJob(rawValue: JsonObject) {
const config = isPlainObject(rawValue.config) ? rawValue.config : {}
return {
@@ -385,6 +405,16 @@ function createDefaultOrderServiceAutoPublishJob() {
}
}
function createDefaultVoucherConsumeDispatchJob() {
return {
id: VOUCHER_CONSUME_DISPATCH_JOB_ID,
type: 'voucher_consume_dispatch',
enabled: true,
intervalSeconds: 5,
config: { batchSize: 20 },
}
}
function createDefaultSalesFactsJob() {
return {
id: SALES_FACTS_JOB_ID,