feat(多模块): 代提交另一会话遗留在工作区的整批改动(内容零修改)
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

原改动人:雨天 <oncwnuHbbvAwYZMdPF78PsWNPadI@git.weixin.qq.com>
代为提交:Lead 会话(本 commit 内容与该会话工作区逐字节一致,未做任何修改),
目的是不让在研成果丢失、并让工作树回到干净可部署状态。

提交前由 Lead 实跑验证:
- 前端 npx tsc --noEmit 0 错误;后端 server npx tsc --noEmit 0 错误
- 本批新增的 7 个测试 54/54 通过;Lead 侧契约测试(散客录单/文案/成本列)42/42 通过
- bash tools/design-consistency/run-all.sh --verify:通过 8 / 未通过 1(check-ai-cost,既有红)/ 未执行 1(verify-facts,本地库不可连)—— 与基线一致

新增能力(各含 docs/design 设计文):
- 独立进货不得有配送任务:生成侧兜底 + 补建候选 + 查询侧三道防线(实测 5 张独立进货单里 4 张有僵尸 delivery_tasks)
- 主系统追加行零价闸门尊重其已声明的 allowUnpriced(否则整批分配行静默丢失)
- 库存抵扣为 0 的原因可见(不再静默,原因判定与抵扣量同源并落到日志与「库存抵扣」入口)
- 退货/删单跟随改独立 2 分钟周期(MAIN_SYSTEM_RETURN_FOLLOW_SEC,置 0 退回旧行为)
- 加工领料可用本单自己的预留(放行必须与本单预留消费成对,避免短送与同一批算两次)
- 出库拍照预览、主系统实收 / SKU 映射 / 单位变更 inbox 等配套

同一批包含对已废弃旧方案的回滚(design doc 与 README 索引行一并移除):
- 独立进货建客户档案(方案甲)→ 回到哨兵方案;随之删除 migrations/20261044_independent_inbound_customer.sql
- 分类新建去重(同名复用已有)
- 分拣标签纸张尺寸预设 / 分拣标签可选客户名与区域

未包含:src/pages/orders/OrderManagementPage.tsx(0 字节空文件,疑似误建,既未提交也未删除)
This commit is contained in:
雨天
2026-10-15 11:29:15 +08:00
committed by Ubuntu
parent 2347068409
commit 29fbf49481
76 changed files with 3333 additions and 1437 deletions
@@ -11,6 +11,7 @@ import { fetchOrderInspectionState } from './orderInspectionStateService';
import { signedExistingPhotos } from './inspectionReviewService';
import { orderNotDeletedSql } from './orderTrashScope';
import { orderVisibleToDeliverySql } from './supplierSkipInbound';
import { salesVisibleOrderSql } from './independentInbound';
import { computeUnloadSeconds } from './deliveryGeofenceLogic';
import { isOrderCodeSearch } from '../utils/orderCodeQuery';
@@ -162,6 +163,7 @@ export async function ensureDeliveryTasksForDeliveryDay(
WHERE COALESCE(o.order_status, 0) >= 50
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
AND ${salesVisibleOrderSql('o')}
AND ${dateFilter}
${branchFilter}
AND NOT EXISTS (SELECT 1 FROM delivery_tasks dt WHERE dt.order_code = o.order_code)`,
@@ -196,6 +198,7 @@ export async function ensureMissingDeliveryTasksForBranch(branchCode?: string |
AND COALESCE(o.order_status, 0) < 90
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
AND ${salesVisibleOrderSql('o')}
${branchFilter}
AND NOT EXISTS (SELECT 1 FROM delivery_tasks dt WHERE dt.order_code = o.order_code)
ORDER BY o.updated_at DESC
@@ -438,6 +441,7 @@ export async function listDeliveryTasksForManagement(
) bind ON true
LEFT JOIN delivery_persons bind_dp ON bind_dp.person_code = bind.person_code
WHERE ${orderVisibleToDeliverySql('o')}
AND ${salesVisibleOrderSql('o')}
${statusFilter}
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
@@ -503,6 +507,7 @@ export async function listDeliveryTasksForDriver(input: {
) bind ON true
LEFT JOIN delivery_persons bind_dp ON bind_dp.person_code = bind.person_code
WHERE ${orderVisibleToDeliverySql('o')}
AND ${salesVisibleOrderSql('o')}
AND COALESCE(o.order_status, 0) < 90
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
@@ -539,6 +544,7 @@ export async function countPendingDriverDeliveryTasks(input: {
FROM delivery_tasks dt
INNER JOIN orders o ON o.order_code = dt.order_code
WHERE ${orderVisibleToDeliverySql('o')}
AND ${salesVisibleOrderSql('o')}
AND COALESCE(o.order_status, 0) < 90
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
@@ -653,6 +659,7 @@ export async function listDeliveryPersonStats(
INNER JOIN orders o ON o.order_code = dt.order_code
LEFT JOIN customers c ON c.customer_code = o.customer_code
WHERE ${orderVisibleToDeliverySql('o')}
AND ${salesVisibleOrderSql('o')}
AND ${orderNotDeletedSql('o')}
AND ${nonRetailOrderSql('o')}
AND NULLIF(TRIM(dt.person_code), '') IS NOT NULL