fix(lastleg): restore fulfillment safeguards and reconcile return regressions

This commit is contained in:
2026-10-08 18:08:42 +08:00
parent c1ddb658bd
commit 3a9ee57e53
12 changed files with 409 additions and 770 deletions
@@ -9,7 +9,7 @@ const domesticSchemas = ['baiyue_auth', 'baiyue_iam', 'baiyue_order', 'baiyue_wa
const overseasSchemas = ['baiyue_lastleg', 'baiyue_lastlag_warehouse']
test('两个入口分别只操作八个主业务库与两个仓储业务库,包括限定名引用', () => {
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 226], [overseas, overseasSchemas, domesticSchemas, 157]]) {
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 226], [overseas, overseasSchemas, domesticSchemas, 159]]) {
assert.deepEqual([...sql.matchAll(/^CREATE DATABASE IF NOT EXISTS (\w+)/gm)].map(m => m[1]), allowed)
assert.deepEqual([...new Set([...sql.matchAll(/^USE (\w+);/gm)].map(m => m[1]))], allowed)
const body = sql.replace(/^--.*$/gm, '')
@@ -39,7 +39,7 @@ test('纯初始化禁止迁移、数据回填、清理、重复建表和提前
assert.doesNotMatch(body.replace(/^CREATE TRIGGER [\s\S]*?\$\$/gm, ''), /^\s*(?:UPDATE|DELETE FROM|REPLACE INTO)\b/gmi)
assert.doesNotMatch(body, /CREATE TABLE IF NOT EXISTS/i)
assert.equal((body.match(/AS initialization_status/g) ?? []).length, 1)
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (226|157) AS initialized_tables;$/)
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (226|159) AS initialized_tables;$/)
}
})
@@ -65,7 +65,7 @@ test('退回实收按真实流水唯一保存,重派拣货必须明确唯一
}
const pick = table(overseas, 'baiyue_lastleg', 'll_dispatch_pda_pick_order')
assert.match(pick, /\breceipt_id BIGINT NULL/i)
assert.match(pick, /CHECK\(\(receipt_id IS NOT NULL AND return_receipt_id IS NULL\) OR \(receipt_id IS NULL AND return_receipt_id IS NOT NULL\)\)/i)
assert.match(pick, /CHECK\(\(receipt_id IS NOT NULL\) \+ \(return_receipt_id IS NOT NULL\) \+ \(return_carton_id IS NOT NULL\) = 1\)/i)
})
test('车辆报价与实测记录保留业务去重和不可变版本', () => {
@@ -121,7 +121,7 @@ test('平台管理员由外部bcrypt引导,强制首登改密且不创建客
})
test('必要系统种子完整保留,但不写入示例资源与业务事实', () => {
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 417, iam_role_permission: 598,
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 419, iam_role_permission: 600,
iam_data_scope: 7, wh_warehouse: 318, wh_warehouse_address: 318, wh_service_capability: 4,
fl_fee_item: 112, fl_price_channel_catalog: 15, fl_price_origin_alias: 7, fl_price_warehouse_mapping: 4,
file_export_task_guard: 1, fin_subject: 1 })) assert.equal(seedRows(cn, name).length, count, name)
@@ -222,3 +222,26 @@ test('最终业务触发器与循环外键均存在,不留下发布过程', ()
assert.ok(disable >= 0 && enable > disable)
assert.ok(!cn.slice(disable, enable).includes('INSERT INTO'))
})
test('退货合箱最终字段直接进入空库建表定义', () => {
for (const [name, fields] of Object.entries({
ll_return_packing_plan: ['source_items_json', 'result_marks_json', 'result_labels_json', 'request_hash', 'completion_hash'],
ll_return_packing_trace: ['source_carton_mark', 'target_carton_mark', 'return_no', 'sku_code'],
ll_return_inventory_carton_item: ['packing_reserved_quantity'],
ll_return_inventory_operation: ['result_json'],
ll_dispatch_pda_pick: ['return_carton_id'],
ll_dispatch_pda_pick_order: ['return_carton_id', 'return_receipt_id']
})) {
const definition = table(overseas, 'baiyue_lastleg', name)
for (const field of fields) assert.ok(definition.includes(field), name + '.' + field)
}
})
test('退货预占状态符合空库数量和状态约束', () => {
const carton = table(overseas, 'baiyue_lastleg', 'll_return_inventory_carton')
for (const name of ['chk_ll_return_inventory_carton_quantity', 'chk_ll_return_inventory_carton_status']) {
const constraint = carton.split('CONSTRAINT ' + name)[1].split('\n')[0]
for (const status of ['PACKING_RESERVED', 'OUTBOUND_PENDING']) assert.ok(constraint.includes(status), name + ':' + status)
}
})