refactor: 移除 order.print.getWavePrintData 接口(已被 getWavePlatformPrintData 替代)
This commit is contained in:
parent
02596feb3d
commit
59bd112893
@ -11,49 +11,12 @@ class OrderPrintService extends OrderBaseService {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
const _noNeedLogin = '';
|
||||
const _noNeedRight = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
const _noNeedLog = 'getWavePrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
const _noNeedAuth = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
const _noNeedRight = 'getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
const _noNeedLog = 'unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
const _noNeedAuth = 'getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData,getPrintDataByWaybillCodes';
|
||||
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取波次打印数据。
|
||||
*
|
||||
* method 层仅负责参数解构与边界校验,具体业务查询由 systems 层实现。
|
||||
* 返回结果中的 ext 会同时包含 missing_wave_ids 与 filtered_wave_ids。
|
||||
*
|
||||
* @param {Object} data 请求体。
|
||||
* @param {Array<number|string>} data.wave_ids 波次ID数组。
|
||||
* @param {number|string} data.warehouse_id 仓库ID。
|
||||
* @return {Promise<Object>} 统一 success 包装的打印数据结果。
|
||||
*/
|
||||
async getWavePrintData(data = {}) {
|
||||
const requestData = this.isPlainObject(data) ? data : {};
|
||||
const {
|
||||
wave_ids: waveIds,
|
||||
warehouse_id: warehouseId,
|
||||
} = requestData;
|
||||
|
||||
if (!Array.isArray(waveIds) || waveIds.length === 0) {
|
||||
throw new Error('wave_ids 必填,且必须为非空数组');
|
||||
}
|
||||
|
||||
if (warehouseId === undefined || warehouseId === null || String(warehouseId).trim() === '') {
|
||||
throw new Error('warehouse_id 必填');
|
||||
}
|
||||
|
||||
const result = await this.service.systems.orderPrint.getWavePrintData({
|
||||
waveIds,
|
||||
warehouseId,
|
||||
});
|
||||
|
||||
return this.success('ok', {
|
||||
data: result,
|
||||
code: 200,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取波次平台打印中间态数据。
|
||||
*
|
||||
|
||||
@ -456,50 +456,6 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取波次打印数据。
|
||||
*
|
||||
* @param {Object} params 请求参数。
|
||||
* @param {Array<number|string>} params.waveIds 波次ID数组。
|
||||
* @param {number|string} params.warehouseId 仓库ID。
|
||||
* @return {Promise<Object>} 通用打印数据结构。
|
||||
*/
|
||||
async getWavePrintData(params = {}) {
|
||||
const requestParams = this.isPlainObject(params) ? params : {};
|
||||
const {
|
||||
waveIds,
|
||||
warehouseId,
|
||||
} = requestParams;
|
||||
|
||||
const normalizedWaveIds = this.normalizeWaveIds(waveIds);
|
||||
if (normalizedWaveIds.length === 0) {
|
||||
throw new Error('wave_ids 必填,且必须为非空数组');
|
||||
}
|
||||
|
||||
const normalizedWarehouseId = this.resolveWarehouseId(warehouseId);
|
||||
const waveRows = await this.queryWavesByIds(normalizedWarehouseId, normalizedWaveIds);
|
||||
if (waveRows.length === 0) {
|
||||
return this.buildEmptyResult(normalizedWaveIds);
|
||||
}
|
||||
|
||||
const hitWaveIdSet = new Set(waveRows.map(row => Number(row.wave_id)));
|
||||
const missingWaveIds = normalizedWaveIds.filter(waveId => !hitWaveIdSet.has(waveId));
|
||||
const hitWaveIds = normalizedWaveIds.filter(waveId => hitWaveIdSet.has(waveId));
|
||||
const orderRows = await this.queryOrdersByWaveIds(hitWaveIds, normalizedWarehouseId);
|
||||
const {
|
||||
validWaveIds,
|
||||
filteredWaveIds,
|
||||
} = this.filterFullyAssignedExpressWaves(hitWaveIds, orderRows);
|
||||
|
||||
return this.buildWavePrintResult({
|
||||
waveRows,
|
||||
orderRows,
|
||||
hitWaveIds: validWaveIds,
|
||||
missingWaveIds,
|
||||
filteredWaveIds,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取波次平台打印数据中间态。
|
||||
*
|
||||
@ -3324,138 +3280,6 @@ ${waveFilterSql}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成空结果结构。
|
||||
*
|
||||
* @param {Array<number>} normalizedWaveIds 规范化后的波次ID数组。
|
||||
* @return {Object} 空结果。
|
||||
*/
|
||||
buildEmptyResult(normalizedWaveIds = []) {
|
||||
return {
|
||||
summary: {
|
||||
total_waves: 0,
|
||||
total_orders: 0,
|
||||
},
|
||||
wave_list: [],
|
||||
ext: {
|
||||
missing_wave_ids: normalizedWaveIds,
|
||||
filtered_wave_ids: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装通用波次打印返回结构。
|
||||
*
|
||||
* @param {Object} payload 聚合输入。
|
||||
* @param {Array<Object>} payload.waveRows 波次列表。
|
||||
* @param {Array<Object>} payload.orderRows 订单列表。
|
||||
* @param {Array<number>} payload.hitWaveIds 命中的波次ID数组。
|
||||
* @param {Array<number>} payload.missingWaveIds 未命中的波次ID数组。
|
||||
* @param {Array<Object>} payload.filteredWaveIds 被过滤的波次及原因。
|
||||
* @return {Object} 波次打印返回结果。
|
||||
*/
|
||||
buildWavePrintResult(payload = {}) {
|
||||
const {
|
||||
waveRows = [],
|
||||
orderRows = [],
|
||||
hitWaveIds = [],
|
||||
missingWaveIds = [],
|
||||
filteredWaveIds = [],
|
||||
} = this.isPlainObject(payload) ? payload : {};
|
||||
|
||||
const waveMetaMap = new Map();
|
||||
for (const row of waveRows) {
|
||||
const waveId = Number(row && row.wave_id || 0);
|
||||
if (!Number.isInteger(waveId) || waveId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
waveMetaMap.set(waveId, {
|
||||
wave_id: waveId,
|
||||
wave_no: String(row && row.wave_no || '').trim(),
|
||||
});
|
||||
}
|
||||
|
||||
const groupedWaveMap = new Map();
|
||||
for (const waveId of hitWaveIds) {
|
||||
const waveMeta = waveMetaMap.get(waveId);
|
||||
if (!waveMeta) {
|
||||
continue;
|
||||
}
|
||||
|
||||
groupedWaveMap.set(waveId, {
|
||||
wave_id: waveMeta.wave_id,
|
||||
wave_no: waveMeta.wave_no,
|
||||
order_count: 0,
|
||||
orders: [],
|
||||
});
|
||||
}
|
||||
|
||||
for (const order of orderRows) {
|
||||
const waveId = Number(order && order.wave_id || 0);
|
||||
const groupedWave = groupedWaveMap.get(waveId);
|
||||
if (!groupedWave) {
|
||||
continue;
|
||||
}
|
||||
|
||||
groupedWave.orders.push({
|
||||
order_id: Number(order && order.id || 0),
|
||||
order_no: String(order && (order.delivery_order_code || order.source_order_codes) || '').trim(),
|
||||
wave_id: waveId,
|
||||
wave_no: String(order && order.wave_no || '').trim() || groupedWave.wave_no,
|
||||
receiver: {
|
||||
name: String(order && order.name || '').trim(),
|
||||
mobile: String(order && order.mobile || '').trim(),
|
||||
tel: String(order && order.tel || '').trim(),
|
||||
province: String(order && order.province || '').trim(),
|
||||
city: String(order && order.city || '').trim(),
|
||||
area: String(order && order.area || '').trim(),
|
||||
town: String(order && order.town || '').trim(),
|
||||
detail_address: String(order && order.detail_address || '').trim(),
|
||||
},
|
||||
channel: {
|
||||
sys_platform_code: String(order && order.sys_platform_code || '').trim(),
|
||||
sys_platform_name: String(order && order.sys_platform_name || '').trim(),
|
||||
logistics_name: String(order && order.logistics_name || '').trim(),
|
||||
},
|
||||
status: {
|
||||
order_status: String(order && order.status || '').trim(),
|
||||
outbound_status: String(order && order.outbound_status || '').trim(),
|
||||
print_status: String(order && order.print_status || '').trim(),
|
||||
},
|
||||
metrics: {
|
||||
items_count: Number(order && order.items_count || 0),
|
||||
items_total: Number(order && order.items_total || 0),
|
||||
items_weight: Number(order && order.items_weight || 0),
|
||||
},
|
||||
times: {
|
||||
create_at: order && order.create_at || null,
|
||||
pay_time: order && order.pay_time || null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const waveList = Array.from(groupedWaveMap.values());
|
||||
waveList.sort((a, b) => String(a.wave_no || '').localeCompare(String(b.wave_no || '')));
|
||||
let totalOrders = 0;
|
||||
for (const wave of waveList) {
|
||||
wave.order_count = wave.orders.length;
|
||||
totalOrders += wave.order_count;
|
||||
}
|
||||
|
||||
return {
|
||||
summary: {
|
||||
total_waves: waveList.length,
|
||||
total_orders: totalOrders,
|
||||
},
|
||||
wave_list: waveList,
|
||||
ext: {
|
||||
missing_wave_ids: missingWaveIds,
|
||||
filtered_wave_ids: filteredWaveIds,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OrderPrintSystemService;
|
||||
|
||||
@ -970,18 +970,6 @@
|
||||
],
|
||||
"type": "modified"
|
||||
},
|
||||
{
|
||||
"version": "2026.05.04-system-03",
|
||||
"date": "2026-05-04",
|
||||
"summary": "新增订单打印模块:按波次IDs获取打印数据并自动过滤未完全分配波次",
|
||||
"methods": [
|
||||
"order.print.getWavePrintData"
|
||||
],
|
||||
"notes": [
|
||||
"按波次IDs获取订单打印数据,内部去重并规范化 wave_ids,自动过滤快递未完全分配的波次;返回通过过滤的波次订单明细,按 wave_no 排序分组,并在 ext 中返回 missing_wave_ids 与 filtered_wave_ids。"
|
||||
],
|
||||
"type": "added"
|
||||
},
|
||||
{
|
||||
"version": "2026.05.04-system-02",
|
||||
"date": "2026-05-04",
|
||||
|
||||
@ -11055,251 +11055,6 @@
|
||||
"groupName": "打印模块",
|
||||
"module": "order.print",
|
||||
"list": [
|
||||
{
|
||||
"method": "order.print.getWavePrintData",
|
||||
"description": "按波次 IDs 获取订单打印数据,自动过滤快递未完全分配的波次,返回通过过滤的波次订单明细,按波次号分组",
|
||||
"isNeedAuth": false,
|
||||
"isNeedLogin": true,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"description": "Bearer token"
|
||||
}
|
||||
],
|
||||
"params": [
|
||||
{
|
||||
"name": "warehouse_id",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"source": "body",
|
||||
"description": "仓库ID"
|
||||
},
|
||||
{
|
||||
"name": "wave_ids",
|
||||
"type": "array",
|
||||
"required": true,
|
||||
"source": "body",
|
||||
"description": "波次ID列表(支持数字或字符串,内部自动去重与归一化)"
|
||||
}
|
||||
],
|
||||
"response": [
|
||||
{
|
||||
"name": "summary",
|
||||
"type": "object",
|
||||
"description": "汇总信息",
|
||||
"children": [
|
||||
{
|
||||
"name": "total_waves",
|
||||
"type": "number",
|
||||
"description": "通过过滤的波次总数"
|
||||
},
|
||||
{
|
||||
"name": "total_orders",
|
||||
"type": "number",
|
||||
"description": "通过过滤的波次下订单总数"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wave_list",
|
||||
"type": "array",
|
||||
"description": "波次列表(按 wave_no 排序)",
|
||||
"children": [
|
||||
{
|
||||
"name": "wave_id",
|
||||
"type": "number",
|
||||
"description": "波次ID"
|
||||
},
|
||||
{
|
||||
"name": "wave_no",
|
||||
"type": "string",
|
||||
"description": "波次号"
|
||||
},
|
||||
{
|
||||
"name": "order_count",
|
||||
"type": "number",
|
||||
"description": "该波次订单数"
|
||||
},
|
||||
{
|
||||
"name": "orders",
|
||||
"type": "array",
|
||||
"description": "订单明细列表(含 order_id、order_no、收件信息等字段)",
|
||||
"children": [
|
||||
{
|
||||
"name": "order_id",
|
||||
"type": "number",
|
||||
"description": "订单ID"
|
||||
},
|
||||
{
|
||||
"name": "order_no",
|
||||
"type": "string",
|
||||
"description": "订单号(delivery_order_code 或 source_order_codes)"
|
||||
},
|
||||
{
|
||||
"name": "receiver",
|
||||
"type": "object",
|
||||
"description": "收件信息",
|
||||
"children": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"description": "收件人姓名"
|
||||
},
|
||||
{
|
||||
"name": "mobile",
|
||||
"type": "string",
|
||||
"description": "手机号"
|
||||
},
|
||||
{
|
||||
"name": "tel",
|
||||
"type": "string",
|
||||
"description": "电话"
|
||||
},
|
||||
{
|
||||
"name": "province",
|
||||
"type": "string",
|
||||
"description": "省"
|
||||
},
|
||||
{
|
||||
"name": "city",
|
||||
"type": "string",
|
||||
"description": "市"
|
||||
},
|
||||
{
|
||||
"name": "area",
|
||||
"type": "string",
|
||||
"description": "区/县"
|
||||
},
|
||||
{
|
||||
"name": "town",
|
||||
"type": "string",
|
||||
"description": "镇/街道"
|
||||
},
|
||||
{
|
||||
"name": "detail_address",
|
||||
"type": "string",
|
||||
"description": "详细地址"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"type": "object",
|
||||
"description": "渠道信息",
|
||||
"children": [
|
||||
{
|
||||
"name": "sys_platform_code",
|
||||
"type": "string",
|
||||
"description": "平台编码"
|
||||
},
|
||||
{
|
||||
"name": "sys_platform_name",
|
||||
"type": "string",
|
||||
"description": "平台名称"
|
||||
},
|
||||
{
|
||||
"name": "logistics_name",
|
||||
"type": "string",
|
||||
"description": "快递名称"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"type": "object",
|
||||
"description": "订单状态简要",
|
||||
"children": [
|
||||
{
|
||||
"name": "order_status",
|
||||
"type": "string",
|
||||
"description": "订单状态"
|
||||
},
|
||||
{
|
||||
"name": "outbound_status",
|
||||
"type": "string",
|
||||
"description": "出库状态"
|
||||
},
|
||||
{
|
||||
"name": "print_status",
|
||||
"type": "string",
|
||||
"description": "打印状态"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "metrics",
|
||||
"type": "object",
|
||||
"description": "数量度量",
|
||||
"children": [
|
||||
{
|
||||
"name": "items_count",
|
||||
"type": "number",
|
||||
"description": "商品种类数"
|
||||
},
|
||||
{
|
||||
"name": "items_total",
|
||||
"type": "number",
|
||||
"description": "商品总件数"
|
||||
},
|
||||
{
|
||||
"name": "items_weight",
|
||||
"type": "number",
|
||||
"description": "重量(单位 g)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "times",
|
||||
"type": "object",
|
||||
"description": "时间字段",
|
||||
"children": [
|
||||
{
|
||||
"name": "create_at",
|
||||
"type": "string",
|
||||
"description": "创建时间"
|
||||
},
|
||||
{
|
||||
"name": "pay_time",
|
||||
"type": "string",
|
||||
"description": "支付时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ext",
|
||||
"type": "object",
|
||||
"description": "扩展字段",
|
||||
"children": [
|
||||
{
|
||||
"name": "missing_wave_ids",
|
||||
"type": "array",
|
||||
"description": "传入但不存在的 wave_id 列表"
|
||||
},
|
||||
{
|
||||
"name": "filtered_wave_ids",
|
||||
"type": "array",
|
||||
"description": "被过滤掉的波次(快递未完全分配),每项含 wave_id、wave_no、reason"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
{
|
||||
"code": "400",
|
||||
"description": "warehouse_id 或 wave_ids 缺失或格式错误"
|
||||
},
|
||||
{
|
||||
"code": "500",
|
||||
"description": "查询失败"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "order.print.getWavePlatformPrintData",
|
||||
"description": "按波次 IDs 获取平台打印中间态数据,自动过滤快递未完全分配的波次,返回 waveGroups(波次 -> 平台 -> 订单)结构",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user