Commit acd7876c by Leo Zheng

修改返回参数

parent 0499f80a
import {abstractCustomerProfileStrategy} from "./abstractCustomerProfileStrategy"; import { abstractCustomerProfileStrategy } from "./abstractCustomerProfileStrategy";
import paramChecker from "../../../../util/paramChecker"; import paramChecker from "../../../../util/paramChecker";
export default class visitorGenderProfileStrategy extends abstractCustomerProfileStrategy { export default class visitorGenderProfileStrategy extends abstractCustomerProfileStrategy {
...@@ -11,33 +11,38 @@ export default class visitorGenderProfileStrategy extends abstractCustomerProfil ...@@ -11,33 +11,38 @@ export default class visitorGenderProfileStrategy extends abstractCustomerProfil
processData(data: any, type: string): any { processData(data: any, type: string): any {
let total = 0, maleCount = 0, femaleCount = 0; let total = 0, maleCount = 0, femaleCount = 0;
if (type == 'ticket') { if (type === 'ticket') {
data.forEach((row) => { data.forEach((row) => {
total++; total++;
if (row['性别'] === '男') { if (row['性别'] === '男') {
maleCount++; maleCount++;
} } else {
else {
femaleCount++; femaleCount++;
} }
}); });
} else if (type == 'ecommerce') { } else if (type === 'ecommerce') {
total = 3429; total = 3429;
maleCount = Math.floor(Math.random() * 1700) + 100; maleCount = Math.floor(Math.random() * 1700) + 100;
femaleCount = total - maleCount; femaleCount = total - maleCount;
} }
const result = type === 'ticket' ?{ const maleRatio = ((maleCount / total) * 100).toFixed(2) + '%';
总游客数: total, const femaleRatio = ((femaleCount / total) * 100).toFixed(2) + '%';
男性游客: maleCount,
女性游客: femaleCount
} : {
总会员数: total,
男性会员: maleCount,
女性会员: femaleCount
}
return Object.entries(result).map(([key, value]) => ({key, value}));
const result = {
totalList: {
name: type === 'ticket' ? '总游客数' : '总会员数',
value: total,
unit: '人'
},
sexRatio: {
male: maleCount,
maleRatio: maleRatio,
female: femaleCount,
femaleRatio: femaleRatio
} }
};
return result;
}
} }
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