Commit b488b68c by Sxy

feat:需求&&订单看板

parent b269b91f
...@@ -34,6 +34,16 @@ class StatisticsCtl extends CtlBase { ...@@ -34,6 +34,16 @@ class StatisticsCtl extends CtlBase {
} }
} }
// 订单渠道分析
async getOrderStatisticsByUappId(pobj, qobj, req) {
try {
const rs = await this.service.getOrderStatisticsByUappId(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
// 需求漏斗图 // 需求漏斗图
async getNeedFunnelStatistics(pobj, qobj, req) { async getNeedFunnelStatistics(pobj, qobj, req) {
try { try {
...@@ -53,5 +63,45 @@ class StatisticsCtl extends CtlBase { ...@@ -53,5 +63,45 @@ class StatisticsCtl extends CtlBase {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
} }
// 订单产品分析
async getOrderStatisticsByProduct(pobj, qobj, req) {
try {
const rs = await this.service.getOrderStatisticsByProduct(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
// 需求地区分析
async getStatisticsByArea(pobj, qobj, req) {
try {
const rs = await this.service.getStatisticsByArea(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async getNeedComparison(pobj, qobj, req) {
try {
const rs = await this.service.getNeedComparison(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async getOrdersComparison(pobj, qobj, req) {
try {
const rs = await this.service.getOrdersComparison(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
} }
module.exports = StatisticsCtl; module.exports = StatisticsCtl;
const ToQiFuTong = require('../../../utils/qifutong/baseClient').getInstance(); const ToQiFuTong = require('../../../utils/qifutong/baseClient').getInstance();
const _ = require("lodash");
class StatisticsService { class StatisticsService {
async getAllChannels(pobj) { async getAllChannels(pobj) {
return ToQiFuTong.getAllChannels(); return ToQiFuTong.getAllChannels();
...@@ -19,6 +20,19 @@ class StatisticsService { ...@@ -19,6 +20,19 @@ class StatisticsService {
data data
}; };
} }
async getOrderStatisticsByUappId(pobj) {
const data = await ToQiFuTong.getOrderStatisticsByUappId({
start: pobj.start,
end: pobj.end,
type_code: pobj.type_code,
status: pobj.status
});
const dates = ToQiFuTong.getAllDate(pobj.start, pobj.end);
return {
x: dates,
data
};
}
async getStatisticsByProduct(pobj) { async getStatisticsByProduct(pobj) {
const data = await ToQiFuTong.getStatisticsByProduct({ const data = await ToQiFuTong.getStatisticsByProduct({
start: pobj.start, start: pobj.start,
...@@ -51,6 +65,38 @@ class StatisticsService { ...@@ -51,6 +65,38 @@ class StatisticsService {
data: result data: result
}; };
} }
async getOrderStatisticsByProduct(pobj) {
const data = await ToQiFuTong.getOrderStatisticsByProduct({
start: pobj.start,
end: pobj.end,
// status: pobj.status,
});
let result = []; // 基础数据
let channels = new Set(); //渠道
let productList = []; //产品
for (let val of data) {
let productCount = 0;
for (let info of val.data) {
productCount += info.count;
channels.add(info.uapp_id.toString());
result.push({
uapp_id: info.uapp_id.toString(),
count: info.count,
type_code: val.type_code
})
}
productList.push({
count: productCount,
type_code: val.type_code
})
}
productList = productList.sort(function (a, b) { return a.count - b.count });
return {
channelList: [...channels],
productList: productList.map((item) => { return item.type_code }),
data: result
};
}
async getNeedFunnelStatistics(pobj) { async getNeedFunnelStatistics(pobj) {
return ToQiFuTong.getNeedFunnelStatistics({ return ToQiFuTong.getNeedFunnelStatistics({
...@@ -60,5 +106,92 @@ class StatisticsService { ...@@ -60,5 +106,92 @@ class StatisticsService {
uapp_id: pobj.uapp_id uapp_id: pobj.uapp_id
}); });
} }
async getStatisticsByArea(pobj) {
const data = await ToQiFuTong.getStatisticsByArea({
start: pobj.start,
end: pobj.end,
type_code: pobj.type_code,
uapp_id: pobj.uapp_id
});
let result = {};
for (let val of data) {
const region = val.province.replace(/(.*)(市|省)$/, '$1');
let sum = 0
for (let info of val.data) {
sum += info.count;
}
if (result[region]) {
let productInfo = _.groupBy([...val.data, ...result[region].data], "type_code");
let productInfoList = [];
for (let key in productInfo) {
let count = 0;
for (let info of productInfo[key]) {
count += info.count;
}
productInfoList.push({
count,
type_code: key
});
}
result[region] = {
sum: result[region].sum + sum,
data: productInfoList
}
} else {
result[region] = {
sum: sum,
data: val.data
}
}
}
return result;
}
async getNeedComparison(pobj) {
const data = await ToQiFuTong.getNeedComparison({
startNow: pobj.startNow,
endNow: pobj.endNow,
startLast: pobj.startLast,
endLast: pobj.endLast,
type_code: pobj.type_code,
uapp_id: pobj.uapp_id
});
return {
businessStatistics: {
sum: data.now.total,
lastSum: data.last.total,
type: ToQiFuTong.judgeSize(data.now.total, data.last.total),
contrast: (data.last.total === 0 ? (data.now.total === 0 ? 0 : 100) : ((data.now.total - data.last.total) / data.last.total * 100)).toFixed(2)
},
businessToOrderStatistics: {
sum: data.now.order,
lastSum: data.last.order,
type: ToQiFuTong.judgeSize(data.now.order, data.last.order),
contrast: (data.last.total === 0 ? (data.now.total === 0 ? 0 : 100) : ((data.now.order - data.last.order) / data.last.order * 100)).toFixed(2)
}
};
}
async getOrdersComparison(pobj) {
const data = await ToQiFuTong.getOrdersComparison({
startNow: pobj.startNow,
endNow: pobj.endNow,
startLast: pobj.startLast,
endLast: pobj.endLast,
type_code: pobj.type_code,
uapp_id: pobj.uapp_id
});
return {
orderStatistics: {
sum: data.now.total,
lastSum: data.last.total,
type: ToQiFuTong.judgeSize(data.now.total, data.last.total),
contrast: (data.last.total === 0 ? (data.now.total === 0 ? 0 : 100) : ((data.now.total - data.last.total) / data.last.total * 100)).toFixed(2)
}
};
}
} }
module.exports = StatisticsService; module.exports = StatisticsService;
\ No newline at end of file
...@@ -105,6 +105,13 @@ class BaseClient { ...@@ -105,6 +105,13 @@ class BaseClient {
}); });
return data; return data;
} }
async getOrderStatisticsByUappId(pobj) {
const data = await this.pushQiFuTong('/web/opaction/order/springBoard', {
"actionType": "getOrderStatisticsByUappId",
"actionBody": pobj
});
return data;
}
async getNeedFunnelStatistics(pobj) { async getNeedFunnelStatistics(pobj) {
const data = await this.pushQiFuTong('/web/action/opNeed/springBoard', { const data = await this.pushQiFuTong('/web/action/opNeed/springBoard', {
"actionType": "getNeedFunnelStatistics", "actionType": "getNeedFunnelStatistics",
...@@ -119,6 +126,34 @@ class BaseClient { ...@@ -119,6 +126,34 @@ class BaseClient {
}); });
return data; return data;
} }
async getOrderStatisticsByProduct(pobj) {
const data = await this.pushQiFuTong('/web/opaction/order/springBoard', {
"actionType": "getOrderStatisticsByProduct",
"actionBody": pobj
});
return data;
}
async getStatisticsByArea(pobj) {
const data = await this.pushQiFuTong('/web/action/opNeed/springBoard', {
"actionType": "getStatisticsByArea",
"actionBody": pobj
});
return data;
}
async getNeedComparison(pobj) {
const data = await this.pushQiFuTong('/web/action/opNeed/springBoard', {
"actionType": "getNeedComparison",
"actionBody": pobj
});
return data;
}
async getOrdersComparison(pobj) {
const data = await this.pushQiFuTong('/web/opaction/order/springBoard', {
"actionType": "getOrdersComparison",
"actionBody": pobj
});
return data;
}
...@@ -149,5 +184,8 @@ class BaseClient { ...@@ -149,5 +184,8 @@ class BaseClient {
data.push(end); data.push(end);
return data; return data;
} }
judgeSize(a, b) {
return a >= b ? (a == b ? "rgba(0, 0, 0, 0.45)" : "red") : "green"
}
} }
module.exports = BaseClient; module.exports = BaseClient;
\ No newline at end of file
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
"glob": "^7.1.6", "glob": "^7.1.6",
"gm": "^1.23.1", "gm": "^1.23.1",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"log4js": "^2.10.0", "log4js": "^2.10.0",
"method-override": "^2.3.10", "method-override": "^2.3.10",
"moment": "^2.26.0", "moment": "^2.26.0",
......
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