Commit a04ad50e by 任晓松

需求统计

parent 160bbf45
......@@ -52,7 +52,10 @@ class OpNeed extends APIBase {
// break;
// case "receiveFeedback"://关闭方案
// opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
// break;
// break;
case "getStatisticsByUappId":
opResult = await this.utilsOpNeedSve.getStatisticsByUappId(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -286,6 +286,73 @@ class UtilsOpNeedService extends AppServiceBase {
return system.getResultSuccess(res);
}
/**
* 各渠道需求统计
* @param pobj
* @returns {Promise<void>}
*/
async getStatisticsByUappId(pobj){
let url = this.centerOrderUrl + "action/opNeed/springBoard";
let result = await this.restPostUrl(pobj, url);
if(result.status != 0){
return system.getResultFail(-1);
}
let data = result.data;
let temp=0;
let arr = [];
let reArr = [];
for(let i=0;i<data.length;i++){
if((temp != data[i].uapp_id && temp !=0)){
let obj = {
uapp_id:temp,
data:arr
}
reArr.push(obj);
arr =[];
}
let dArr = {
time:data[i].time,
count:data[i].count
}
arr.push(dArr);
temp = data[i].uapp_id;
if (i == data.length-1){
let obj = {
uapp_id:temp,
data:arr
}
reArr.push(obj);
}
}
reArr.sort((a,b) =>{
return a.uapp_id - b.uapp_id;
})
let temp2 = 0;
let arr2=[];
let final = [];
for(let i =0;i<reArr.length;i++){
if((temp2 != reArr[i].uapp_id && temp2 !=0)){
let o = {
uapp_id: temp2,
data: arr2
};
final.push(o);
arr2 = [];
}
console.log(reArr[i].data)
arr2 = arr2.concat(reArr[i].data);
temp2 = reArr[i].uapp_id;
if (i == reArr.length-1){
let obj = {
uapp_id:temp2,
data:arr2
}
final.push(obj);
}
}
return system.getResultSuccess(final);
}
urlSplit(url) {
var arr = url.split("?")[1]; //根据?跟个url
......
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