42 Commits

Author SHA1 Message Date
liufumingren
66ea0c4c36 feat(storeWarehouse): 新增开始自动分配时间 allocate_start_time,支持跨天自动分配窗口,截单时间下限放开到 00:00,开始时间等于截单时间时保存拒绝 2026-09-03 17:00:46 +08:00
liufumingren
80c73bb34b feat(order): 订单创建自动分配快递改为队列+定时批量消费,消除取号死锁
- 新增 wms_waybill_allocate_queue 队列表(migration + model),订单创建异步流程仅入队(截单/未审核不入队)

- 新增 consume_waybill_allocate_queue 定时任务:15s/worker/重入保护,按仓库+货主串行批量消费,同关系下同一时刻仅一个取号事务

- express_platform 三处结算事务统一先 FOR UPDATE wms_store_warehouse 再更新 wms_order_express(lockAndDeductWaybillSettlement),消除 AB-BA 死锁
2026-08-27 20:11:52 +08:00
liufumingren
a6d67a17fe feat(order): 快递策略漏斗支持外部编码开启时仅匹配纯货主维度策略 2026-08-26 17:24:03 +08:00
liufumingren
73d12cdf1a feat(order): 订单新增 oaid_order_source_code 字段落库,取号链路 plattradeno 优先取该字段 2026-08-26 15:33:11 +08:00
liufumingren
51f6b27d6a fix(qimen): itemId 非主键时降级按 item_code 查找商品,修复奇门推单误报未同步推送到仓库 2026-08-25 13:09:53 +08:00
liufumingren
705678487d fix(returnUnpack): 拆包视频拼接 CDN 域名,商品复核字段透出与缓存失效修复
- returnUnpack: list/detail/videoList/queryByWaybill 输出 videos[].video_url 自动拼接
  http://w{warehouseId}-c{recordingComputerId}.o.gztbyc.com{path},与 order.packing 同口径
  (录制电脑从 wms_print_computer 按 is_recording=true 获取,无录制电脑时保持原始相对路径)
- recheckOrder: scanOrder/scanTask 报文 stock 明细新增 need_recheck 字段(缺省 Y)
- stock: getStockDetails 双实现透出 need_recheck;saveWarehouseStock/handleBatchChange 更新成功后
  显式清除商品详情缓存(bulk update 不触发实例级 afterUpdate hook,修复旧缓存被持续读取)
- delivery_order: 订单创建时间统一取服务器当前时间,不采用报文 createTime,避免被平台上报时间覆盖
- 同步 methods/system.json 文档与 methods/changes/system.json 变更记录
2026-08-23 22:13:33 +08:00
liufumingren
f2d1ed0849 fix(order): 异步链路显式传递仓库上下文,避免 Qimen 无登录用户静默失败
- pendingOrder/orderStorageAllocation: 优先取显式传入的 warehouse_id,缺失时回退 getWarehouseId

- deliveryOrder: buildExpressAllocateRequest 携带 warehouse_id,并补充自动分配开关判定日志
2026-08-22 17:22:46 +08:00
liufumingren
9894e15ccd fix(express-policy): 违禁品策略无法命中——订单创建时聚合商品违禁品类型参与匹配
- addOrderLines 批量查询 StockWarehouse 增加 prohibited_id 字段并聚合去重
- itemsInfo 返回 prohibited_type_ids,matchPolicy 由写死 null 改为传入真实值
- 修复限定违禁品类型的快递策略此前永远被跳过、订单降级默认快递的问题
2026-08-21 22:56:01 +08:00
liufumingren
59019e07a6 feat(deliveryOrder): 快递解析快照与策略漏斗调整、手动单库存归属校验
- resolveExpressSnapshot 全路径补日志与回退快递名称, 未匹配也写快递回退操作日志
- enable_external_express_code 开启时跳过快递策略漏斗, 保留外部匹配/兜底结果
- 手动单直接传 stock_id 时校验库存归属货主, 跨货主库存拒绝下单
2026-08-21 02:20:36 +08:00
liufumingren
3817948b35 feat(order): 锁定订单作业门禁与订单列表 lock_status 转 Y/N
- lock_guard: 新增 isLockedOrderStatus,lock_status 非 none 一律视为已锁定
- 储位分配(allocatePicking)跳过锁定订单,skipped_reason=locked
- 快递分配(createWaybillCodePipeline、wave.batchAllocateExpress)跳过锁定订单并返回 skipped_locked_order_ids
- 抓取波次 singleFetchByIds 排除锁定订单并返回 excluded_locked_order_ids
- 自动加团(delivery_order)锁定订单跳过自动分配快递/储位/自动加团
- 订单列表 normalizeOrderListItem 统一 lock_status 输出 Y/N(none→N,其余→Y)
- 同步 methods/system.json、methods/changes/system.json 文档
2026-08-18 16:25:12 +08:00
liufumingren
37104079e5 feat(order): 订单/明细 id 防回退——序列表唯一发号 + 分表免重建 + 水位自愈 + 迁移任务执行历史 2026-08-15 20:12:23 +08:00
liufumingren
358fef0f71 chore: apply ESLint auto-fixes, JSDoc additions, and CRLF→LF normalization (no logic changes) 2026-08-08 20:28:18 +08:00
liufumingren
0b781a7e70 feat: 店铺快递绑定策略模块 + 订单创建链路集成 + 运单号分配优化
【新增模块】
- app/model/store_express_binding_policy.js: 策略数据模型(17字段,JSON数组)
- app/service/systems/store_express_binding_policy.js: CRUD+列表(含名称批量解析)
- app/service/systems/express_policy.js: 缓存优先策略查询 + 6维漏斗匹配引擎
- app/service/systemMethods/store_express_binding_policy.js: method路由层
- database/designs/store-express-binding-policy-design.md: 设计文档

