154 lines
3.6 KiB
JavaScript
154 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
const MainService = require('../main');
|
|
|
|
class orderServer extends MainService {
|
|
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
// 初始化公共变量
|
|
this.orderType = {
|
|
JYCK: {
|
|
method: 'ORDER',
|
|
name: '一般交易出库单',
|
|
},
|
|
HHCK: {
|
|
method: 'ORDER',
|
|
name: '换货出库',
|
|
},
|
|
BFCK: {
|
|
method: 'ORDER',
|
|
name: '补发出库',
|
|
},
|
|
PTCK: {
|
|
method: 'CK',
|
|
name: '普通出库单',
|
|
},
|
|
DBCK: {
|
|
method: 'CK',
|
|
name: '调拨出库',
|
|
},
|
|
B2BCK: {
|
|
method: 'CK',
|
|
name: 'B2B出库',
|
|
},
|
|
QTCK: {
|
|
method: 'CK',
|
|
name: '其他出库',
|
|
},
|
|
CGTH: {
|
|
method: 'CK',
|
|
name: '采购退货出库单',
|
|
},
|
|
B2BRK: {
|
|
method: 'RK',
|
|
name: 'B2B入库',
|
|
},
|
|
SCRK: {
|
|
method: 'RK',
|
|
name: '生产入库',
|
|
},
|
|
LYRK: {
|
|
method: 'RK',
|
|
name: '领用入库',
|
|
},
|
|
CCRK: {
|
|
method: 'RK',
|
|
name: '残次品入库',
|
|
},
|
|
CGRK: {
|
|
method: 'RK',
|
|
name: '采购入库',
|
|
},
|
|
DBRK: {
|
|
method: 'RK',
|
|
name: '调拨入库',
|
|
},
|
|
QTRK: {
|
|
method: 'RK',
|
|
name: '其他入库',
|
|
},
|
|
XTRK: {
|
|
method: 'BACKORDER',
|
|
name: '销退入库',
|
|
},
|
|
THRK: {
|
|
method: 'BACKORDER',
|
|
name: '退货入库',
|
|
},
|
|
HHRK: {
|
|
method: 'BACKORDER',
|
|
name: '换货入库',
|
|
},
|
|
CNJG: {
|
|
method: 'JG',
|
|
name: '仓内加工单',
|
|
},
|
|
};
|
|
}
|
|
|
|
async cancel(data) {
|
|
const { ctx } = this;
|
|
const info = this.getInfo();
|
|
const orderType = this.orderType[data.request.orderType];
|
|
switch (orderType.method) {
|
|
case 'ORDER':
|
|
return this.success('取消订单成功');
|
|
break;
|
|
case 'RK' :
|
|
console.log(data, info);
|
|
const existingOrder = await ctx.model.EntryOrder.findOne({
|
|
where: {
|
|
entry_order_code: data.request.orderCode,
|
|
warehouse_id: info.warehouseId,
|
|
store_id: info.storeId,
|
|
},
|
|
});
|
|
if (existingOrder) {
|
|
await existingOrder.update({
|
|
order_status: 'CANCELLED',
|
|
updated_at: new Date(),
|
|
});
|
|
return this.success('取消入库单成功');
|
|
}
|
|
return this.fail('未找到对应的入库单');
|
|
break;
|
|
case 'CK' :
|
|
return this.fail('取消出库单未开发完成');
|
|
break;
|
|
case 'JG' :
|
|
return this.fail('取消加工单未开发完成');
|
|
break;
|
|
case 'BACKORDER':
|
|
return this.fail('取消退货单未开发完成');
|
|
break;
|
|
default:
|
|
return this.fail(`未识别的作业类型${orderType.method}`, {});
|
|
}
|
|
}
|
|
async pending(data) {
|
|
console.log(data);
|
|
const orderType = this.orderType[data.request.orderType];
|
|
switch (orderType.method) {
|
|
case 'ORDER':
|
|
return this.fail('锁定订单未开发完成');
|
|
break;
|
|
case 'RK' :
|
|
return this.fail('锁定入库单未开发完成');
|
|
break;
|
|
case 'CK' :
|
|
return this.fail('锁定出库单未开发完成');
|
|
break;
|
|
case 'JG' :
|
|
return this.fail('锁定加工单未开发完成');
|
|
break;
|
|
case 'BACKORDER':
|
|
return this.fail('锁定退货单未开发完成');
|
|
break;
|
|
default:
|
|
return this.fail(`未识别的作业类型${orderType.method}`, {});
|
|
}
|
|
}
|
|
}
|
|
module.exports = orderServer;
|