Commit 3fac574e by 任晓松

订单统计

parent 80eace4c
......@@ -48,6 +48,9 @@ class IcAPI extends APIBase {
case "getStatisticsByProduct":
opResult = await this.opNeedInfoSve.getStatisticsByProduct(pobj);
break;
case "getStatisticsByArea":
opResult = await this.opNeedInfoSve.getStatisticsByCity(pobj);
break;
case "getNeedFunnelStatistics":
opResult = await this.opNeedInfoSve.getNeedFunnelStatistics(pobj);
break;
......
......@@ -32,6 +32,12 @@ class OrderAPI extends APIBase {
case "getOrderInfo"://获取订单列表信息
opResult = await this.orderinfoSve.getOrderInfo(pobj, pobj.actionBody);
break;
case "getOrderStatisticsByUappId":
opResult = await this.orderinfoSve.getOrdersStatisticsByUappId(pobj);
break;
case "getOrderStatisticsByProduct":
opResult = await this.orderinfoSve.getOrdersStatisticsByProduct(pobj);
break;
case "getOrderListByOrderServiceNo"://根据合同号获取子订单
opResult = await this.orderinfoSve.getOrderListByOrderServiceNo(pobj, pobj.actionBody);
break;
......
......@@ -1194,6 +1194,52 @@ class OrderInfoService extends ServiceBase {
}
/**
* 需求统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
async getOrdersStatisticsByUappId(pobj){
let ac = pobj.actionBody;
let sql = `SELECT uapp_id,count(*) count,DATE_FORMAT(created_at,'%Y-%m-%d') time FROM c_order_info WHERE deleted_at is null `;
let whereParam = {};
if(ac.start&&ac.end){
sql += ` AND created_at >= :start AND created_at <= :end`;
whereParam.start = ac.start;
whereParam.end = ac.end;
}
if(ac.type_code){
sql += ` AND typeCode = :type_code`;
whereParam.type_code = ac.type_code;
}
if(ac.status){
sql += ` AND status = :status`;
whereParam.status = ac.status;
}
sql += ` GROUP BY uapp_id,DATE_FORMAT(created_at,'%Y-%m-%d') ORDER BY created_at ASC`
let result = await this.customQuery(sql,whereParam);
return system.getResultSuccess(result);
}
/**
* 需求统计(产品维度)
* @param pobj
* @returns {Promise<void>}
*/
async getOrdersStatisticsByProduct(pobj){
let ac = pobj.actionBody;
let sql = `SELECT b.itemCode typeCode,a.uapp_id,count( * ) count FROM c_order_info a left join c_order_product b on a.orderNo = b.sourceOrderNo WHERE b.itemCode is not null `;
let whereParams = {};
if(ac.start&&ac.end){
sql += ` and a.created_at >= :start and a.created_at <= :end `;
whereParams.start = ac.start;
whereParams.end = ac.end;
}
sql += ` GROUP BY b.itemCode,a.uapp_id`;
let result = await this.customQuery(sql,whereParams);
return system.getResultSuccess(result);
}
//根据合同号,获取子订单
async getOrderListByOrderServiceNo(pobj) {
let sql = "select `orderNo`,`channelServiceNo`,`channelOrderNo`,`channelUserId`,`ownerUserId`,`payTime`,`quantity`,`serviceQuantity`,`orderStatusName`,`orderStatus`,`totalSum`,`payTotalSum`,`refundSum`," +
......
......@@ -224,6 +224,25 @@ class NeedinfoService extends ServiceBase {
let result = await this.customQuery(sql,whereParams);
return system.getResultSuccess(result);
}
/**
* 需求统计(区域维度)
* @param pobj
* @returns {Promise<void>}
*/
async getStatisticsByCity(pobj){
let ac = pobj.actionBody;
let sql = `select typeCode,province,count(*) count from n_need_info where province is not null and typeCode is not null `;
let whereParams = {};
if(ac.start&&ac.end){
sql += ` and created_at >= :start and created_at <= :end `;
whereParams.start = ac.start;
whereParams.end = ac.end;
}
sql += ` GROUP BY province,typeCode`;
let result = await this.customQuery(sql,whereParams);
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