fix(finance): 重写履约路由迁移与统一渠道配置
重写 120/121 迁移,统一内部 SKU、渠道 id、config_json 和旧规则转换。 后台渠道配置改读统一渠道表,卡券与人工配置不再写旧规则。 增加安全渠道切换,并排除已关闭、失败或过期的历史任务载体。 按生产 119 基线重跑迁移、完整履约财务链路和严格预检。
This commit is contained in:
@@ -92,6 +92,11 @@ const failures: string[] = []
|
||||
// 用「已发布基线」而不是 HEAD 做比较,是因为以 HEAD 为基线时,本次提交新增的
|
||||
// 迁移也会被算成历史迁移,合并提交后必然自相矛盾。
|
||||
const MIGRATION_BASELINE_REF = resolveMigrationBaselineRef()
|
||||
// 生产当前已发布到 119;120+ 仍允许在部署前重写。部署 120 后应将此值提升到 120。
|
||||
const PUBLISHED_MIGRATION_MAX_VERSION = Math.max(
|
||||
0,
|
||||
Math.trunc(Number(process.env.PUBLISHED_MIGRATION_MAX_VERSION) || 119),
|
||||
)
|
||||
|
||||
function resolveMigrationBaselineRef(): string | null {
|
||||
const candidates = [process.env.MIGRATION_BASELINE_REF, 'main', 'origin/main'].filter(
|
||||
@@ -132,7 +137,11 @@ if (!MIGRATION_BASELINE_REF) {
|
||||
const changedHistoricalMigrations = diffOutput
|
||||
.split('\n')
|
||||
.map((line) => line.trim().split(/\s+/))
|
||||
.filter(([status, file]) => status && file?.endsWith('.sql') && status !== 'A')
|
||||
.filter(([status, file]) => {
|
||||
if (!status || !file?.endsWith('.sql') || status === 'A') return false
|
||||
const version = Number(path.basename(file).slice(0, 3))
|
||||
return Number.isFinite(version) && version <= PUBLISHED_MIGRATION_MAX_VERSION
|
||||
})
|
||||
.map(([status, file]) => `${status} ${file}`)
|
||||
if (changedHistoricalMigrations.length > 0) {
|
||||
failures.push(
|
||||
|
||||
Reference in New Issue
Block a user