Commit 438a9472 by 任晓松

需求统计

parent b0d4e29f
......@@ -42,6 +42,9 @@ class IcAPI extends APIBase {
case "opGetItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve.getItemByNeedNo(pobj);
break;
case "getStatisticsByUappId":
opResult = await this.opNeedInfoSve.getStatisticsByUappId(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -140,6 +140,33 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess();
}
}
/**
* 各渠道需求统计
* @param pobj
* @returns {Promise<void>}
*/
async getStatisticsByUappId(pobj){
let ac = pobj.actionBody;
let sql = `SELECT uapp_id,count(*) count,DATE_FORMAT(created_at,'%Y-%m-%d') time FROM n_need_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);
}
}
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