Commit a6560128 by 孙亚楠

dd

parent 70ea71d3
...@@ -52,16 +52,14 @@ class ActionAPI extends APIBase { ...@@ -52,16 +52,14 @@ class ActionAPI extends APIBase {
opResult = await this.oorderSve.orders(action_body); opResult = await this.oorderSve.orders(action_body);
break; break;
case "assignSalesman": //分配业务员(平台) case "orderDelivers": //订单管理(交付商)
opResult = await this.oorderstatusSve.handleStatus(action_body);
break;
case "assignDeliver": //分配交付商
opResult = await this.oorderSve.assignDeliver(action_body);
break;
case "orderDelivers": //订单管理(交付商)
opResult = await this.oorderdeliverSve.orderDelivers(action_body); opResult = await this.oorderdeliverSve.orderDelivers(action_body);
break; break;
case "handleStatus": //进度处理
opResult = await this.oorderstatusSve.handleStatus(action_body);
break;
case "addSourceOrder": // 创建来源订单 case "addSourceOrder": // 创建来源订单
opResult = await this.oorderSve.addSourceOrder(action_body); opResult = await this.oorderSve.addSourceOrder(action_body);
break; break;
......
...@@ -84,7 +84,7 @@ class OorderdeliverService extends ServiceBase { ...@@ -84,7 +84,7 @@ class OorderdeliverService extends ServiceBase {
} }
/** /**
* 处理订单状态数据 * 格式化订单状态数据
* @param orderList * @param orderList
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
...@@ -106,58 +106,6 @@ class OorderdeliverService extends ServiceBase { ...@@ -106,58 +106,6 @@ class OorderdeliverService extends ServiceBase {
} }
console.log(orderList); console.log(orderList);
} }
/**
* 分配业务员(交付商)
* @param {*} params
* @id String 订单ID
* @operator_id String 业务员ID
* @status String 下一个状态码
*/
async assignSalesman(params) {
if (!params.bd_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
//更新订单业务员
let _order = await this.findById(params.id);
if (!_order) {
return system.getResult(null, `订单不存在`);
}
//to do ... 验证下一个状态
await this.statusAction(params);
_order.bd_id = this.trim(params.bd_id);
_order.status = this.trim(params.status);
_order.bd_path = this.trim(params.bd_path);
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async statusAction(params) {
let _order = await this.oorderDao.findById(params.id);
if (!_order) {
return system.getResult(null, `订单不存在`);
}
//todo ... 验证状态
let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status);
let nextStatus = JSON.parse(_orderStatus.next_status);
if (params.status != nextStatus.next_status) {
return system.getResult(null, `订单状态错误,下一订单状态应该是${nextStatus.next_name}`);
}
}
} }
module.exports = OorderdeliverService; module.exports = OorderdeliverService;
\ No newline at end of file
...@@ -19,11 +19,15 @@ class OorderstatusService extends ServiceBase { ...@@ -19,11 +19,15 @@ class OorderstatusService extends ServiceBase {
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao"); this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
} }
/***************************************以下是订单处理的分发器***************************************************************** */
/** /**
* 验证订单状态 * 验证订单状态
* @param params * @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>} * @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
* @id 订单ID
* @status 订单下一个状态
* @other 其他参数
*/ */
async handleStatus(params) { async handleStatus(params) {
try { try {
...@@ -31,25 +35,28 @@ class OorderstatusService extends ServiceBase { ...@@ -31,25 +35,28 @@ class OorderstatusService extends ServiceBase {
if (!_order) { if (!_order) {
return system.getResult(null, `订单不存在`); return system.getResult(null, `订单不存在`);
} }
//todo ... 验证状态
let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status); let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status);
let nextStatus = JSON.parse(_orderStatus.next_status); let nextStatus = JSON.parse(_orderStatus.next_status);
var statuses = []; var statuses = [];
for(var ns of nextStatus) { for (var ns of nextStatus) {
statuses.push(ns.next_status); statuses.push(ns.next_status);
} }
if (statuses.indexOf(params.status) == -1) { if (statuses.indexOf(params.status) == -1) {
return system.getResult(null, `订单状态错误,下一订单状态应该是${nextStatus.next_name}`); return system.getResult(null, `订单状态错误,下一订单状态应该是${nextStatus.next_name}`);
} }
params._order = _order; params._order = _order;
//调用对应的方法 TODO SOMETHING .....
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** /**
* 获取订单状态对象 * 获取订单状态对象
* @param order_id * @param order_id
...@@ -61,27 +68,24 @@ class OorderstatusService extends ServiceBase { ...@@ -61,27 +68,24 @@ class OorderstatusService extends ServiceBase {
return map[order_id + "_" + status] || {}; return map[order_id + "_" + status] || {};
} }
/*******************************以下是订单处理进度(平台)**************************************************** */
/** /**
* 分配业务员 * 分配业务员(平台)
* @param {*} params * @param {*} params
* @id String 订单ID * @id String 订单ID
* @bd_id String 业务员ID * @bd_id String 业务员ID
* @status String 下一个状态码 * @status String 下一个状态码
* @bd_path String 业务员权限 * @bd_path String 业务员权限
*/ */
async assignSalesman(params) { async platformAassignSalesman(params) {
if (!params.bd_id) { if (!params.bd_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`); return system.getResult(null, `参数错误 业务员ID不能为空`);
} }
try { try {
//更新订单业务员 //更新订单业务员
let _order = await this.findById(params.id); let _order = params._order;
if (!_order) {
return system.getResult(null, `订单不存在`);
}
//to do ... 验证下一个状态
await this.statusAction(params);
_order.bd_id = this.trim(params.bd_id); _order.bd_id = this.trim(params.bd_id);
_order.status = this.trim(params.status); _order.status = this.trim(params.status);
_order.bd_path = this.trim(params.bd_path); _order.bd_path = this.trim(params.bd_path);
...@@ -116,7 +120,6 @@ class OorderstatusService extends ServiceBase { ...@@ -116,7 +120,6 @@ class OorderstatusService extends ServiceBase {
} }
try { try {
let _order = params._order;
let self = this; let self = this;
let res = await this.db.transaction(async t => { let res = await this.db.transaction(async t => {
//创建orderdeliver记录 //创建orderdeliver记录
...@@ -142,6 +145,44 @@ class OorderstatusService extends ServiceBase { ...@@ -142,6 +145,44 @@ class OorderstatusService extends ServiceBase {
} }
} }
/**********************************以下是交付商订单业务处理******************************************************** */
/**
* 分配业务员(交付商)
* @param {*} params
* @id String 订单ID
* @operator_id String 业务员ID
* @status String 下一个状态码
* @deliver_id String 交付商ID
*/
async deliverAssignSalesman(params) {
if (!params.operator_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
if (!params.operator_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
//更新订单交付表业务员ID
//更新订单状态
let _order = params._order;
_order.status = this.trim(params.status);
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
} }
module.exports = OorderstatusService; module.exports = OorderstatusService;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment