Commit 852a3b62 by 王昆

gsb

parent 3207e98e
...@@ -45,167 +45,165 @@ class ActionAPI extends APIBase { ...@@ -45,167 +45,165 @@ class ActionAPI extends APIBase {
var opResult = null; var opResult = null;
try{ try{
switch (action_type) {
case "orders": //订单列表
opResult = await this.oorderSve.orders(action_body);
break;
case "assignSalesman": //分配业务员
opResult = await this.oorderSve.assignSalesman(action_body);
break;
case "assignDeliver": //分配交付商
opResult = await this.oorderSve.assignDeliver(action_body);
break;
case "addSourceOrder": // 创建来源订单
opResult = await this.oorderSve.addSourceOrder(action_body);
break;
//******************************************************************** */
// 订单
case "createOrder": //创建订单
opResult = await this.iborderbaseSve.apiCreateOrder(action_body);
break;
case "completedOrder": //完善信息接口
opResult = await this.iborderbaseSve.apiCompletedOrder(action_body);
break;
case "handling": //订单办理接口
opResult = await this.iborderbaseSve.apiHandling(action_body);
break;
// case "orders": //订单列表
// opResult = await this.iborderbaseSve.apiOrders(action_body);
// break;
case "addOrder":
opResult = await this.iborderSve.apiAdd(action_body);
break;
case "updOrder":
opResult = await this.iborderSve.apiUpd(action_body);
break;
// -------------------
case "allOrderList":
opResult = await this.iborderSve.apiAllList(action_body);
break;
case "orderInfo":
opResult = await this.iborderSve.apiInfo(action_body);
break;
case "orderInfoAll":
opResult = await this.iborderSve.apiAllInfo(action_body);
break;
case "byChannelOrderId":
opResult = await this.iborderSve.apiByChannelOrderId(action_body);
break;
case "orderEdit":
opResult = await this.iborderSve.apiEdit(action_body);
break;
case "orderAssign":
opResult = await this.iborderSve.apiAssign(action_body);
break;
case "myOrderPage":
opResult = await this.iborderSve.apiMyPage(action_body);
break;
case "orderPay":
opResult = await this.iborderSve.apiOrderPay(action_body);
break;
case "orderClose":
opResult = await this.iborderSve.apiOrderClose(action_body);
break;
case "closeOrderById":
opResult = await this.iborderSve.apiCloseById(action_body);
break;
case "orderComplete":
opResult = await this.iborderSve.apiComplete(action_body);
break;
case "orderByDeliverId":
opResult = await this.iborderSve.apiByDeliverId(action_body);
break;
// 订单办理
case "orderDeliverList":
opResult = await this.iborderdeliverSve.apiPage(action_body);
break;
case "orderDeliverHandle":
opResult = await this.iborderdeliverSve.apiHandle(action_body);
break;
case "orderDeliverInfo":
opResult = await this.iborderdeliverSve.apiInfo(action_body);
break;
case "orderDeliverEdit":
opResult = await this.iborderdeliverSve.apiEdit(action_body);
break;
case "orderDeliverAudit":
opResult = await this.iborderdeliverSve.apiAudit(action_body);
break;
case "orderDeliverClose":
opResult = await this.iborderdeliverSve.apiClose(action_body);
break;
// 个体户管理
case "businessmenByOrderId":
opResult = await this.businessmenSve.apiByOrderId(action_body);
break;
case "businessmenByChannelOrderNo":
opResult = await this.businessmenSve.apiByChannelOrderNo(action_body);
break;
case "businessmenNameList":
opResult = await this.businessmenSve.apiNameList(action_body);
break;
case "businessmenPage":
opResult = await this.businessmenSve.apiPage(action_body);
break;
case "businessmenInfo":
opResult = await this.businessmenSve.apiInfo(action_body);
break;
case "businessmenSign":
opResult = await this.businessmenSve.apiSign(action_body);
break;
case "businessmenSignPage":
opResult = await this.businessmenSve.apiSignPage(action_body);
break;
case "businessmenInfoPage":
opResult = await this.businessmenSve.apiInfoPage(action_body);
break;
case "businessmenUserPage":
opResult = await this.businessmenSve.apiUserPage(action_body);
break;
case "businessmenDeliverPage":
opResult = await this.businessmenSve.apiDeliverPage(action_body);
break;
case "addBusinessmenContract":
opResult = await this.businessmenSve.apiAddContract(action_body);
break;
case "businessmenCompleteMapByCreditCodes":
opResult = await this.businessmenSve.apiCompleteMapByCreditCodes(action_body);
break;
// 统计数据
case "statTransData":
opResult = await this.iborderSve.apiStatTransData(action_body);
break;
case "statBusinessData":
opResult = await this.iborderSve.apiStatBusinessData(action_body);
break;
case "statDeliverData":
opResult = await this.iborderdeliverSve.apiStatDeliverData(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
} catch (e) { } catch (e) {
console.log(e);
} return system.getResult(null, "order服务异常");
switch (action_type) {
case "orders": //订单列表
opResult = await this.oorderSve.orders(action_body);
break;
case "assignSalesman": //分配业务员
opResult = await this.oorderSve.assignSalesman(action_body);
break;
case "assignDeliver": //分配交付商
opResult = await this.oorderSve.assignDeliver(action_body);
break;
//******************************************************************** */
// 订单
case "addSourceOrder": //创建订单
opResult = await this.oorderSve.addSourceOrder(action_body);
break;
// 订单
case "createOrder": //创建订单
opResult = await this.iborderbaseSve.apiCreateOrder(action_body);
break;
case "completedOrder": //完善信息接口
opResult = await this.iborderbaseSve.apiCompletedOrder(action_body);
break;
case "handling": //订单办理接口
opResult = await this.iborderbaseSve.apiHandling(action_body);
break;
// case "orders": //订单列表
// opResult = await this.iborderbaseSve.apiOrders(action_body);
// break;
case "addOrder":
opResult = await this.iborderSve.apiAdd(action_body);
break;
case "updOrder":
opResult = await this.iborderSve.apiUpd(action_body);
break;
// -------------------
case "allOrderList":
opResult = await this.iborderSve.apiAllList(action_body);
break;
case "orderInfo":
opResult = await this.iborderSve.apiInfo(action_body);
break;
case "orderInfoAll":
opResult = await this.iborderSve.apiAllInfo(action_body);
break;
case "byChannelOrderId":
opResult = await this.iborderSve.apiByChannelOrderId(action_body);
break;
case "orderEdit":
opResult = await this.iborderSve.apiEdit(action_body);
break;
case "orderAssign":
opResult = await this.iborderSve.apiAssign(action_body);
break;
case "myOrderPage":
opResult = await this.iborderSve.apiMyPage(action_body);
break;
case "orderPay":
opResult = await this.iborderSve.apiOrderPay(action_body);
break;
case "orderClose":
opResult = await this.iborderSve.apiOrderClose(action_body);
break;
case "closeOrderById":
opResult = await this.iborderSve.apiCloseById(action_body);
break;
case "orderComplete":
opResult = await this.iborderSve.apiComplete(action_body);
break;
case "orderByDeliverId":
opResult = await this.iborderSve.apiByDeliverId(action_body);
break;
// 订单办理
case "orderDeliverList":
opResult = await this.iborderdeliverSve.apiPage(action_body);
break;
case "orderDeliverHandle":
opResult = await this.iborderdeliverSve.apiHandle(action_body);
break;
case "orderDeliverInfo":
opResult = await this.iborderdeliverSve.apiInfo(action_body);
break;
case "orderDeliverEdit":
opResult = await this.iborderdeliverSve.apiEdit(action_body);
break;
case "orderDeliverAudit":
opResult = await this.iborderdeliverSve.apiAudit(action_body);
break;
case "orderDeliverClose":
opResult = await this.iborderdeliverSve.apiClose(action_body);
break;
// 个体户管理
case "businessmenByOrderId":
opResult = await this.businessmenSve.apiByOrderId(action_body);
break;
case "businessmenByChannelOrderNo":
opResult = await this.businessmenSve.apiByChannelOrderNo(action_body);
break;
case "businessmenNameList":
opResult = await this.businessmenSve.apiNameList(action_body);
break;
case "businessmenPage":
opResult = await this.businessmenSve.apiPage(action_body);
break;
case "businessmenInfo":
opResult = await this.businessmenSve.apiInfo(action_body);
break;
case "businessmenSign":
opResult = await this.businessmenSve.apiSign(action_body);
break;
case "businessmenSignPage":
opResult = await this.businessmenSve.apiSignPage(action_body);
break;
case "businessmenInfoPage":
opResult = await this.businessmenSve.apiInfoPage(action_body);
break;
case "businessmenUserPage":
opResult = await this.businessmenSve.apiUserPage(action_body);
break;
case "businessmenDeliverPage":
opResult = await this.businessmenSve.apiDeliverPage(action_body);
break;
case "addBusinessmenContract":
opResult = await this.businessmenSve.apiAddContract(action_body);
break;
case "businessmenCompleteMapByCreditCodes":
opResult = await this.businessmenSve.apiCompleteMapByCreditCodes(action_body);
break;
// 统计数据
case "statTransData":
opResult = await this.iborderSve.apiStatTransData(action_body);
break;
case "statBusinessData":
opResult = await this.iborderSve.apiStatBusinessData(action_body);
break;
case "statDeliverData":
opResult = await this.iborderdeliverSve.apiStatDeliverData(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
} }
return opResult;
} }
exam() { exam() {
return `<pre><pre/>`; return `<pre><pre/>`;
......
...@@ -5,6 +5,28 @@ class OorderprocessDao extends Dao { ...@@ -5,6 +5,28 @@ class OorderprocessDao extends Dao {
super(Dao.getModelName(OorderprocessDao)); super(Dao.getModelName(OorderprocessDao));
} }
async mapByOrderIdsAndStatus(orderIds, statuses) {
var result = {};
if(!orderIds || orderIds.length == 0 || !statuses || statuses.length == 0) {
return result;
}
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM `o_order_process`");
sql.push("WHERE order_id IN (:orderIds)");
sql.push("AND `status` IN (:statuses)");
let list = await this.customQuery(sql.join(" "), {orderIds: orderIds, statuses: statuses});
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
result[item.order_id + "_" + item.status] = item;
}
return result;
}
} }
module.exports = OorderprocessDao; module.exports = OorderprocessDao;
\ No newline at end of file
...@@ -5,6 +5,20 @@ class OprocessDao extends Dao { ...@@ -5,6 +5,20 @@ class OprocessDao extends Dao {
super(Dao.getModelName(OprocessDao)); super(Dao.getModelName(OprocessDao));
} }
async mapAll(attrs) {
var result = {};
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM `o_process`";
var list = await this.customQuery(sql);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async findMapByIds(ids, attrs) { async findMapByIds(ids, attrs) {
var result = {}; var result = {};
if (!ids || ids.length == 0) { if (!ids || ids.length == 0) {
......
...@@ -57,7 +57,7 @@ class OorderService extends ServiceBase { ...@@ -57,7 +57,7 @@ class OorderService extends ServiceBase {
} }
// 构建订单流程列表 // 构建订单流程列表
let orderProcessList = await this.buildOrderProcess(order.product_id); let orderProcessList = await this.buildOrderProcess(order.product_id, [10010200, 10010500]);
if (!orderProcessList || orderProcessList.length == 0) { if (!orderProcessList || orderProcessList.length == 0) {
return system.getResult(null, "产品流程未配置"); return system.getResult(null, "产品流程未配置");
} }
...@@ -120,20 +120,9 @@ class OorderService extends ServiceBase { ...@@ -120,20 +120,9 @@ class OorderService extends ServiceBase {
// 查询产品流程 // 查询产品流程
let productProcessMap = await this.oproductprocessDao.findMapByProductProductIds(productPid, productIds); let productProcessMap = await this.oproductprocessDao.findMapByProductProductIds(productPid, productIds);
// 产品流程ids
let processIds = [];
for (var idx in productProcessMap) {
let plist = productProcessMap[idx];
if (!plist) {
continue;
}
for (let p of plist) {
processIds.push(p.process_id);
}
}
// 批量查流程 // 批量查流程
let processMap = await this.oprocessDao.findMapByIds(processIds); let processMap = await this.oprocessDao.mapAll();
let orderProcessList = []; let orderProcessList = [];
...@@ -148,23 +137,35 @@ class OorderService extends ServiceBase { ...@@ -148,23 +137,35 @@ class OorderService extends ServiceBase {
// 风还钻该处理每一个子项流程 变为 订单流程对象 // 风还钻该处理每一个子项流程 变为 订单流程对象
let productProcess = productProcessList[idx]; let productProcess = productProcessList[idx];
let process = processMap[productProcess.process_id]; let process = processMap[productProcess.process_id];
let nextArr = this.trim(productProcess.next_status).split(",");
let nextStatus = [];
for (var nextId of nextArr) {
nextId = Number(nextId || 0);
let nextObj = processMap[nextId];
if (!nextObj) {
continue;
}
nextStatus.push({next_status: nextObj.status, next_name: nextObj.name});
}
let orderProcess = { let orderProcess = {
product_id: productPid, product_id: productPid,
name: process.name, name: process.name,
status: process.status, status: process.status,
func: productProcess.func, func: productProcess.func,
next_status: productProcess.next_status, next_status: JSON.stringify(nextStatus),
name1: productProcess.name1, name1: productProcess.name1,
name2: productProcess.name2, name2: productProcess.name2,
name3: productProcess.name3, name3: productProcess.name3,
name4: productProcess.name4, name4: productProcess.name4,
sort: productProcess.sort, sort: productProcess.sort,
autoIncrement: true autoIncrement: true
}; };
// 上一个产品流程于当前产品流程连接 // 上一个产品流程于当前产品流程连接
if (idx == 0 && orderProcessList.length > 0) { if (idx == 0 && orderProcessList.length > 0) {
let lastProcess = orderProcessList[orderProcessList.length - 1]; let lastProcess = orderProcessList[orderProcessList.length - 1];
lastProcess.next_status = productProcess.process_id; let nextObj = processMap[productProcess.process_id];
lastProcess.next_status = JSON.stringify([{next_status: nextObj.status, next_name: nextObj.name}]);
} }
orderProcessList.push(orderProcess); orderProcessList.push(orderProcess);
} }
...@@ -174,28 +175,28 @@ class OorderService extends ServiceBase { ...@@ -174,28 +175,28 @@ class OorderService extends ServiceBase {
/** /**
* 订单管理列表 * 订单管理列表
* @param {*} params * @param {*} params
*/ */
async orders(params){ async orders(params) {
let where = {}; let where = {};
if(params.id){ if (params.id) {
where.id = this.trim(params.id); where.id = this.trim(params.id);
} }
if(params.progress){ if (params.progress) {
where.progress = this.trim(params.progress); where.progress = this.trim(params.progress);
} }
if(params.beginDate && params.endDate){ if (params.beginDate && params.endDate) {
where.beginDate = this.trim(params.beginDate); where.beginDate = this.trim(params.beginDate);
where.endDate = this.trim(params.endDate); where.endDate = this.trim(params.endDate);
} }
if(params.deliver_id){ if (params.deliver_id) {
where.deliver_id = this.trim(params.deliver_id); where.deliver_id = this.trim(params.deliver_id);
} }
where.currentPage = Number(params.currentPage || 1); where.currentPage = Number(params.currentPage || 1);
where.pageSize = Number(params.pageSize || 10); where.pageSize = Number(params.pageSize || 10);
where.startRow = (where.currentPage-1)*where.pageSize; where.startRow = (where.currentPage - 1) * where.pageSize;
try { try {
let ordersCountRes = await this.dao.ordersCount(where); let ordersCountRes = await this.dao.ordersCount(where);
let count = ordersCountRes[0]['orderCount']; let count = ordersCountRes[0]['orderCount'];
...@@ -207,30 +208,30 @@ class OorderService extends ServiceBase { ...@@ -207,30 +208,30 @@ class OorderService extends ServiceBase {
//格式化交付商 //格式化交付商
this.formateDeliver(rows); this.formateDeliver(rows);
//格式化业务员 //格式化业务员
let res = { let res = {
count,rows count, rows
}; };
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** /**
* 格式化列表来源数据 * 格式化列表来源数据
* @param {*} orderList * @param {*} orderList
*/ */
async formateSource(orderList){ async formateSource(orderList) {
let sourceIdList=[]; let sourceIdList = [];
for (let item of orderList) { for (let item of orderList) {
if(item.source_id){ if (item.source_id) {
sourceIdList.push(item.source_id); sourceIdList.push(item.source_id);
} }
} }
let sourceMap = await this.osourceDao.mapByIds(sourceIdList); let sourceMap = await this.osourceDao.mapByIds(sourceIdList);
for (let item of orderList) { for (let item of orderList) {
item.osource = sourceMap[item.source_id] || {} item.osource = sourceMap[item.source_id] || {}
...@@ -239,16 +240,16 @@ class OorderService extends ServiceBase { ...@@ -239,16 +240,16 @@ class OorderService extends ServiceBase {
/** /**
* 格式化订单产品 * 格式化订单产品
* @param {*} orderList * @param {*} orderList
*/ */
async formateProduct(orderList){ async formateProduct(orderList) {
let productIdList=[]; let productIdList = [];
for (let item of orderList) { for (let item of orderList) {
if(item.product_id){ if (item.product_id) {
productIdList.push(item.product_id); productIdList.push(item.product_id);
} }
} }
let productMap = await this.oproductDao.mapByIds(productIdList); let productMap = await this.oproductDao.mapByIds(productIdList);
for (let item of productMap) { for (let item of productMap) {
item.oproduct = productMap[item.product_id] || {} item.oproduct = productMap[item.product_id] || {}
...@@ -257,71 +258,104 @@ class OorderService extends ServiceBase { ...@@ -257,71 +258,104 @@ class OorderService extends ServiceBase {
/** /**
* 格式化订单交付商 * 格式化订单交付商
* @param {*} orderList * @param {*} orderList
*/ */
async formateDeliver(orderList){ async formateDeliver(orderList) {
let deliverIdList=[]; let deliverIdList = [];
for (let item of orderList) { for (let item of orderList) {
if(item.deliver_id){ if (item.deliver_id) {
deliverIdList.push(item.deliver_id); deliverIdList.push(item.deliver_id);
} }
} }
let deliverMap = await this.oorderdeliverDao.mapByIds(deliverIdList); let deliverMap = await this.oorderdeliverDao.mapByIds(deliverIdList);
for (let item of deliverMap) { for (let item of deliverMap) {
item.odeliver = deliverMap[item.deliver_id] || {} item.odeliver = deliverMap[item.deliver_id] || {}
} }
} }
/**
* 处理订单状态数据
* @param orderList
* @returns {Promise<void>}
*/
async formateStatus(orderList) {
let ids = [];
let statuses = [];
for (let item of orderList) {
ids.push(item.id);
statuses.push(item.status);
}
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus(ids, statuses);
for (let item of orderList) {
let key = item.id + "_" + item.status;
let v = map[key] || {};
item.statusName = v.name;
item.next_status = JSON.parse(v.next_status || "[]");
}
console.log(orderList);
}
/**
* 获取订单状态对象
* @param order_id
* @param status
* @returns {Promise<*|{}>}
*/
async getOrderProcessStatus(order_id, status) {
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus([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
*/ */
async assignSalesman (params){ async assignSalesman(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 = await this.findById(params.id);
_order.bd_id = this.trim(params.bd_id); _order.bd_id = this.trim(params.bd_id);
let res = await _order.save(); let res = await _order.save();
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** /**
* 分配交付商 * 分配交付商
* @param {*} params * @param {*} params
* @id String 订单ID * @id String 订单ID
* *
* *
* *
*/ */
async assignDeliver(params){ async assignDeliver(params) {
//参数验证 //参数验证
if(!params.id){ if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`); return system.getResult(null, `参数错误 订单ID不能为空`);
} }
if(!params.deliver_id){ if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商ID不能为空`); return system.getResult(null, `参数错误 交付商ID不能为空`);
} }
if(!params.hasOwnProperty(`deliver_divide`)){ if (!params.hasOwnProperty(`deliver_divide`)) {
return system.getResult(null, `参数错误 交付商分成不能为空`); return system.getResult(null, `参数错误 交付商分成不能为空`);
} }
//创建orderdeliver记录 //创建orderdeliver记录
//更新oorder订单记录 //更新oorder订单记录
} }
} }
......
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