liufumingren 81350c0d6b fix: 定时任务同步日志 + 基础设施修复 + 权限迁移(收尾)
【定时任务】sync_outbound_orders_to_delivery: 执行日志写缓存 + 错误详情提取(parent/validation)

【基础设施】system.js: snake_case→camelCase 服务路由转换(兼容 express_interface 等)

【看板】dashboard: queryWarehouseStats 支持 storeId 货主维度过滤

【订单基类】order/base: getOrderModel 兼容无上下文时传入 warehouseId(货主侧场景)

【库存】inventory: 全量移库软删除→硬删除(force destroy)释放唯一键 + 唯一约束/校验错误友好提示

【快递平台】express_platform: KS(快手)平台 receiver.phone 不传(平台要求)

【迁移】delivery 自增起点 + supervisor CS 权限修复
2026-07-27 03:49:27 +08:00

184 lines
6.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const OrderBaseService = require('./base');
class OrderPrintService extends OrderBaseService {
/**
* 初始化订单打印模块的免登录、免权限、免日志和免鉴权配置。
*
* @param {Egg.Context} ctx 请求上下文。
*/
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
const _noNeedLog = 'getWavePrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
const _noNeedAuth = 'getWavePrintData,getWavePlatformPrintData,unlockWavePlatformPrintDataByGroup,getOrderPrintData';
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,
});
}
/**
* 获取波次平台打印中间态数据。
*
* method 层仅负责参数解构与边界校验,具体业务查询与打印数据组装由 systems 层实现。
*
* @param {Object} data 请求体。
* @param {Array<number|string>} data.wave_ids 波次ID数组。
* @param {number|string} data.warehouse_id 仓库ID。
* @return {Promise<Object>} 统一 success 包装的平台打印中间态结果。
*/
async getWavePlatformPrintData(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.getWavePlatformPrintData({
waveIds,
warehouseId,
});
return this.success('ok', {
data: result,
code: 200,
});
}
/**
* 按订单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,
});
}
/**
* 按分组解锁波次平台打印锁。
*
* method 层仅负责参数解构与边界校验,具体解锁逻辑由 systems 层实现。
*
* @param {Object} data 请求体。
* @param {Array<number|string>} data.wave_ids 波次ID数组。
* @param {number|string} data.warehouse_id 仓库ID。
* @param {string} [data.group_type='platform_express'] 分组类型,支持 platform、platform_express、order。
* @param {string} [data.unlock_scope='group'] 解锁范围,支持 group、wave。
* @param {Array<Object>} data.groups 分组条件列表。
* @return {Promise<Object>} 统一 success 包装的解锁结果。
*/
async unlockWavePlatformPrintDataByGroup(data = {}) {
const requestData = this.isPlainObject(data) ? data : {};
const {
wave_ids: waveIds,
warehouse_id: warehouseId,
group_type: groupType = 'platform_express',
unlock_scope: unlockScope = 'group',
groups,
} = 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 normalizedGroupType = String(groupType || '').trim();
if (![ 'platform', 'platform_express', 'order' ].includes(normalizedGroupType)) {
throw new Error('group_type 仅支持 platform、platform_express、order');
}
const normalizedUnlockScope = String(unlockScope || '').trim();
if (![ 'group', 'wave' ].includes(normalizedUnlockScope)) {
throw new Error('unlock_scope 仅支持 group、wave');
}
if (!Array.isArray(groups) || groups.length === 0) {
throw new Error('groups 必填,且必须为非空数组');
}
const result = await this.service.systems.orderPrint.unlockWavePlatformPrintDataByGroup({
waveIds,
warehouseId,
groupType: normalizedGroupType,
unlockScope: normalizedUnlockScope,
groups,
});
return this.success('ok', {
data: result,
code: 200,
});
}
}
module.exports = OrderPrintService;