Commit 093e6e07 by Leo Zheng

更新了一些返回格式

parent d562e619
...@@ -12,15 +12,15 @@ export default class merchantBusinessStatisticsStrategy extends abstractMerchant ...@@ -12,15 +12,15 @@ export default class merchantBusinessStatisticsStrategy extends abstractMerchant
const result = [ const result = [
{ {
key: 'totalBusinesses', key: '营业商家数',
value: totalBusinesses value: totalBusinesses
}, },
{ {
key: 'totalShops', key: '营业店铺数',
value: totalShops value: totalShops
}, },
{ {
key: 'businessActivityRate', key: '商家动销率',
value: businessActivityRate value: businessActivityRate
} }
]; ];
......
...@@ -27,10 +27,14 @@ export default class visitorGenderProfileStrategy extends abstractCustomerProfil ...@@ -27,10 +27,14 @@ export default class visitorGenderProfileStrategy extends abstractCustomerProfil
femaleCount = total - maleCount; femaleCount = total - maleCount;
} }
const result = { const result = type === 'ticket' ?{
total: total, 总游客数: total,
maleCount: maleCount, 男性游客: maleCount,
femaleCount: femaleCount 女性游客: femaleCount
} : {
总会员数: total,
男性会员: maleCount,
女性会员: femaleCount
} }
return Object.entries(result).map(([key, value]) => ({key, value})); return Object.entries(result).map(([key, value]) => ({key, value}));
......
...@@ -28,18 +28,14 @@ export default class visitorHomeProfileStrategy extends abstractCustomerProfileS ...@@ -28,18 +28,14 @@ export default class visitorHomeProfileStrategy extends abstractCustomerProfileS
const scaledCount = Math.floor(count * scaleFactor); const scaledCount = Math.floor(count * scaleFactor);
return { return {
key, key,
value: { value: scaledCount
count: scaledCount,
percent: ((scaledCount / total) * 100).toFixed(2) + '%'
}
}; };
}); });
const currentTotal = result.reduce((sum, city) => sum + city.value.count, 0); const currentTotal = result.reduce((sum, city) => sum + city.value, 0);
if (currentTotal !== total) { if (currentTotal !== total) {
const difference = total - currentTotal; const difference = total - currentTotal;
result[0].value.count += difference; result[0].value += difference;
result[0].value.percent = ((result[0].value.count / total) * 100).toFixed(2) + '%';
} }
return result; 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