【策略漏斗匹配逻辑】
- 按priority DESC逐条匹配: store_ids→shop_name→prohibited→regions→exclude→weight
- NULL/空数组=不限, 未命中自动continue到下一条
- 地区/店铺匹配使用子串包含(省/市/区/详细地址均生效)
- 违禁品匹配使用数组交集
- 输出快递编码+重量类型, 未命中返回null

【订单创建链路集成】
- addOrder→addOrderLines后触发matchPolicy(weight可用)
- 命中: 写入logistics/sys_logistics 4字段+weight_type+操作日志
- 未命中: 降级到resolveExpressSnapshot默认值+兜底DEFAULT_STORE_SUBJECT_CONFIG(STO)
- 系统快递4字段一致, 自定义映射(express_setting)分流写入

【运单号分配优化】
- pickWaybillExpressInterface两步兜底:
  Step1: logistics_code仅匹配express_code(自定义编码精确)
  Step2: sys_logistics_code匹配全候选码(系统编码兜底)
- 新增weight_type过滤器(接口NULL=通配, 设限须精确匹配)
- groupedOrder.options新增sys_logistics_code/weight_type传递

【操作码翻译】
- ORDER_EXPRESS_POLICY_MATCH: '策略命中'
- ORDER_EXPRESS_FALLBACK: '快递降级'
- 无策略命中时写入快递降级日志

【API文档】
- methods/system.json: 策略模块4接口+响应字段(express_name/数组类型等)

【数据库迁移】
- 13个migration: 建表→字段迭代→TEXT改JSON→prohibited改数组(dev+prod均执行)
2026-08-04 08:18:43 +08:00
liufumingren
da4208707d fix: 修复自动分配快递时 warehouse_id 上下文丢失导致 FK 约束失败及平台解析异常
- express.js: createWaybillCode 优先使用传入的 warehouse_id,修复 setImmediate 后 ctx.user 丢失导致 wms_order_express.warehouse_id 外键约束失败
- delivery_order.js: asyncProcessOrderCreated 中平台/快递解析逻辑修正
- recheckOrder.js: 复核单快递分配状态判断优化
- express_platform.js: 快递平台自动同步回传链路修正
- order_async.js: 奇门异步下单上下文增强
- polo_api_client.js: PolyAPI 客户端微调
2026-08-02 22:40:58 +08:00
liufumingren
02b3a5e813 fix(order): 订单同步/运单/库位分配防御性修复
- express: 运单查询补充 pay_no/from_key 字段;step 更新增加 status!=cancel 过滤
- order_async: 同步分发前过滤 sync_status=fin 的已完成订单;修复 Op.ne 引用缺失;强制 SELECT FOR UPDATE 重读;多处更新增加 status!=cancel 守卫
- order_storage_allocation: SN/快递分配失败回写增加 status!=cancel 守卫
- methods: allocateExpressCode 文档更新为异步接口说明
2026-08-02 00:38:34 +08:00
liufumingren
f747e73aea fix(deliveryOrder): 货主默认配置统一读取合约 policy_config,移除对 wms_store.subject_config 的错误依赖
- prepareOrderData 不再调用 getStoreSubjectConfig(storeId) 读取死数据
- resolveExpressSnapshot: 默认快递编码统一从合约 policy_config 读取
- resolvePlatformSnapshot: 兜底平台编码只走合约 policy_config
- resolveEnableExternalExpressCode: 移除 storeSubjectConfig 死数据兜底
- 仓库级 getStoreSubjectConfig(warehouseId) 保留(有 warehouse setting 更新入口)
2026-08-01 15:59:22 +08:00
liufumingren
fbb12cf205 fix(deliveryOrder): resolveExpressSnapshot 兜底读取 policy_config.default_express_code
- 修复前只读 store.subject_config.default_express_code,导致 subject_config 为 NULL 时始终命中默认 STO
- 修复后货主 subject_config 优先,未配置时兜底读仓库 policy_config.default_express_code
- 解决广州趣电贸易等 subject_config 为空的货主无法使用仓库级 ZTO 配置的问题
- 新增 resolveExpressSnapshot 单测 14 个用例全覆盖两大分支
2026-08-01 13:56:21 +08:00
liufumingren
19c3fe09a7 refactor(weight): 重量字段统一为 INTEGER(g),取代 DECIMAL(kg)
- 8 个 model 重量字段类型 DECIMAL→INTEGER,注释 kg→g

