免入库(主系统骑手上门取货): - 50 展示「待取货」、副文案「待主系统骑手上门取货」、不建我方配送任务(守卫与开关解耦) - 我方 50 即回写备货完成;两开关(SKIP_INBOUND_AWAIT_PICKUP / FULFILLMENT_EVENTS)改默认开 核货事实镜像(「核货完毕」标记): - 按主系统 lookup 的 actual_qty 落台账,新增 GET/POST /orders/:orderCode/main-system-prep-facts[/refresh] - 详情行内显示「核货完毕」(含核货量),分配对账兜底刷新 实收数量/单位口径变更(对方先改 + 我方事后同步): - 台账加 applied_at;inbound 与 picking_check 同为事实登记(驳回不回滚) - 同意才落我方值:免入库改装车核货量、送仓改验收实收(已入库走既有库存调整)、已结算/已结案只留痕 - 计划量与金额一起改,并同步结算投影(syncStatementsForOrderSafe) - 审核页语义改「主系统实际值(已生效)/ 是否同步」+ 已处理历史(双方时间与落值结论) 台账对照与回写修复: - 行级对照改整单一次性(同名商品不再重复认领)+ 存量纠正 healOrderPrepMapping - 堵住客户绑定回填旁路(免入库单不再被派我方骑手) - 回写触发函数改对象参数(修 branch/order 传反导致的静默不回写) 文档:设计文档 4 篇 +《给主系统 AI 的对接改造清单》§2.9(第六批契约) 回归:服务端全量与 HEAD 基线一致(24 个失败文件同集合);前端 140 文件 / 699 测试全绿;tsc 双端干净
130 lines
5.2 KiB
TypeScript
130 lines
5.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
buildProgressStatusHint,
|
|
computeEffectiveOrderStatus,
|
|
pickDisplayOrderStatus,
|
|
type OrderProgressFacts,
|
|
} from '../src/services/orderStatusDisplayService';
|
|
|
|
const baseFacts = (over: Partial<OrderProgressFacts> = {}): OrderProgressFacts => ({
|
|
allocationFulfilled: false,
|
|
pendingPreps: 0,
|
|
pendingPurchases: 0,
|
|
itemCount: 1,
|
|
inspectionCount: 0,
|
|
pendingProcessing: 0,
|
|
pendingPicks: 0,
|
|
outboundPicks: 0,
|
|
deliveryStarted: false,
|
|
deliveryEnded: false,
|
|
customerSigned: false,
|
|
...over,
|
|
});
|
|
|
|
describe('order list allocation hint', () => {
|
|
it('shows 未分配 hint only when status 20 and not allocationFulfilled', () => {
|
|
expect(
|
|
buildProgressStatusHint(20, 'none', baseFacts({ allocationFulfilled: false }))
|
|
).toBe('尚有明细未分配供应商/采购');
|
|
|
|
expect(
|
|
buildProgressStatusHint(20, 'none', baseFacts({ allocationFulfilled: true }))
|
|
).toBeNull();
|
|
});
|
|
|
|
it('treats fulfilled facts as past 待分配 (no 未分配 hint)', () => {
|
|
const facts = baseFacts({
|
|
allocationFulfilled: true,
|
|
pendingPreps: 1,
|
|
pendingPurchases: 0,
|
|
});
|
|
expect(computeEffectiveOrderStatus(20, facts, 'none', true)).toBe(30);
|
|
expect(buildProgressStatusHint(30, 'none', facts, undefined, true)).toContain('未完成备货');
|
|
|
|
const covered = baseFacts({ allocationFulfilled: true, pendingPreps: 0, pendingPurchases: 0 });
|
|
// 无待备货/自采时会推进到待验收
|
|
expect(computeEffectiveOrderStatus(20, covered, 'none', true)).toBe(40);
|
|
expect(buildProgressStatusHint(40, 'none', covered)).toBe('待仓管验收');
|
|
});
|
|
|
|
it('does not fake 90 when signed/ended but order not finalized', () => {
|
|
const ended = baseFacts({ deliveryEnded: true, deliveryStarted: true });
|
|
expect(computeEffectiveOrderStatus(60, ended, 'passed', true)).toBe(60);
|
|
expect(buildProgressStatusHint(60, 'passed', ended)).toContain('待结案归档');
|
|
|
|
const signed = baseFacts({ customerSigned: true, deliveryStarted: true });
|
|
expect(computeEffectiveOrderStatus(50, signed, 'passed', true)).toBe(60);
|
|
expect(buildProgressStatusHint(60, 'passed', signed)).toContain('待结案归档');
|
|
});
|
|
|
|
it('does not regress 50→45 when picking re-enabled without outbound', () => {
|
|
const facts = baseFacts({ inspectionCount: 1 });
|
|
// 验收已过、无出库分拣、分拣已开:若库内已是 50,保持 50
|
|
expect(computeEffectiveOrderStatus(50, facts, 'passed', true)).toBe(50);
|
|
// 库内仍是 40/未到配送:才落到 45
|
|
expect(computeEffectiveOrderStatus(40, facts, 'passed', true)).toBe(45);
|
|
expect(pickDisplayOrderStatus(50, 45)).toBe(50);
|
|
expect(pickDisplayOrderStatus(50, 45, facts, 'passed')).toBe(50);
|
|
});
|
|
|
|
it('加工单未完工不挡推进:入库已确认即可进分拣/待配送', () => {
|
|
const facts = baseFacts({
|
|
allocationFulfilled: true,
|
|
inspectionCount: 1,
|
|
pendingProcessing: 2,
|
|
});
|
|
expect(computeEffectiveOrderStatus(40, facts, 'passed', true)).toBe(45);
|
|
expect(computeEffectiveOrderStatus(40, facts, 'passed', false)).toBe(50);
|
|
});
|
|
|
|
it('未确认入库不得停在待配送:验收 pending 时从 50 退回待验收', () => {
|
|
const facts = baseFacts({
|
|
allocationFulfilled: true,
|
|
inspectionCount: 1,
|
|
pendingProcessing: 1,
|
|
});
|
|
expect(computeEffectiveOrderStatus(50, facts, 'pending', false)).toBe(40);
|
|
expect(pickDisplayOrderStatus(50, 40, facts, 'pending')).toBe(40);
|
|
});
|
|
|
|
it('does not jump to 待配送 while purchase still pending', () => {
|
|
const facts = baseFacts({
|
|
allocationFulfilled: true,
|
|
pendingPurchases: 1,
|
|
inspectionCount: 2,
|
|
});
|
|
// 验收态即便误为 passed,有待采也不得进 45/50
|
|
expect(computeEffectiveOrderStatus(50, facts, 'passed', true)).toBe(30);
|
|
expect(computeEffectiveOrderStatus(40, facts, 'passed', false)).toBe(30);
|
|
expect(pickDisplayOrderStatus(50, 30, facts)).toBe(30);
|
|
});
|
|
|
|
it('待备货已有待处理备货/自采时不因关联异步补链回退待分配', () => {
|
|
const facts = baseFacts({ allocationFulfilled: false, pendingPreps: 1 });
|
|
expect(computeEffectiveOrderStatus(30, facts, 'none', true)).toBe(20);
|
|
expect(pickDisplayOrderStatus(30, 20, facts, 'none')).toBe(30);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 主系统「免入库」单在 50 的**副文案**口径(2026-10-11 开发者定稿):
|
|
* 我方不派车、货由主系统骑手上门取走 ⇒ 副文案必须与徽标「待取货」同口径,
|
|
* 不得再写「待配送员开始配送」(张冠李戴)。
|
|
*/
|
|
describe('免入库单 50 副文案', () => {
|
|
const facts = baseFacts({ allocationFulfilled: true });
|
|
|
|
it('免入库:待主系统骑手上门取货', () => {
|
|
expect(buildProgressStatusHint(50, 'passed', facts, undefined, true, true)).toBe(
|
|
'待主系统骑手上门取货'
|
|
);
|
|
});
|
|
|
|
it('送仓/自建单:仍是待配送员开始配送(skipInbound 缺省或 false 不得改口径)', () => {
|
|
expect(buildProgressStatusHint(50, 'passed', facts, undefined, true)).toBe('待配送员开始配送');
|
|
expect(buildProgressStatusHint(50, 'passed', facts, undefined, true, false)).toBe(
|
|
'待配送员开始配送'
|
|
);
|
|
});
|
|
});
|