开发者 2026-10-17 裁决:我方不做本地竞价管理(菜单已摘除),只做两件事 ——
收到主系统 bid.opened 后显示本轮要报什么、把单价报回去;中标后沿用既有「分配 → 建单」。
主系统契约(对方 docs/design/20261017-bid-opened-push.md):
· `bid.opened` 推送(单对象、无 data[]、同一套 X-Signature)
· `GET /api/supplier/bids`:列表兜底(对方 webhook 只重试 2 次)
· `GET /api/supplier/bids/:round_id`:单轮详情(明细 + 我的报价 + 我的中标)
· `POST /api/supplier/bids/:round_id/quotes`:提交报价(批量 upsert,只有我的视角)
我方实现:
· 迁移 20261055:public.main_system_bid_invitations / _invitation_items,
幂等键 (branch_code, round_id, supplier_code)、明细 (invitation_id, sku_code)
· webhook 新增 bid.opened 分支(就地 return,绝不落进 preparations.allocated 建单兜底);
验签逻辑一字未改;落库前按该分公司生效绑定校验并规范化 supplier_code
· 主系统调用走既有分层:services/mainSystem/{config,endpoints,http,token}.ts + api/bids.ts;
401 强制刷新 token 只重试一次;403 判语义拒绝不重试
· 业务层:mainSystemBidInbox(整轮对齐/唯一派生口径 deriveLocalStatus)、
mainSystemBidQuotes(列表/同步/刷新/提交 + 错误码中文映射)
· 页面侧 4 个 REST:GET 清单 / POST sync / GET :roundId / POST :roundId/quotes
(挂 workflow 模块,权限沿用 order_manage|order_edit|order_entry)
· Web「待报价」页 + 菜单(orders-bid-invitations)+ 三语文案;复用既有 bids 命名空间
口径与边界(设计文 docs/design/20261017-主系统竞价待报价与报价提交.md):
· 事实源在主系统,我方两张表是镜像:刷新/提交成功一律「整轮先清空再写」
· 失败绝不改本地报价(不能让用户以为报上了);只写 sync_error 留痕
· 退化响应守卫:对方 2xx 但载荷不可识别 ⇒ 失败且不落库(否则会清空我方已报价与中标)
· 终态不可回退:closed / awarded / cancelled 收到迟到 bid.opened 不得改回 open
· item_count 只认去重后的实际明细行数(避免"列表 3 件、点开 2 件")
· 多绑定同一轮:页面每行带 supplierCode 精确定位;不带且命中多行 ⇒ 409 不猜
· 单价:只收 number 或纯数字字符串,>0、≤4 位小数、≤99999999.9999
验证(真实输出见交付说明):
· server/tests/mainSystemBidQuote.test.ts 28 用例、mainSystemBidQuoteBoundary.test.ts 91 用例、
mainSystemBidQuoteDb.integration.test.ts 真库 11 用例(BID_DB_TEST=1 才跑)全过
· Web:BidInvitationsPage.render 7 用例 + 菜单契约/menuLayout 共 86 用例全过;
npm run typecheck 0 错;cd server && npx tsc --noEmit 0 错
(注意:根 tsconfig include 只有 src,后端必须单独 typecheck)
· 全量后端套件与基线 14d7afe 逐文件比对:失败集合完全一致(30 文件 / 38 用例,均既有失败)
· 本地真环境:伪造签名 401;真实签名连推两次只落 1 行 + 去重后 2 条明细;
未绑定编码 ⇒ ignored 不落库;详情对不存在轮次 404 且台账自动 cancelled
· 独立复核(verifier)B1–B9/B11/B13 全 pass;红队(adversary)未发现误建单/跨租户/资金精度类高危,
两条中危(多绑定错供应商、2xx 畸形响应清空本地)已修并被用例钉住
· 设计门禁:8 通过 / 1 已知红 check-ai-cost / verify-facts 因本地缺 tenant_br003 红(均基线)
219 lines
9.1 KiB
TypeScript
219 lines
9.1 KiB
TypeScript
import type { BusinessModuleDescriptor } from './types';
|
|
import type { Router } from 'express';
|
|
import { advanceFromAllocation } from './handlers/orderAllocationHandler';
|
|
import { advanceFromPreparation } from './handlers/preparationHandler';
|
|
import { advanceFromInspection } from './handlers/inspectionHandler';
|
|
import { advanceFromPicking } from './handlers/pickingHandler';
|
|
import {
|
|
advanceFromDelivering,
|
|
advanceFromPendingDelivery,
|
|
} from './handlers/deliveryFinanceHandlers';
|
|
import { mountPickingWorkflowRoutes } from './workflow/routes/pickingRoutes';
|
|
import { mountNotificationWorkflowRoutes } from './workflow/routes/notificationRoutes';
|
|
import { mountInspectionWorkflowRoutes } from './workflow/routes/inspectionRoutes';
|
|
import { mountOrderWorkflowRoutes } from './workflow/routes/orderRoutes';
|
|
import { mountBidWorkflowRoutes } from './workflow/routes/bidRoutes';
|
|
import { mountMainSystemBidWorkflowRoutes } from './workflow/routes/mainSystemBidRoutes';
|
|
import { mountPurchaseWorkflowRoutes } from './workflow/routes/purchaseRoutes';
|
|
import { mountPreparationWorkflowRoutes } from './workflow/routes/preparationRoutes';
|
|
import { mountFinanceWorkflowRoutes } from './workflow/routes/financeRoutes';
|
|
import { mountDeliveryWorkflowRoutes } from './workflow/routes/deliveryRoutes';
|
|
import { mountQuoteWorkflowRoutes } from './workflow/routes/quoteRoutes';
|
|
import { mountCustomerWorkflowRoutes } from './workflow/routes/customerRoutes';
|
|
import { mountMarketWorkflowRoutes } from './workflow/routes/marketRoutes';
|
|
import { mountSupplierWorkflowRoutes } from './workflow/routes/supplierRoutes';
|
|
import { mountPlatformConfigWorkflowRoutes } from './workflow/routes/platformRoutes';
|
|
import { mountTraceWorkflowRoutes } from './workflow/routes/traceRoutes';
|
|
import { mountInventoryWorkflowRoutes } from './workflow/routes/inventoryRoutes';
|
|
import { mountImportMappingWorkflowRoutes } from './workflow/routes/importMappingRoutes';
|
|
import { mountUnitWorkflowRoutes } from './workflow/routes/unitRoutes';
|
|
import { mountSkuDirectDeliveryWorkflowRoutes } from './workflow/routes/skuDirectDeliveryRoutes';
|
|
import { mountSkuPreferredSupplierWorkflowRoutes } from './workflow/routes/skuPreferredSupplierRoutes';
|
|
import { mountUiPreferenceWorkflowRoutes } from './workflow/routes/uiPreferenceRoutes';
|
|
|
|
function mountPlatformWorkflowRoutes(router: Router): void {
|
|
mountNotificationWorkflowRoutes(router);
|
|
mountPlatformConfigWorkflowRoutes(router);
|
|
mountImportMappingWorkflowRoutes(router);
|
|
mountUiPreferenceWorkflowRoutes(router);
|
|
}
|
|
|
|
export const orderModule: BusinessModuleDescriptor = {
|
|
id: 'order',
|
|
name: '订单与分配',
|
|
description: '下单、订单列表、智能分配与状态推进',
|
|
permissions: ['order_manage', 'order_edit', 'order_entry', 'allocation_manage', 'bid_manage'],
|
|
orderStatuses: [20],
|
|
workflowApiPrefix: '/orders',
|
|
services: ['orderWorkflowService', 'orderAllocationService', 'customerOrderSubmitService'],
|
|
workflowTransitions: { 20: advanceFromAllocation },
|
|
mountWorkflowRoutes: (router) => {
|
|
mountOrderWorkflowRoutes(router);
|
|
// 本地竞价管理(已停用并摘除菜单,代码保留)
|
|
mountBidWorkflowRoutes(router);
|
|
// 主系统竞价「待报价」:我方只报价、不定标(2026-10-17)
|
|
mountMainSystemBidWorkflowRoutes(router);
|
|
},
|
|
};
|
|
|
|
export const purchaseModule: BusinessModuleDescriptor = {
|
|
id: 'purchase',
|
|
name: '采购与备货',
|
|
permissions: ['purchase_manage', 'preparation_manage'],
|
|
orderStatuses: [30],
|
|
workflowApiPrefix: '/purchase',
|
|
mobileApiPrefix: '/mobile/purchase',
|
|
services: ['preparationFulfillmentService', 'purchaseInboundService'],
|
|
workflowTransitions: { 30: advanceFromPreparation },
|
|
mountWorkflowRoutes: (router) => {
|
|
mountPreparationWorkflowRoutes(router);
|
|
mountPurchaseWorkflowRoutes(router);
|
|
},
|
|
};
|
|
|
|
export const inspectionModule: BusinessModuleDescriptor = {
|
|
id: 'inspection',
|
|
// 模块名以前端 src/modules/businessModules.ts 为准(该模块前端名即「验收与加工」)
|
|
name: '验收与加工',
|
|
permissions: ['inspection_manage', 'processing_manage'],
|
|
orderStatuses: [40],
|
|
workflowApiPrefix: '/inspection',
|
|
mobileApiPrefix: '/mobile/inspection',
|
|
services: ['inspectionComplianceService', 'processingTaskService'],
|
|
workflowTransitions: { 40: advanceFromInspection },
|
|
mountWorkflowRoutes: mountInspectionWorkflowRoutes,
|
|
};
|
|
|
|
export const pickingModule: BusinessModuleDescriptor = {
|
|
id: 'picking',
|
|
name: '分拣出库',
|
|
permissions: ['picking_manage', 'picking_barcode', 'picking_scale'],
|
|
orderStatuses: [45],
|
|
workflowApiPrefix: '/picking',
|
|
mobileApiPrefix: '/mobile/picking',
|
|
services: ['pickingService', 'pickingBarcodeService'],
|
|
workflowTransitions: { 45: advanceFromPicking },
|
|
mountWorkflowRoutes: mountPickingWorkflowRoutes,
|
|
};
|
|
|
|
export const deliveryModule: BusinessModuleDescriptor = {
|
|
id: 'delivery',
|
|
name: '配送',
|
|
permissions: ['delivery_manage', 'delivery_sign_photo', 'delivery_loading_photo', 'delivery_loading_qty_edit'],
|
|
orderStatuses: [50, 60],
|
|
workflowApiPrefix: '/delivery',
|
|
mobileApiPrefix: '/mobile/delivery',
|
|
services: ['deliveryRoutingService', 'deliveryLoadingService', 'deliveryPhotoService'],
|
|
workflowTransitions: {
|
|
50: advanceFromPendingDelivery,
|
|
60: advanceFromDelivering,
|
|
},
|
|
mountWorkflowRoutes: mountDeliveryWorkflowRoutes,
|
|
};
|
|
|
|
export const financeModule: BusinessModuleDescriptor = {
|
|
id: 'finance',
|
|
name: '财务',
|
|
description: '成本入账、结算单、发票与经营分析(与订单履约状态解耦)',
|
|
permissions: ['finance_manage', 'cost_manage', 'statement_manage', 'invoice_manage'],
|
|
workflowApiPrefix: '/finance',
|
|
services: [
|
|
'financeReconciliationService',
|
|
'costAllocationService',
|
|
'freeCostService',
|
|
'fixedCostTypeService',
|
|
'costDisplayNameService',
|
|
'orderCostPostingService',
|
|
],
|
|
mountWorkflowRoutes: mountFinanceWorkflowRoutes,
|
|
};
|
|
|
|
export const productModule: BusinessModuleDescriptor = {
|
|
id: 'product',
|
|
name: '商品主数据',
|
|
permissions: ['category_manage', 'sku_manage', 'alias_manage', 'product_manage'],
|
|
services: ['categoryCatalogService', 'quoteSheetService', 'unitDictionaryService'],
|
|
mountWorkflowRoutes: (router: Router) => {
|
|
mountQuoteWorkflowRoutes(router);
|
|
mountMarketWorkflowRoutes(router);
|
|
mountUnitWorkflowRoutes(router);
|
|
mountSkuDirectDeliveryWorkflowRoutes(router);
|
|
mountSkuPreferredSupplierWorkflowRoutes(router);
|
|
},
|
|
};
|
|
|
|
export const customerModule: BusinessModuleDescriptor = {
|
|
id: 'customer',
|
|
name: '客户管理',
|
|
permissions: ['customer_manage'],
|
|
services: ['customerBudgetService', 'quoteSheetService'],
|
|
mountWorkflowRoutes: mountCustomerWorkflowRoutes,
|
|
};
|
|
|
|
export const supplierModule: BusinessModuleDescriptor = {
|
|
id: 'supplier',
|
|
name: '供应商',
|
|
permissions: ['supplier_manage', 'supplier_supply_manage'],
|
|
services: ['supplierRatingService'],
|
|
mountWorkflowRoutes: mountSupplierWorkflowRoutes,
|
|
};
|
|
|
|
export const inventoryModule: BusinessModuleDescriptor = {
|
|
id: 'inventory',
|
|
name: '库存',
|
|
permissions: ['inventory_manage'],
|
|
// 本模块同时挂载 /inventory/* 与 /trace/*(商品溯源在前端也归属 inventory 模块的 menuKeys),
|
|
// 但主前缀应为本模块的主路由 /inventory —— 原值 '/trace' 是溯源路由,属填错。
|
|
workflowApiPrefix: '/inventory',
|
|
services: ['inboundGapRepairService', 'productTraceService', 'inventoryStockCoverService'],
|
|
mountWorkflowRoutes: (router: Router) => {
|
|
mountTraceWorkflowRoutes(router);
|
|
mountInventoryWorkflowRoutes(router);
|
|
},
|
|
};
|
|
|
|
/** 运营(售后 / 异常 / 市场行情):此前只存在于前端,后端注册表缺失 */
|
|
export const opsModule: BusinessModuleDescriptor = {
|
|
id: 'ops',
|
|
name: '运营',
|
|
description: '售后工单、异常工单、市场行情监控',
|
|
permissions: ['aftersales_manage', 'exception_manage', 'market_monitor'],
|
|
services: ['afterSaleLifecycleService', 'exceptionPredictionService', 'marketIndexService'],
|
|
};
|
|
|
|
/** 数据看板:此前只存在于前端,后端注册表缺失(无独立权限码,前端按角色 admin/super_admin 放行) */
|
|
export const dashboardModule: BusinessModuleDescriptor = {
|
|
id: 'dashboard',
|
|
name: '数据看板',
|
|
description: '首页 KPI、趋势、待办与损耗分析',
|
|
services: ['dashboardService', 'dashboardLossAnalysis'],
|
|
};
|
|
|
|
export const platformModule: BusinessModuleDescriptor = {
|
|
id: 'platform',
|
|
// 模块名以前端 src/modules/businessModules.ts 为准(前端该模块名为「系统」;
|
|
// docs/modules 的文件名仍是描述性长名「12-平台与系统.md」,两者有意不同)
|
|
name: '系统',
|
|
permissions: ['system_manage', 'role_manage', 'user_manage', 'branch_manage'],
|
|
workflowApiPrefix: '/system',
|
|
services: ['permissionCatalogService', 'roleDefinitionService', 'tenantScope'],
|
|
mountWorkflowRoutes: mountPlatformWorkflowRoutes,
|
|
};
|
|
|
|
/** 顺序与 docs/modules/01..13 的编号一致 */
|
|
export const ALL_BUSINESS_MODULES: BusinessModuleDescriptor[] = [
|
|
orderModule,
|
|
purchaseModule,
|
|
inspectionModule,
|
|
pickingModule,
|
|
deliveryModule,
|
|
financeModule,
|
|
productModule,
|
|
customerModule,
|
|
supplierModule,
|
|
inventoryModule,
|
|
opsModule,
|
|
platformModule,
|
|
dashboardModule,
|
|
];
|