- order_express 称重校验改为正整数(g)

- delivery_order 手动单查 StockStore + warehouse 称重毛重

- openapi.json 毛重/净重描述 kg→g

- 迁移: 20260725120000-unify-weight-fields-to-int-g

- 脚本: update-stock-warehouse-weight.cjs
2026-07-27 03:46:07 +08:00
liufumingren
16d5f18fa1 feat(openapi): interface_type_id=2 强制合约注入 + 全链路 store_id 防护
核心改动:
- openapi.js: 新增 resolveOpenapiContract 强制合约解析(required:true JOIN),
  dispatchOpenapiMethod 统一注入上下文(setInfo)
- 5个 openapiMethods: 移除重复 resolveAppInfo, 统一使用 this.getInfo()
- deliveryorder/entryorder/stockout: findByPk(itemId) 后增加 store_id 一致性校验

安全修复:
- 修复 itemId 路径跨货主越权漏洞(FindByPk 无 store_id 过滤)
- deliveryorder/inventory/singleitem 查询补全 store_id 过滤
- 合约缺失返回 403 而非穿透业务层

测试覆盖: 9方法×3层防护(合约/注入/过滤)全部通过集成测试
2026-07-15 00:10:40 +08:00
liufumingren
ca5c8a269e feat: 推单二级校验 + 快递分配异步化 + 打印 stock_id 直读
- delivery_order: 新增 auth_status=2 + warehouse_use_status=1 二级签约校验

- express: createWaybillCodePipeline 支持 awaitTasks/onBatchComplete 选项

- pendingOrder: allocateExpressCode 异步进度缓存 + cancelAllocateStorage 拣货完成前置校验

- order_print: 新增 wms_picking.stock_id→wms_stock_warehouse 直读路径,消除 order_items 强依赖
2026-07-09 03:36:15 +08:00
liufumingren
76c52fa268 use_status 重命名为 warehouse_use_status,新增 store_use_status;仓库/货主侧独立控制签约使用状态,unbind 按身份分派字段 2026-07-06 22:12:23 +08:00
liufumingren
70ad3153a1 创建订单原货主策略读取字段错误调整 2026-07-06 17:16:42 +08:00
liufumingren
7f05b26db2 1 2026-07-04 21:40:31 +08:00
liufumingren
5ef99e3bed 1 2026-07-01 14:00:59 +08:00
liufumingren
77435aeb79 1 2026-06-23 18:48:33 +08:00
liufumingren
d743e67b9d 1 2026-06-17 01:18:55 +08:00
liufumingren
0b207a1c9c 1 2026-06-10 09:14:05 +08:00
liufumingren
43c60dd934 1 2026-06-09 14:12:02 +08:00
liufumingren
c2b5ffc319 1 2026-06-07 20:42:24 +08:00
liufumingren
eb100b056d 1 2026-06-07 01:52:06 +08:00
liufumingren
99367e5043 1 2026-06-06 05:15:46 +08:00
liufumingren
9fca81e7b5 1 2026-05-19 16:33:58 +08:00
liufumingren
9c2b254206 1
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 08:44:27 +08:00
liufumingren
d711ba9c21 0506更新
Co-authored-by: Copilot <copilot@github.com>
2026-05-06 17:53:54 +08:00
liufumingren
9b2cc5fc73 fix(receiving): 修复获取收货单时重复定义属性的问题 2026-05-06 01:32:55 +08:00
liufumingren
5ce689d771 1
Co-authored-by: Copilot <copilot@github.com>
2026-04-30 19:20:31 +08:00
liufumingren
b7f980188f 1
Co-authored-by: Copilot <copilot@github.com>
2026-04-29 17:43:54 +08:00
liufumingren
0ffe290a21 chore: commit all current workspace changes 2026-04-27 16:09:26 +08:00
liufumingren
622869787a feat: sync workspace changes 2026-04-17 19:21:57 +08:00
liufumingren
e73a311076 ok 2026-04-11 17:09:06 +08:00
liufumingren
3d824a3a1d chore: sync lint and service fixes 2026-04-09 01:36:49 +08:00
63b4536766 chore: initialize wms project 2026-03-16 14:01:22 +08:00