Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
remarketing-yunying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
yaobeibei
remarketing-yunying
Commits
39f0e6d4
Commit
39f0e6d4
authored
Jun 14, 2018
by
yaobeibei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api 提交
parent
b9095350
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
178 additions
and
170 deletions
+178
-170
api.js
api/api.js
+178
-170
No files found.
api/api.js
View file @
39f0e6d4
...
...
@@ -31,7 +31,7 @@ app.post('/login', async function (req, res) {
console
.
log
(
body
)
if
(
body
.
userName
===
'admin'
)
{
if
(
body
.
password
===
'goyooyunying'
)
{
res
.
send
({
status
:
230
,
message
:
'登陆成功'
})
res
.
send
({
status
:
230
,
message
:
'登陆成功'
})
}
else
{
res
.
send
({
status
:
200
,
message
:
'密码错误'
})
}
...
...
@@ -49,7 +49,7 @@ app.post('/dataList', async function (req, res) {
console
.
log
(
body
)
console
.
log
(
startTime
,
endTime
)
let
dateQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'date'
})
let
dateQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'date'
})
// console.log(dateQs)
let
results
=
await
db
.
collection
(
'dailyStats'
).
aggregate
([
...
...
@@ -59,11 +59,11 @@ app.post('/dataList', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
pv
:
{
$sum
:
'$pv'
},
uid
:
{
$sum
:
'$uid'
}
pv
:
{
$sum
:
'$pv'
},
uid
:
{
$sum
:
'$uid'
}
}
}
]).
sort
({
'date'
:
-
1
}).
toArray
()
]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(results)
let
touchCount
=
await
db
.
collection
(
'recognition'
).
aggregate
([
...
...
@@ -73,13 +73,13 @@ app.post('/dataList', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
touchCount
:
{
$sum
:
1
}
touchCount
:
{
$sum
:
1
}
}
}
]).
sort
({
'date'
:
-
1
}).
toArray
()
]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(touchCount)
let
creatQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'createdAt'
})
let
creatQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'createdAt'
})
console
.
log
(
creatQs
)
let
msgTask
=
await
db
.
collection
(
'task'
).
aggregate
([
...
...
@@ -89,9 +89,9 @@ app.post('/dataList', async function (req, res) {
{
$group
:
{
_id
:
'$accountID'
,
msgCount
:
{
$sum
:
1
}
msgCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(msgTask)
let
callTask
=
await
db
.
collection
(
'callTask'
).
aggregate
([
...
...
@@ -101,15 +101,15 @@ app.post('/dataList', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
callCount
:
{
$sum
:
1
}
callCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(callTask)
let
companyName
=
await
db
.
collection
(
'account'
).
find
({
from
:
{
$exists
:
false
},
$or
:
[{
formID
:
{
$exists
:
false
}},
{
formID
:
{
$exists
:
true
,
$in
:
[
'self'
,
null
]}}]}).
sort
({
'date'
:
-
1
}).
toArray
()
let
companyName
=
await
db
.
collection
(
'account'
).
find
({
from
:
{
$exists
:
false
},
$or
:
[{
formID
:
{
$exists
:
false
}
},
{
formID
:
{
$exists
:
true
,
$in
:
[
'self'
,
null
]
}
}]
}).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(companyName)
let
auditDate
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'auditAt'
})
let
auditDate
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'auditAt'
})
console
.
log
(
auditDate
)
let
getCount
=
await
db
.
collection
(
'recognition'
).
aggregate
([
{
...
...
@@ -118,9 +118,9 @@ app.post('/dataList', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
getCount
:
{
$sum
:
1
}
getCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
let
dataArr
=
[]
let
item
=
{}
...
...
@@ -167,7 +167,7 @@ app.post('/dataList', async function (req, res) {
// dataArr = dataArr.slice((currentPage - 1) * pageSize, pageSize * currentPage)
// console.log(dataArr)
res
.
send
({
status
:
200
,
total
:
arrTotal
,
data
:
dataArr
})
res
.
send
({
status
:
200
,
total
:
arrTotal
,
data
:
dataArr
})
})
// 获取渠道数据
...
...
@@ -178,7 +178,7 @@ app.post('/distributor', async function (req, res) {
console
.
log
(
body
)
console
.
log
(
startTime
,
endTime
)
let
dateQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'date'
})
let
dateQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'date'
})
// console.log(dateQs)
let
results
=
await
db
.
collection
(
'dailyStats'
).
aggregate
([
...
...
@@ -188,11 +188,11 @@ app.post('/distributor', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
pv
:
{
$sum
:
'$pv'
},
uid
:
{
$sum
:
'$uid'
}
pv
:
{
$sum
:
'$pv'
},
uid
:
{
$sum
:
'$uid'
}
}
}
]).
sort
({
'date'
:
-
1
}).
toArray
()
]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(results)
let
touchCount
=
await
db
.
collection
(
'recognition'
).
aggregate
([
...
...
@@ -202,13 +202,13 @@ app.post('/distributor', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
touchCount
:
{
$sum
:
1
}
touchCount
:
{
$sum
:
1
}
}
}
]).
sort
({
'date'
:
-
1
}).
toArray
()
]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(touchCount)
let
creatQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'createdAt'
})
let
creatQs
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'createdAt'
})
console
.
log
(
creatQs
)
let
msgTask
=
await
db
.
collection
(
'task'
).
aggregate
([
...
...
@@ -218,9 +218,9 @@ app.post('/distributor', async function (req, res) {
{
$group
:
{
_id
:
'$accountID'
,
msgCount
:
{
$sum
:
1
}
msgCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(msgTask)
let
callTask
=
await
db
.
collection
(
'callTask'
).
aggregate
([
...
...
@@ -230,15 +230,15 @@ app.post('/distributor', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
callCount
:
{
$sum
:
1
}
callCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(callTask)
let
companyName
=
await
db
.
collection
(
'account'
).
find
({
fromID
:
{
$exists
:
true
,
$nin
:
[
'self'
,
null
]
}}).
sort
({
'date'
:
-
1
}).
toArray
()
let
companyName
=
await
db
.
collection
(
'account'
).
find
({
fromID
:
{
$exists
:
true
,
$nin
:
[
'self'
,
null
]
}
}).
sort
({
'date'
:
-
1
}).
toArray
()
// console.log(companyName)
let
auditDate
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'auditAt'
})
let
auditDate
=
getTimeRange
({
start
:
startTime
,
end
:
endTime
,
key
:
'auditAt'
})
console
.
log
(
auditDate
)
let
getCount
=
await
db
.
collection
(
'recognition'
).
aggregate
([
{
...
...
@@ -247,9 +247,9 @@ app.post('/distributor', async function (req, res) {
{
$group
:
{
_id
:
'$pubID'
,
getCount
:
{
$sum
:
1
}
getCount
:
{
$sum
:
1
}
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
let
dataArr
=
[]
let
item
=
{}
...
...
@@ -297,7 +297,7 @@ app.post('/distributor', async function (req, res) {
// dataArr = dataArr.slice((currentPage - 1) * pageSize, pageSize * currentPage)
// console.log(dataArr)
res
.
send
({
status
:
200
,
total
:
arrTotal
,
data
:
dataArr
})
res
.
send
({
status
:
200
,
total
:
arrTotal
,
data
:
dataArr
})
})
...
...
@@ -315,26 +315,26 @@ app.post('/consume', async function (req, res) {
let
counsume
=
await
db
.
collection
(
'bills'
).
aggregate
([
{
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
},
{
$group
:
{
_id
:
{
accountID
:
'$accountID'
,
pre
:
'$pre'
},
number
:
{
$sum
:
'$number'
}
_id
:
{
accountID
:
'$accountID'
,
pre
:
'$pre'
},
number
:
{
$sum
:
'$number'
}
}
}]).
toArray
()
console
.
log
(
counsume
)
let
companyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
companyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
data
=
[]
let
preData
=
[]
for
(
let
i
=
0
;
i
<
counsume
.
length
;
i
++
)
{
if
(
counsume
[
i
].
_id
.
pre
===
true
)
{
preData
.
push
({
_id
:
counsume
[
i
].
_id
.
accountID
,
preNumber
:
counsume
[
i
].
number
})
preData
.
push
({
_id
:
counsume
[
i
].
_id
.
accountID
,
preNumber
:
counsume
[
i
].
number
})
}
else
{
data
.
push
({
_id
:
counsume
[
i
].
_id
.
accountID
,
number
:
counsume
[
i
].
number
})
data
.
push
({
_id
:
counsume
[
i
].
_id
.
accountID
,
number
:
counsume
[
i
].
number
})
}
}
// console.log(data)
...
...
@@ -385,7 +385,7 @@ app.post('/consume', async function (req, res) {
console
.
log
(
consumeTotalNumber
)
console
.
log
(
preTotalNumber
)
// dataArr = dataArr.slice((currentPage - 1) * pageSize, pageSize * currentPage)
res
.
send
({
status
:
200
,
consumeTotalNumber
:
consumeTotalNumber
,
preTotalNumber
:
preTotalNumber
,
total
:
dataTotal
,
data
:
dataArr
})
res
.
send
({
status
:
200
,
consumeTotalNumber
:
consumeTotalNumber
,
preTotalNumber
:
preTotalNumber
,
total
:
dataTotal
,
data
:
dataArr
})
})
// 充值数据
...
...
@@ -403,12 +403,12 @@ app.post('/finance', async function (req, res) {
let
finance
=
await
db
.
collection
(
'recharge'
).
aggregate
([
{
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
},
{
$group
:
{
_id
:
'$accountID'
,
number
:
{
$sum
:
'$number'
}
number
:
{
$sum
:
'$number'
}
}
}]).
toArray
()
...
...
@@ -419,7 +419,7 @@ app.post('/finance', async function (req, res) {
company
:
'$company'
,
email
:
'$email'
}
}]).
sort
({
'date'
:
-
1
}).
toArray
()
}]).
sort
({
'date'
:
-
1
}).
toArray
()
startTime
=
moment
(
startTime
).
startOf
(
'day'
).
format
(
'YYYY-MM-DD'
)
endTime
=
moment
(
endTime
).
startOf
(
'day'
).
format
(
'YYYY-MM-DD'
)
...
...
@@ -456,7 +456,7 @@ app.post('/finance', async function (req, res) {
financeNumber
=
financeNumber
.
toFixed
(
2
)
// dataArr = dataArr.slice((currentPage - 1) * pageSize, pageSize * currentPage)
res
.
send
({
status
:
200
,
financeNumber
:
financeNumber
,
total
:
dataTolal
,
data
:
dataArr
})
res
.
send
({
status
:
200
,
financeNumber
:
financeNumber
,
total
:
dataTolal
,
data
:
dataArr
})
})
...
...
@@ -473,12 +473,12 @@ app.post('/surplus', async function (req, res) {
let
consume
=
await
db
.
collection
(
'bills'
).
aggregate
([
{
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
$match
:
{
createdAt
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}
},
{
$group
:
{
_id
:
'$accountID'
,
number
:
{
$sum
:
'$number'
}
number
:
{
$sum
:
'$number'
}
}
}]).
toArray
()
...
...
@@ -486,12 +486,12 @@ app.post('/surplus', async function (req, res) {
{
$group
:
{
_id
:
'$accountID'
,
number
:
{
$sum
:
'$number'
}
number
:
{
$sum
:
'$number'
}
}
}]).
toArray
()
let
companyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
companyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
dataArr
=
[]
...
...
@@ -536,25 +536,26 @@ app.post('/surplus', async function (req, res) {
let
dataTotal
=
dataArr
.
length
console
.
log
(
dataArr
)
// dataArr = dataArr.slice((currentPage - 1) * pageSize, pageSize * currentPage)
res
.
send
({
status
:
200
,
total
:
dataTotal
,
data
:
dataArr
,
surplusTotal
:
surPlusTotal
})
res
.
send
({
status
:
200
,
total
:
dataTotal
,
data
:
dataArr
,
surplusTotal
:
surPlusTotal
})
})
function
getTimeRange
({
start
,
end
,
key
})
{
function
getTimeRange
({
start
,
end
,
key
})
{
if
(
key
===
'date'
)
{
start
=
moment
(
start
).
startOf
(
'day'
).
format
(
'YYYYMMDD'
)
end
=
moment
(
end
).
endOf
(
'day'
).
format
(
'YYYYMMDD'
)
return
{
[
key
]:
{
'$gte'
:
start
,
'$lte'
:
end
}
return
{
[
key
]:
{
'$gte'
:
start
,
'$lte'
:
end
}
}
}
if
(
key
===
'createdAt'
)
{
start
=
moment
(
start
).
startOf
(
'day'
).
valueOf
()
end
=
moment
(
end
).
endOf
(
'day'
).
valueOf
()
return
{
[
key
]:
{
'$gte'
:
start
,
'$lte'
:
end
}
}
return
{
[
key
]:
{
'$gte'
:
start
,
'$lte'
:
end
}
}
}
if
(
key
===
'auditAt'
)
{
start
=
moment
(
start
).
startOf
(
'day'
).
valueOf
()
end
=
moment
(
end
).
endOf
(
'day'
).
valueOf
()
return
{
'auditAt'
:
{
'$gte'
:
start
,
'$lte'
:
end
},
'auditStatus'
:
{
'$eq'
:
2
}
}
return
{
'auditAt'
:
{
'$gte'
:
start
,
'$lte'
:
end
},
'auditStatus'
:
{
'$eq'
:
2
}
}
}
}
...
...
@@ -566,8 +567,8 @@ app.post('/releaseInfo', async function (req, res) {
console
.
log
(
body
)
await
db
.
collection
(
'inform'
).
insertOne
(
body
,
function
(
err
,
rep
)
{
if
(
!
err
)
{
db
.
collection
(
'account'
).
update
({},
{
$set
:
{
inform
:
true
}},
{
multi
:
true
})
res
.
send
({
status
:
200
,
message
:
'更新成功'
})
db
.
collection
(
'account'
).
update
({},
{
$set
:
{
inform
:
true
}
},
{
multi
:
true
})
res
.
send
({
status
:
200
,
message
:
'更新成功'
})
}
})
})
...
...
@@ -577,8 +578,8 @@ app.post('/releaseInfo', async function (req, res) {
app
.
post
(
'/getInfo'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入公告'
)
console
.
log
(
req
.
body
)
let
{
currentPage
,
pageSize
}
=
req
.
body
let
info
=
await
db
.
collection
(
'inform'
).
find
().
sort
({
'createdAt'
:
-
1
}).
toArray
()
let
{
currentPage
,
pageSize
}
=
req
.
body
let
info
=
await
db
.
collection
(
'inform'
).
find
().
sort
({
'createdAt'
:
-
1
}).
toArray
()
let
dataArr
=
[]
info
.
forEach
(
x
=>
{
let
item
=
{}
...
...
@@ -590,7 +591,7 @@ app.post('/getInfo', async function (req, res) {
})
let
dataArrTotal
=
dataArr
.
length
dataArr
=
dataArr
.
slice
((
currentPage
-
1
)
*
pageSize
,
pageSize
*
currentPage
)
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataArrTotal
})
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataArrTotal
})
})
// 云呼审核数据
...
...
@@ -598,7 +599,7 @@ app.post('/checkCall', async function (req, res) {
console
.
log
(
'进入了审核'
)
let
{
startTime
,
endTime
,
total
,
pageSize
,
currentPage
,
choose
}
=
req
.
body
let
{
startTime
,
endTime
,
total
,
pageSize
,
currentPage
,
choose
}
=
req
.
body
console
.
log
(
req
.
body
)
...
...
@@ -609,9 +610,9 @@ app.post('/checkCall', async function (req, res) {
console
.
log
(
startTime
)
console
.
log
(
endTime
)
let
comapnyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
comapnyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
callName
=
await
db
.
collection
(
'bills'
).
find
({
'type'
:
'dspbuynumber'
,
'groupID'
:
{
$exists
:
1
},
'createdAt'
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}).
toArray
()
let
callName
=
await
db
.
collection
(
'bills'
).
find
({
'type'
:
'dspbuynumber'
,
'groupID'
:
{
$exists
:
1
},
'createdAt'
:
{
$gt
:
startTime
,
$lte
:
endTime
}
}).
toArray
()
let
dspCallGroupsName
=
await
db
.
collection
(
'dspCallGroups'
).
find
().
toArray
()
...
...
@@ -704,7 +705,7 @@ app.post('/checkCall', async function (req, res) {
dataArr
=
dataArr
.
reverse
()
dataArr
=
dataArr
.
slice
((
currentPage
-
1
)
*
pageSize
,
currentPage
*
pageSize
)
res
.
send
({
state
:
200
,
data
:
dataArr
,
total
:
dataTotal
})
res
.
send
({
state
:
200
,
data
:
dataArr
,
total
:
dataTotal
})
})
...
...
@@ -712,21 +713,21 @@ app.post('/checkCall', async function (req, res) {
app
.
post
(
'/send'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入send'
)
console
.
log
(
req
.
body
)
let
{
taskId
,
groupId
,
interestlist
,
hostlist
,
status
}
=
req
.
body
let
{
taskId
,
groupId
,
interestlist
,
hostlist
,
status
}
=
req
.
body
if
(
status
===
8
)
{
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$unset
:
{
'checkStatus'
:
''
}
})
res
.
send
({
status
:
200
,
message
:
'状态已重置'
})
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$unset
:
{
'checkStatus'
:
''
}
})
res
.
send
({
status
:
200
,
message
:
'状态已重置'
})
}
if
(
status
===
0
)
{
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'checkStatus'
:
0
,
pre
:
false
,
number
:
0
}
})
res
.
send
({
status
:
200
,
message
:
'审核未通过'
})
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'checkStatus'
:
0
,
pre
:
false
,
number
:
0
}
})
res
.
send
({
status
:
200
,
message
:
'审核未通过'
})
}
if
(
status
===
1
)
{
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'checkStatus'
:
1
}
})
await
db
.
collection
(
'dspCallGroups'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
groupId
)},
{
$set
:
{
'interestlist'
:
interestlist
,
'hostlist'
:
hostlist
}
})
res
.
send
({
status
:
200
,
message
:
'审核通过'
})
await
db
.
collection
(
'bills'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'checkStatus'
:
1
}
})
await
db
.
collection
(
'dspCallGroups'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
groupId
)
},
{
$set
:
{
'interestlist'
:
interestlist
,
'hostlist'
:
hostlist
}
})
res
.
send
({
status
:
200
,
message
:
'审核通过'
})
}
})
...
...
@@ -735,7 +736,7 @@ app.post('/getCheckNote', async function (req, res) {
console
.
log
(
'进入了getData'
)
let
{
startTime
,
endTime
,
total
,
pageSize
,
currentPage
,
chooseId
,
operatorId
}
=
req
.
body
let
{
startTime
,
endTime
,
total
,
pageSize
,
currentPage
,
chooseId
,
operatorId
}
=
req
.
body
console
.
log
(
req
.
body
)
console
.
log
(
chooseId
)
...
...
@@ -745,13 +746,13 @@ app.post('/getCheckNote', async function (req, res) {
console
.
log
(
startTime
)
console
.
log
(
endTime
)
let
comapnyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
comapnyName
=
await
db
.
collection
(
'account'
).
find
({}).
sort
({
'date'
:
-
1
}).
toArray
()
let
msgTagName
=
await
db
.
collection
(
'msgTemps'
).
find
().
sort
({
'date'
:
-
1
}).
toArray
()
let
msgTagName
=
await
db
.
collection
(
'msgTemps'
).
find
().
sort
({
'date'
:
-
1
}).
toArray
()
let
dspGroupsName
=
await
db
.
collection
(
'dspGroups'
).
find
().
sort
({
'date'
:
-
1
}).
toArray
()
let
dspGroupsName
=
await
db
.
collection
(
'dspGroups'
).
find
().
sort
({
'date'
:
-
1
}).
toArray
()
let
dspTask
=
await
db
.
collection
(
'dspTask'
).
find
({
'createdAt'
:
{
$gte
:
startTime
,
$lte
:
endTime
}}).
sort
({
'date'
:
1
}).
toArray
()
let
dspTask
=
await
db
.
collection
(
'dspTask'
).
find
({
'createdAt'
:
{
$gte
:
startTime
,
$lte
:
endTime
}
}).
sort
({
'date'
:
1
}).
toArray
()
let
dataArr
=
[]
let
item
=
{}
...
...
@@ -797,17 +798,17 @@ app.post('/getCheckNote', async function (req, res) {
}
})
if
(
operatorId
+
''
===
'联通'
+
''
&&
(
item
.
popover
.
operator
===
undefined
||
item
.
popover
.
operator
===
'联通'
+
''
))
{
if
(
x
.
checkStatus
===
0
)
{
item
.
status
=
'审核未通过'
item
.
disable
=
true
}
else
if
(
x
.
checkStatus
===
1
)
{
item
.
status
=
'审核通过'
item
.
disable
=
true
}
else
{
item
.
status
=
'未审核'
item
.
disable
=
false
}
dataArr
.
push
(
item
)
if
(
x
.
checkStatus
===
0
)
{
item
.
status
=
'审核未通过'
item
.
disable
=
true
}
else
if
(
x
.
checkStatus
===
1
)
{
item
.
status
=
'审核通过'
item
.
disable
=
true
}
else
{
item
.
status
=
'未审核'
item
.
disable
=
false
}
dataArr
.
push
(
item
)
}
else
{
if
(
item
.
popover
.
operator
+
''
===
operatorId
+
''
)
{
if
(
x
.
status
===
0
||
x
.
status
===
undefined
)
{
...
...
@@ -839,7 +840,7 @@ app.post('/getCheckNote', async function (req, res) {
dataStatus
=
dataStatus
.
slice
((
currentPage
-
1
)
*
pageSize
,
currentPage
*
pageSize
)
}
})
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
}
if
(
chooseId
===
'one'
)
{
dataArr
.
forEach
(
x
=>
{
...
...
@@ -850,7 +851,7 @@ app.post('/getCheckNote', async function (req, res) {
}
})
console
.
log
(
dataStatus
)
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
}
if
(
chooseId
===
'two'
)
{
dataArr
.
forEach
(
x
=>
{
...
...
@@ -860,11 +861,11 @@ app.post('/getCheckNote', async function (req, res) {
dataStatus
=
dataStatus
.
slice
((
currentPage
-
1
)
*
pageSize
,
currentPage
*
pageSize
)
}
})
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
res
.
send
({
status
:
200
,
data
:
dataStatus
,
total
:
dataTotal
})
}
if
(
chooseId
===
'all'
)
{
dataArr
=
dataArr
.
slice
((
currentPage
-
1
)
*
pageSize
,
currentPage
*
pageSize
)
res
.
send
({
status
:
200
,
data
:
dataArr
,
total
:
dataTotal
})
res
.
send
({
status
:
200
,
data
:
dataArr
,
total
:
dataTotal
})
}
})
...
...
@@ -872,46 +873,46 @@ app.post('/getCheckNote', async function (req, res) {
app
.
post
(
'/sendCheckNote'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入send'
)
console
.
log
(
req
.
body
)
let
{
taskId
,
status
,
sendNum
,
operatorId
}
=
req
.
body
let
{
taskId
,
status
,
sendNum
,
operatorId
}
=
req
.
body
if
(
status
===
8
)
{
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'status'
:
0
}
})
res
.
send
({
status
:
200
,
message
:
'状态已重置'
})
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'status'
:
0
}
})
res
.
send
({
status
:
200
,
message
:
'状态已重置'
})
}
if
(
operatorId
===
'联通'
)
{
await
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
(
async
(
err
,
rep
)
=>
{
await
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
(
async
(
err
,
rep
)
=>
{
if
(
status
===
1
)
{
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'checkStatus'
:
0
}
})
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'status'
:
1
}
})
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'checkStatus'
:
0
}
})
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'status'
:
1
}
})
await
db
.
collection
(
'bills'
).
update
({
taskID
:
mongodb
.
ObjectId
(
taskId
),
pre
:
true
},
{
$set
:
{
pre
:
false
,
number
:
0
}
})
res
.
send
({
status
:
200
,
message
:
'审核未通过'
})
res
.
send
({
status
:
200
,
message
:
'审核未通过'
})
}
if
(
status
===
2
)
{
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'checkStatus'
:
1
}
})
res
.
send
({
status
:
200
,
message
:
'审核通过'
})
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'checkStatus'
:
1
}
})
res
.
send
({
status
:
200
,
message
:
'审核通过'
})
}
})
}
else
{
let
sureStatus
=
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
(
async
(
err
,
rep
)
=>
{
let
sureStatus
=
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
(
async
(
err
,
rep
)
=>
{
console
.
log
(
rep
)
if
(
!
rep
[
0
].
status
)
{
if
(
status
===
2
)
{
let
setdata
=
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'status'
:
2
,
'sendNum'
:
sendNum
}
})
let
setdata
=
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'status'
:
2
,
'sendNum'
:
sendNum
}
})
await
db
.
collection
(
'bills'
).
update
({
taskID
:
mongodb
.
ObjectId
(
taskId
),
pre
:
true
},
{
$set
:
{
pre
:
false
,
number
:
sendNum
*
0.5
}
});
res
.
send
({
status
:
200
,
message
:
'审核通过,短信发送中'
})
res
.
send
({
status
:
200
,
message
:
'审核通过,短信发送中'
})
}
if
(
status
===
1
)
{
let
setdata
=
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)},
{
$set
:
{
'status'
:
1
}
})
let
setdata
=
await
db
.
collection
(
'dspTask'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
},
{
$set
:
{
'status'
:
1
}
})
await
db
.
collection
(
'bills'
).
update
({
taskID
:
mongodb
.
ObjectId
(
taskId
),
pre
:
true
},
{
$set
:
{
pre
:
false
,
number
:
0
}
});
res
.
send
({
status
:
200
,
message
:
'审核未通过,任务驳回'
})
res
.
send
({
status
:
200
,
message
:
'审核未通过,任务驳回'
})
}
}
else
{
res
.
send
({
status
:
200
,
message
:
'状态无法更改'
})
res
.
send
({
status
:
200
,
message
:
'状态无法更改'
})
}
})
}
let
makeSure
=
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
((
err
,
res
)
=>
{
let
makeSure
=
db
.
collection
(
'dspTask'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
taskId
)
}).
toArray
((
err
,
res
)
=>
{
console
.
log
(
res
)
if
(
err
)
{
console
.
log
(
'错了'
)
}
})
...
...
@@ -921,7 +922,7 @@ app.post('/sendCheckNote', async function (req, res) {
app
.
post
(
'/getAccount'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入用户控制'
)
console
.
log
(
req
.
body
)
let
{
currentPage
,
pageSize
,
choose
}
=
req
.
body
let
{
currentPage
,
pageSize
,
choose
}
=
req
.
body
let
accounts
=
await
db
.
collection
(
'account'
).
find
().
toArray
()
let
dataArr
=
[]
let
emailArr
=
[]
...
...
@@ -954,7 +955,7 @@ app.post('/getAccount', async function (req, res) {
let
dataArrTotal
=
dataArr
.
length
dataArr
=
dataArr
.
slice
((
currentPage
-
1
)
*
pageSize
,
pageSize
*
currentPage
)
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataArrTotal
,
emailArr
:
emailArr
})
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataArrTotal
,
emailArr
:
emailArr
})
})
...
...
@@ -962,14 +963,14 @@ app.post('/getAccount', async function (req, res) {
app
.
post
(
'/deleteAccount'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入用户控制'
)
console
.
log
(
req
.
body
)
let
{
accountId
,
status
}
=
req
.
body
let
{
accountId
,
status
}
=
req
.
body
if
(
status
===
0
||
status
===
'0'
)
{
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)},
{
$set
:
{
'isDelete'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'用户注销成功'
})
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)
},
{
$set
:
{
'isDelete'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'用户注销成功'
})
}
if
(
status
===
1
||
status
===
'1'
)
{
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)},
{
$set
:
{
'isDelete'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'用户恢复成功'
})
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)
},
{
$set
:
{
'isDelete'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'用户恢复成功'
})
}
})
...
...
@@ -977,14 +978,14 @@ app.post('/deleteAccount', async function (req, res) {
app
.
post
(
'/closeBtn'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入自动备案'
)
console
.
log
(
req
.
body
)
let
{
accountId
,
status
}
=
req
.
body
let
{
accountId
,
status
}
=
req
.
body
if
(
status
===
0
||
status
===
'0'
)
{
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)},
{
$set
:
{
'isCloseAuto'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'自动备案关闭成功'
})
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)
},
{
$set
:
{
'isCloseAuto'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'自动备案关闭成功'
})
}
if
(
status
===
1
||
status
===
'1'
)
{
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)},
{
$set
:
{
'isCloseAuto'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'自动备案开启成功'
})
await
db
.
collection
(
'account'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
accountId
)
},
{
$set
:
{
'isCloseAuto'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'自动备案开启成功'
})
}
})
...
...
@@ -993,7 +994,7 @@ app.post('/getSlot', async function (req, res) {
console
.
log
(
'进入获取代码位'
)
console
.
log
(
req
.
body
)
let
{
currentPage
,
pageSize
,
choose
}
=
req
.
body
let
{
currentPage
,
pageSize
,
choose
}
=
req
.
body
let
company
=
await
db
.
collection
(
'account'
).
find
({}).
toArray
()
...
...
@@ -1033,7 +1034,7 @@ app.post('/getSlot', async function (req, res) {
dataArr
.
push
(
item
)
}
}
else
{
dataArr
.
push
(
item
)
dataArr
.
push
(
item
)
}
})
...
...
@@ -1041,29 +1042,29 @@ app.post('/getSlot', async function (req, res) {
dataArr
=
dataArr
.
slice
((
currentPage
-
1
)
*
pageSize
,
pageSize
*
currentPage
)
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataTotal
,
emailArr
:
emailArr
})
res
.
send
({
status
:
200
,
data
:
dataArr
,
dataTotal
:
dataTotal
,
emailArr
:
emailArr
})
})
// 代码位备案策略
app
.
post
(
'/slotAutoRule'
,
async
function
(
req
,
res
)
{
console
.
log
(
req
.
body
)
let
{
slotId
,
autoRule
}
=
req
.
body
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)},
{
$set
:
{
'autoRule'
:
autoRule
}
})
res
.
send
({
status
:
200
,
message
:
'备案策略更改成功'
})
let
{
slotId
,
autoRule
}
=
req
.
body
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)
},
{
$set
:
{
'autoRule'
:
autoRule
}
})
res
.
send
({
status
:
200
,
message
:
'备案策略更改成功'
})
})
// 代码位开关
app
.
post
(
'/deleteSlot'
,
async
function
(
req
,
res
)
{
console
.
log
(
'进入代码位控制'
)
console
.
log
(
req
.
body
)
let
{
slotId
,
status
}
=
req
.
body
let
{
slotId
,
status
}
=
req
.
body
if
(
status
===
0
||
status
===
'0'
)
{
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)},
{
$set
:
{
'isSlotDelete'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'代码位注销成功'
})
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)
},
{
$set
:
{
'isSlotDelete'
:
true
}
})
res
.
send
({
status
:
200
,
data
:
'代码位注销成功'
})
}
if
(
status
===
1
||
status
===
'1'
)
{
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)},
{
$set
:
{
'isSlotDelete'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'代码位恢复成功'
})
await
db
.
collection
(
'slotTemps'
).
update
({
'_id'
:
mongodb
.
ObjectId
(
slotId
)
},
{
$set
:
{
'isSlotDelete'
:
false
}
})
res
.
send
({
status
:
200
,
data
:
'代码位恢复成功'
})
}
})
...
...
@@ -1089,7 +1090,7 @@ app.post('/poolData', async function (req, res) {
dataArr
.
push
(
item
)
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
})
// 导入
...
...
@@ -1097,16 +1098,16 @@ app.post('/leadPool', async function (req, res) {
console
.
log
(
'进入营销池导入'
)
console
.
log
(
req
.
body
)
let
{
pattern
,
startTime
,
endTime
,
accountID
}
=
req
.
body
let
{
pattern
,
startTime
,
endTime
,
accountID
}
=
req
.
body
startTime
=
moment
(
startTime
).
startOf
(
'day'
).
valueOf
()
endTime
=
moment
(
endTime
).
endOf
(
'day'
).
valueOf
()
console
.
log
(
startTime
)
console
.
log
(
endTime
)
let
user
=
await
db
.
collection
(
'recognition'
).
find
({
'updateTimestamp'
:
{
$gt
:
startTime
,
$lte
:
endTime
},
pubID
:
accountID
}).
toArray
()
let
user
=
await
db
.
collection
(
'recognition'
).
find
({
'updateTimestamp'
:
{
$gt
:
startTime
,
$lte
:
endTime
},
pubID
:
accountID
}).
toArray
()
console
.
log
(
user
.
length
)
let
company
=
await
db
.
collection
(
'account'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
accountID
)
}).
toArray
()
let
company
=
await
db
.
collection
(
'account'
).
find
({
'_id'
:
mongodb
.
ObjectId
(
accountID
)
}).
toArray
()
let
poolUser
=
await
db
.
collection
(
'marketingPool'
).
find
().
toArray
()
...
...
@@ -1154,7 +1155,7 @@ app.post('/leadPool', async function (req, res) {
}
leadArr
.
forEach
(
x
=>
{
db
.
collection
(
'marketingPool'
).
insert
({
unikey
:
x
.
unikey
,
tags
:
x
.
tags
,
fromEmail
:
leadFromEmail
,
fromCompany
:
leadFromName
,
leadTime
:
leadTime
})
db
.
collection
(
'marketingPool'
).
insert
({
unikey
:
x
.
unikey
,
tags
:
x
.
tags
,
fromEmail
:
leadFromEmail
,
fromCompany
:
leadFromName
,
leadTime
:
leadTime
})
})
let
leadNumber
=
leadArr
.
length
...
...
@@ -1162,9 +1163,9 @@ app.post('/leadPool', async function (req, res) {
let
filterNumber
=
filterArr
.
length
await
db
.
collection
(
'leadTask'
).
insert
({
leadNumber
:
leadNumber
,
filterNumber
:
filterNumber
,
leadTime
:
leadTime
,
fromEmail
:
leadFromEmail
,
fromCompany
:
leadFromName
})
await
db
.
collection
(
'leadTask'
).
insert
({
leadNumber
:
leadNumber
,
filterNumber
:
filterNumber
,
leadTime
:
leadTime
,
fromEmail
:
leadFromEmail
,
fromCompany
:
leadFromName
})
res
.
send
({
status
:
200
,
message
:
'进去了'
})
res
.
send
({
status
:
200
,
message
:
'进去了'
})
})
// 营销池导入任务
...
...
@@ -1184,7 +1185,7 @@ app.post('/getLeadTask', async function (req, res) {
dataArr
.
push
(
item
)
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
})
// 获取筛选
...
...
@@ -1197,7 +1198,7 @@ app.post('/getEmail', async function (req, res) {
let
slot
=
[]
if
(
accountID
)
{
slot
=
await
db
.
collection
(
'slotTemps'
).
find
({
accountID
:
mongodb
.
ObjectId
(
accountID
)
}).
toArray
()
slot
=
await
db
.
collection
(
'slotTemps'
).
find
({
accountID
:
mongodb
.
ObjectId
(
accountID
)
}).
toArray
()
}
else
{
slot
=
await
db
.
collection
(
'slotTemps'
).
find
().
toArray
()
}
...
...
@@ -1215,19 +1216,19 @@ app.post('/getEmail', async function (req, res) {
})
slot
.
forEach
(
x
=>
{
let
item
=
{}
item
.
slotName
=
x
.
slotName
let
item
=
{}
item
.
slotName
=
x
.
slotName
item
.
slotID
=
x
.
_id
slotArr
.
push
(
item
)
})
res
.
send
({
status
:
200
,
emailArr
:
emailArr
,
slotArr
:
slotArr
})
res
.
send
({
status
:
200
,
emailArr
:
emailArr
,
slotArr
:
slotArr
})
})
// 导出
app
.
post
(
'/exprot'
,
async
function
(
req
,
res
)
{
console
.
log
(
req
.
body
)
let
{
selectUnikeyArr
,
exportDataArr
,
selectUnikeyNumber
}
=
req
.
body
let
{
selectUnikeyArr
,
exportDataArr
,
selectUnikeyNumber
}
=
req
.
body
let
exportTime
=
moment
().
valueOf
()
...
...
@@ -1237,36 +1238,43 @@ app.post('/exprot', async function (req, res) {
let
errCount
=
0
// let upsertArr = []
selectUnikeyArr
.
forEach
(
async
x
=>
{
await
db
.
collection
(
'marketingPool'
).
update
({
unikey
:
x
},
{
$addToSet
:
{
exportDataArr
:
{
$each
:
exportDataArr
}},
$inc
:
{
exportNum
:
1
}})
// exportDataArr.forEach(async y => {
// await db.collection('recognition').find({unikey: x, pubID: y.accountID, slotID: y.slotID}).toArray(async (err, response) => {
// if (err) { count(err) }
// if (response === [] || response.length === 0) {
// await db.collection('recognition').insert({unikey: x, pubID: y.accountID, slotID: y.slotID, updateTimestamp: exportTime, auditStatus: 0, score: 3, scoreTimestamp: exportTime, fromPool: true})
// count()
// } else {
// count(true)
// }
// })
// }
function
count
(
err
)
{
allCount
++
if
(
err
)
{
errCount
++
}
else
{
createRecogNum
++
}
if
(
allCount
===
selectUnikeyArr
.
length
*
exportDataArr
.
length
)
{
console
.
log
(
'存入任务表中'
)
console
.
log
(
errCount
,
createRecogNum
)
db
.
collection
(
'exportTask'
).
insert
({
'exportUnikeyNumber'
:
selectUnikeyNumber
,
createRecogNum
:
createRecogNum
,
exportTime
:
exportTime
,
exportDataArr
:
exportDataArr
})
res
.
send
({
status
:
200
,
message
:
'导出了'
})
}
}
await
db
.
collection
(
'marketingPool'
).
update
({
unikey
:
x
},
{
$addToSet
:
{
exportDataArr
:
{
$each
:
exportDataArr
}
},
$inc
:
{
exportNum
:
1
}
})
exportDataArr
.
forEach
(
async
y
=>
{
// let { upsertId } = await db.collection('recognition').updateOne({unikey: x, pubID: y.accountID, slotID: y.slotID},{},{upsert: true}).catch(err => { console.log(err)})
// upsertArr.push(upsertId._id)
// await db.collection('recognition').updateMany()
await
db
.
collection
(
'recognition'
).
find
({
unikey
:
x
,
pubID
:
y
.
accountID
,
slotID
:
y
.
slotID
}).
toArray
(
async
(
err
,
response
)
=>
{
if
(
err
)
{
count
(
err
)
}
if
(
response
===
[]
||
response
.
length
===
0
)
{
await
db
.
collection
(
'recognition'
).
insert
({
unikey
:
x
,
pubID
:
y
.
accountID
,
slotID
:
y
.
slotID
,
updateTimestamp
:
exportTime
,
auditStatus
:
0
,
score
:
3
,
scoreTimestamp
:
exportTime
,
fromPool
:
true
})
count
()
}
else
{
count
(
true
)
}
})
})
})
function
count
(
err
)
{
allCount
++
if
(
err
)
{
errCount
++
}
else
{
createRecogNum
++
}
if
(
allCount
===
selectUnikeyArr
.
length
*
exportDataArr
.
length
)
{
console
.
log
(
'存入任务表中'
)
console
.
log
(
errCount
,
createRecogNum
)
db
.
collection
(
'exportTask'
).
insert
({
'exportUnikeyNumber'
:
selectUnikeyNumber
,
createRecogNum
:
createRecogNum
,
exportTime
:
exportTime
,
exportDataArr
:
exportDataArr
})
res
.
send
({
status
:
200
,
message
:
'导出了'
})
}
}
})
// 导出任务列表
...
...
@@ -1287,7 +1295,7 @@ app.post('/getExportTask', async function (req, res) {
dataArr
.
push
(
item
)
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
res
.
send
({
status
:
200
,
datas
:
dataArr
})
})
module
.
exports
=
app
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