59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const OrderBaseService = require('./base');
|
|
|
|
class OrderPrintService extends OrderBaseService {
|
|
/**
|
|
* 初始化订单打印模块的免登录、免权限、免日志和免鉴权配置。
|
|
*
|
|
* @param {Egg.Context} ctx 请求上下文。
|
|
*/
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
const _noNeedLogin = '';
|
|
const _noNeedRight = 'getWavePrintData';
|
|
const _noNeedLog = 'getWavePrintData';
|
|
const _noNeedAuth = 'getWavePrintData';
|
|
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,
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = OrderPrintService;
|