47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const OrderBaseService = require('./base');
|
|
|
|
/**
|
|
* 系统方法层:订单储位分配入口。
|
|
* 仅负责参数归一化与调用底层公共 service。
|
|
*/
|
|
class StorageAllocationService extends OrderBaseService {
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
const _noNeedLogin = '';
|
|
const _noNeedRight = 'allocateStorage';
|
|
const _noNeedLog = 'allocateStorage';
|
|
const _noNeedAuth = 'allocateStorage';
|
|
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
|
|
}
|
|
|
|
/**
|
|
* 批量分配订单储位。
|
|
*
|
|
* @param {Object} data 请求体。
|
|
* @return {Promise<Object>} 统一 success 包装。
|
|
*/
|
|
async allocateStorage(data = {}) {
|
|
const { service } = this;
|
|
const requestData = this.isPlainObject(data) ? data : {};
|
|
const normalizedData = {
|
|
allow_storage_location: requestData.allow_storage_location
|
|
?? requestData.allowStorageLocation
|
|
?? requestData.is_allow_storage
|
|
?? requestData.isAllowStorage,
|
|
order_ids: requestData.order_ids
|
|
?? requestData.orderIds
|
|
?? requestData.ids
|
|
?? requestData.order_id
|
|
?? requestData.orderId
|
|
?? requestData.id,
|
|
warehouse_id: requestData.warehouse_id ?? requestData.warehouseId,
|
|
};
|
|
|
|
const result = await service.systems.orderStorageAllocation.allocateStorage(normalizedData);
|
|
return this.success('ok', result);
|
|
}
|
|
}
|
|
|
|
module.exports = StorageAllocationService; |