Commit a2b78e4f by Leo Zheng

修改右侧接口的返回格式

parent acd7876c
......@@ -15,10 +15,10 @@ export default class paymentMethodAnalysisStrategy extends abstractDataStrategyL
}
processData(data: any, timeFrame: string, type: string, ticketCategory: string): any {
return this.processPaymentMethodData(data, timeFrame);
return this.processPaymentMethodData(data, timeFrame, type);
}
private processPaymentMethodData(data: any, timeFrame: string): any {
private processPaymentMethodData(data: any, timeFrame: string, type: string): any {
const currentDate = new Date();
let startDate = new Date();
if (timeFrame === '12month') {
......@@ -70,7 +70,8 @@ export default class paymentMethodAnalysisStrategy extends abstractDataStrategyL
return {
paymentMethod: key,
amount: parseFloat(amount.toFixed(2)),
percentage: `${percentage}%`
percentage: `${percentage}%`,
unit: type === 'amount' ? '元' : '张'
};
});
......
......@@ -11,9 +11,9 @@ export default class businessStatusStrategy implements dataStrategy{
const closedStores = totalStores - openStores;
const result = [
{ key: '门店数', value: totalStores },
{ key: '开店数', value: openStores },
{ key: '关店数', value: closedStores }
{ key: '门店数', value: totalStores, unit: '家' },
{ key: '开店数', value: openStores, unit: '家' },
{ key: '关店数', value: closedStores, unit: '家' }
];
result.sort((a, b) => b.value - a.value);
......
......@@ -8,20 +8,25 @@ export default class merchantBusinessStatisticsStrategy extends abstractMerchant
processData(): any {
const totalBusinesses = Math.floor(Math.random() * 2000) + 1000;
const totalShops = Math.floor(Math.random() * 2500) + 1500;
const businessActivityRate = Math.floor(Math.random() * 50) + 50; // Random percentage between 50% and 100%
const businessActivityRate = Math.floor(Math.random() * 50) + 50;
const result = [
{
key: '营业商家数',
value: totalBusinesses
value: totalBusinesses,
unit: '家'
},
{
key: '营业店铺数',
value: totalShops
value: totalShops,
unit: '家'
},
{
key: '商家动销率',
value: businessActivityRate
value: businessActivityRate,
unit: '%'
}
];
......
......@@ -4,8 +4,6 @@ export default class storeTypeDistributionStrategy {
}
private generateStoreTypeData(): any {
const totalStores = 1000; // Total number of stores to be randomly distributed
const storeTypes = [
'文化创意',
'特色餐饮',
......@@ -16,13 +14,14 @@ export default class storeTypeDistributionStrategy {
'体验式商铺'
];
const randomValues = Array.from({ length: storeTypes.length - 1 }, () => Math.floor(Math.random() * totalStores * 0.3));
const remainingValue = totalStores - randomValues.reduce((a, b) => a + b, 0);
randomValues.push(remainingValue);
const randomValues = Array.from({ length: storeTypes.length }, () => Math.floor(Math.random() * 300) + 1);
const totalStores = randomValues.reduce((sum, value) => sum + value, 0);
const result = randomValues.map((value, index) => ({
key: storeTypes[index],
value: value
value: value,
percent: ((value / totalStores) * 100).toFixed(2) + '%'
}));
result.sort((a, b) => b.value - a.value);
......
......@@ -10,7 +10,6 @@ export default class visitorAgeProfileStrategy extends abstractCustomerProfileSt
processData(type: string): any {
const total = type === 'ticket' ? 1000 : 3429;
// Generate random values for each age group ensuring they sum up to total
const children = Math.floor(Math.random() * (total * 0.2));
const teenagers = Math.floor(Math.random() * (total * 0.2));
const youngAdults = Math.floor(Math.random() * (total * 0.5));
......
......@@ -36,6 +36,8 @@ export default class visitorGenderProfileStrategy extends abstractCustomerProfil
unit: '人'
},
sexRatio: {
maleName: type === 'ticket' ? '男性游客' : '男性会员',
femaleName: type === 'ticket' ? '女性游客' : '女性会员',
male: maleCount,
maleRatio: maleRatio,
female: femaleCount,
......
......@@ -23,8 +23,9 @@ export default class visitorHomeProfileStrategy extends abstractCustomerProfileS
const totalVisitors = Object.values(cityCounts).reduce((a, b) => a + b, 0);
const scaleFactor = total / totalVisitors;
let count = 0;
const result = Object.entries(cityCounts).map(([key, count]) => {
let result = Object.entries(cityCounts).map(([key, count]) => {
const scaledCount = Math.floor(count * scaleFactor);
return {
key,
......@@ -38,6 +39,7 @@ export default class visitorHomeProfileStrategy extends abstractCustomerProfileS
result[0].value += difference;
}
result = result.slice(0, 10);
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