chore(order): 配送表 dispath_time 链路文档同步与回归测试收尾

- methods/system.json:order.manualOutboundOrder 描述补充 dispath_time 迁移时间说明,errors 键规范化为 message,版本升至 0.3.95(含 store.openAccount 移除 logo_url/domain 入参的同步)

- methods/changes/system.json:新增 order-delivery-dispatch-dispath-time 与 store-openAccount-remove-logo-url-domain 两条变更记录

- test:order_delivery_migration.test.js 超时重试路径 dispath_time 断言与 buildDispatchRow 专项用例;return_received.dispatch_trigger.test.js 退货间接触发用例
This commit is contained in:
liufumingren 2026-09-07 17:49:49 +08:00
parent efadcba56e
commit 6a1abbe00c
4 changed files with 210 additions and 19 deletions

View File

@ -1,4 +1,41 @@
[
{
"version": "2026.09.07-store-openAccount-remove-logo-url-domain",
"date": "2026-09-07",
"type": "changed",
"summary": "storeWarehouse.store.openAccount 入参移除 logo_url、domain 两个可选参数:wms_store 表的 logo_url、domain 字段已废弃(代码写入链路已移除、数据库已执行删列迁移 20260907140000-drop-logo-url-and-domain-from-wms-store),文档同步删除这两个可选 body 入参对象;字段无业务承载,前端若仍传参会被忽略,不破坏响应结构。",
"methods": [
"storeWarehouse.store.openAccount"
],
"notes": [
"database/migrations/20260907140000-drop-logo-url-and-domain-from-wms-store.js:删除 wms_store 表的 logo_url、domain 两列(开发库已执行完成)",
"代码写入链路(openAccount 创建货主)已由开发 agent 移除 logo_url、domain 写入,app/ 下无 logo_url 残留引用",
"methods/system.json:storeWarehouse.store.openAccount 的 params 删除 logo_url(name logo_url、type string、required false、source body、description Logo 链接)与 domain(name domain、type string、required false、source body、description 绑定域名)两个可选 body 入参对象;其余 17 个入参、response(store_id/account_id/contract_id/company_name/username/role_id)与 errors 均不变;版本 0.3.94 -> 0.3.95(docMeta.version),updatedAt 保持 2026-09-07",
"影响说明:字段已无业务承载,前端若仍传参会被忽略;响应结构不变,无错误码、鉴权方式、公共请求头变化",
"methods/ 全目录检索确认:logo_url、Logo 链接、绑定域名 仅存在于 methods/system.json 本方法参数块,无其他文件或方法残留引用",
"本次仅同步文档,未修改任何代码、迁移脚本或数据库"
],
"module": "storeWarehouse.store"
},
{
"version": "2026.09.07-order-delivery-dispatch-dispath-time",
"date": "2026-09-07",
"type": "changed",
"summary": "配送表 wms_order_delivery_{wh}_dispatch 新增 dispath_time 字段(DATETIME 可空无默认值,comment 订单迁移进配送表的时间),用于记录订单从待处理表迁移进配送表的时刻:模型 dispatch 分支新增字段定义,出库迁移 buildDispatchRow 写入 new Date(),迁移脚本覆盖全部配送分表;仅配送表独有(基表/current/history/outsourced 不涉及),无接口入参/响应结构变化。",
"methods": [
"order.manualOutboundOrder"
],
"notes": [
"database/migrations/20260907120000-add-dispath-time-to-order-delivery-dispatch.js:为库内全部配送分表 wms_order_delivery_{wh}_dispatch 增加 dispath_time 列(DATETIME 可空无默认值,comment 订单迁移进配送表的时间),仅配送表独有、不加基表/current/history/outsourced 分表;describeTable 幂等检测,列已存在则跳过;开发、生产均已执行。",
"app/model/order_delivery_table_schema.js buildTableAttributes:dispatch 分支新增 dispath_time 字段定义(Sequelize DATE / allowNull=true / comment 订单迁移进配送表的时间),与既有 dispatch_lane 并列,仅 dispatch 分表生效。",
"app/service/systems/order_delivery_migration.js buildDispatchRow:写入配送表行时追加 dispath_time = new Date()(订单迁移进配送表的时刻),源表数据不受影响;保留先删除源行 dispatch_lane、再统一写 DISPATCH_LANE 的既有逻辑。",
"methods/system.json:order.manualOutboundOrder description 补充「迁移写入配送表的订单行记录 dispath_time(buildDispatchRow 写入 new Date(),仅配送表独有)」说明;errors 由 description 键规范化为 message 键(文案不变,满足更新脚本 schema);版本 0.3.93 -> 0.3.94(docMeta.version),updatedAt 更新为 2026-09-07。",
"无接口入参/响应结构/错误码/鉴权变化;配送表整行 raw 响应(order.pendingOrder.detail 订单头、order.list 列表行等)文档均为 raw 行引用而非全量字段清单,按既有口径不硬加字段说明,仅在本变更记录体现。",
"AI_METHOD_ROUTING.md(函数清单,无配送表字段清单章节)与 AI_TOOLBOX.md(无配送表字段相关内容)均无需同步;README.md 与 docs/*.md 亦无配送表字段清单章节。",
"发布版本 v1.0.0-20260907164410-c5150bc(2026-09-07 发布);本次仅同步文档,未修改任何代码、迁移脚本或数据库。"
],
"module": "order.index"
},
{
"version": "2026.09.06-workbench-resetLoginCode-reset-token",
"date": "2026-09-06",

View File

@ -1,8 +1,8 @@
{
"module": "system",
"description": "系统接口标准入口,method 对应系统内置方法,全部使用 POST 请求,参数统一放在 body 内",
"version": "0.3.93",
"updatedAt": "2026-09-06",
"version": "0.3.95",
"updatedAt": "2026-09-07",
"headers": [
{
"name": "platform",
@ -2128,7 +2128,7 @@
},
{
"method": "order.manualOutboundOrder",
"description": "手动触发出库迁移,将当前仓库内已出库订单同步到配送表。请求体直接透传给 orderDeliveryMigration.syncOutboundOrdersToDelivery。",
"description": "手动触发出库迁移,将当前仓库内已出库订单同步到配送表。请求体直接透传给 orderDeliveryMigration.syncOutboundOrdersToDelivery。迁移写入配送表(wms_order_delivery_{仓库}_dispatch)的订单行会记录 dispath_time(订单迁移进配送表的时间,由 orderDeliveryMigration.buildDispatchRow 写入 new Date(),仅配送表独有)。",
"isNeedAuth": false,
"isNeedLogin": true,
"headers": [
@ -2222,11 +2222,11 @@
"errors": [
{
"code": "400",
"description": "仓库ID为空或请求参数格式错误"
"message": "仓库ID为空或请求参数格式错误"
},
{
"code": "500",
"description": "迁移失败或数据库错误"
"message": "迁移失败或数据库错误"
}
]
},
@ -27807,20 +27807,6 @@
"source": "body",
"description": "所属行业"
},
{
"name": "logo_url",
"type": "string",
"required": false,
"source": "body",
"description": "Logo 链接"
},
{
"name": "domain",
"type": "string",
"required": false,
"source": "body",
"description": "绑定域名"
},
{
"name": "auth_start",
"type": "string",

View File

@ -722,5 +722,32 @@ describe('test/app/service/systems/order_delivery_migration.test.js', () => {
assert.equal(sourceItemModel.rows.length, 1);
assert.equal(targetItemModel.rows.length, 1);
assert.equal(targetItemModel.rows[0].order_id, targetOrderModel.rows[0].id);
assert.ok(
capture.bulkCreateRows[0].rows[0].dispath_time instanceof Date,
'超时重试路径写入配送表的订单行同样应记录 dispath_time 迁移时间'
);
assert.equal(capture.bulkCreateRows[0].rows[0].dispatch_lane, 'm4');
});
it('should stamp dispath_time and force dispatch_lane when building dispatch rows', () => {
const { service } = createHarness({});
const sourceRow = {
id: 7,
warehouse_id: 100000,
store_id: 1000000,
delivery_order_code: 'OD-00007',
step: 4,
outbound_status: 'fin',
dispatch_lane: 'legacy-lane',
};
const built = service.buildDispatchRow(sourceRow);
assert.equal(built.id, 7);
assert.equal(built.delivery_order_code, 'OD-00007');
assert.equal(built.dispatch_lane, 'm4');
assert.ok(built.dispath_time instanceof Date, 'buildDispatchRow 应写入 dispath_time 迁移时间');
assert.ok(!Number.isNaN(built.dispath_time.getTime()), 'dispath_time 应为有效时间');
assert.equal(sourceRow.dispatch_lane, 'legacy-lane', '不应修改入参行');
});
});

View File

@ -0,0 +1,141 @@
'use strict';
const assert = require('node:assert/strict');
const Sequelize = require('sequelize');
const ReturnReceivedService = require('../../../../app/service/systems/return_received');
/**
* 构造退货间接触发迁移链路的最小测试上下文。
*
* 仅桩住 OrderDeliveryFactory 与操作日志服务:
* - current/dispatch 模型桩记录 findOne/update 的真实调用参数;
* - 其余依赖(Sequelize、logger)与真实运行一致。
*
* @param {Object} [options] 测试数据。
* @param {Object|null} [options.currentRow] current 表(待处理)订单行,null 表示不存在。
* @param {Object|null} [options.dispatchRow] dispatch 表(配送)订单行,null 表示不存在。
* @return {Object} ctx 与调用捕获。
*/
function createCtx(options = {}) {
const calls = {
findOneOrder: [],
updateValues: [],
updateWhere: [],
createOperationLogParams: [],
};
const buildModel = modelId => {
const model = {
modelId,
async findOne(query = {}) {
calls.findOneOrder.push({
modelId,
where: query.where,
attributes: query.attributes,
});
return options[`${modelId}Row`] !== undefined ? options[`${modelId}Row`] : null;
},
async update(values, query = {}) {
calls.updateValues.push({
modelId,
values: {
...(values || {}),
},
});
calls.updateWhere.push({
modelId,
where: query.where || {},
});
return [ 1 ];
},
};
return model;
};
const ctx = {
app: {
Sequelize,
},
logger: {
info() {},
warn() {},
error() {},
debug() {},
},
model: {
OrderDeliveryFactory: {
async getCurrentModel() {
return buildModel('current');
},
async getDispatchModel() {
return buildModel('dispatch');
},
},
},
service: {
systems: {
operationLog: {
async createOperationLog(params) {
calls.createOperationLogParams.push(params);
return { id: 1 };
},
},
},
},
};
return { ctx, calls };
}
describe('test/app/service/systems/return_received.dispatch_trigger.test.js', () => {
it('should set step=4 and outbound_status=fin on current orders to trigger scheduled migration into dispatch table', async () => {
const { ctx, calls } = createCtx({
currentRow: {
id: 100,
delivery_order_code: 'OD-100',
intercept_status: 'none',
},
});
const service = new ReturnReceivedService(ctx);
await service._updateOrderInterceptStatus(100, 100000, 90001, '测试员');
const orderUpdate = calls.updateValues.find(item => item.modelId === 'current');
assert.ok(orderUpdate, 'current 表订单应执行更新');
assert.equal(orderUpdate.values.step, 4, '待处理表应置 step=4 触发定时迁移');
assert.equal(orderUpdate.values.outbound_status, 'fin', '待处理表应置 outbound_status=fin 触发定时迁移');
assert.equal(orderUpdate.values.intercept_status, 'returned');
assert.ok(orderUpdate.values.intercept_time instanceof Date, '应写入拦截时间');
assert.deepEqual(
calls.updateWhere.find(item => item.modelId === 'current').where,
{ id: 100, warehouse_id: 100000 }
);
assert.equal(calls.findOneOrder.filter(item => item.modelId === 'dispatch').length, 0, 'current 表命中后不应再查 dispatch 表');
assert.equal(calls.createOperationLogParams.length, 1);
assert.equal(calls.createOperationLogParams[0].operationCode, 'ORDER_RETURN_RECEIVED');
});
it('should only update intercept_status on dispatch orders without touching step/outbound_status', async () => {
const { ctx, calls } = createCtx({
currentRow: null,
dispatchRow: {
id: 101,
delivery_order_code: 'OD-101',
intercept_status: 'none',
},
});
const service = new ReturnReceivedService(ctx);
await service._updateOrderInterceptStatus(101, 100000, 90001, '测试员');
const orderUpdate = calls.updateValues.find(item => item.modelId === 'dispatch');
assert.ok(orderUpdate, 'dispatch 表订单应执行更新');
assert.equal(orderUpdate.values.intercept_status, 'returned');
assert.equal('step' in orderUpdate.values, false, '配送表不应改 step');
assert.equal('outbound_status' in orderUpdate.values, false, '配送表不应改 outbound_status');
assert.ok(orderUpdate.values.intercept_time instanceof Date, '应写入拦截时间');
assert.equal(calls.createOperationLogParams.length, 1);
});
});