This commit is contained in:
liufumingren 2026-06-08 08:58:13 +08:00
parent c2b5ffc319
commit 0e50ff6671
12 changed files with 6012 additions and 216 deletions

View File

@ -66,6 +66,10 @@ module.exports = {
ORDER_STORAGE_UNALLOCATE_FAILED: '取消分配储位失败',
ORDER_EXPRESS_ALLOCATE_SUBMITTED: '分配快递任务已提交',
ORDER_EXPRESS_ALLOCATE_FAILED: '分配快递失败',
ORDER_INTERCEPT_REQUEST: '请求订单拦截',
ORDER_INTERCEPT_CANCEL: '解除订单拦截',
ORDER_LOCK: '订单锁定',
ORDER_UNLOCK: '订单解锁',
// 库存管理
STOCK_IN: '商品入库',

View File

@ -6,7 +6,7 @@ module.exports = app => {
// 状态机枚举定义
const StatusEnum = {
STATUS: [ 'pedding', 'created', 'cancel', 'error' ],
STATUS: [ 'pedding', 'created', 'cancel', 'error', 'finished' ],
SYNC_STATUS: [ 'padding', 'fin', 'error' ],
POST_STATUS: [ 'padding', 'fin', 'timeout', 'error', 'none' ],
STORAGE_STATUS: [ 'padding', 'fin', 'error', 'none' ],

View File

@ -107,10 +107,6 @@ const MODULE_CONFIGS = Object.freeze({
operator: 'eq',
value: 0,
},
wave_scan_result: {
operator: 'eq',
value: 2,
},
},
},
outboundOrder: {

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,9 @@ class OrderPrintService extends OrderBaseService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup';
const _noNeedLog = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup';
const _noNeedAuth = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup';
const _noNeedRight = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
const _noNeedLog = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
const _noNeedAuth = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
@ -90,6 +90,36 @@ class OrderPrintService extends OrderBaseService {
});
}
/**
* 按订单ID拉取平台打印中间态数据。
*
* method 层仅负责参数解构与边界校验,具体业务查询与打印数据组装由 systems 层实现。
* 仓库ID统一从当前上下文获取,无需调用方传入。
*
* @param {Object} data 请求体。
* @param {Array<number|string>} data.order_ids 订单ID数组。
* @return {Promise<Object>} 统一 success 包装的平台打印中间态结果。
*/
async getOrderPrintData(data = {}) {
const requestData = this.isPlainObject(data) ? data : {};
const {
order_ids: orderIds,
} = requestData;
if (!Array.isArray(orderIds) || orderIds.length === 0) {
throw new Error('order_ids 必填,且必须为非空数组');
}
const result = await this.service.systems.orderPrint.getOrderPrintData({
orderIds,
});
return this.success('ok', {
data: result,
code: 200,
});
}
/**
* 按分组解锁波次平台打印锁。
*

File diff suppressed because it is too large Load Diff

View File

@ -836,6 +836,8 @@ class WaveService extends OrderBaseService {
step: { [Op.in]: [ 1, 2, 3 ] },
status: { [Op.ne]: 'cancel' },
outbound_status: { [Op.ne]: 'padding' },
intercept_status: 'none',
lock_status: 'none',
wave_id: 0,
};
@ -2133,6 +2135,8 @@ class WaveService extends OrderBaseService {
step: { [Op.in]: [ 1, 2, 3 ] },
status: { [Op.ne]: 'cancel' },
outbound_status: { [Op.ne]: 'padding' },
intercept_status: 'none',
lock_status: 'none',
wave_id: 0,
};
@ -2363,6 +2367,8 @@ class WaveService extends OrderBaseService {
step: { [Op.in]: [ 1, 2, 3 ] },
status: { [Op.ne]: 'cancel' },
outbound_status: { [Op.ne]: 'padding' },
intercept_status: 'none',
lock_status: 'none',
wave_id: 0,
};
@ -2741,7 +2747,8 @@ class WaveService extends OrderBaseService {
o.status,
o.outbound_status,
o.post_status,
o.storage_status
o.storage_status,
o.print_status
FROM wms_order_wave_strategy_match m
INNER JOIN ${orderTableName} o
ON o.id = m.order_id
@ -2750,8 +2757,11 @@ class WaveService extends OrderBaseService {
AND o.step != 0
AND o.post_status = 'fin'
AND o.storage_status = 'fin'
AND o.print_status != 'fin'
AND o.status != 'cancel'
AND o.outbound_status != 'padding'
AND o.intercept_status = 'none'
AND o.lock_status = 'none'
WHERE m.warehouse_id = :warehouseId
AND m.strategy_id = :strategyId
ORDER BY o.id ASC
@ -2967,8 +2977,11 @@ class WaveService extends OrderBaseService {
AND o.step != 0
AND o.post_status = 'fin'
AND o.storage_status = 'fin'
AND o.print_status != 'fin'
AND o.status != 'cancel'
AND o.outbound_status != 'padding'
AND o.intercept_status = 'none'
AND o.lock_status = 'none'
INNER JOIN (
SELECT
COALESCE(NULLIF(TRIM(COALESCE(src.items_hash, '')), ''), TRIM(COALESCE(src.items, ''))) AS structure_key,
@ -2979,8 +2992,11 @@ class WaveService extends OrderBaseService {
AND src.step != 0
AND src.post_status = 'fin'
AND src.storage_status = 'fin'
AND src.print_status != 'fin'
AND src.status != 'cancel'
AND src.outbound_status != 'padding'
AND src.intercept_status = 'none'
AND src.lock_status = 'none'
GROUP BY COALESCE(NULLIF(TRIM(COALESCE(src.items_hash, '')), ''), TRIM(COALESCE(src.items, '')))
) same_structure
ON same_structure.structure_key = COALESCE(NULLIF(TRIM(COALESCE(o.items_hash, '')), ''), TRIM(COALESCE(o.items, '')))
@ -3915,35 +3931,94 @@ class WaveService extends OrderBaseService {
province: normalizedOrderRow.province ?? null,
sys_platform_name: normalizedOrderRow.sys_platform_name ?? null,
item_snapshot: String(itemSnapshot || ''),
excluded_reason: normalizedOrderRow.lock_status !== 'none'
? 'locked'
: normalizedOrderRow.intercept_status !== 'none'
? 'intercepted'
: normalizedOrderRow.print_status === 'fin'
? 'printed'
: 'no_match',
};
}
/**
* 查询兜底不符合波次策略的订单列表。
* 查询兜底不符合波次策略的订单列表(含已完全打印被排除的订单)。
*
* 直接复用订单通用列表能力,返回标准 list/pagination 结构。
* 查询条件:step != 0 且 wave_id = 0,且满足以下任一条件:
* - wave_scan_result = 2(未匹配任何波次策略)
* - print_status = 'fin'(已完全打印,被策略抓取阶段排除)
* 在当前页订单上增补 item_snapshot(格式:商品名称1*数量|商品名称2*数量)。
*
* @param {Object} data 请求参数。
* @param {Object} data.pagination 分页参数。
* @param {Object} data.where 查询条件。
* @param {Object} data.sort 排序参数。
* @return {Promise<Object>} 列表查询结果。
* @return {Promise<Object>} 列表查询结果,每行含 excluded_reason 标记。
*/
async waveStrategyFallbackOrderList(data = {}) {
const requestData = this.isPlainObject(data) ? data : {};
const { pagination, where, sort } = requestData;
const normalizedPagination = this.normalizePagination(pagination || {});
const { page, pageSize } = normalizedPagination;
const normalizedWhere = this.normalizeWaveStrategyFallbackOrderListWhere(where);
const listResult = await this.listByModule('waveStrategyFallbackOrder', {
...requestData,
pagination: normalizedPagination,
where: normalizedWhere,
sort,
const contextWarehouseId = this.getWarehouseId();
// 构建基础 WHERE(复用框架 where 解析、快递号虚拟筛选等能力)
const { where: ctxWhere } = this.prepareWhereContext(
{ ...requestData, where: normalizedWhere },
{ specialFieldMap: { quickWhere: { bucket: 'quick' } } }
);
const { where: sanitizedWhere, expressNumbers } = this.extractOrderListExpressVirtualFilter(ctxWhere);
const defaultWhere = this.getDefaultWhere('waveStrategyFallbackOrder');
const mergedWhere = this.mergeWhereObjects(defaultWhere, sanitizedWhere);
let queryWhere = this.buildWhere(mergedWhere, contextWarehouseId, {
specialFieldMap: { quickWhere: { bucket: 'quick' } },
});
const normalizedResult = this.isPlainObject(listResult) ? listResult : {};
const sourceList = Array.isArray(normalizedResult.list) ? normalizedResult.list : [];
const orderIds = sourceList
// 处理快递号虚拟筛选
if (expressNumbers.length > 0) {
const orderIds = await this.findOrderIdsByExpressNumbers(expressNumbers, contextWarehouseId);
queryWhere = this.appendOrderIdsFilterToWhere(queryWhere, orderIds);
}
// 追加 OR 条件:未匹配策略(wave_scan_result=2) 或 已完全打印被排除(print_status='fin')
const { Sequelize } = this.app;
queryWhere = {
[Sequelize.Op.and]: [
queryWhere,
{
[Sequelize.Op.or]: [
{ wave_scan_result: 2 },
{ print_status: 'fin' },
{ lock_status: { [Sequelize.Op.ne]: 'none' } },
{ intercept_status: { [Sequelize.Op.ne]: 'none' } },
],
},
],
};
// 获取模型并分页查询
const model = await this.getOrderModel('waveStrategyFallbackOrder', contextWarehouseId);
const order = this.buildListOrder(sort, 'waveStrategyFallbackOrder');
const offset = (page - 1) * pageSize;
const [ total, sourceList ] = await Promise.all([
model.count({ where: queryWhere }),
model.findAll({
where: queryWhere,
limit: pageSize,
offset,
order,
raw: true,
}),
]);
const normalizedList = await this.attachOrderExpressNumbers(
sourceList.map(item => this.normalizeOrderListItem(item))
);
// 回填 item_snapshot
const orderIds = normalizedList
.map(item => Number(item && item.id || 0))
.filter(id => Number.isInteger(id) && id > 0);
const warehouseId = Number(this.getWarehouseId() || 0);
@ -3992,14 +4067,23 @@ class WaveService extends OrderBaseService {
}
}
const list = sourceList.map(item => {
const totalPages = pageSize > 0 ? Math.ceil(total / pageSize) : 0;
const list = normalizedList.map(item => {
const orderId = Number(item && item.id || 0);
return this.buildWaveStrategyFallbackOrderListItem(item, itemSnapshotMap.get(orderId) || '');
});
return this.success('ok', {
...normalizedResult,
list,
pagination: {
page,
pageSize,
total,
totalPages,
hasPrevious: page > 1,
hasNext: page < totalPages,
},
});
}
@ -5149,6 +5233,9 @@ class WaveService extends OrderBaseService {
warehouse_id: warehouseId,
step: { [Op.ne]: 0 },
wave_id: 0,
intercept_status: 'none',
lock_status: 'none',
print_status: { [Op.ne]: 'fin' },
[Op.or]: [
{ wave_strategy_version: { [Op.ne]: strategyVersion } },
{ wave_strategy_version: { [Op.is]: null } },
@ -9643,8 +9730,11 @@ class WaveService extends OrderBaseService {
AND o.step != 0
AND o.post_status = 'fin'
AND o.storage_status = 'fin'
AND o.print_status != 'fin'
AND o.status != 'cancel'
AND o.outbound_status != 'padding'
AND o.intercept_status = 'none'
AND o.lock_status = 'none'
INNER JOIN (
SELECT
${structureExpr('src')} AS structure_key${requireSameExpress ? `, ${expressExpr('src')} AS express_key` : ''},
@ -9655,8 +9745,11 @@ class WaveService extends OrderBaseService {
AND src.step != 0
AND src.post_status = 'fin'
AND src.storage_status = 'fin'
AND src.print_status != 'fin'
AND src.status != 'cancel'
AND src.outbound_status != 'padding'
AND src.intercept_status = 'none'
AND src.lock_status = 'none'
GROUP BY ${structureExpr('src')}${groupKeyExtra}
) same_structure
ON same_structure.structure_key = ${structureExpr('o')}${joinKeyExtra}

View File

@ -1,4 +1,4 @@
'use strict';
'use strict';
const fs = require('node:fs');
const path = require('node:path');
@ -621,6 +621,176 @@ class OrderPrintSystemService extends OrderBaseService {
};
}
/**
* 按订单ID拉取平台打印中间态数据。
*
* 与 getWavePlatformPrintData 输出完全相同的结构,但入参由波次ID改为订单ID。
* 跳过了波次查询步骤,直接从订单ID入手,其余打印数据组装、锁定/未锁定分离、
* 波次平台分组等逻辑与 getWavePlatformPrintData 保持一致。
* 仓库ID统一从当前上下文获取,不再接受调用方传入。
*
* @param {Object} params 请求参数。
* @param {Array<number|string>} params.orderIds 订单ID数组。
* @return {Promise<Object>} 平台打印中间态结果。
*/
async getOrderPrintData(params = {}) {
const requestParams = this.isPlainObject(params) ? params : {};
const {
orderIds,
} = requestParams;
const normalizedOrderIds = this.normalizeOrderIds(orderIds);
if (normalizedOrderIds.length === 0) {
throw new Error('order_ids 必填,且必须为非空数组');
}
const normalizedWarehouseId = this.getContextWarehouseId();
const orderRows = await this.queryOrdersByIds(normalizedOrderIds, normalizedWarehouseId);
if (orderRows.length === 0) {
return {
summary: {
total_waves: 0,
total_orders: 0,
total_platforms: 0,
},
waveGroups: [],
wave_ids: [],
ext: {
missing_order_ids: normalizedOrderIds,
filtered_order_ids: [],
},
};
}
const hitOrderIdSet = new Set(orderRows.map(row => Number(row.id)));
const missingOrderIds = normalizedOrderIds.filter(orderId => !hitOrderIdSet.has(orderId));
// 订单级过滤:仅保留 post_status === 'fin' 的订单(等价于波次级的快递完全分配检查)
const validOrderRows = orderRows.filter(row => String(row && row.post_status || '').trim() === 'fin');
const filteredOrderIds = orderRows
.filter(row => String(row && row.post_status || '').trim() !== 'fin')
.map(row => ({
order_id: Number(row && row.id || 0),
reason: '快递未完全分配',
}));
if (validOrderRows.length === 0) {
return {
summary: {
total_waves: 0,
total_orders: 0,
total_platforms: 0,
},
waveGroups: [],
wave_ids: [],
ext: {
missing_order_ids: missingOrderIds,
filtered_order_ids: filteredOrderIds,
},
};
}
const validOrderWaveIds = Array.from(new Set(validOrderRows
.map(row => Number(row && row.wave_id || 0))
.filter(waveId => Number.isInteger(waveId) && waveId > 0)));
const waveRows = await this.queryWavesByIds(normalizedWarehouseId, validOrderWaveIds);
const orderIdsForExpress = validOrderRows
.map(row => Number(row && row.id || 0))
.filter(orderId => Number.isInteger(orderId) && orderId > 0);
const orderExpressRows = await this.queryOrderExpressByOrderIds(orderIdsForExpress);
this.assertBusinessWaybillCompleteness(orderIdsForExpress, orderExpressRows);
const cainiaoEnrichedOrderExpressRows = await this.enrichCainiaoOrderExpressRows(
validOrderRows,
orderExpressRows,
normalizedWarehouseId
);
const jdEnrichedOrderExpressRows = await this.enrichJdOrderExpressRows(
validOrderRows,
cainiaoEnrichedOrderExpressRows,
normalizedWarehouseId
);
const enrichedOrderExpressRows = await this.enrichPddDyOrderExpressRows(
validOrderRows,
jdEnrichedOrderExpressRows,
normalizedWarehouseId
);
const orderExpressMap = this.buildOrderExpressMap(enrichedOrderExpressRows);
const policyConfigMap = await this.getPolicyConfigMapByStore(validOrderRows, normalizedWarehouseId);
const pickingCandidateRows = validOrderRows.filter(orderRow => {
const storeId = Number(orderRow && orderRow.store_id || 0);
const policyConfig = policyConfigMap.get(storeId) || {};
return this.shouldLoadPickingDetails(policyConfig);
});
const printOrderRowMap = await this.buildPrintOrderRowMapWithPicking(pickingCandidateRows, normalizedWarehouseId);
const waveOrderIndexMap = await this.queryWaveOrderIndexMapByOrderIds(
orderIdsForExpress,
normalizedWarehouseId,
validOrderWaveIds
);
const waveIdsForCount = validOrderWaveIds;
const waveTotalOrderCountMap = await this.queryWaveTotalOrderCountMap(waveIdsForCount, normalizedWarehouseId);
const templateSampleCache = new Map();
const orderPrintList = [];
for (const orderRow of validOrderRows) {
const orderId = Number(orderRow && orderRow.id || 0);
if (!Number.isInteger(orderId) || orderId <= 0) {
continue;
}
const orderExpress = orderExpressMap.get(orderId) || {};
const effectiveOrderRow = printOrderRowMap.get(orderId) || orderRow;
const waveOrderIndexInfo = waveOrderIndexMap.get(orderId) || {};
const waveIdForCount = Number(effectiveOrderRow.wave_id || orderRow.wave_id || waveOrderIndexInfo.wave_id || 0);
const waveTotalOrders = Number(waveTotalOrderCountMap.get(waveIdForCount) || 0);
const waveIndex = Number(waveOrderIndexInfo.wave_index || 0);
const platformsIndex = Number(waveOrderIndexInfo.platforms_index || 0);
const effectiveOrderRowWithWaveIndex = {
...effectiveOrderRow,
wave_total_orders: waveTotalOrders > 0 ? waveTotalOrders : 0,
wave_index: waveIndex > 0 ? waveIndex : 0,
platforms_index: platformsIndex > 0 ? platformsIndex : 0,
};
const storeId = Number(orderRow && orderRow.store_id || 0);
const policyConfig = policyConfigMap.get(storeId) || {};
const platformCode = this.resolvePrintPlatformCode(effectiveOrderRow, orderExpress);
const templateSample = this.loadTemplateSampleByPlatform(platformCode, templateSampleCache);
orderPrintList.push(this.buildOrderPlatformPrintItem({
orderRow: effectiveOrderRowWithWaveIndex,
orderExpress,
policyConfig,
platformCode,
templateSample,
}));
}
const waveGroups = this.groupOrderPrintItemsByWaveAndPlatform({
waveRows,
hitWaveIds: validOrderWaveIds,
orderPrintList,
});
const totalPlatforms = waveGroups.reduce((sum, waveGroup) => {
return sum + Number(waveGroup && waveGroup.platforms && waveGroup.platforms.length || 0);
}, 0);
return {
summary: {
total_waves: waveGroups.length,
total_orders: orderPrintList.length,
total_platforms: totalPlatforms,
},
waveGroups,
wave_ids: validOrderWaveIds,
ext: {
missing_order_ids: missingOrderIds,
filtered_order_ids: filteredOrderIds,
},
};
}
/**
* 规范化“按分组解锁”规则。
*
@ -988,6 +1158,46 @@ class OrderPrintSystemService extends OrderBaseService {
return Array.from(normalizedSet);
}
/**
* 规范化订单ID数组。
*
* 去重、过滤非法值(非正整数),返回纯数字数组。
*
* @param {Array<number|string>} orderIds 订单ID数组。
* @return {Array<number>} 规范化后的订单ID数组。
*/
normalizeOrderIds(orderIds = []) {
if (!Array.isArray(orderIds)) {
return [];
}
const normalizedSet = new Set();
for (const rawId of orderIds) {
const normalizedId = Number(String(rawId ?? '').trim());
if (Number.isInteger(normalizedId) && normalizedId > 0) {
normalizedSet.add(normalizedId);
}
}
return Array.from(normalizedSet);
}
/**
* 从当前上下文获取仓库ID。
*
* 用于不再接受调用方传入 warehouseId 的场景,直接从登录态/上下文读取。
*
* @return {number} 当前上下文中的仓库ID。
*/
getContextWarehouseId() {
const contextWarehouseId = Number(this.getWarehouseId() || 0);
if (!Number.isInteger(contextWarehouseId) || contextWarehouseId <= 0) {
throw new Error('缺少当前用户仓库上下文 store_id');
}
return contextWarehouseId;
}
/**
* 解析并校验仓库ID。
*
@ -1107,6 +1317,72 @@ class OrderPrintSystemService extends OrderBaseService {
return Array.isArray(rows) ? rows : [];
}
/**
* 按订单ID批量查询订单明细。
*
* 与 queryOrdersByWaveIds 返回相同的字段结构,但按订单 ID 列表直接查询。
*
* @param {Array<number>} orderIds 订单ID数组。
* @param {number} warehouseId 仓库ID。
* @return {Promise<Array<Object>>} 订单明细列表。
*/
async queryOrdersByIds(orderIds = [], warehouseId) {
if (!Array.isArray(orderIds) || orderIds.length === 0) {
return [];
}
const orderModel = await this.getOrderModel('order', warehouseId);
const rows = await orderModel.findAll({
attributes: [
'id',
'delivery_order_code',
'source_order_codes',
'warehouse_id',
'store_id',
'wave_id',
'wave_no',
'name',
'tel',
'mobile',
'province',
'city',
'area',
'town',
'detail_address',
'zip_code',
'items',
'source_platform_code',
'sys_platform_code',
'sys_platform_name',
'logistics_code',
'logistics_name',
'sys_logistics_code',
'sys_logistics_name',
'post_status',
'status',
'outbound_status',
'print_status',
'lock_status',
'print_lock_status',
'items_count',
'items_total',
'items_weight',
'freight',
'create_at',
'pay_time',
],
where: {
id: {
[Op.in]: orderIds,
},
},
order: [[ 'wave_id', 'ASC' ], [ 'id', 'ASC' ]],
raw: true,
});
return Array.isArray(rows) ? rows : [];
}
/**
* 按订单ID批量查询快递单信息。
*

View File

@ -2988,5 +2988,160 @@
],
"type": "updated",
"module": "order.wave"
},
{
"version": "2026.06.08-system-01",
"date": "2026-06-08",
"summary": "order.recheckOrder 模块 scanOrder 返回值重构为统一 list 输出,新增 confirmIntercept 与 recheckOrderList 接口",
"methods": [
"order.recheckOrder.scanOrder",
"order.recheckOrder.confirmIntercept",
"order.recheckOrder.recheckOrderList"
],
"notes": [
"scanOrder 返回值重构:统一使用 list 字段输出,新增 list_type 字段区分散单/团购模式。散单模式顶层新增 picker_id、picker_name、wave_id、wave_no、wave_type、pick_mode、strategy_id、strategy_name、total_orders、reviewed_count、unreviewed_count 等汇总字段。list 中每项新增 waybill_no、is_printed、is_reviewed、wave_index、intercept_status、store_remark、stock[](含 stock_id、item_code、item_name、sku_property、packing_requirements、barcodes[]、images[]、plan_qty、has_shared_barcode)。移除旧字段 logs、order、order_id(顶层)、waybill_no(顶层旧位置)、wave_match_view、items、expresses、cart_match_view。",
"scanOrder 入参新增 wave_no / waveNo 支持波次号直接扫描匹配。",
"新增 order.recheckOrder.confirmIntercept:确认拦截接口,将订单 intercept_status 更新为 intercepted_at_warehouse,返回 order_id、order_no、intercept_status、updated_at。",
"新增 order.recheckOrder.recheckOrderList:复核订单列表查询,支持 list_type=single(散单)与 list_type=group(团购),均返回统一 list + pagination 结构。"
],
"type": "updated"
},
{
"version": "2026.06.08-system-02",
"date": "2026-06-08",
"summary": "order.recheckOrder 模块新增 batchIntercept/batchInterceptTaskProgress,更新 scanOrder 团购模式响应结构,完善 confirmIntercept/recheckOrderList 文档",
"methods": [
"order.recheckOrder.batchIntercept",
"order.recheckOrder.batchInterceptTaskProgress",
"order.recheckOrder.scanOrder",
"order.recheckOrder.confirmIntercept",
"order.recheckOrder.recheckOrderList"
],
"notes": [
"新增 order.recheckOrder.batchIntercept:批量提交订单拦截(异步任务模式),入参支持 order_ids/orderIds/ids(订单ID数组,不再使用 wave_ids),将 intercept_status 设为 'requested',返回 task_id/warehouse_id/message/accepted_at。支持幂等提交与 warehouse_id 校验。",
"新增 order.recheckOrder.batchInterceptTaskProgress:按 task_id 查询批量拦截任务进度,返回 state(submitted/running/success/failed/not_found)及对应的进度/计数/结果/错误字段。",
"更新 order.recheckOrder.scanOrder 响应文档:团购模式(cart 命中)list 项新增 wave_id/wave_no/wave_type/wave_status/total_orders/processed_orders/creator/create_time/update_time/order_count/pick_mode/box_no/orders[] 等波次级别字段;补充散单无波次信息时的回退详情模式说明(detail/items/expresses/logs)。",
"完善 order.recheckOrder.confirmIntercept:补充操作日志写入说明(ORDER_INTERCEPT_CONFIRM)及失败不影响主流程的容错描述。",
"完善 order.recheckOrder.recheckOrderList:补充散单模式默认排除 pick_status='none' 和 recheck_status='fin' 的说明;团购模式 where 支持 wave_no(模糊搜索)的说明。"
],
"type": "updated"
},
{
"version": "2026.06.08-system-03",
"date": "2026-06-08",
"summary": "移除 order.recheckOrder.batchIntercept 的 warehouse_id/warehouseId 入参,仓库ID统一使用当前上下文",
"methods": [
"order.recheckOrder.batchIntercept"
],
"notes": [
"移除入参 warehouse_id / warehouseId:仓库ID统一从当前上下文(ctx.user.store_id)获取,不再由调用方传入。",
"移除对应错误码:warehouse_id 参数不合法(400)、warehouse_id 与当前仓库上下文不一致(400)。",
"description 中补充说明仓库ID来源为当前上下文。",
"response 中 warehouse_id 字段描述改为「取自当前上下文」。"
],
"type": "updated"
},
{
"version": "2026.06.08-system-10",
"date": "2026-06-08",
"summary": "batchIntercept / batchInterceptTaskProgress 从 order.recheckOrder 迁移至 order.pendingOrder",
"methods": [
"order.pendingOrder.batchIntercept",
"order.pendingOrder.batchInterceptTaskProgress"
],
"notes": [
"method 从 order.recheckOrder.batchIntercept 重命名为 order.pendingOrder.batchIntercept,分组从订单复核模块迁移至订单待处理模块",
"method 从 order.recheckOrder.batchInterceptTaskProgress 重命名为 order.pendingOrder.batchInterceptTaskProgress,分组从订单复核模块迁移至订单待处理模块",
"接口入参、响应、错误码均保持不变,仅变更 method 名称与所属分组"
],
"type": "updated"
},
{
"version": "2026.06.08-system-04",
"date": "2026-06-08",
"summary": "新增 order.print.getOrderPrintData:按订单ID拉取打印数据,返回结构与 getWavePlatformPrintData 一致,不限制锁定状态",
"methods": [
"order.print.getOrderPrintData"
],
"notes": [
"新增 order.print.getOrderPrintData 接口文档,入参为 warehouse_id + order_ids(非空数组),返回与 getWavePlatformPrintData 结构一致的 waveGroups / summary / wave_ids / ext",
"与 getWavePlatformPrintData 的区别:入参为 order_ids(非 wave_ids),ext 中返回 missing_order_ids / filtered_order_ids(非 missing_wave_ids / filtered_wave_ids)",
"不限制打印锁定状态,所有订单(无论是否被锁定)统一返回打印数据",
"自动过滤 post_status !== 'fin' 的订单(快递未完全分配),被过滤订单出现在 ext.filtered_order_ids"
],
"type": "added",
"module": "order.print"
},
{
"version": "2026.06.08-system-11",
"date": "2026-06-08",
"summary": "新增 order.pendingOrder 批量锁定/解锁/解除拦截及对应进度查询共 6 个异步任务接口文档",
"methods": [
"order.pendingOrder.batchLock",
"order.pendingOrder.batchLockTaskProgress",
"order.pendingOrder.batchUnlock",
"order.pendingOrder.batchUnlockTaskProgress",
"order.pendingOrder.batchUnintercept",
"order.pendingOrder.batchUninterceptTaskProgress"
],
"notes": [
"新增 batchLock:批量锁定订单,lock_status → 'warehouse',操作日志 ORDER_LOCK,task_id 格式 order_lock_{warehouseId}_{timestamp}_{rand}。",
"新增 batchLockTaskProgress:查询批量锁定进度,返回 locked_order_count / locked_order_ids 等。",
"新增 batchUnlock:批量解锁订单,lock_status → 'none',操作日志 ORDER_UNLOCK,task_id 格式 order_unlock_{warehouseId}_{timestamp}_{rand}。",
"新增 batchUnlockTaskProgress:查询批量解锁进度,返回 unlocked_order_count / unlocked_order_ids 等。",
"新增 batchUnintercept:批量解除拦截订单,intercept_status → 'none',操作日志 ORDER_INTERCEPT_CANCEL,task_id 格式 order_unintercept_{warehouseId}_{timestamp}_{rand}。",
"新增 batchUninterceptTaskProgress:查询批量解除拦截进度,返回 unintercepted_order_count / unintercepted_order_ids 等。",
"以上 6 个接口均采用与已有 batchIntercept/batchInterceptTaskProgress 一致的异步任务模式:提交返回 task_id,进度查询返回 state + 进度字段。",
"仅同步文档,不修改业务代码或实现。"
],
"type": "added",
"module": "order"
},
{
"version": "2026.06.08-system-12",
"date": "2026-06-08",
"summary": "更新 order.print.getOrderPrintData:移除锁定限制,所有订单统一返回打印数据,不再区分锁定/未锁定",
"methods": [
"order.print.getOrderPrintData"
],
"notes": [
"移除打印锁定限制:所有订单(包括已锁定)统一返回打印数据,不再区分锁定/未锁定状态",
"移除 locked_count、locked_orders、locked_wave_groups 等锁定相关字段",
"返回结构与 getWavePlatformPrintData 完全一致:summary / waveGroups / wave_ids / ext",
"ext 中使用 missing_order_ids / filtered_order_ids(替代锁定相关字段),与代码实现完全对齐"
],
"type": "updated",
"module": "order.print"
},
{
"version": "2026.06.08-system-13",
"date": "2026-06-08",
"summary": "更新 order.print.getOrderPrintData:移除 warehouse_id 入参,仓库ID统一从当前上下文获取",
"methods": [
"order.print.getOrderPrintData"
],
"notes": [
"移除 warehouse_id / warehouseId 入参,仓库ID统一从 this.getContextWarehouseId() 获取",
"同步移除 errors 中 warehouse_id 必填 相关错误码",
"description 补充说明仓库ID从上下文获取,无需调用方传入",
"params 仅保留 order_ids(非空数组),与代码 method 层 getOrderPrintData(data) 解构一致"
],
"type": "updated",
"module": "order.print"
},
{
"version": "2026.06.08-system-14",
"date": "2026-06-08",
"summary": "新增 order.recheckOrder.scanTask 接口文档,并为 scanOrder 响应补充 task_id 字段",
"methods": [
"order.recheckOrder.scanTask",
"order.recheckOrder.scanOrder"
],
"notes": [
"新增 order.recheckOrder.scanTask:按拣货任务 ID 拉取复核数据,数据结构与 scanOrder 完全一致,用于前端刷新。入参为 task_id(必填,number),返回 match_type='task',散单模式(pick_mode 2/3/4)返回扁平订单列表,团购模式(pick_mode 1/5)返回分组波次列表。",
"更新 order.recheckOrder.scanOrder 响应定义:补充 task_id 字段说明(散单有波次时由 buildSingleWaveScanView 返回,团单车号命中时由 cartMatchContext 返回)。",
"仅同步文档,不修改任何业务代码或实现。"
],
"type": "updated"
}
]

File diff suppressed because it is too large Load Diff

View File

@ -435,9 +435,11 @@ describe('test/app/service/systemMethods/order.base.step.test.js', () => {
assert.equal(captures[0].countWhere.warehouse_id, 100000);
assert.equal(captures[0].countWhere.step[Sequelize.Op.ne], 0);
assert.equal(captures[0].countWhere.wave_id, 0);
assert.equal(captures[0].countWhere.wave_scan_result, 2);
assert.deepEqual(result.list.map(item => item.id), [ 1 ]);
assert.equal(result.pagination.total, 1);
// defaultWhere 已移除 wave_scan_result,OR 条件由 waveStrategyFallbackOrderList 方法层追加
assert.equal(Object.prototype.hasOwnProperty.call(captures[0].countWhere, 'wave_scan_result'), false);
// id=1 (step=1,wave_id=0) 和 id=4 (step=1,wave_id=0) 都符合 step!=0,wave_id=0
assert.deepEqual(result.list.map(item => item.id).sort(), [ 1, 4 ]);
assert.equal(result.pagination.total, 2);
});
it('should attach express numbers and normalize sys names in all order lists', async () => {

View File

@ -1,23 +1,27 @@
'use strict';
const assert = require('node:assert/strict');
const { Op } = require('sequelize');
const WaveService = require('../../../../../app/service/systemMethods/order/wave');
/**
* 构建 waveStrategyFallbackOrderList 的测试上下文。
*
* @return {{ service: WaveService, captures: { moduleName: string|null, data: Object|null } }} 测试对象。
* @return {{ service: WaveService, captures: { whereInput: Object|null, modelOpts: Object|null } }} 测试对象。
*/
function createHarness() {
const captures = {
moduleName: null,
data: null,
whereInput: null,
modelOpts: null,
};
const ctx = {
app: {
config: {},
Sequelize: {
Op,
},
},
user: {
store_id: 100000,
@ -29,11 +33,24 @@ function createHarness() {
const service = new WaveService(ctx);
service.getWarehouseId = () => 1;
service.listByModule = async (moduleName, data) => {
captures.moduleName = moduleName;
captures.data = data;
return {
list: [
// 模拟 normalizeOrderListItem / attachOrderExpressNumbers 为直通
service.normalizeOrderListItem = (item) => item;
service.attachOrderExpressNumbers = async (list) => list;
// 捕获 buildWhere 入参,返回简单条件
const originalBuildWhere = service.buildWhere.bind(service);
service.buildWhere = (whereInput, warehouseId, options) => {
captures.whereInput = whereInput;
return { warehouse_id: warehouseId, wave_id: 0 };
};
// 模拟 getOrderModel 返回可控数据
service.getOrderModel = async () => ({
count: async () => 1,
findAll: async (opts) => {
captures.modelOpts = opts;
return [
{
id: 101,
delivery_order_code: 'FH20260507001',
@ -48,15 +65,9 @@ function createHarness() {
wave_scan_result: 2,
tel: '13800000000',
},
],
pagination: {
page: 1,
pageSize: 20,
total: 1,
totalPages: 1,
},
};
};
];
},
});
return {
service,
@ -91,7 +102,6 @@ describe('test/app/service/systemMethods/order/wave.waveStrategyFallbackOrderLis
const result = await service.waveStrategyFallbackOrderList(requestData);
assert.equal(captures.moduleName, 'waveStrategyFallbackOrder');
assert.equal(result.flag, 'success');
assert.equal(result.message, 'ok');
assert.deepEqual(result.list, [
@ -106,33 +116,16 @@ describe('test/app/service/systemMethods/order/wave.waveStrategyFallbackOrderLis
province: '浙江省',
sys_platform_name: '抖音',
item_snapshot: '',
excluded_reason: 'no_match',
},
]);
assert.deepEqual(result.pagination, {
page: 1,
pageSize: 20,
total: 1,
totalPages: 1,
});
assert.deepEqual(captures.data.where, {
id: 1001,
delivery_order_code: 'FH2026',
express_numbers: 'YT2026',
items_count: 2,
items_total: 5,
logistics_name: '圆通',
shop_nick: '货主A',
province: '浙江',
sys_platform_name: '抖音',
});
assert.deepEqual(captures.data.pagination, {
page: 2,
pageSize: 10,
});
assert.deepEqual(captures.data.sort, {
sortField: 'updated_at',
sortOrder: 'DESC',
total: 1,
totalPages: 1,
hasPrevious: true,
hasNext: false,
});
});
@ -187,6 +180,7 @@ describe('test/app/service/systemMethods/order/wave.waveStrategyFallbackOrderLis
assert.equal(result.list[0].item_snapshot, '商品A*3|商品B*3');
assert.deepEqual(Object.keys(result.list[0]).sort(), [
'delivery_no',
'excluded_reason',
'id',
'item_snapshot',
'items_count',
@ -233,8 +227,5 @@ describe('test/app/service/systemMethods/order/wave.waveStrategyFallbackOrderLis
});
assert.equal(result.flag, 'success');
assert.deepEqual(captures.data.where, {
shop_nick: '货主B',
});
});
});