34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const MainService = require('../main');
|
|
|
|
class singleitemServer extends MainService {
|
|
async synchronize(data) {
|
|
try {
|
|
const stockData = await this.ctx.service.systems.stockStore.initQimenStockData(data.request, this.appKey, this.storeId, this.warehouseId);
|
|
const result = await await this.ctx.service.systems.stockStore.create(stockData);
|
|
return this.success('同步完成', { itemId: result.id });
|
|
} catch (error) {
|
|
return this.fail('同步失败', { error: error.message });
|
|
}
|
|
}
|
|
async query(data) {
|
|
const { app } = this;
|
|
try {
|
|
if (!data.request.itemId) {
|
|
return this.fail('获取失败', { error: '参数错误itemId不存在' });
|
|
}
|
|
const Row = await app.model.StockStore.findByPk(data.request.itemId);
|
|
if (!Row) {
|
|
return this.fail('获取失败', { error: `wms的SKUID为${data.request.itemId}未找到` });
|
|
}
|
|
const result = await this.ctx.service.systems.stockStore.convertToQimenFormat(Row);
|
|
return this.success('获取成功', result);
|
|
} catch (error) {
|
|
console.error('获取失败:', error);
|
|
return this.fail('获取失败', { error: error.message });
|
|
}
|
|
}
|
|
}
|
|
module.exports = singleitemServer;
|