Commit 596a5c2d authored by yaobeibei's avatar yaobeibei

add xibao

parent 1febb1b9
...@@ -26,6 +26,7 @@ if (process.env.MONGO) { ...@@ -26,6 +26,7 @@ if (process.env.MONGO) {
var db = {} var db = {}
var db_oem_mtty = {} var db_oem_mtty = {}
var db_oem_xibao = {}
mongoClient.connect(dbpath, function (err, res) { mongoClient.connect(dbpath, function (err, res) {
...@@ -38,8 +39,10 @@ mongoClient.connect(dbpath_oem, function (err, res) { ...@@ -38,8 +39,10 @@ mongoClient.connect(dbpath_oem, function (err, res) {
if (process.env.MONGO) { if (process.env.MONGO) {
db_oem_mtty = res.db('oem_mtty_remarketing') db_oem_mtty = res.db('oem_mtty_remarketing')
db_oem_xibao = res.db('oem_xibao_remarketing')
} else { } else {
db_oem_mtty = res.db('remarketing2') db_oem_mtty = res.db('remarketing2')
db_oem_xibao = res.db('remarketing3')
} }
}) })
...@@ -786,15 +789,17 @@ app.post('/checkCall', async function (req, res) { ...@@ -786,15 +789,17 @@ app.post('/checkCall', async function (req, res) {
} }
}) })
let oem_comapnyName = await db_oem_mtty.collection('account').find({}).sort({ 'date': -1 }).toArray()
let oem_callName = await db_oem_mtty.collection('bills').find({ 'type': 'dspbuynumber', 'groupID': { $exists: 1 }, 'createdAt': { $gt: startTime, $lte: endTime }, 'oemCheckStatus': 1}).toArray() // 获取麦田
let oem_mtty_comapnyName = await db_oem_mtty.collection('account').find({}).sort({ 'date': -1 }).toArray()
let oem_dspCallGroupsName = await db_oem_mtty.collection('dspCallGroups').find().toArray() let oem_mtty_callName = await db_oem_mtty.collection('bills').find({ 'type': 'dspbuynumber', 'groupID': { $exists: 1 }, 'createdAt': { $gt: startTime, $lte: endTime }, 'oemCheckStatus': 1}).toArray()
let oem_mtty_dspCallGroupsName = await db_oem_mtty.collection('dspCallGroups').find().toArray()
oem_callName.forEach(x => {
oem_mtty_callName.forEach(x => {
let item = {} let item = {}
item.oem = x.oem item.oem = x.oem
item.preNum = x.preNum / 3 item.preNum = x.preNum / 3
...@@ -805,12 +810,12 @@ app.post('/checkCall', async function (req, res) { ...@@ -805,12 +810,12 @@ app.post('/checkCall', async function (req, res) {
} }
item.time = moment(x.createdAt).format('YYYY-MM-DD HH:mm') item.time = moment(x.createdAt).format('YYYY-MM-DD HH:mm')
console.log(item.time) console.log(item.time)
oem_comapnyName.forEach(y => { oem_mtty_comapnyName.forEach(y => {
if (x.accountID + '' === y._id + '' || x.accountID === y._id) { if (x.accountID + '' === y._id + '' || x.accountID === y._id) {
item.companyName = y.company item.companyName = y.company
} }
}) })
oem_dspCallGroupsName.forEach(z => { oem_mtty_dspCallGroupsName.forEach(z => {
if (x.groupID + '' === z._id + '' || x.groupID === z._id) { if (x.groupID + '' === z._id + '' || x.groupID === z._id) {
console.log(z.dspgroup) console.log(z.dspgroup)
item.name = x._id item.name = x._id
...@@ -877,6 +882,97 @@ app.post('/checkCall', async function (req, res) { ...@@ -877,6 +882,97 @@ app.post('/checkCall', async function (req, res) {
}) })
// 获取喜宝
let oem_xibao_comapnyName = await db_oem_xibao.collection('account').find({}).sort({ 'date': -1 }).toArray()
let oem_xibao_callName = await db_oem_xibao.collection('bills').find({ 'type': 'dspbuynumber', 'groupID': { $exists: 1 }, 'createdAt': { $gt: startTime, $lte: endTime }, 'oemCheckStatus': 1}).toArray()
let oem_xibao_dspCallGroupsName = await db_oem_xibao.collection('dspCallGroups').find().toArray()
oem_xibao_callName.forEach(x => {
let item = {}
item.oem = x.oem
item.preNum = x.preNum / 3
if (x.pre === false) {
item.sendNum = x.number / 3
} else {
item.sendNum = 0
}
item.time = moment(x.createdAt).format('YYYY-MM-DD HH:mm')
console.log(item.time)
oem_xibao_comapnyName.forEach(y => {
if (x.accountID + '' === y._id + '' || x.accountID === y._id) {
item.companyName = y.company
}
})
oem_xibao_dspCallGroupsName.forEach(z => {
if (x.groupID + '' === z._id + '' || x.groupID === z._id) {
console.log(z.dspgroup)
item.name = x._id
item.groupID = z._id
item.popover = {}
if (z.sexlist.length === 1) {
item.popover.sexlist = z.sexlist
} else {
item.popover.sexlist = '不限'
}
item.popover.citylist = z.citylist
item.popover.agelist = z.agelist
if (z.businesstypelist.length === 3) {
item.popover.businesstypelist = '不限'
} else {
item.popover.businesstypelist = z.businesstypelist
}
item.popover.phonelist = z.phonelist
item.popover.opsystemlist = z.opsystemlist
item.popover.consumelist = z.consumelist
item.popover.flowlist = z.flowlist
item.popover.hobbylist = z.hobbylist
item.popover.interestlist = z.interestlist
item.popover.hostlist = z.hostlist
}
})
if (item.popover) {
if (choose === 'zero' && x.checkStatus === undefined) {
console.log(choose)
item.status = '未审核'
dataArr.push(item)
}
if (choose === 'one' && x.checkStatus === 0) {
console.log(choose)
item.status = '审核未通过'
item.disable = true
dataArr.push(item)
}
if (choose === 'two' && (x.checkStatus === 1)) {
console.log(choose)
item.status = '审核通过'
item.disable = true
dataArr.push(item)
}
if (choose === 'all') {
console.log(choose)
if (x.checkStatus === undefined) {
item.status = '未审核'
item.disable = false
}
if (x.checkStatus === 0) {
item.status = '审核未通过'
item.disable = true
}
if (x.checkStatus === 1) {
item.status = '审核通过'
item.disable = true
}
// console.log(item)
dataArr.push(item)
}
}
})
...@@ -900,8 +996,10 @@ app.post('/send', async function (req, res) { ...@@ -900,8 +996,10 @@ app.post('/send', async function (req, res) {
if (status === 8) { if (status === 8) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } }) await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
} else { } else if (oem === '麦田'){
await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } }) await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
} else {
await db_oem_xibao.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
} }
res.send({ status: 200, message: '状态已重置' }) res.send({ status: 200, message: '状态已重置' })
} }
...@@ -909,8 +1007,10 @@ app.post('/send', async function (req, res) { ...@@ -909,8 +1007,10 @@ app.post('/send', async function (req, res) {
if (status === 0) { if (status === 0) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0, pre: false, number: 0 } }) await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0, pre: false, number: 0 } })
} else { } else if (oem === '麦田'){
await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0, pre: false, number: 0 } }) await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0, pre: false, number: 0 } })
} else {
await db_oem_xibao.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0, pre: false, number: 0 } })
} }
res.send({ status: 200, message: '审核未通过' }) res.send({ status: 200, message: '审核未通过' })
} }
...@@ -918,9 +1018,12 @@ app.post('/send', async function (req, res) { ...@@ -918,9 +1018,12 @@ app.post('/send', async function (req, res) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 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 } }) await db.collection('dspCallGroups').update({ '_id': mongodb.ObjectId(groupId) }, { $set: { 'interestlist': interestlist, 'hostlist': hostlist } })
} else { } else if (oem === '麦田'){
await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } }) await db_oem_mtty.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } })
await db_oem_mtty.collection('dspCallGroups').update({ '_id': mongodb.ObjectId(groupId) }, { $set: { 'interestlist': interestlist, 'hostlist': hostlist } }) await db_oem_mtty.collection('dspCallGroups').update({ '_id': mongodb.ObjectId(groupId) }, { $set: { 'interestlist': interestlist, 'hostlist': hostlist } })
} else {
await db_oem_xibao.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } })
await db_oem_xibao.collection('dspCallGroups').update({ '_id': mongodb.ObjectId(groupId) }, { $set: { 'interestlist': interestlist, 'hostlist': hostlist } })
} }
...@@ -1029,17 +1132,17 @@ app.post('/getCheckNote', async function (req, res) { ...@@ -1029,17 +1132,17 @@ app.post('/getCheckNote', async function (req, res) {
} }
}) })
// 获取oem // 获取麦田
let oem_comapnyName = await db_oem_mtty.collection('account').find({}).sort({ 'date': -1 }).toArray() let oem_mtty_comapnyName = await db_oem_mtty.collection('account').find({}).sort({ 'date': -1 }).toArray()
let oem_msgTagName = await db_oem_mtty.collection('msgTemps').find().sort({ 'date': -1 }).toArray() let oem_mtty_msgTagName = await db_oem_mtty.collection('msgTemps').find().sort({ 'date': -1 }).toArray()
let oem_dspGroupsName = await db_oem_mtty.collection('dspGroups').find().sort({ 'date': -1 }).toArray() let oem_mtty_dspGroupsName = await db_oem_mtty.collection('dspGroups').find().sort({ 'date': -1 }).toArray()
let oem_dspTask = await db_oem_mtty.collection('dspTask').find({ 'createdAt': { $gte: startTime, $lte: endTime }, 'oemCheckStatus': 1 }).sort({ 'date': 1 }).toArray() let oem_mtty_dspTask = await db_oem_mtty.collection('dspTask').find({ 'createdAt': { $gte: startTime, $lte: endTime }, 'oemCheckStatus': 1 }).sort({ 'date': 1 }).toArray()
oem_dspTask.forEach(x => { oem_mtty_dspTask.forEach(x => {
let item = {} let item = {}
item.taskID = x._id item.taskID = x._id
item.oem = x.oem item.oem = x.oem
...@@ -1053,18 +1156,18 @@ app.post('/getCheckNote', async function (req, res) { ...@@ -1053,18 +1156,18 @@ app.post('/getCheckNote', async function (req, res) {
item.sendNum = x.sendNum item.sendNum = x.sendNum
} }
item.createdAt = moment(x.createdAt).format('YYYY-MM-DD HH:mm:ss') item.createdAt = moment(x.createdAt).format('YYYY-MM-DD HH:mm:ss')
oem_comapnyName.forEach(y => { oem_mtty_comapnyName.forEach(y => {
if (x.accountID + '' === y._id + '') { if (x.accountID + '' === y._id + '') {
item.companyName = y.company item.companyName = y.company
} }
}) })
oem_msgTagName.forEach(z => { oem_mtty_msgTagName.forEach(z => {
if (x.templateId + '' === z._id + '' && x.accountID + '' === z.accountID + '') { if (x.templateId + '' === z._id + '' && x.accountID + '' === z.accountID + '') {
item.msgName = z.name item.msgName = z.name
item.msgContent = z.content item.msgContent = z.content
} }
}) })
oem_dspGroupsName.forEach(m => { oem_mtty_dspGroupsName.forEach(m => {
if (x.groupID + '' === m._id + '' && x.accountID === m.accountID) { if (x.groupID + '' === m._id + '' && x.accountID === m.accountID) {
item.popover = { item.popover = {
sexlist: m.sexlist, sexlist: m.sexlist,
...@@ -1112,8 +1215,89 @@ app.post('/getCheckNote', async function (req, res) { ...@@ -1112,8 +1215,89 @@ app.post('/getCheckNote', async function (req, res) {
} }
} }
}) })
// 获取喜宝
let oem_xibao_comapnyName = await db_oem_xibao.collection('account').find({}).sort({ 'date': -1 }).toArray()
let oem_xibao_msgTagName = await db_oem_xibao.collection('msgTemps').find().sort({ 'date': -1 }).toArray()
let oem_xibao_dspGroupsName = await db_oem_xibao.collection('dspGroups').find().sort({ 'date': -1 }).toArray()
let oem_xibao_dspTask = await db_oem_xibao.collection('dspTask').find({ 'createdAt': { $gte: startTime, $lte: endTime }, 'oemCheckStatus': 1 }).sort({ 'date': 1 }).toArray()
oem_xibao_dspTask.forEach(x => {
let item = {}
item.taskID = x._id
item.oem = x.oem
item.taskName = x.taskName
item.accountID = x.accountID
item.sendTime = moment(x.sendTime).format('YYYY-MM-DD HH:mm:ss')
item.preSendNum = x.nums
if (x.sendNum === null) {
item.sendNum = 0
} else {
item.sendNum = x.sendNum
}
item.createdAt = moment(x.createdAt).format('YYYY-MM-DD HH:mm:ss')
oem_xibao_comapnyName.forEach(y => {
if (x.accountID + '' === y._id + '') {
item.companyName = y.company
}
})
oem_xibao_msgTagName.forEach(z => {
if (x.templateId + '' === z._id + '' && x.accountID + '' === z.accountID + '') {
item.msgName = z.name
item.msgContent = z.content
}
})
oem_xibao_dspGroupsName.forEach(m => {
if (x.groupID + '' === m._id + '' && x.accountID === m.accountID) {
item.popover = {
sexlist: m.sexlist,
agelist: m.agelist,
businesstypelist: m.businesstypelist,
phonelist: m.phonelist,
opsystemlist: m.opsystemlist,
consumelist: m.consumelist,
flowlist: m.flowlist,
citylist: m.citylist,
hobbylist: m.hobbylist
}
if (m.operator) {
item.popover.operator = m.operator
}
}
})
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)
} else {
if (item.popover.operator + '' === operatorId + '') {
if (x.status === 0 || x.status === undefined) {
item.status = '未审核'
item.disable = false
}
if (x.status === 1) {
item.status = '审核未通过'
item.disable = true
}
if (x.status === 2) {
item.status = '审核通过'
item.disable = true
}
dataArr.push(item)
}
}
})
...@@ -1178,20 +1362,25 @@ app.post('/sendCheckNote', async function (req, res) { ...@@ -1178,20 +1362,25 @@ app.post('/sendCheckNote', async function (req, res) {
await db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0 } }) 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: { 'status': 1 } })
await db.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } }) await db.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } })
} else { } else if (oem === '麦田') {
await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0 } }) await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0 } })
await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } }) await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } })
await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } }) await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } })
} else {
await db_oem_xibao.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 0 } })
await db_oem_xibao.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } })
await db_oem_xibao.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) { if (status === 2) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } }) await db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } })
} else { } else if ( oem === '麦田'){
await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } }) await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } })
} else {
await db_oem_xibao.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'checkStatus': 1 } })
} }
res.send({ status: 200, message: '审核通过' }) res.send({ status: 200, message: '审核通过' })
} }
}) })
...@@ -1203,9 +1392,12 @@ app.post('/sendCheckNote', async function (req, res) { ...@@ -1203,9 +1392,12 @@ app.post('/sendCheckNote', async function (req, res) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 2, 'sendNum': sendNum } }) 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 } }); await db.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: sendNum * 0.5 } });
} else { } else if (oem === '麦田'){
await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 2, 'sendNum': sendNum } }) await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 2, 'sendNum': sendNum } })
await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: sendNum * 0.5 } }); await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: sendNum * 0.5 } });
} else {
await db_oem_xibao.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 2, 'sendNum': sendNum } })
await db_oem_xibao.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: '审核通过,短信发送中' })
...@@ -1214,9 +1406,12 @@ app.post('/sendCheckNote', async function (req, res) { ...@@ -1214,9 +1406,12 @@ app.post('/sendCheckNote', async function (req, res) {
if (oem === '微聚合' || oem === null || oem === undefined) { if (oem === '微聚合' || oem === null || oem === undefined) {
await db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } }) 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 } }); await db.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } });
} else { } else if (oem === '喜宝'){
await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } }) await db_oem_mtty.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } })
await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } }); await db_oem_mtty.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } });
} else {
await db_oem_xibao.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 1 } })
await db_oem_xibao.collection('bills').update({ taskID: mongodb.ObjectId(taskId), pre: true }, { $set: { pre: false, number: 0 } });
} }
res.send({ status: 200, message: '审核未通过,任务驳回' }) res.send({ status: 200, message: '审核未通过,任务驳回' })
......
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