Commit a87f54d3 by 任晓松

需求,订单对比

parent 3fac574e
......@@ -54,6 +54,9 @@ class IcAPI extends APIBase {
case "getNeedFunnelStatistics":
opResult = await this.opNeedInfoSve.getNeedFunnelStatistics(pobj);
break;
case "getNeedComparison":
opResult = await this.opNeedInfoSve.getNeedComparison(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -38,6 +38,9 @@ class OrderAPI extends APIBase {
case "getOrderStatisticsByProduct":
opResult = await this.orderinfoSve.getOrdersStatisticsByProduct(pobj);
break;
case "getOrdersComparison":
opResult = await this.orderinfoSve.getOrdersComparison(pobj);
break;
case "getOrderListByOrderServiceNo"://根据合同号获取子订单
opResult = await this.orderinfoSve.getOrderListByOrderServiceNo(pobj, pobj.actionBody);
break;
......
......@@ -1239,6 +1239,44 @@ class OrderInfoService extends ServiceBase {
let result = await this.customQuery(sql,whereParams);
return system.getResultSuccess(result);
}
/**
* 订单对比
* @param pobj
* @returns {Promise<void>}
*/
async getOrdersComparison(pobj){
let ab =pobj.actionBody;
let sql1 = `select count(*) count from c_order_info where deleted_at is null `;
let whereParams = {};
if(ab.startNow&&ab.endNow){
sql1 += ` and created_at >= :start and created_at <= :end`;
whereParams.start = ab.startNow;
whereParams.end = ab.endNow;
}
if(ab.uapp_id){
sql1 += ` and uapp_id = :uapp_id`;
whereParams.uapp_id = ab.uapp_id;
}
if(ab.type_code){
sql1 += ` and typeCode = :type_code`;
whereParams.type_code = ab.type_code;
}
let totalRet1 = await this.customQuery(sql1,whereParams);
if(ab.startLast&&ab.endLast){
whereParams.start = ab.startLast;
whereParams.end = ab.endLast;
}
let totalRet2 = await this.customQuery(sql1,whereParams);
let result ={
now:{
total:totalRet1[0].count,
},
last:{
total:totalRet2[0].count,
}
}
return system.getResultSuccess(result);
}
//根据合同号,获取子订单
async getOrderListByOrderServiceNo(pobj) {
......
......@@ -239,10 +239,65 @@ class NeedinfoService extends ServiceBase {
whereParams.start = ac.start;
whereParams.end = ac.end;
}
if(ac.type_code){
sql += ` and typeCode = :typeCode`;
whereParams.typeCode = ac.type_code;
}
if(ac.uapp_id){
sql += ` and uapp_id = :uapp_id`;
whereParams.uapp_id = ac.uapp_id;
}
sql += ` GROUP BY province,typeCode`;
let result = await this.customQuery(sql,whereParams);
return system.getResultSuccess(result);
}
/**
* 需求对比
* @param pobj
* @returns {Promise<void>}
*/
async getNeedComparison(pobj){
let ab =pobj.actionBody;
let sql1 = `select count(*) count from n_need_info where deleted_at is null `;
let sql2 = `select count(DISTINCT(a.needNo)) count from n_need_solution a left join n_need_info b on a.needNo = b.needNo where a.deleted_at is null and b.status = 'ycd'`;
let whereParams = {};
if(ab.startNow&&ab.endNow){
sql1 += ` and created_at >= :start and created_at <= :end`;
sql2 += ` and b.created_at >= :start and b.created_at <= :end`;
whereParams.start = ab.startNow;
whereParams.end = ab.endNow;
}
if(ab.uapp_id){
sql1 += ` and uapp_id = :uapp_id`;
sql2 += ` and b.uapp_id = :uapp_id`;
whereParams.uapp_id = ab.uapp_id;
}
if(ab.type_code){
sql1 += ` and typeCode = :type_code`;
sql2 += ` and b.typeCode = :type_code`;
whereParams.type_code = ab.type_code;
}
let totalRet1 = await this.customQuery(sql1,whereParams);
let orderRet1 = await this.customQuery(sql2,whereParams);
if(ab.startLast&&ab.endLast){
whereParams.start = ab.startLast;
whereParams.end = ab.endLast;
}
let totalRet2 = await this.customQuery(sql1,whereParams);
let orderRet2 = await this.customQuery(sql2,whereParams);
let result ={
now:{
total:totalRet1[0].count,
order:orderRet1[0].count
},
last:{
total:totalRet2[0].count,
order:orderRet2[0].count
}
}
return system.getResultSuccess(result);
}
}
module.exports = NeedinfoService;
......
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