- 下单即建分拣/配送,待取货/散客/独立进货守卫 - 30/40/45 直接发车/分拣,入库与分拣二选一 - 分拣完成补上游、清理 pending 验收,直接配送补分拣 - 库存抵扣/计划/实收 FIFO,软扣部分扣减,并发出库串行 - 结束配送不被库存不足/待入库残留阻断 - 待验收并发唯一索引(含 name-only),finalize 共享连接修复 - 售后自动绑定订单明细、客户取货/采购并发修复 - 仓库表格自适应、弹窗滚动锁闪烁修复
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const migration = readFileSync(
|
|
new URL('../../migrations/20261086_pending_inspections_name_unique.sql', import.meta.url),
|
|
'utf8'
|
|
);
|
|
const inspection = readFileSync(
|
|
new URL('../src/services/inspectionRejectFulfillmentService.ts', import.meta.url),
|
|
'utf8'
|
|
);
|
|
|
|
describe('待验收单并发防重', () => {
|
|
it('迁移先清历史 pending 重复,再建唯一索引(不删已入库)', () => {
|
|
expect(migration).toContain('ROW_NUMBER() OVER');
|
|
expect(migration).toContain('actual_qty, 0) = 0');
|
|
expect(migration).toContain('inspections_pending_order_supplier_key_uidx');
|
|
expect(migration).toContain('WHERE inspection_time IS NULL');
|
|
expect(migration).toContain('__NAME__');
|
|
expect(migration).toContain('LOWER(TRIM(item_name))');
|
|
});
|
|
|
|
it('并发插入被唯一索引拦截时返回 false,不报错', () => {
|
|
expect(inspection).toContain('ON CONFLICT DO NOTHING');
|
|
expect(inspection).toContain("COALESCE(NULLIF(TRIM(sku_code), ''), '') = ''");
|
|
expect(inspection).toContain('LOWER(TRIM(item_name))');
|
|
expect(inspection).toContain("error?.code === '23505'");
|
|
expect(inspection).toContain('return false;');
|
|
});
|
|
});
|