feat(fleet): integrate costs quotes operations and in-transit handovers

This commit is contained in:
2026-10-03 12:38:04 +08:00
parent 274ecac474
commit cb6c54ffe5
107 changed files with 7304 additions and 42 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, 223], [overseas, overseasSchemas, domesticSchemas, 145]]) {
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 226], [overseas, overseasSchemas, domesticSchemas, 152]]) {
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, '')
@@ -28,7 +28,45 @@ 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, (223|145) AS initialized_tables;$/)
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (226|152) AS initialized_tables;$/)
}
})
test('车次直接成本按车次幂等并保留独立币种与不可变更正历史', () => {
const cost = table(overseas, 'baiyue_lastleg', 'll_fleet_trip_cost')
const history = table(overseas, 'baiyue_lastleg', 'll_fleet_trip_cost_history')
assert.match(cost, /UNIQUE KEY uk_fleet_trip_cost_request\(trip_id,created_by,request_key\)/i)
assert.match(cost, /FOREIGN KEY\(trip_id\) REFERENCES ll_fleet_trip\(id\)/i)
assert.match(cost, /CHECK\(amount>=0\)/i)
assert.match(cost, /CHECK\(currency IN \('CNY','USD'\)\)/i)
assert.match(history, /UNIQUE KEY uk_fleet_trip_cost_history\(cost_id,record_version\)/i)
assert.match(history, /FOREIGN KEY\(cost_id\) REFERENCES ll_fleet_trip_cost\(id\)/i)
assert.match(history, /snapshot_json JSON NOT NULL/i)
})
test('车辆报价与实测记录保留业务去重和不可变版本', () => {
const quote = table(overseas, 'baiyue_lastleg', 'll_fleet_quote')
assert.match(quote, /UNIQUE KEY uk_fleet_quote_no \(quote_no\)/i)
assert.match(quote, /UNIQUE KEY uk_fleet_quote_natural \(natural_key\)/i)
assert.match(quote, /UNIQUE KEY uk_fleet_quote_create \(created_by,create_key\)/i)
assert.match(table(overseas, 'baiyue_lastleg', 'll_fleet_quote_history'), /UNIQUE KEY uk_fleet_quote_history_version \(quote_id,record_version\)/i)
const measured = table(overseas, 'baiyue_lastleg', 'll_fleet_trip_operations_record')
assert.match(measured, /UNIQUE KEY uk_fleet_operations_version \(trip_no,record_version\)/i)
assert.match(measured, /UNIQUE KEY uk_fleet_operations_request \(trip_no,operator_id,request_key\)/i)
})
test('公司车辆费用隔离于客户账务并约束实际付款金额', () => {
const cost = table(cn, 'baiyue_finance', 'fin_vehicle_cost')
assert.doesNotMatch(cost, /\b(customer_id|tenant_id)\b/i)
assert.match(cost, /subject_id BIGINT UNSIGNED NOT NULL/i)
assert.match(cost, /UNIQUE KEY uk_fin_vehicle_cost_source \(subject_id,source_type,source_no\)/i)
assert.match(cost, /CHECK \(amount>0 AND paid_amount>=0 AND paid_amount<=amount\)/i)
assert.match(table(cn, 'baiyue_finance', 'fin_vehicle_cost_payment'), /FOREIGN KEY \(cost_id\) REFERENCES fin_vehicle_cost\(id\)/i)
assert.match(table(cn, 'baiyue_finance', 'fin_vehicle_cost_revision'), /UNIQUE KEY uk_fin_vehicle_cost_request \(operator_id,action,request_key\)/i)
const admin = roleAuthorities(cn, 'PLATFORM_ADMIN'), merchant = roleAuthorities(cn, 'MERCHANT_OWNER')
for (const action of ['list', 'approve', 'void', 'pay', 'upload']) {
assert.ok(admin.has(`platform:finance:vehicle-cost:${action}`))
assert.ok(!merchant.has(`platform:finance:vehicle-cost:${action}`))
}
})
@@ -56,7 +94,7 @@ test('平台管理员由外部bcrypt引导,强制首登改密且不创建客
})
test('必要系统种子完整保留,但不写入示例资源与业务事实', () => {
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 392, iam_role_permission: 573,
for (const [name, count] of Object.entries({ iam_role: 8, iam_permission: 411, iam_role_permission: 592,
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)
@@ -84,9 +122,17 @@ test('国内IAM权限与角色授权没有丢失或悬挂,客户模板仍完
for (const action of ['list', 'create', 'edit', 'status', 'review', 'upload']) {
assert.ok(admin.has(`platform:overseas-master-data:driver:${action}`))
}
for (const action of ['list', 'create', 'edit', 'assign', 'cancel']) {
for (const action of ['list', 'create', 'edit', 'assign', 'cancel', 'cost-create', 'cost-edit']) {
assert.ok(admin.has(`platform:fleet:trip:${action}`))
}
for (const action of ['list', 'create', 'edit', 'status', 'delete', 'import', 'export']) {
assert.ok(admin.has(`platform:fleet:quote:${action}`))
assert.ok(!merchant.has(`platform:fleet:quote:${action}`))
}
for (const action of ['list', 'export', 'edit']) {
assert.ok(admin.has(`platform:fleet:operations:${action}`))
assert.ok(!merchant.has(`platform:fleet:operations:${action}`))
}
assert.ok(!permissions.some(row => row.permission_code === 'platform:order:complete'),
'订单完成必须由可信履约回写产生,不能恢复人工完成权限')
for (const code of ['platform:order:declaration:edit', 'platform:firstleg:inbound:hold',