Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
aae54743
Commit
aae54743
authored
May 27, 2021
by
gongguan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改数据需求的获取形式
parent
1df4d685
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
35 deletions
+54
-35
stat.service.ts
v2.0/src/service/common/stat.service.ts
+54
-35
No files found.
v2.0/src/service/common/stat.service.ts
View file @
aae54743
...
...
@@ -68,25 +68,21 @@ export default class StatService {
const
endDayTimestamp
=
formatDate
(
endDay
).
getTimestamp
()
while
(
curDayTimestamp
<=
endDayTimestamp
)
{
// 访问PV
const
PV
=
await
this
.
accessdao
.
count
({
activityId
,
createDay
:
day
})
const
PV
promise
=
this
.
accessdao
.
count
({
activityId
,
createDay
:
day
})
// 访问UV
const
UV
=
await
this
.
userdao
.
count
({
activityId
,
[
`login.
${
day
}
`
]:
{
$exists
:
true
}
})
const
UV
promise
=
this
.
userdao
.
count
({
activityId
,
[
`login.
${
day
}
`
]:
{
$exists
:
true
}
})
// 新增UV
const
newUV
=
await
this
.
userdao
.
count
({
activityId
,
createDay
:
day
})
// 新增PV
// const newPV = await this.userdao.count({ activityId, createDay: day })
const
newUVpromise
=
this
.
userdao
.
count
({
activityId
,
createDay
:
day
})
// 新增UV(通过邀请)
const
newUVFromInviteUV
=
(
await
this
.
accessdao
.
aggregate
([
const
newUVFromInviteUVpromise
=
this
.
accessdao
.
aggregate
([
{
$match
:
{
activityId
,
createDay
:
day
,
inviteId
:
{
$exists
:
true
}
}
},
{
$project
:
{
openId
:
true
}
},
{
$group
:
{
_id
:
'$openId'
,
count
:
{
$sum
:
1
}
}
}
])
).
length
// 已入会(老会员)PV
const
vipPV
=
await
this
.
accessdao
.
count
({
const
vipPV
promise
=
this
.
accessdao
.
count
({
activityId
,
createDay
:
day
,
//@ts-ignore
...
...
@@ -95,7 +91,7 @@ export default class StatService {
})
// 已入会(老会员)UV
const
vipUV
=
await
this
.
userdao
.
count
({
const
vipUV
promise
=
this
.
userdao
.
count
({
activityId
,
[
`login.
${
day
}
`
]:
{
$exists
:
true
},
$or
:
[
...
...
@@ -107,30 +103,26 @@ export default class StatService {
})
// 未入会PV
const
noVipPV
=
await
this
.
accessdao
.
count
({
activityId
,
createDay
:
day
,
isVip
:
false
})
const
noVipPV
promise
=
this
.
accessdao
.
count
({
activityId
,
createDay
:
day
,
isVip
:
false
})
// 未入会UV
const
noVipUV
=
(
await
this
.
accessdao
.
aggregate
([
const
noVipUVpromise
=
this
.
accessdao
.
aggregate
([
{
$match
:
{
activityId
,
createDay
:
day
,
isVip
:
false
}
},
{
$project
:
{
openId
:
true
}
},
{
$group
:
{
_id
:
'$openId'
,
count
:
{
$sum
:
1
}
}
}
])
).
length
// 新增入会UV
const
newVipUV
=
await
this
.
userdao
.
count
({
activityId
,
'member.newMember'
:
true
,
'member.bememberDay'
:
day
})
const
newVipUV
promise
=
this
.
userdao
.
count
({
activityId
,
'member.newMember'
:
true
,
'member.bememberDay'
:
day
})
const
newFollowUV
=
await
this
.
userdao
.
count
({
activityId
,
'follow.newFollow'
:
true
,
'follow.followDay'
:
day
})
const
newFollowUV
promise
=
this
.
userdao
.
count
({
activityId
,
'follow.newFollow'
:
true
,
'follow.followDay'
:
day
})
// 助力成功UV
const
helpSuccessUV
=
(
await
this
.
statdao
.
aggregate
([
const
helpSuccessUVpromise
=
this
.
statdao
.
aggregate
([
{
$match
:
{
activityId
,
createDay
:
day
,
type
:
STAT_TYPE
.
INITE_SUCCESS
}
},
{
$project
:
{
openId
:
true
}
},
{
$group
:
{
_id
:
'$openId'
,
count
:
{
$sum
:
1
}
}
}
])
).
length
// 根据任务类型获取完成任务的人数
// example: await getTaskCompleteUV('collectGoods', day)
...
...
@@ -141,22 +133,48 @@ export default class StatService {
})
}
const
[
PV
,
UV
,
newUV
,
newUVFromInviteUV
,
vipPV
,
vipUV
,
noVipPV
,
noVipUV
,
newVipUV
,
newFollowUV
,
helpSuccessUV
,
]
=
await
Promise
.
all
([
PVpromise
,
UVpromise
,
newUVpromise
,
newUVFromInviteUVpromise
,
vipPVpromise
,
vipUVpromise
,
noVipPVpromise
,
noVipUVpromise
,
newVipUVpromise
,
newFollowUVpromise
,
helpSuccessUVpromise
,
])
const
keyValueMapper
=
{
时间
:
day
,
访问
PV
:
PV
,
访问
UV
:
UV
,
新增
UV
:
newUV
,
'新增UV(通过邀请)'
:
newUVFromInviteUV
,
'新增UV(通过邀请)'
:
newUVFromInviteUV
.
length
,
'已入会(老会员)PV'
:
vipPV
,
'已入会(老会员)UV'
:
vipUV
,
未入会
PV
:
noVipPV
,
未入会
UV
:
noVipUV
,
未入会
UV
:
noVipUV
.
length
,
新入会
UV
:
newVipUV
,
新增关注
UV
:
newFollowUV
,
助力成功
UV
:
helpSuccessUV
助力成功
UV
:
helpSuccessUV
.
length
//收藏商品任务完成UV: await getTaskCompleteUV('collectGoods', day)
}
console
.
log
(
keyValueMapper
,
'xlsxData'
)
console
.
log
(
'keyValueMapper::::::::::'
,
keyValueMapper
)
if
(
day
===
startDay
)
{
xlsxData
.
push
(
Object
.
keys
(
keyValueMapper
))
...
...
@@ -167,6 +185,7 @@ export default class StatService {
curDayTimestamp
=
tommorrow
day
=
dateFormatter
(
transformBeijingDate
(
tommorrow
),
'yyyy/MM/dd'
)
}
console
.
log
(
'xlsxData::::::::::'
,
xlsxData
)
return
xlsxData
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment