perf: admin

This commit is contained in:
archer
2023-06-30 10:56:34 +08:00
parent c411ca4bd4
commit a4e2c6510f
4 changed files with 107 additions and 13 deletions

View File

@@ -188,16 +188,21 @@ export const useUserRoute = (app) => {
$match: {
status: 'SUCCESS',
createTime: {
$gte: new Date(Date.now() - day * 24 * 60 * 60 * 1000)
$gte: new Date(Date.now() - day * 24 * 60 * 60 * 1000 + 8 * 60 * 60 * 1000) // 补时差
}
}
},
{
$addFields: {
adjustedCreateTime: { $add: ['$createTime', 8 * 60 * 60 * 1000] }
}
},
{
$group: {
_id: {
year: { $year: '$createTime' },
month: { $month: '$createTime' },
day: { $dayOfMonth: '$createTime' }
year: { $year: '$adjustedCreateTime' },
month: { $month: '$adjustedCreateTime' },
day: { $dayOfMonth: '$adjustedCreateTime' }
},
count: { $sum: '$price' }
}
@@ -216,7 +221,8 @@ export const useUserRoute = (app) => {
startCount += item.count;
return {
date: item.date,
count: startCount
total: startCount,
count: item.count
};
});