Files
SupplierSystem/migrations/20261071_main_system_quantity_conflicts.sql
T
Ubuntu 521e1ae13d
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
feat(main-system): 消费 preparations.quantity_changed 同步订单计划数量
- webhook 消费:event_id+prep_id 幂等、revision 防乱序,业务失败 200 靠对账兜底
- 未出库:订单数量/金额/分拣 required_qty/库存抵扣差额/已分配备货/自采/结算同步
- 已出库/备货完成竞态/共享行缺订单行 id:不覆盖,落冲突台账 + 站内通知
- 定时对账兜底:mainSystemReturnFollow + 事件消费者 quantity_sync
- 迁移两张台账表;新增 13 条单测
2026-10-28 10:37:52 +08:00

34 lines
1.1 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 主系统「计划数量变化」冲突/差异台账(2026-10-28)
-- 已出库/已发车/备货完成竞态/已拣超量等场景不静默覆盖,落表交人工。
BEGIN;
CREATE TABLE IF NOT EXISTS public.main_system_quantity_conflicts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
branch_code VARCHAR(20) NOT NULL,
main_order_code VARCHAR(64),
our_order_code VARCHAR(64),
prep_id UUID,
main_order_item_id UUID,
our_order_item_id UUID,
sku_code VARCHAR(64),
item_name VARCHAR(255),
old_quantity NUMERIC(14,3),
new_quantity NUMERIC(14,3),
target_quantity NUMERIC(14,3),
reason VARCHAR(64) NOT NULL,
detail JSONB,
event_id UUID,
revision INTEGER,
status VARCHAR(20) NOT NULL DEFAULT 'open',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
resolved_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_quantity_conflicts_open
ON public.main_system_quantity_conflicts (branch_code, status, created_at DESC);
COMMENT ON TABLE public.main_system_quantity_conflicts IS
'主系统数量变化冲突/差异(已出库拒绝覆盖 / 备货完成竞态 / 已拣超量等),交人工处理';
COMMIT;