Commit 329dc106 authored by 刘松's avatar 刘松

init

parents
node_modules
babelCache
draft/
config/dev.js
app/built/
.vscode
*.logs
*.log
.DS_Store
package-lock.json
### Health check 'curl /ping'
FROM reg.yunpro.cn/library/node:9.11.1
WORKDIR /app
ADD . /app/
ENV PORT=8010
ENV PROJECT_LEVEL=production
ENV MONGO_DB='mongodb://wjh:c9yJ2gBFkp7U6@mongo-bjwjh-v4-1:1304,mongo-bjwjh-v4-2:1304,mongo-bjwjh-v4-3:1304/remarketingv3?replicaSet=bjwjh-v4'
ENV NODE_ENV='production'
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
let accountMap = {};
let accounts = await account.find({}).toArray();
let agents = await agent.find({}).toArray();
let accountIDs = [];
let agentMap = {};
let fromMap = {};
accounts.forEach(({email,company,_id,fromID}) => {
accountIDs.push(_id);
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
agents.forEach(({email,company,_id}) => {
accountIDs.push(_id);
agentMap[ _id + ''] = email + '[' + company + ']'
})
let typeMap = {
msg: '短信(联通)',
call: '云呼(联通)',
tycall: '精选云呼(电信)',
audit: '备案',
dsp: '精选短信(联通)',
dspcall: '精选云呼(联通)',
dspbuynumber: '精选备案(联通)',
dspbuynumber_ctcc: '精选备案(电信)',
dsp_ctcc: '精选短信(电信)',
urlbuynumber: '网址取号备案',
device: '设备'
}
let data = [['代理商','总余额','预扣账单/金额']];
let _count = 0;
let datas = await agent.find({ "role" : 2 }).toArray();
let tasks = [];
datas.forEach( async ({ email, company, balance,role, preNumber }) => {
data.push([email + company,balance, (preNumber || []).map( x => x.billID + '') ]);
_count ++;
if(_count === datas.length) {
data = data.map( (x,i) => {
return (x.length ? x : []).concat([_arrs[i] || 0])
})
data = header.concat(data);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./代理商信息.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
module.exports = {
mongo: process.env.MONGO || "mongodb://10.11.3.61:1301/remarketing?poolSize=100000000"
}
\ No newline at end of file
'use strict';
const mongodb = require('mongodb');
const config = require('./config');
const MongoClient = mongodb.MongoClient;
const dbpath = config.mongo;
let db = {};
let agentDb = {};
let newDb = {};
async function getDb() {
const conn = await MongoClient.connect(dbpath);
db = conn.db("remarketing");
return db;
}
async function getAgentDb() {
const conn = await MongoClient.connect(dbpath);
agentDb = conn.db("remarketingAgent");
return agentDb;
}
async function getNewDb() {
const conn = await MongoClient.connect('mongodb://wjh:c9yJ2gBFkp7U6@10.11.3.136:1304,10.11.3.137:1304,10.11.3.134:1304/remarketingv3?replicaSet=bjwjh-v4');
newDb = conn.db("remarketingv3");
return newDb;
}
async function getCollection (collectionName)
{
if(!db.collection) {
const db = await getDb();
return db.collection(collectionName);
}
else return db.collection(collectionName);
}
async function getAgentCollection (collectionName)
{
if(!agentDb.collection) {
const agentDb = await getAgentDb();
return agentDb.collection(collectionName);
}
else return agentDb.collection(collectionName);
}
async function getNewCollection (collectionName)
{
if(!newDb.collection) {
const newDb = await getNewDb();
return newDb.collection(collectionName);
}
else return newDb.collection(collectionName);
}
module.exports = {
getCollection: getCollection,
getNewCollection: getNewCollection,
getAgentCollection: getAgentCollection,
ObjectID: mongodb.ObjectID
};
const stats = require('./module/stats');
try {
stats.start();
} catch(err) {
console.dir(err);
}
\ No newline at end of file
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const account = await db.getCollection('account');
const charge = await db.getCollection('recharge');
let data = [['直客账号','直客公司','代理商账户','代理商公司','备注','日期','直客充值','直客户订单数','最近一次下单','最近一次反数']];
let _count = 0;
let accounts = await account.find({}).toArray();
let agents = await agent.find({}).toArray();
let charges = await charge.find({}).toArray();
let roleMap = {};
let companyMap = {}
let agentMap = {};
let accountMap = {};
let accountcompanyMap = {};
let fromMap = {};
agents.forEach(({email,company,_id, role}) => {
//accountIDs.push(_id);
agentMap[ _id + ''] = email;
roleMap[ _id + ''] = role;
companyMap[ _id + ''] = company;
})
accounts.forEach(({email,company,_id,fromID}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
let tasks = [];
charges.forEach( async ({ number, accountID, meta, createdAt }) => {
data.push([ number, accountMap[accountID + ''],accountcompanyMap[ accountID + ''], agentMap[ fromMap[accountID + '']], companyMap[fromMap[accountID + '']], meta, moment(createdAt).format('YYYY-MM-DD HH') ]);
_count ++;
if(_count === charges.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./充值信息.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const charge = await db.getAgentCollection('charge');
let data = [['代理商充值','账号','公司','角色','备注','日期']];
let _count = 0;
let agents = await agent.find({}).toArray();
let charges = await charge.find({oper:"admin@goyoo.com"}).toArray();
let roleMap = {};
let companyMap = {}
let agentMap = {};
agents.forEach(({email,company,_id, role}) => {
//accountIDs.push(_id);
agentMap[ _id + ''] = email;
roleMap[ _id + ''] = role;
companyMap[ _id + ''] = company;
})
let tasks = [];
charges.forEach( async ({ money, date, accountID, oper,meta }) => {
if(roleMap[ accountID + ''] == 2) data.push([ money, agentMap[accountID + ''],companyMap[ accountID + ''], roleMap[ accountID + ''], meta, moment(date).format('YYYY-MM-DD HH') ]);
_count ++;
if(_count === charges.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./代理商充值信息.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
let data = [['代理商','总余额','显示余额','预扣账单/金额']];
let _count = 0;
let datas = await agent.find({ "role" : 2 }).toArray();
let tasks = [];
datas.forEach( async ({ email, company, balance,role, preNumber }) => {
let count = 0;
for(var k in preNumber) {
count += (preNumber[k].number || 0)
}
data.push([email + company,balance, balance - count, (preNumber || []).map( x => x.billID + '') ]);
_count ++;
if(_count === datas.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./代理商信息.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
var a = [{"p":"直辖市","c":["北京","天津","上海","重庆"]},{"p":"河北","c":["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"]},{"p":"山西","c":["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"]},{"p":"内蒙古","c":["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"]},{"p":"辽宁","c":["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"]},{"p":"吉林","c":["长春","吉林","四平","辽源","通化","白山","松原","白城","延边"]},{"p":"黑龙江","c":["哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","大兴安岭"]},{"p":"江苏","c":["南京","无锡","徐州","常州","苏州","南通","连云港","淮安","盐城","扬州","镇江","泰州","宿迁"]},{"p":"浙江","c":["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"]},{"p":"安徽","c":["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城"]},{"p":"福建","c":["福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德"]},{"p":"江西","c":["南昌","景德镇","萍乡","九江","新余","鹰潭","赣州","吉安","宜春","抚州","上饶"]},{"p":"山东","c":["济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","菏泽"]},{"p":"河南","c":["郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店","济源"]},{"p":"湖北","c":["武汉","黄石","十堰","宜昌","襄樊","鄂州","荆门","孝感","荆州","黄冈","咸宁","随州","恩施","仙桃","潜江","天门","神农架"]},{"p":"湖南","c":["长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","湘西"]},{"p":"广东","c":["广州","韶关","深圳","珠海","汕头","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭阳","云浮"]},{"p":"广西","c":["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"]},{"p":"海南","c":["海口","三亚","五指山","琼海","儋州","文昌","万宁","东方"]},{"p":"四川","c":["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","眉山","宜宾","广安","达川","雅安","巴中","资阳","阿坝","甘孜","凉山"]},{"p":"贵州","c":["贵阳","六盘水","遵义","安顺","铜仁","黔西南","毕节","黔东南","黔南"]},{"p":"云南","c":["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","楚雄","红河","文山","西双版纳","大理","德宏","怒江傈","迪庆"]},{"p":"西藏","c":["拉萨","昌都","山南","日喀则","那曲","阿里","林芝"]},{"p":"陕西","c":["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"]},{"p":"甘肃","c":["兰州","嘉峪关","金昌","白银","天水","武威","张掖","平凉","酒泉","庆阳","定西","陇南","临夏","甘南"]},{"p":"青海","c":["西宁","海东","海北","黄南","海南","果洛","玉树","梅西"]},{"p":"宁夏","c":["银川","石嘴山","吴忠","固原","中卫"]},{"p":"新疆","c":["乌鲁木齐","克拉玛依","吐鲁番","哈密","昌吉","博尔塔拉","巴音郭楞","阿克苏","克孜勒苏","喀什","和田","伊犁","塔城","阿勒泰","石河子","阿拉尔","图木舒克","五家渠"]},{"p":"地区","c":["香港","澳门","台湾"]}]
let map = {};
a.forEach(x => {
let p = x.p ;
x.c.forEach( y => {
map[y] = (p === '直辖市' ? y : p);
});
});
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const bills = await db.getCollection('bills');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {};
let agentcompanyMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data;
}
})
let _count = 0;
let query = { _id : {'$in' : [
"5bf639b62e4fb2000782715c",
"5bf4fba52e4fb20007826ffb",
"5bf4d1d92e4fb20007826fb4",
"5bf4ce2a2e4fb20007826fa7",
"5bf38c8e2e4fb20007826da4",
"5bf3719c2e4fb20007826cdb",
"5bf36dc52e4fb20007826cb7",
"5bf368cb2e4fb20007826c91",
"5bf3666e2e4fb20007826c7c",
"5bf35c112e4fb20007826c3a",
"5bf25a1e2e4fb20007826b15",
"5bf22c502e4fb20007826a94",
"5bf2191a2e4fb20007826a28",
"5bee77a7e3ec3033c82d7ff2",
"5bee3dfe2e4fb200078266f1",
"5bee3c092e4fb200078266e4",
"5bee36e82e4fb200078266bd",
"5bee2e7e2e4fb200078266a4",
"5bee2e532e4fb200078266a0",
"5bee2777c5ed930007209d93",
"5bed5b85c5ed930007209d0a",
"5bed47f8c5ed930007209cf6",
"5bed22e8e17798293e8d883c",
"5bed1eedc5ed930007209c0c",
"5bece2f2537c8d0007db60b1",
"5becde87537c8d0007db60a1",
"5becdaf3537c8d0007db6085",
"5beaaf4c537c8d0007db5d94",
"5bea8eb8537c8d0007db5ce8",
"5bea3997232b830007e19cfc",
"5bea2af7232b830007e19c6c",
"5be95630232b830007e19bc7",
"5be93109232b830007e19b06",
"5be8e3bd232b830007e199bf"].map( x => db.ObjectID(x) )}}
console.dir(query);
let arrs = await bills.find(query).limit(1000000000000).toArray();
let data = [['任务名称','类型','客户筛选标签','省分','城市']];
console.dir(arrs.length + '====>');
arrs.forEach( async ({ _id, groupID }) => {
let group = groupMap[groupID];
_count ++;
if(group) {
let areas = [];
let citylist = group.citylist || [];
let provincelist = group.provincelist || [];
let cityMap = {};
citylist.forEach( x => {
provincelist = provincelist.concat(map[x]);
cityMap[map[x]] = (cityMap[map[x]] || []).concat(x)
});
provincelist.forEach( x => {
areas.push([x, (cityMap[x] || []).join(',') ])
})
let interestlist = group.interestlist || [];
let applist = group.applist || [];
let hostlist = group.hostlist || []
areas.forEach( x => {
interestlist.forEach( y => {
data.push([_id + '', '关键字', y ].concat(x))
})
applist.forEach( z => {
data.push([_id + '', 'APP', z ].concat(x))
})
hostlist.forEach( m => {
data.push([_id + '', '域名', m ].concat(x))
})
})
}
if(_count === arrs.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./area1.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const url = require('url');
const moment = require('moment');
let max = 0;
async function task(argument) {
const account = await db.getCollection('account');
const bills = await db.getCollection('bills');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
let tagMap = {}
let tagMap1 = {}
let listMap = {}
let cityMap = {}
let appMap = {}
let hostMap = {}
let keyMap = {}
let zhuMap = {}
let zhuMap1 = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data.dspgroup;
}
// max = Math.max(max,data['applist'].length);
console.dir(data.dspgroup);
listMap[data._id + ''] = data['hostlist'] || [];
zhuMap[data._id + ''] = (data['hostlist'] || []).map( x => url.parse(x).host || x);
zhuMap1[data._id + ''] = zhuMap[data._id + ''].map( x => x.replace(/www./, ""));
cityMap[data._id + ''] = (data['citylist'] || []).concat(data['provincelist'] || [])
keyMap[data._id + ''] = data['interestlist']
hostMap[data._id + ''] = data['hostlist']
appMap[data._id + ''] = data['applist']
for(var k in data) {
if(k !== '_id' && k !== 'dspgroup') {
if(k !== 'applist' && k !== 'hostlist' && k !== 'interestlist')
tagMap[data._id + ''] = (tagMap[data._id + ''] || []).concat(Array.isArray(data[k]) ? data[k] : [data[k]])
else
tagMap1[data._id + ''] = (tagMap1[data._id + ''] || []).concat(Array.isArray(data[k]) ? data[k] : [data[k]])
}
}
})
console.dir(groupMap);
let data = [['id','公司','meta','提交时间','用户组','地区','关键词','域名','主域名','去www域名','app','预计','实际','状态']];
//let data = [];
let ids= [
"5bf639b62e4fb2000782715c",
"5bf4fba52e4fb20007826ffb",
"5bf4d1d92e4fb20007826fb4",
"5bf4ce2a2e4fb20007826fa7",
"5bf38c8e2e4fb20007826da4",
"5bf3719c2e4fb20007826cdb",
"5bf36dc52e4fb20007826cb7",
"5bf368cb2e4fb20007826c91",
"5bf3666e2e4fb20007826c7c",
"5bf35c112e4fb20007826c3a",
"5bf25a1e2e4fb20007826b15",
"5bf22c502e4fb20007826a94",
"5bf2191a2e4fb20007826a28",
"5bee77a7e3ec3033c82d7ff2",
"5bee3dfe2e4fb200078266f1",
"5bee3c092e4fb200078266e4",
"5bee36e82e4fb200078266bd",
"5bee2e7e2e4fb200078266a4",
"5bee2e532e4fb200078266a0",
"5bee2777c5ed930007209d93",
"5bed5b85c5ed930007209d0a",
"5bed47f8c5ed930007209cf6",
"5bed22e8e17798293e8d883c",
"5bed1eedc5ed930007209c0c",
"5bece2f2537c8d0007db60b1",
"5becde87537c8d0007db60a1",
"5becdaf3537c8d0007db6085",
"5beaaf4c537c8d0007db5d94",
"5bea8eb8537c8d0007db5ce8",
"5bea3997232b830007e19cfc",
"5bea2af7232b830007e19c6c",
"5be95630232b830007e19bc7",
"5be93109232b830007e19b06",
"5be8e3bd232b830007e199bf"].map(x => db.ObjectID(x) );
let _arrs = await account.find({ }).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
let _count = 0;
/*let metas = {
meta: {
}
}*/
let arrs = await bills.find({type:{ $in:["dspbuynumber","dspbuynumber_ctcc"] }}).limit(1000000000000).toArray();
let map = {};
console.dir(arrs.length);
arrs.forEach( async ({date, _id, groupID, meta, accountID, preNum, info, pre }) => {
/* if(groupID) {
let group = groupID + '';
data.push([ _id+'', meta, groupMap[group], tagMap[group] ])
}*/
let group = groupID + '';
data.push([ _id+'', accountMap[accountID + ''], meta, date, groupMap[group], cityMap[group], keyMap[group], hostMap[group], zhuMap[group], zhuMap1[group], appMap[group], preNum/3, info ? info.qty : 0, pre ? '进行中' : '已关闭' ])
// data.push([ _id+'',meta].concat(listMap[group]));
++_count;
//console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./订单hanhan.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
let accountMap = {};
let accounts = await account.find({ fromID: '5bb09bd96eeb87000752adde'}).toArray();
// let agents = await agent.find({}).toArray();
let accountIDs = [];
let agentMap = {};
let fromMap = {};
accounts.forEach(({email,company,_id,fromID}) => {
accountIDs = accountIDs.concat([_id,_id+'']);
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
// agents.forEach(({email,company,_id}) => {
// agentMap[ _id + ''] = email + '[' + company + ']'
// })
let typeMap = {
msg: '短信(联通)',
call: '云呼(联通)',
tycall: '精选云呼(电信)',
audit: '备案',
dsp: '精选短信(联通)',
dspcall: '精选云呼(联通)',
dspbuynumber: '精选备案(联通)',
dspbuynumber_ctcc: '精选备案(电信)',
dsp_ctcc: '精选短信(电信)',
urlbuynumber: '网址取号备案',
device: '设备'
}
let header = [['账单ID','meta','扣款状态','类型','扣款','直客账户','渠道商扣款','渠道账户','开始日期','结束日期']];
let _count = 0;
console.dir(accounts.length);
let [ start , end ] = ISODateRange('20181101', '20181131');
let data = [];
let bills = await bill.find({ accountID: { $in: accountIDs }}).toArray();
console.dir(bills.length);
let tasks = [];
bills.forEach( async ({ accountID, _id, meta, type, number, agent, date, endDate, pre}) => {
/* tasks.push(new Promise(async (r,e) => {
console.dir({ billID: _id + ''});
r(await dspRecognition
.count({ billID: _id + '' }) || 0);
}))*/
data.push([_id + '', meta, pre ? '预扣' : '实扣', typeMap[type], (number || 0), accountMap[accountID + ''], (agent && agent.number ? agent.number : 0), agentMap[ fromMap[accountID + ''] ], date, endDate ]);
_count ++;
if(_count === bills.length) {
//console.dir(JSON.stringify(data));
/*let _arrs = await Promise.all(tasks);
data = data.map( (x,i) => {
return (x.length ? x : []).concat([_arrs[i] || 0])
})*/
data = header.concat(data);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./账单dong.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const dspCallTask = await db.getCollection('dspCallTask');
const callTask = await db.getCollection('callTask');
let data = [['被叫用户','账户ID','z']];
let _count = 0;
let arrs = await dspCallTask.find({ "date" : { $gte: "20180801", $lte: "20180831" }}).limit(1000000000000).toArray();
console.dir(arrs);
arrs.forEach( async ({ tags, _id, groupID }) => {
/* let areas = provincelist.concat(citylist)
data.push([dspgroup,areas.join(","),interestlist.join(",")]);
console.dir(_count + '====>');*/
let group = await dspCallGroups.findOne({_id: db.ObjectID(groupID) });
data.push([_id+'',(group ? group.dspgroup : ''), tags]);
_count ++;
if(_count === arrs.length) {
//console.dir(JSON.stringify(data));
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./data2.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const account = await db.getCollection('account');
const charge = await db.getCollection('recharge');
let data = [['直客充值','直客账号','直客公司','代理商账户','代理商公司','备注','日期']];
let _count = 0;
let accounts = await account.find({}).toArray();
let agents = await agent.find({}).toArray();
let charges = await charge.find({}).toArray();
let roleMap = {};
let companyMap = {}
let agentMap = {};
let accountMap = {};
let accountcompanyMap = {};
let fromMap = {};
agents.forEach(({email,company,_id, role}) => {
//accountIDs.push(_id);
agentMap[ _id + ''] = email;
roleMap[ _id + ''] = role;
companyMap[ _id + ''] = company;
})
accounts.forEach(({email,company,_id,fromID}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
let tasks = [];
charges.forEach( async ({ number, accountID, meta, createdAt }) => {
data.push([ number, accountMap[accountID + ''],accountcompanyMap[ accountID + ''], agentMap[ fromMap[accountID + '']], companyMap[fromMap[accountID + '']], meta, moment(createdAt).format('YYYY-MM-DD HH') ]);
_count ++;
if(_count === charges.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./充值信息.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const recharge = await db.getCollection('recharge');
const dspRecognition = await db.getCollection('dspRecognition');
//const _bills = await bills.find({pre:true,fromID:{$exists:1},date:'20180912'}).toArray();
let accounts = await account.find({ role: 2 }).toArray();
let data = [['客户账户','客户公司','代理商账户','代理商公司','预购订单量','预购订单数','实际返回订单数']];
let _count = 0;
console.dir(accounts.length);
accounts.forEach( async ({ email, company, fromID, _id }) => {
let _agent = await agent.findOne({_id: db.ObjectID(fromID) });
let agent_email = '';
let agent_company = '';
if(_agent) {
agent_email = _agent.email;
agent_company = _agent.company;
}
let bills = await bill.find({ "accountID" : _id , pre: false, type: { $in: [ 'dspbuynumber', 'dspbuynumber_ctcc' ] }, "createdAt" : { $gt: moment("2018-08-31T16:00:00.812Z").toDate() } }).toArray();
let leng = bills.length;
console.dir(bills.map( x => x.preNum));
let count = 0;
if(bills.length) {
count = bills.map( x => x.preNum).reduce((a,b) => { return a + b })/3
}
//let count = _.sumBy(data, 'preNum') / 3;
let a = await dspRecognition.count({ "accountID" : _id + '', createdDate:{$gte: '20180901', $lte:"20180930"} });
data.push([email, company,agent_email,agent_company,count,leng, a]);
_count ++;
if(_count === accounts.length) {
//console.dir(JSON.stringify(data));
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./data.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const recharge = await db.getCollection('recharge');
const dspRecognition = await db.getCollection('dspRecognition');
//const _bills = await bills.find({pre:true,fromID:{$exists:1},date:'20180912'}).toArray();
//let bills = await bill.find({ pre: false, end }).toArray();
let data = [['下单时间','订单ID','预定量','下单账户','代理商账户','状态','返还数','来源']];
let bills = await bill.find({ type: { $in: [ 'dspbuynumber_ctcc', 'dspbuynumber' ] }, "createdAt" : { $gt: moment("2018-08-31T16:00:00.812Z").toDate() } }).toArray();
let _count = 0;
bills.forEach( async ({ accountID, _id, type, createdAt, pre, preNum }) => {
let _account = await account.findOne({_id: accountID });
let _agent = null;
if(_account.fromID) {
_agent = await agent.findOne({_id: db.ObjectID(_account.fromID) });
}
let date = moment(createdAt).format('YYYYMMDD HH:mm:ss');
let _pre = pre ? '预扣' : '实扣';
let con = _account.email + '[' + _account.company + ']';
let agent_con = _agent ? (_agent.email + '[' + _agent.company + ']') : '~';
let a = await dspRecognition.count({billID: _id + ''});
let _p = preNum /3;
let carrir = (type == 'dspbuynumber_ctcc' ? '电信' : '联通');
_count ++;
data.push([
date,
_id,
_p,
con,
agent_con,
_pre,
a,
carrir
]);
if(_count === bills.length) {
//console.dir(JSON.stringify(data));
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./data1.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
let map = function() {
var d = new Date(this.updateTimestamp + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit({ unikey: this.unikey }, { recognitionID : this._id + '' });
};
let reduce = function(k, vals) {
var result = { recognitionID: [] };
for(var i in vals) {
result.recognitionID = result.recognitionID.concat(vals);
}
return result;
};
async function task () {
const recognition = await db.getCollection('recognition')
const arrs = await recognition.mapReduce(map, reduce, { query: {}, out: { inline : 1 } } );
arrs.forEach( x => {
if(typeof x.value.recognitionID === 'object' ) {
console.dir(x.value.recognitionID)
}
})
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let agents = await agent.find({}).toArray();
let groupMap = {};
let agentMap = {};
let agentcompanyMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data.dspgroup;
}
})
agents.forEach(({email,company,_id}) => {
agentMap[ _id + ''] = email
agentcompanyMap[ _id + ''] = company
})
console.dir(groupMap);
let data = [['unikey','订单ID','客户','公司','代理商账户','代理商公司']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
let accountcompanyMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email
accountcompanyMap[ _id + ''] = company
})
console.dir(accountMap);
console.dir('begin ====>');
let arrs = await dspRecognition.find({ createdDate: { $gte:"20181101", $lte: "20181131"} }).limit(1000000000000).toArray();
console.dir(arrs.length);
arrs.forEach( async ({ tags,createdDate, fromID, unikey, _id, groupID, billID, remark, systemTags, calledInfo, accountID }) => {
let [ tag1,tag2,tag3,tag4,tag5] = tags;
data.push([unikey, billID, accountMap[accountID],accountcompanyMap[accountID], agentMap[fromID], agentcompanyMap[fromID], createdDate])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
console.dir(data.length);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./dongdong3.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data.dspgroup;
}
})
console.dir(groupMap);
let data = [['unikey','账单','客户','拨打次数','入库时间','用户标签1','用户标签2','用户标签3','用户标签4','用户标签5','标签','备注']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
console.dir(accountMap);
console.dir('begin ====>');
let arrs = await dspRecognition.find({ billID: { '$in' : ['5bd2d6e0d3ee0a0007fd4722']} }).limit(1000000000000).toArray();
console.dir(arrs.length);
arrs.forEach( async ({ tags,createdDate, unikey, _id, groupID, billID, remark, systemTags, calledInfo, accountID }) => {
let [ tag1,tag2,tag3,tag4,tag5] = tags;
data.push([unikey, billID, accountMap[accountID], calledInfo && calledInfo.length ? calledInfo.length : 0, createdDate,tag1,tag2,tag3,tag4,tag5, (systemTags || []).join('、'), (remark || []).join('、')])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
console.dir(data.length);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./dong3.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const _agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
let accountMap = {};
let accounts = await account.find({}).toArray();
let agents = await agent.find({}).toArray();
let accountIDs = [];
let agentMap = {};
let fromMap = {};
accounts.forEach(({email,company,_id,fromID}) => {
accountIDs.push(_id);
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
agents.forEach(({email,company,_id}) => {
accountIDs.push(_id);
agentMap[ _id + ''] = email + '[' + company + ']'
})
let typeMap = {
msg: '短信(联通)',
call: '云呼(联通)',
tycall: '精选云呼(电信)',
audit: '备案',
dsp: '精选短信(联通)',
dspcall: '精选云呼(联通)',
dspbuynumber: '精选备案(联通)',
dspbuynumber_ctcc: '精选备案(电信)',
dsp_ctcc: '精选短信(电信)',
urlbuynumber: '网址取号备案',
device: '设备'
}
let header = [['账单ID','meta','扣款状态','类型','直客扣款','直客账户','渠道商扣款','渠道账户','开始日期','结束日期','endTime','已返回数量','预扣中']];
let _count = 0;
console.dir(accounts.length);
let [ start , end ] = ISODateRange('20181001', '20181031');
let data = [];
let bills = await bill.find({ type: { '$in': ['dspbuynumber_ctcc' ]}, date: { $gte: '20180914'} }).toArray();
console.dir(bills.length);
let tasks = [];
let _tasks = [];
let tasks1 = [];
bills.forEach( async ({ accountID, _id, meta, type, number, agent, date,endTime, endDate, pre}) => {
tasks.push(new Promise(async (r,e) => {
console.dir({ billID: _id + ''});
r(await dspRecognition
.count({ billID: _id + '' }) || 0);
}))
_tasks.push(new Promise(async (r,e) => {
r(await _agent
.count({ "preNumber.billID": {$in:[_id,_id + '']} }) || 0);
}));
data.push([_id + '', meta, pre ? '预扣' : '实扣', typeMap[type], (number || 0), accountMap[accountID + ''], (agent && agent.number ? agent.number : 0), agentMap[ fromMap[accountID + ''] ], date, endDate,endTime ]);
_count ++;
if(_count === bills.length) {
//console.dir(JSON.stringify(data));
let _arrs = await Promise.all(tasks);
let _arrs1 = await Promise.all(_tasks);
data = data.map( (x,i) => {
return (x.length ? x : []).concat([_arrs[i] || 0]).concat([_arrs1[i] || 0])
})
data.forEach( x => {
if(x[2] == '实扣' ) {
//console.dir(x);
let _id = x[0];
let endTime = x[10];
if(!endTime) {
endTime = Date.now();
}
let endDate = moment(endTime,'x').format('YYYYMMDD');
let num = x[11] * 8;
let agent_num = x[11] * 8 * 0.3;
let update_num = agent_num.toFixed(1);
console.dir({_id, endTime, num, agent_num, update_num});
tasks1.push(new Promise(async (r,e) => {
//let p = await _agent.update({ "preNumber.billID": { $in:[x[0], db.ObjectID(x[0]) ]} }, { $set: { bak_balace: ag.balace }, $pull: { preNumber: { billID:{ $in:[x[0], db.ObjectID(x[0]) ]} }}, $inc: { balace: -update_num }});
console.dir({ number: num, "agent.number": update_num, endTime: endTime, endDate: endDate });
let p1 = await bill.update({ _id:db.ObjectID(x[0]) },{ $set: { number: num, "agent.number": update_num, endTime: endTime, endDate: endDate }})
console.dir(p1.result.nModified);
r('===' + p1.result.nModified);
}))
}
});
console.dir(tasks1.length + '==========>')
console.dir(await Promise.all(tasks1));
data = header.concat(data);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./账单1.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const bill = await db.getCollection('bills');
const bills = await bill.find({ endDate: { $exists:false } ,pre:false}).toArray();
console.dir(bills.length);
bills.forEach( async ({ createdAt, date, _id }) => {
let endDate = moment(createdAt).format('YYYYMMDD');
let endTime = parseInt(moment(createdAt).format('x'));
let endAt = createdAt;
//await bill.update({ _id },{ "$set": { endDate, endAt, endTime}});
let rep = await bill.update({ _id },{ "$set": { endDate, endAt, endTime}});
console.dir(rep)
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const dspCallGroups = await db.getCollection('dspCallGroups');
const dspRecognition = await db.getCollection('dspRecognition');
let data = [['recogid','用户组','标签1','标签2','标签3','标签4','客户标签','客户备注']];
let _count = 0;
let arrs = await dspRecognition.find({ billID: '5bbef0e09fd6a700073e7928' }).limit(1000000000000).toArray();
console.dir(arrs);
arrs.forEach( async ({ tags, _id, groupID,remark = [], systemTags = [] }) => {
/* let areas = provincelist.concat(citylist)
data.push([dspgroup,areas.join(","),interestlist.join(",")]);
console.dir(_count + '====>');*/
let group = await dspCallGroups.findOne({_id: db.ObjectID(groupID) });
data.push([_id+'',(group ? group.dspgroup : ''), tags[0], tags[1], tags[2], tags[3], systemTags.join(','), remark.join(',')]);
_count ++;
if(_count === arrs.length) {
//console.dir(JSON.stringify(data));
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./dongdong.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const metas = ["TY00087120181030A","TY00086520181030A","TY00085920181030A","TY00085320181030A","TY00085020181030A","TY00084920181030A","TY00084820181030A","TY00084720181030A","TY00084620181030A","TY00083220181029A","TY00080720181025A","TY00079920181025A","TY00079820181025A","TY00079320181024A","TY00078320181023A","TY00078120181023A","TY00077120181023A","TY00077020181023A","TY00075920181022A","TY00075820181022A","TY00075720181022A","TY00075620181022A","TY00075220181022A","TY00074420181019A","TY00073620181019A","TY00072020181018A","TY00071920181018A","TY00071420181017A","TY00071320181017A","TY00071220181017A","TY00071020181017A","TY00070020181016A","TY00069120181016A","TY00069020181016A","TY00068920181016A","TY00068820181016A","TY00068620181016A","TY00068420181016A","TY00068220181016A","TY00068120181015A","TY00067620181015A","TY00067220181015A","TY00067020181015A","TY00066720181015A","TY00066120181013A","TY00065020181012A","TY00063520181011A","TY00063420181010A","TY00063320181010A","TY00062720181010A","TY00062320181009A","TY00062120181009A","TY00061520181009A","TY00061320181009A","TY00061220181009A","TY00060420181009A","TY00060120181008A","TY00060020181008A","TY00059920181008A","TY00059620181008A","TY00059520181008A","TY00059120181008A","TY00059020181008A"];
const bills = await db.getCollection('bills');
const group = await db.getCollection('dspCallGroups');
const account = await db.getCollection('account');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
let tagMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data.dspgroup;
}
for(var k in data) {
if(k !== '_id' && k !== 'dspgroup') {
tagMap[data._id + ''] = (tagMap[data._id + ''] || []).concat(Array.isArray(data[k]) ? data[k] : [data[k]])
}
}
})
console.dir(groupMap);
let data = [['meta','账户','用户组','标签']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
let arrs = await bills.find({ meta: { '$in' : metas } }).limit(1000000000000).toArray();
arrs.forEach( async ({ accountID,groupID, meta }) => {
data.push([meta, accountMap[accountID + ''],groupMap[groupID + ''] ,tagMap[groupID + ''].join('、')])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
console.dir(data.length);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./dong1.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const bill = await db.getCollection('bills');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
let accountMap = {};
let accounts = await account.find({}).toArray();
let agents = await agent.find({}).toArray();
let accountIDs = [];
let agentMap = {};
let fromMap = {};
accounts.forEach(({email,company,_id,fromID}) => {
accountIDs.push(_id);
accountMap[ _id + ''] = email + '[' + company + ']'
fromMap[ _id + ''] = fromID;
})
agents.forEach(({email,company,_id}) => {
accountIDs.push(_id);
agentMap[ _id + ''] = email + '[' + company + ']'
})
let typeMap = {
msg: '短信(联通)',
call: '云呼(联通)',
tycall: '精选云呼(电信)',
audit: '备案',
dsp: '精选短信(联通)',
dspcall: '精选云呼(联通)',
dspbuynumber: '精选备案(联通)',
dspbuynumber_ctcc: '精选备案(电信)',
dsp_ctcc: '精选短信(电信)',
urlbuynumber: '网址取号备案',
device: '设备'
}
let header = [['账单ID','meta','扣款状态','类型','直客扣款','直客账户','渠道商扣款','渠道账户','开始日期','结束日期','已返回数量']];
let _count = 0;
console.dir(accounts.length);
let [ start , end ] = ISODateRange('20181001', '20181031');
let data = [];
let bills = await bill.find({ type: { '$in': ['dspbuynumber_ctcc' ]}, date: { $gte: '20180914'} }).toArray();
console.dir(bills.length);
let tasks = [];
bills.forEach( async ({ accountID, _id, meta, type, number, agent, date, endDate, pre}) => {
tasks.push(new Promise(async (r,e) => {
console.dir({ billID: _id + ''});
r(await dspRecognition
.count({ billID: _id + '' }) || 0);
}))
data.push([_id + '', meta, pre ? '预扣' : '实扣', typeMap[type], (number || 0), accountMap[accountID + ''], (agent && agent.number ? agent.number : 0), agentMap[ fromMap[accountID + ''] ], date, endDate ]);
_count ++;
if(_count === bills.length) {
let _arrs = await Promise.all(tasks);
data = data.map( (x,i) => {
return (x.length ? x : []).concat([_arrs[i] || 0])
})
data = header.concat(data);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./账单1.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const agent = await db.getAgentCollection('account');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let agents = await agent.find({}).toArray();
let groupMap = {};
let agentMap = {};
let agentcompanyMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = data.dspgroup;
}
})
agents.forEach(({email,company,_id}) => {
agentMap[ _id + ''] = email
agentcompanyMap[ _id + ''] = company
})
console.dir(groupMap);
let _arrs1 = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
let accountcompanyMap = {};
_arrs1.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email
accountcompanyMap[ _id + ''] = company
})
console.dir(accountMap);
console.dir('begin ====>');
const dspCallTask = await db.getCollection('dspCallTask');
const bills = await db.getCollection('bills');
let billMap = {};
let calls = await bills.find({ type: { $in: ['tycall','dspcall'] }, "date" : {$gte:'20181001'}}).limit(1000000000000).toArray();
calls.forEach(({accountID,taskID, number}) => {
billMap[ accountID + '' + taskID] = number
})
let data = [['话单ID','秒数','通话分钟数','主叫','被叫','客户','公司','代理商账户','代理商公司', '消耗费用', '开始时间','结束时间', '录音']];
let _count = 0;
let arrs = await dspCallTask.find({"date": { $gte:"20181101", $lte: "20181130"}}).limit(1000000000000).toArray();
console.dir(arrs.length);
let map = {};
arrs.forEach( async ({ _id, unikey, duration, date, pubID,result,caller,called, url, updateTime , startTime, fromID }) => {
data.push([_id, (duration || 0) / 60, duration, called, caller, accountMap[pubID], accountcompanyMap[pubID], agentMap[fromID], agentcompanyMap[fromID], billMap[pubID + '' + _id], startTime ? moment(startTime,'x').format('YYYYMMDD HH:mm') : '', updateTime ? moment(updateTime,'x').format('YYYYMMDD HH:mm'): '' , url, result])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./话单2.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const moment = require('moment');
async function task(argument) {
const recognition = await db.getCollection('recognition');
let arrs = ["010016da78a50ca474454a9fed242555",
"010016da78a50ca474454a9fed242556",
"010016da78a50ca474454a9fed242557",
"010016da78a50ca474454a9fed242558",
"010016da78a50ca474454a9fed242559",
"010016da78a50ca474454a9fed242560",
"010016da78a50ca474454a9fed242561",
"010016da78a50ca474454a9fed242562",
"010016da78a50ca474454a9fed242563",
"010016da78a50ca474454a9fed242564",
"010016da78a50ca474454a9fed242565",
"010016da78a50ca474454a9fed242566",
"010016da78a50ca474454a9fed242567",
"010016da78a50ca474454a9fed242568",
"010016da78a50ca474454a9fed242569",
"010016da78a50ca474454a9fed242570",
"010016da78a50ca474454a9fed242571",
"010016da78a50ca474454a9fed242572",
"010016da78a50ca474454a9fed242573",
"010016da78a50ca474454a9fed242574",
"010016da78a50ca474454a9fed242575",
"010016da78a50ca474454a9fed242576",
"010016da78a50ca474454a9fed242577",
"010016da78a50ca474454a9fed242578",
"010016da78a50ca474454a9fed242579",
"010016da78a50ca474454a9fed242580",
"010016da78a50ca474454a9fed242581",
"010016da78a50ca474454a9fed242582",
"010016da78a50ca474454a9fed242583",
"010016da78a50ca474454a9fed242584",
"010016da78a50ca474454a9fed242585",
"010016da78a50ca474454a9fed242586",
"010016da78a50ca474454a9fed242587",
"010016da78a50ca474454a9fed242588",
"010016da78a50ca474454a9fed242589",
"010016da78a50ca474454a9fed242590",
"010016da78a50ca474454a9fed242591",
"010016da78a50ca474454a9fed242592",
"010016da78a50ca474454a9fed242593",
"010016da78a50ca474454a9fed242594",
"010016da78a50ca474454a9fed242595",
"010016da78a50ca474454a9fed242596",
"010016da78a50ca474454a9fed242597",
"010016da78a50ca474454a9fed242598",
"010016da78a50ca474454a9fed242599",
"010016da78a50ca474454a9fed242600",
"010016da78a50ca474454a9fed242601",
"010016da78a50ca474454a9fed242602",
"010016da78a50ca474454a9fed242603",
"010016da78a50ca474454a9fed242604",
"010016da78a50ca474454a9fed242605",
"010016da78a50ca474454a9fed242606",
"010016da78a50ca474454a9fed242607",
"010016da78a50ca474454a9fed242608",
"010016da78a50ca474454a9fed242609",
"010016da78a50ca474454a9fed242610",
"010016da78a50ca474454a9fed242611",
"010016da78a50ca474454a9fed242612",
"010016da78a50ca474454a9fed242613",
"010016da78a50ca474454a9fed242614",
"010016da78a50ca474454a9fed242615",
"010016da78a50ca474454a9fed242616",
"010016da78a50ca474454a9fed242617",
"010016da78a50ca474454a9fed242618",
"010016da78a50ca474454a9fed242619",
"010016da78a50ca474454a9fed242620",
"010016da78a50ca474454a9fed242621",
"010016da78a50ca474454a9fed242622",
"010016da78a50ca474454a9fed242623",
"010016da78a50ca474454a9fed242624",
"010016da78a50ca474454a9fed242625",
"010016da78a50ca474454a9fed242626",
"010016da78a50ca474454a9fed242627",
"010016da78a50ca474454a9fed242628",
"010016da78a50ca474454a9fed242629",
"010016da78a50ca474454a9fed242630",
"010016da78a50ca474454a9fed242631",
"010016da78a50ca474454a9fed242632",
"010016da78a50ca474454a9fed242633",
"010016da78a50ca474454a9fed242634",
"010016da78a50ca474454a9fed242635",
"010016da78a50ca474454a9fed242636",
"010016da78a50ca474454a9fed242637",
"010016da78a50ca474454a9fed242638",
"010016da78a50ca474454a9fed242639",
"010016da78a50ca474454a9fed242640",
"010016da78a50ca474454a9fed242641",
"010016da78a50ca474454a9fed242642",
"010016da78a50ca474454a9fed242643",
"010016da78a50ca474454a9fed242644",
"010016da78a50ca474454a9fed242645",
"010016da78a50ca474454a9fed242646",
"010016da78a50ca474454a9fed242647",
"010016da78a50ca474454a9fed242648",
"010016da78a50ca474454a9fed242649",
"010016da78a50ca474454a9fed242650",
"010016da78a50ca474454a9fed242651",
"010016da78a50ca474454a9fed242652",
"010016da78a50ca474454a9fed242653",
"010016da78a50ca474454a9fed242654",
"010016da78a50ca474454a9fed242655",
"010016da78a50ca474454a9fed242656",
"010016da78a50ca474454a9fed242657",
"010016da78a50ca474454a9fed242658",
"010016da78a50ca474454a9fed242659",
"010016da78a50ca474454a9fed242660",
"010016da78a50ca474454a9fed242661",
"010016da78a50ca474454a9fed242662",
"010016da78a50ca474454a9fed242663",
"010016da78a50ca474454a9fed242664",
"010016da78a50ca474454a9fed242665",
"010016da78a50ca474454a9fed242666",
"010016da78a50ca474454a9fed242667",
"010016da78a50ca474454a9fed242668",
"010016da78a50ca474454a9fed242669",
"010016da78a50ca474454a9fed242670",
"010016da78a50ca474454a9fed242671",
"010016da78a50ca474454a9fed242672",
"010016da78a50ca474454a9fed242673",
"010016da78a50ca474454a9fed242674",
"010016da78a50ca474454a9fed242675",
"010016da78a50ca474454a9fed242676",
"010016da78a50ca474454a9fed242677",
"010016da78a50ca474454a9fed242678",
"010016da78a50ca474454a9fed242679",
"010016da78a50ca474454a9fed242680",
"010016da78a50ca474454a9fed242681",
"010016da78a50ca474454a9fed242682",
"010016da78a50ca474454a9fed242683",
"010016da78a50ca474454a9fed242684",
"010016da78a50ca474454a9fed242685",
"010016da78a50ca474454a9fed242686",
"010016da78a50ca474454a9fed242687",
"010016da78a50ca474454a9fed242688",
"010016da78a50ca474454a9fed242689",
"010016da78a50ca474454a9fed242690",
"010016da78a50ca474454a9fed242691",
"010016da78a50ca474454a9fed242692",
"010016da78a50ca474454a9fed242693",
"010016da78a50ca474454a9fed242694",
"010016da78a50ca474454a9fed242695",
"010016da78a50ca474454a9fed242696",
"010016da78a50ca474454a9fed242697",
"010016da78a50ca474454a9fed242698",
"010016da78a50ca474454a9fed242699",
"010016da78a50ca474454a9fed242700",
"010016da78a50ca474454a9fed242701",
"010016da78a50ca474454a9fed242702",
"010016da78a50ca474454a9fed242703",
"010016da78a50ca474454a9fed242704",
"010016da78a50ca474454a9fed242705",
"010016da78a50ca474454a9fed242706",
"010016da78a50ca474454a9fed242707",
"010016da78a50ca474454a9fed242708",
"010016da78a50ca474454a9fed242709",
"010016da78a50ca474454a9fed242710",
"010016da78a50ca474454a9fed242711",
"010016da78a50ca474454a9fed242712",
"010016da78a50ca474454a9fed242713",
"010016da78a50ca474454a9fed242714",
"010016da78a50ca474454a9fed242715",
"010016da78a50ca474454a9fed242716",
"010016da78a50ca474454a9fed242717",
"010016da78a50ca474454a9fed242718",
"010016da78a50ca474454a9fed242719",
"010016da78a50ca474454a9fed242720",
"010016da78a50ca474454a9fed242721",
"010016da78a50ca474454a9fed242722",
"010016da78a50ca474454a9fed242723",
"010016da78a50ca474454a9fed242724",
"010016da78a50ca474454a9fed242725",
"010016da78a50ca474454a9fed242726",
"010016da78a50ca474454a9fed242727",
"010016da78a50ca474454a9fed242728",
"010016da78a50ca474454a9fed242729",
"010016da78a50ca474454a9fed242730",
"010016da78a50ca474454a9fed242731",
"010016da78a50ca474454a9fed242732",
"010016da78a50ca474454a9fed242733",
"010016da78a50ca474454a9fed242734",
"010016da78a50ca474454a9fed242735",
"010016da78a50ca474454a9fed242736",
"010016da78a50ca474454a9fed242737",
"010016da78a50ca474454a9fed242738",
"010016da78a50ca474454a9fed242739",
"010016da78a50ca474454a9fed242740",
"010016da78a50ca474454a9fed242741",
"010016da78a50ca474454a9fed242742",
"010016da78a50ca474454a9fed242743",
"010016da78a50ca474454a9fed242744",
"010016da78a50ca474454a9fed242745",
"010016da78a50ca474454a9fed242746",
"010016da78a50ca474454a9fed242747",
"010016da78a50ca474454a9fed242748",
"010016da78a50ca474454a9fed242749",
"010016da78a50ca474454a9fed242750",
"010016da78a50ca474454a9fed242751",
"010016da78a50ca474454a9fed242752",
"010016da78a50ca474454a9fed242753",
"010016da78a50ca474454a9fed242754",
"010016da78a50ca474454a9fed242755",
"010016da78a50ca474454a9fed242756",
"010016da78a50ca474454a9fed242757",
"010016da78a50ca474454a9fed242758",
"010016da78a50ca474454a9fed242759",
"010016da78a50ca474454a9fed242760",
"010016da78a50ca474454a9fed242761",
"010016da78a50ca474454a9fed242762",
"010016da78a50ca474454a9fed242763",
"010016da78a50ca474454a9fed242764",
"010016da78a50ca474454a9fed242765",
"010016da78a50ca474454a9fed242766",
"010016da78a50ca474454a9fed242767",
"010016da78a50ca474454a9fed242768",
"010016da78a50ca474454a9fed242769",
"010016da78a50ca474454a9fed242770",
"010016da78a50ca474454a9fed242771",
"010016da78a50ca474454a9fed242772",
"010016da78a50ca474454a9fed242773",
"010016da78a50ca474454a9fed242774",
"010016da78a50ca474454a9fed242775",
"010016da78a50ca474454a9fed242776",
"010016da78a50ca474454a9fed242777",
"010016da78a50ca474454a9fed242778",
"010016da78a50ca474454a9fed242779",
"010016da78a50ca474454a9fed242780",
"010016da78a50ca474454a9fed242781",
"010016da78a50ca474454a9fed242782",
"010016da78a50ca474454a9fed242783",
"010016da78a50ca474454a9fed242784",
"010016da78a50ca474454a9fed242785",
"010016da78a50ca474454a9fed242786",
"010016da78a50ca474454a9fed242787",
"010016da78a50ca474454a9fed242788",
"010016da78a50ca474454a9fed242789",
"010016da78a50ca474454a9fed242790",
"010016da78a50ca474454a9fed242791",
"010016da78a50ca474454a9fed242792",
"010016da78a50ca474454a9fed242793",
"010016da78a50ca474454a9fed242794",
"010016da78a50ca474454a9fed242795",
"010016da78a50ca474454a9fed242796",
"010016da78a50ca474454a9fed242797",
"010016da78a50ca474454a9fed242798",
"010016da78a50ca474454a9fed242799",
"010016da78a50ca474454a9fed242800",
"010016da78a50ca474454a9fed242801",
"010016da78a50ca474454a9fed242802",
"010016da78a50ca474454a9fed242803",
"010016da78a50ca474454a9fed242804",
"010016da78a50ca474454a9fed242805",
"010016da78a50ca474454a9fed242806",
"010016da78a50ca474454a9fed242807",
"010016da78a50ca474454a9fed242808",
"010016da78a50ca474454a9fed242809",
"010016da78a50ca474454a9fed242810",
"010016da78a50ca474454a9fed242811",
"010016da78a50ca474454a9fed242812",
"010016da78a50ca474454a9fed242813",
"010016da78a50ca474454a9fed242814",
"010016da78a50ca474454a9fed242815",
"010016da78a50ca474454a9fed242816",
"010016da78a50ca474454a9fed242817",
"010016da78a50ca474454a9fed242818",
"010016da78a50ca474454a9fed242819",
"010016da78a50ca474454a9fed242820",
"010016da78a50ca474454a9fed242821",
"010016da78a50ca474454a9fed242822",
"010016da78a50ca474454a9fed242823",
"010016da78a50ca474454a9fed242824",
"010016da78a50ca474454a9fed242825",
"010016da78a50ca474454a9fed242826",
"010016da78a50ca474454a9fed242827",
"010016da78a50ca474454a9fed242828",
"010016da78a50ca474454a9fed242829",
"010016da78a50ca474454a9fed242830",
"010016da78a50ca474454a9fed242831",
"010016da78a50ca474454a9fed242832",
"010016da78a50ca474454a9fed242833",
"010016da78a50ca474454a9fed242834",
"010016da78a50ca474454a9fed242835",
"010016da78a50ca474454a9fed242836",
"010016da78a50ca474454a9fed242837",
"010016da78a50ca474454a9fed242838",
"010016da78a50ca474454a9fed242839",
"010016da78a50ca474454a9fed242840",
"010016da78a50ca474454a9fed242841",
"010016da78a50ca474454a9fed242842",
"010016da78a50ca474454a9fed242843",
"010016da78a50ca474454a9fed242844",
"010016da78a50ca474454a9fed242845",
"010016da78a50ca474454a9fed242846",
"010016da78a50ca474454a9fed242847",
"010016da78a50ca474454a9fed242848",
"010016da78a50ca474454a9fed242849",
"010016da78a50ca474454a9fed242850",
"010016da78a50ca474454a9fed242851",
"010016da78a50ca474454a9fed242852",
"010016da78a50ca474454a9fed242853",
"010016da78a50ca474454a9fed242854",
"010016da78a50ca474454a9fed242855",
"010016da78a50ca474454a9fed242856",
"010016da78a50ca474454a9fed242857",
"010016da78a50ca474454a9fed242858",
"010016da78a50ca474454a9fed242859",
"010016da78a50ca474454a9fed242860",
"010016da78a50ca474454a9fed242861",
"010016da78a50ca474454a9fed242862",
"010016da78a50ca474454a9fed242863",
"010016da78a50ca474454a9fed242864",
"010016da78a50ca474454a9fed242865",
"010016da78a50ca474454a9fed242866",
"010016da78a50ca474454a9fed242867",
"010016da78a50ca474454a9fed242868",
"010016da78a50ca474454a9fed242869",
"010016da78a50ca474454a9fed242870",
"010016da78a50ca474454a9fed242871",
"010016da78a50ca474454a9fed242872",
"010016da78a50ca474454a9fed242873",
"010016da78a50ca474454a9fed242874",
"010016da78a50ca474454a9fed242875",
"010016da78a50ca474454a9fed242876",
"010016da78a50ca474454a9fed242877",
"010016da78a50ca474454a9fed242878",
"010016da78a50ca474454a9fed242879",
"010016da78a50ca474454a9fed242880",
"010016da78a50ca474454a9fed242881",
"010016da78a50ca474454a9fed242882",
"010016da78a50ca474454a9fed242883",
"010016da78a50ca474454a9fed242884",
"010016da78a50ca474454a9fed242885",
"010016da78a50ca474454a9fed242886",
"010016da78a50ca474454a9fed242887",
"010016da78a50ca474454a9fed242888",
"010016da78a50ca474454a9fed242889",
"010016da78a50ca474454a9fed242890",
"010016da78a50ca474454a9fed242891",
"010016da78a50ca474454a9fed242892",
"010016da78a50ca474454a9fed242893",
"010016da78a50ca474454a9fed242894",
"010016da78a50ca474454a9fed242895",
"010016da78a50ca474454a9fed242896",
"010016da78a50ca474454a9fed242897",
"010016da78a50ca474454a9fed242898",
"010016da78a50ca474454a9fed242899",
"010016da78a50ca474454a9fed242900",
"010016da78a50ca474454a9fed242901",
"010016da78a50ca474454a9fed242902",
"010016da78a50ca474454a9fed242903",
"010016da78a50ca474454a9fed242904",
"010016da78a50ca474454a9fed242905",
"010016da78a50ca474454a9fed242906",
"010016da78a50ca474454a9fed242907",
"010016da78a50ca474454a9fed242908",
"010016da78a50ca474454a9fed242909",
"010016da78a50ca474454a9fed242910",
"010016da78a50ca474454a9fed242911",
"010016da78a50ca474454a9fed242912",
"010016da78a50ca474454a9fed242913",
"010016da78a50ca474454a9fed242914",
"010016da78a50ca474454a9fed242915",
"010016da78a50ca474454a9fed242916",
"010016da78a50ca474454a9fed242917",
"010016da78a50ca474454a9fed242918",
"010016da78a50ca474454a9fed242919",
"010016da78a50ca474454a9fed242920",
"010016da78a50ca474454a9fed242921",
"010016da78a50ca474454a9fed242922",
"010016da78a50ca474454a9fed242923",
"010016da78a50ca474454a9fed242924",
"010016da78a50ca474454a9fed242925",
"010016da78a50ca474454a9fed242926",
"010016da78a50ca474454a9fed242927",
"010016da78a50ca474454a9fed242928",
"010016da78a50ca474454a9fed242929",
"010016da78a50ca474454a9fed242930",
"010016da78a50ca474454a9fed242931",
"010016da78a50ca474454a9fed242932",
"010016da78a50ca474454a9fed242933",
"010016da78a50ca474454a9fed242934",
"010016da78a50ca474454a9fed242935",
"010016da78a50ca474454a9fed242936",
"010016da78a50ca474454a9fed242937",
"010016da78a50ca474454a9fed242938",
"010016da78a50ca474454a9fed242939",
"010016da78a50ca474454a9fed242940",
"010016da78a50ca474454a9fed242941",
"010016da78a50ca474454a9fed242942",
"010016da78a50ca474454a9fed242943",
"010016da78a50ca474454a9fed242944",
"010016da78a50ca474454a9fed242945",
"010016da78a50ca474454a9fed242946",
"010016da78a50ca474454a9fed242947",
"010016da78a50ca474454a9fed242948",
"010016da78a50ca474454a9fed242949",
"010016da78a50ca474454a9fed242950",
"010016da78a50ca474454a9fed242951",
"010016da78a50ca474454a9fed242952",
"010016da78a50ca474454a9fed242953",
"010016da78a50ca474454a9fed242954",
"010016da78a50ca474454a9fed242955",
"010016da78a50ca474454a9fed242956",
"010016da78a50ca474454a9fed242957",
"010016da78a50ca474454a9fed242958",
"010016da78a50ca474454a9fed242959",
"010016da78a50ca474454a9fed242960",
"010016da78a50ca474454a9fed242961",
"010016da78a50ca474454a9fed242962",
"010016da78a50ca474454a9fed242963",
"010016da78a50ca474454a9fed242964",
"010016da78a50ca474454a9fed242965",
"010016da78a50ca474454a9fed242966",
"010016da78a50ca474454a9fed242967",
"010016da78a50ca474454a9fed242968",
"010016da78a50ca474454a9fed242969",
"010016da78a50ca474454a9fed242970",
"010016da78a50ca474454a9fed242971",
"010016da78a50ca474454a9fed242972",
"010016da78a50ca474454a9fed242973",
"010016da78a50ca474454a9fed242974",
"010016da78a50ca474454a9fed242975",
"010016da78a50ca474454a9fed242976",
"010016da78a50ca474454a9fed242977",
"010016da78a50ca474454a9fed242978",
"010016da78a50ca474454a9fed242979",
"010016da78a50ca474454a9fed242980",
"010016da78a50ca474454a9fed242981",
"010016da78a50ca474454a9fed242982",
"010016da78a50ca474454a9fed242983",
"010016da78a50ca474454a9fed242984",
"010016da78a50ca474454a9fed242985",
"010016da78a50ca474454a9fed242986",
"010016da78a50ca474454a9fed242987",
"010016da78a50ca474454a9fed242988",
"010016da78a50ca474454a9fed242989",
"010016da78a50ca474454a9fed242990",
"010016da78a50ca474454a9fed242991",
"010016da78a50ca474454a9fed242992",
"010016da78a50ca474454a9fed242993",
"010016da78a50ca474454a9fed242994",
"010016da78a50ca474454a9fed242995",
"010016da78a50ca474454a9fed242996",
"010016da78a50ca474454a9fed242997",
"010016da78a50ca474454a9fed242998",
"010016da78a50ca474454a9fed242999",
"010016da78a50ca474454a9fed243000",
"010016da78a50ca474454a9fed243001",
"010016da78a50ca474454a9fed243002",
"010016da78a50ca474454a9fed243003",
"010016da78a50ca474454a9fed243004",
"010016da78a50ca474454a9fed243005",
"010016da78a50ca474454a9fed243006",
"010016da78a50ca474454a9fed243007",
"010016da78a50ca474454a9fed243008",
"010016da78a50ca474454a9fed243009",
"010016da78a50ca474454a9fed243010",
"010016da78a50ca474454a9fed243011",
"010016da78a50ca474454a9fed243012",
"010016da78a50ca474454a9fed243013",
"010016da78a50ca474454a9fed243014",
"010016da78a50ca474454a9fed243015",
"010016da78a50ca474454a9fed243016",
"010016da78a50ca474454a9fed243017",
"010016da78a50ca474454a9fed243018",
"010016da78a50ca474454a9fed243019",
"010016da78a50ca474454a9fed243020",
"010016da78a50ca474454a9fed243021",
"010016da78a50ca474454a9fed243022",
"010016da78a50ca474454a9fed243023",
"010016da78a50ca474454a9fed243024",
"010016da78a50ca474454a9fed243025",
"010016da78a50ca474454a9fed243026",
"010016da78a50ca474454a9fed243027",
"010016da78a50ca474454a9fed243028",
"010016da78a50ca474454a9fed243029",
"010016da78a50ca474454a9fed243030",
"010016da78a50ca474454a9fed243031",
"010016da78a50ca474454a9fed243032",
"010016da78a50ca474454a9fed243033",
"010016da78a50ca474454a9fed243034",
"010016da78a50ca474454a9fed243035",
"010016da78a50ca474454a9fed243036",
"010016da78a50ca474454a9fed243037",
"010016da78a50ca474454a9fed243038",
"010016da78a50ca474454a9fed243039",
"010016da78a50ca474454a9fed243040",
"010016da78a50ca474454a9fed243041",
"010016da78a50ca474454a9fed243042",
"010016da78a50ca474454a9fed243043",
"010016da78a50ca474454a9fed243044",
"010016da78a50ca474454a9fed243045",
"010016da78a50ca474454a9fed243046",
"010016da78a50ca474454a9fed243047",
"010016da78a50ca474454a9fed243048",
"010016da78a50ca474454a9fed243049",
"010016da78a50ca474454a9fed243050",
"010016da78a50ca474454a9fed243051",
"010016da78a50ca474454a9fed243052",
"010016da78a50ca474454a9fed243053",
"010016da78a50ca474454a9fed243054",
"010016da78a50ca474454a9fed243055",
"010016da78a50ca474454a9fed243056",
"010016da78a50ca474454a9fed243057",
"010016da78a50ca474454a9fed243058",
"010016da78a50ca474454a9fed243059",
"010016da78a50ca474454a9fed243060",
"010016da78a50ca474454a9fed243061",
"010016da78a50ca474454a9fed243062",
"010016da78a50ca474454a9fed243063",
"010016da78a50ca474454a9fed243064",
"010016da78a50ca474454a9fed243065",
"010016da78a50ca474454a9fed243066",
"010016da78a50ca474454a9fed243067",
"010016da78a50ca474454a9fed243068",
"010016da78a50ca474454a9fed243069",
"010016da78a50ca474454a9fed243070",
"010016da78a50ca474454a9fed243071",
"010016da78a50ca474454a9fed243072",
"010016da78a50ca474454a9fed243073",
"010016da78a50ca474454a9fed243074",
"010016da78a50ca474454a9fed243075",
"010016da78a50ca474454a9fed243076",
"010016da78a50ca474454a9fed243077",
"010016da78a50ca474454a9fed243078",
"010016da78a50ca474454a9fed243079",
"010016da78a50ca474454a9fed243080",
"010016da78a50ca474454a9fed243081",
"010016da78a50ca474454a9fed243082",
"010016da78a50ca474454a9fed243083",
"010016da78a50ca474454a9fed243084",
"010016da78a50ca474454a9fed243085",
"010016da78a50ca474454a9fed243086",
"010016da78a50ca474454a9fed243087",
"010016da78a50ca474454a9fed243088",
"010016da78a50ca474454a9fed243089",
"010016da78a50ca474454a9fed243090",
"010016da78a50ca474454a9fed243091",
"010016da78a50ca474454a9fed243092",
"010016da78a50ca474454a9fed243093",
"010016da78a50ca474454a9fed243094",
"010016da78a50ca474454a9fed243095",
"010016da78a50ca474454a9fed243096",
"010016da78a50ca474454a9fed243097",
"010016da78a50ca474454a9fed243098",
"010016da78a50ca474454a9fed243099",
"010016da78a50ca474454a9fed243100",
"010016da78a50ca474454a9fed243101",
"010016da78a50ca474454a9fed243102",
"010016da78a50ca474454a9fed243103",
"010016da78a50ca474454a9fed243104",
"010016da78a50ca474454a9fed243105",
"010016da78a50ca474454a9fed243106",
"010016da78a50ca474454a9fed243107",
"010016da78a50ca474454a9fed243108",
"010016da78a50ca474454a9fed243109",
"010016da78a50ca474454a9fed243110",
"010016da78a50ca474454a9fed243111",
"010016da78a50ca474454a9fed243112",
"010016da78a50ca474454a9fed243113",
"010016da78a50ca474454a9fed243114",
"010016da78a50ca474454a9fed243115",
"010016da78a50ca474454a9fed243116",
"010016da78a50ca474454a9fed243117",
"010016da78a50ca474454a9fed243118",
"010016da78a50ca474454a9fed243119",
"010016da78a50ca474454a9fed243120",
"010016da78a50ca474454a9fed243121",
"010016da78a50ca474454a9fed243122",
"010016da78a50ca474454a9fed243123",
"010016da78a50ca474454a9fed243124",
"010016da78a50ca474454a9fed243125",
"010016da78a50ca474454a9fed243126",
"010016da78a50ca474454a9fed243127",
"010016da78a50ca474454a9fed243128",
"010016da78a50ca474454a9fed243129",
"010016da78a50ca474454a9fed243130",
"010016da78a50ca474454a9fed243131",
"010016da78a50ca474454a9fed243132",
"010016da78a50ca474454a9fed243133",
"010016da78a50ca474454a9fed243134",
"010016da78a50ca474454a9fed243135",
"010016da78a50ca474454a9fed243136",
"010016da78a50ca474454a9fed243137",
"010016da78a50ca474454a9fed243138",
"010016da78a50ca474454a9fed243139",
"010016da78a50ca474454a9fed243140",
"010016da78a50ca474454a9fed243141",
"010016da78a50ca474454a9fed243142",
"010016da78a50ca474454a9fed243143",
"010016da78a50ca474454a9fed243144",
"010016da78a50ca474454a9fed243145",
"010016da78a50ca474454a9fed243146",
"010016da78a50ca474454a9fed243147",
"010016da78a50ca474454a9fed243148",
"010016da78a50ca474454a9fed243149",
"010016da78a50ca474454a9fed243150",
"010016da78a50ca474454a9fed243151",
"010016da78a50ca474454a9fed243152",
"010016da78a50ca474454a9fed243153",
"010016da78a50ca474454a9fed243154",
"010016da78a50ca474454a9fed243155",
"010016da78a50ca474454a9fed243156",
"010016da78a50ca474454a9fed243157",
"010016da78a50ca474454a9fed243158",
"010016da78a50ca474454a9fed243159",
"010016da78a50ca474454a9fed243160",
"010016da78a50ca474454a9fed243161",
"010016da78a50ca474454a9fed243162",
"010016da78a50ca474454a9fed243163",
"010016da78a50ca474454a9fed243164",
"010016da78a50ca474454a9fed243165",
"010016da78a50ca474454a9fed243166",
"010016da78a50ca474454a9fed243167",
"010016da78a50ca474454a9fed243168",
"010016da78a50ca474454a9fed243169",
"010016da78a50ca474454a9fed243170",
"010016da78a50ca474454a9fed243171",
"010016da78a50ca474454a9fed243172",
"010016da78a50ca474454a9fed243173",
"010016da78a50ca474454a9fed243174",
"010016da78a50ca474454a9fed243175",
"010016da78a50ca474454a9fed243176",
"010016da78a50ca474454a9fed243177",
"010016da78a50ca474454a9fed243178",
"010016da78a50ca474454a9fed243179",
"010016da78a50ca474454a9fed243180",
"010016da78a50ca474454a9fed243181",
"010016da78a50ca474454a9fed243182",
"010016da78a50ca474454a9fed243183",
"010016da78a50ca474454a9fed243184",
"010016da78a50ca474454a9fed243185",
"010016da78a50ca474454a9fed243186",
"010016da78a50ca474454a9fed243187",
"010016da78a50ca474454a9fed243188",
"010016da78a50ca474454a9fed243189",
"010016da78a50ca474454a9fed243190",
"010016da78a50ca474454a9fed243191",
"010016da78a50ca474454a9fed243192",
"010016da78a50ca474454a9fed243193",
"010016da78a50ca474454a9fed243194",
"010016da78a50ca474454a9fed243195",
"010016da78a50ca474454a9fed243196",
"010016da78a50ca474454a9fed243197",
"010016da78a50ca474454a9fed243198",
"010016da78a50ca474454a9fed243199",
"010016da78a50ca474454a9fed243200",
"010016da78a50ca474454a9fed243201",
"010016da78a50ca474454a9fed243202",
"010016da78a50ca474454a9fed243203",
"010016da78a50ca474454a9fed243204",
"010016da78a50ca474454a9fed243205",
"010016da78a50ca474454a9fed243206",
"010016da78a50ca474454a9fed243207",
"010016da78a50ca474454a9fed243208",
"010016da78a50ca474454a9fed243209",
"010016da78a50ca474454a9fed243210",
"010016da78a50ca474454a9fed243211",
"010016da78a50ca474454a9fed243212",
"010016da78a50ca474454a9fed243213",
"010016da78a50ca474454a9fed243214",
"010016da78a50ca474454a9fed243215",
"010016da78a50ca474454a9fed243216",
"010016da78a50ca474454a9fed243217",
"010016da78a50ca474454a9fed243218",
"010016da78a50ca474454a9fed243219",
"010016da78a50ca474454a9fed243220",
"010016da78a50ca474454a9fed243221",
"010016da78a50ca474454a9fed243222",
"010016da78a50ca474454a9fed243223",
"010016da78a50ca474454a9fed243224",
"010016da78a50ca474454a9fed243225",
"010016da78a50ca474454a9fed243226",
"010016da78a50ca474454a9fed243227",
"010016da78a50ca474454a9fed243228",
"010016da78a50ca474454a9fed243229",
"010016da78a50ca474454a9fed243230",
"010016da78a50ca474454a9fed243231",
"010016da78a50ca474454a9fed243232",
"010016da78a50ca474454a9fed243233",
"010016da78a50ca474454a9fed243234",
"010016da78a50ca474454a9fed243235",
"010016da78a50ca474454a9fed243236",
"010016da78a50ca474454a9fed243237",
"010016da78a50ca474454a9fed243238",
"010016da78a50ca474454a9fed243239",
"010016da78a50ca474454a9fed243240",
"010016da78a50ca474454a9fed243241",
"010016da78a50ca474454a9fed243242",
"010016da78a50ca474454a9fed243243",
"010016da78a50ca474454a9fed243244",
"010016da78a50ca474454a9fed243245",
"010016da78a50ca474454a9fed243246",
"010016da78a50ca474454a9fed243247",
"010016da78a50ca474454a9fed243248",
"010016da78a50ca474454a9fed243249",
"010016da78a50ca474454a9fed243250",
"010016da78a50ca474454a9fed243251",
"010016da78a50ca474454a9fed243252"];
let count = 0;
arrs.forEach( async ( item ) => {
let doc = {
"pubID" : "5acd8c615602120007188309",
"slotID" : "5ad7f918d55d6e00075c4b94",
"updateTimestamp" : Date.now(),
"auditStatus" : 0,
"date" : "20180516",
"score" : 1.0,
"scoreTimestamp" : Date.now(),
}
doc.unikey = item;
const rep = await recognition.insert(doc);
console.dir(++count + '========================>');
console.dir(rep);
});
}
task();
const _ip2geo = require('./util/ip')();
_ip2geo.init();
const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob({
cronTime: '00 00 * * * 0-6',
onTick: function() {
fetchRecoginto();
},
start: false,
});
//console.dir(_ip2geo.binarySearch('1.119.186.194'));
const db = require('../db');
const moment = require('moment');
async function task(argument) {
const recognition = await db.getCollection('recognition');
const account = await db.getCollection('account')
const arrs = recognition.find({date:{$exists:false}});
arrs.forEach( async ( item ) => {
console.dir(moment(item.createdAt).format('YYYYMMDD'));
const count = await bills.update({_id:item._id},{ $set:{date:moment(item.createdAt).format('YYYYMMDD') }});
console.dir(count);
});
}
task();
\ No newline at end of file
const db = require('../db');
async function task(argument) {
const emails = [
'858182656@qq.com',
'jieline7@163.com',
'tangyong@mobivans.com',
'649406896@qq.com',
'1874165638@qq.com',
'2169551847@qq.com',
'xiaoxing@careutrip.com',
'bailu@vfast.com.cn',
'wanghongjuan@sunlands.com',
'3199882101@qq.com',
'398607600@qq.com',
'103171407@qq.com',
'798195077@qq.com',
'laurahe@ttledu.com',
'1259598236@qq.com',
'262632873@qq.com',
'chencx@sanhao.com',
'1906718345@qq.com',
'27094666@qq.com',
'565856097@qq.com',
'service@dy-investment.com',
'992488580@qq.com',
'duanyinchu@meizhaike.com',
'wanghuifeng@bonaol.com',
'rerbada@163.com',
'16348448@qq.com',
'nq@puhuilicai.com',
'yangwj@itaojin.cn',
'2000@hb-360.com'];
const fromID = "5b17941d6dea22000776a1cd";
const from = '代理商平台-xiaoshou@xiaoyun.com';
const account = await db.getCollection('account');
const recognition = await db.getCollection('recognition');
const dailyStats = await db.getCollection('dailyStats');
const bills = await db.getCollection('bills');
const callTask = await db.getCollection('callTask');
const dspCallTask = await db.getCollection('dspCallTask');
const dspRecognition = await db.getCollection('dspRecognition');
const statistics = await db.getCollection('statistics');
const task = await db.getCollection('task');
console.dir(emails.length)
let count = 0;
emails.forEach( async item => {
const rep = await account.update({email:item},{$set:{status:1}})
/*let pubID = rep._id + '';
const _rep = await account.update({accountID:rep._id},{$set:{status:1}},{multi:true});*/
console.dir(rep.result.nModified);
//console.dir(pubID);
});
}
task();
const db = require('../db');
let map = function() {
var d = new Date(this.updateTimestamp + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit(this.unikey, (this._id + ""));
};
let reduce = function(k, vals) {
var result = "";
result += vals;
return result;
};
async function task () {
const audit = await db.getCollection('audit')
const arrs = await audit.mapReduce(map, reduce, { query: {}, out: { inline : 1 } } );
let count = 0;
arrs.forEach( x => {
if(x.value.indexOf(',') >= 0) {
x.value.split(',').splice(1).forEach( async y => {
console.dir(y);
//const d = await audit.update({_id:db.ObjectID(y)},{$set:{removed:true}})
//console.dir(d.result);
});
}
})
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(email) {
const agent = await db.getAgentCollection('account');
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const Recognition = await db.getCollection('recognition');
const dspCallTask = await db.getCollection('dspCallTask');
let data = [['unikey','账单批次','账户','账户信息','金额','一级代理商信息','金额','录入日期']];
let recognition_data = [['unikey','备案时间','账户','账户信息','金额','一级代理商信息','金额']];
let call_data = [['通话unikey','时长','分钟','账户','账户信息','金额','一级代理商信息','金额','通话日期']];
let _count = 0;
//let email = "834693562@qq.com";
let agentInfo = await agent.findOne({ email });
console.dir(agentInfo._id + '');
//console.dir(agentInfo);
let accounts = await account.find({ fromID: agentInfo._id + '' }).limit(1000).toArray();
let accountsQuery = [];
let map = {};
accounts = accounts.forEach(x => {
accountsQuery.push(x._id);
accountsQuery.push(x._id + '');
map[x._id + ''] = {
email: x.email,
company: x.company
}
});
//console.dir(accountsQuery);
let datas = await agent.find({ "role" : 2 }).toArray();
let tasks = [];
let mark = moment('20180913').startOf('day').format('x');
let a = await dspRecognition.find({ accountID: { $in: accountsQuery } }).limit(100000000000000).toArray();
let recognitions = await Recognition.find({ pubID: { $in: accountsQuery } }).limit(100000000000000).toArray();
let calls = await dspCallTask.find({ pubID: { $in: accountsQuery } }).limit(100000000000000).toArray();
// 有客精选数据扣费
for( x of a) {
let { unikey, billID, accountID, createdAt } = x;
data.push([unikey, billID, map[accountID].email, map[accountID].company, (createdAt > mark ? 8 : 3), agentInfo.company, (createdAt > mark ? 8 * 0.3 : 0) , moment(createdAt, 'x').format('YYYY-MM-DD HH:mm:dd')]);
}
for( x of calls) {
let { duration = 0, pubID, unikey, startTime } = x;
let minutes = Math.ceil(duration / 60);
call_data.push([unikey, duration, minutes, map[pubID].email,map[pubID].company, (startTime > mark ? minutes : '-') , agentInfo.company, (startTime > mark ? minutes * 0.6 : 0), moment(startTime, 'x').format('YYYY-MM-DD HH:mm:dd') ])
}
for( x of recognitions ) {
let { unikey, audit: audits, pubID, audit } = x;
if(audits) {
audit.forEach( item => {
let { audit } = item;
recognition_data.push([unikey, moment(audit, 'x').format('YYYY-MM-DD HH:mm:dd'), map[pubID].email, (audit > mark ? 8 : 3), agentInfo.company, (audit > mark ? 8 * 2.3 : 0) ])
});
}
}
console.dir(data.length);
var buffer = xlsx.build([{name: "mySheetName", data: call_data }]);
fs.writeFileSync('./bill/' + agentInfo.company +'_话单详单扣费' +'.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
var buffer1 = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFileSync('./bill/' + agentInfo.company + '_有客精选数据详单扣费.xlsx', buffer1, function(err) {
if (err) {
throw err;
}
console.log('Hello1.');
});
var buffer2 = xlsx.build([{name: "mySheetName", data: recognition_data}]);
fs.writeFileSync('./bill/'+ agentInfo.company + '_有客通详单扣费.xlsx', buffer2, function(err) {
if (err) {
throw err;
}
console.log('Hello2.');
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
async function cycle() {
const agent = await db.getAgentCollection('account');
const agents = await agent.find({ role: 2, type: 1}).limit(10000).toArray();
for(let item of agents) {
let email = item.email;
console.dir(email);
task(email);
}
}
//task('119882374@xiaoyun.com');
cycle();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
const INFINITE = 10000000000000000000;
async function task(argument) {
const agent = await db.getAgentCollection('account');
const tokens = await db.getCollection('tokens');
const new_tokens = await db.getNewCollection('tokens');
//let agents = agent.find();
let _tokens = await tokens.find({}).limit(INFINITE).toArray();
for(token of _tokens) {
let { phone, token: password, _id, passwd, saleGroupId, removed, createdAt, updatedAt, nickname, accountID} = token
if(!removed) {
let data = {
_id,
account: db.ObjectID(accountID),
phone,
password,
createdAt,
updatedAt: updatedAt || createdAt
}
if(saleGroupId) data.salegroup = db.ObjectID(saleGroupId)
if(nickname) data.nickname = nickname;
await new_tokens.insert(data);
}
}
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
function generateCode(leng,num) {
let s = '';
if(leng <= (num + '').length) return num + '';
for (var i = 0; i < leng - (num + '').length; i++) {
s += '0';
}
return s + (num + '');
}
async function task(email) {
console.dir( '=====1');
const agent = await db.getNewCollection('agent_caches');
const account = await db.getNewCollection('accounts');
const orders = await db.getNewCollection('orders');
const order_productions = await db.getNewCollection('order_productions');
const groups = await db.getNewCollection('groups');
const group_behaviors = await db.getNewCollection('group_behaviors');
const clues = await db.getNewCollection('clues');
const bills = await db.getNewCollection('bills');
const dspRecognition = await db.getCollection('dspRecognition');
const Recognition = await db.getCollection('recognition');
const bill = await db.getCollection('bills');
const dspCallTask = await db.getCollection('dspCallTask');
console.dir( '====2');
let data = [['unikey','账单批次','账户','账户信息','金额','一级代理商信息','金额','录入日期']];
let recognition_data = [['unikey','备案时间','账户','账户信息','金额','一级代理商信息','金额']];
let call_data = [['通话unikey','时长','分钟','账户','账户信息','金额','一级代理商信息','金额','通话日期']];
//let email = "834693562@qq.com";
let agentInfo = await agent.findOne({ username: email });
console.dir(agentInfo._id + '');
let accounts = await account.find({ "discount.agent.id": agentInfo._id }).limit(1000).toArray();
console.dir(accounts);
let accountsQuery = [];
let map = {};
let agentCode = agentInfo.code;
accounts = accounts.forEach(x => {
//accountsQuery.push(x._id);
accountsQuery.push(x._id + '');
map[x._id + ''] = {
email: x.email,
company: x.company,
code: x.code
}
});
console.dir(accountsQuery);
let tasks = [];
let mark = moment('20180913').startOf('day').format('x');
let a = await dspRecognition.find({ accountID: { $in: accountsQuery } }).limit(100000000000000).toArray();
//let recognitions = await Recognition.find({ pubID: { $in: accountsQuery } }).limit(100000000000000).toArray();
//let calls = await dspCallTask.find({ pubID: { $in: accountsQuery } }).limit(100000000000000).toArray();
let billMap = {}; // account agent money info
let money = 0;
// 有客精选数据扣费
let _count = 0;
console.dir(a.length + '=====');
for( x of a) {
let { _id,unikey, billID, accountID, createdAt, tags, city, province, gender, groupID, carrier, systemTags, remark, tokenInfo } = x;
money += (createdAt > mark ? 8 : 3);
console.dir(billID);
if(!billMap[ billID ]) {
let { date, preNum = 0, createdAt, endTime } = await bill.findOne({_id: db.ObjectID(billID) })
let { lastmodify } = await groups.findOne({ _id: db.ObjectID(groupID) });
billMap[ billID ] = {
code: 'D' + date + generateCode(3,_count),
account: accountID,
agent: agentInfo._id + '',
count: (preNum || 0) / 3,
money: 0,
groupID,
lastmodify,
agentMoney: 0,
clue:0,
createdAt: moment(createdAt).toDate(),
endAt: endTime ? moment(endTime).toDate() : moment(createdAt).toDate()
}
}
billMap[ billID ].money += (createdAt > mark ? 8 : 3);
billMap[ billID ].agentMoney += (createdAt > mark ? 8 * 0.3 : 0);
billMap[ billID ].clue += 1;
console.dir(tokenInfo);
let data = {
_id,
tags: tags,
calledHistory: [],
account: db.ObjectID(accountID),
city: city,
province: province,
unikey: unikey,
code: _id + '',
type: 'group',
from: carrier ? carrier : 'cucc',
key: tags.join(','),
sex: gender,
//token: tokenInfo && tokenInfo.tokenID ? db.ObjectID((tokenInfo.tokenID + '').replace(/saleGroupId_/,"")) : null,
selfTag: systemTags && systemTags.length ? systemTags[systemTags.length -1] : null,
remark: remark && remark.length ? remark[remark.length -1] : null,
createdAt: createdAt,
updatedAt: createdAt
};
if(tokenInfo && tokenInfo.tokenID ){
if((tokenInfo.tokenID + '').indexOf('saleGroupId') >= 0) data.salegroup = db.ObjectID(tokenInfo.tokenID.replace(/saleGroupId_/,""))
else data.token = db.ObjectID(tokenInfo.tokenID);
}
console.dir(data);
await clues.insert(data);
//data.push([unikey, billID, map[accountID].email, map[accountID].company, (createdAt > mark ? 8 : 3), agentInfo.company, (createdAt > mark ? 8 * 0.3 : 0) , moment(createdAt, 'x').format('YYYY-MM-DD HH:mm:dd')]);
}
console.dir(billMap);
for(let billID of Object.keys(billMap)) {
let { account, agent, money, agentMoney, clue = 0, createdAt, endAt, groupID, lastmodify, count } = billMap[billID];
let order = await orders.insert({
award: false,
clue,
count: count,
subOrder:[],
account: db.ObjectID(account),
meta: '',
type: 'data',
group: db.ObjectID(groupID),
status: '已关闭',
"history" : [
{
"status" : "审核中",
"operator" : "",
"date" : createdAt
},
{
"status" : "执行中",
"operator" : "",
"date" : createdAt
},
{
"status" : "已关闭",
"operator" : "",
"date" : endAt
}
],
createdAt: createdAt,
updatedAt: endAt
})
let orderid = order.ops[0]._id;
let sub = await order_productions.insert({
group: db.ObjectID(groupID),
groupbehavior: lastmodify,
createdAt: createdAt,
updatedAt: endAt,
count: clue || 0,
order: orderid
})
await bills.insert({
_id: db.ObjectID(billID),
createdAt: createdAt,
updatedAt:endAt,
subOrder:sub.ops[0]._id,
account: db.ObjectID(account),
money: money,
moneyReal: money,
moneyAward: 0,
type : "data",
count : clue,
price : money / clue,
agent : {
id : db.ObjectID(agentInfo._id),
"money" : agentMoney,
"moneyReal" :agentMoney,
"moneyAward" : 0,
"discount" : 0.3
}
})
}
/* for( x of calls) {
let { duration = 0, pubID, unikey, startTime } = x;
let minutes = Math.ceil(duration / 60);
call_data.push([unikey, duration, minutes, map[pubID].email,map[pubID].company, (startTime > mark ? minutes : '-') , agentInfo.company, (startTime > mark ? minutes * 0.6 : 0), moment(startTime, 'x').format('YYYY-MM-DD HH:mm:dd') ])
}
for( x of recognitions ) {
let { unikey, audit: audits, pubID, audit } = x;
if(audits) {
audit.forEach( item => {
let { audit } = item;
recognition_data.push([unikey, moment(audit, 'x').format('YYYY-MM-DD HH:mm:dd'), map[pubID].email, (audit > mark ? 8 : 3), agentInfo.company, (audit > mark ? 8 * 2.3 : 0) ])
});
}
}*/
/* var buffer = xlsx.build([{name: "mySheetName", data: call_data }]);
fs.writeFileSync('./bill/' + agentInfo.company +'_话单详单扣费' +'.xlsx', buffer, function(err) {
if (err) {
throw err;
}
console.log('Hello.');
});
var buffer1 = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFileSync('./bill/' + agentInfo.company + '_有客精选数据详单扣费.xlsx', buffer1, function(err) {
if (err) {
throw err;
}
console.log('Hello1.');
});
var buffer2 = xlsx.build([{name: "mySheetName", data: recognition_data}]);
fs.writeFileSync('./bill/'+ agentInfo.company + '_有客通详单扣费.xlsx', buffer2, function(err) {
if (err) {
throw err;
}
console.log('Hello2.');
});*/
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
async function cycle() {
const agent = await db.getAgentCollection('account');
const agents = await agent.find({ role: 2, type: 1 }).limit(10000).toArray();
for(let item of agents) {
let email = item.email;
console.dir(email);
await task(email);
}
}
//task('xiaoshou@xiaoyun.com');
cycle();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
group_arrs.forEach((data) => {
if(data && data._id) {
groupMap[data._id + ''] = '';
for(var k in data) {
console.dir(data[k])
if(k == '_id' || k == 'createdAt') {
groupMap[data._id + ''] += ''
}
else {
groupMap[data._id + ''] += (Array.isArray(data[k]) ? data[k].join(',') : data[k])
}
}
}
})
console.dir(groupMap);
let data = [['账单','客户','筛选条件','出数','拨打次数','标签','备注']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
let arrs = await dspRecognition.find({}).limit(1000000000000).toArray();
let map = {};
arrs.forEach( async ({ tags, _id, groupID, billID, remark, systemTags, calledInfo, accountID }) => {
if(map[billID]) {
map[billID].remark = map[billID].remark.concat(remark || []);
map[billID].systemTags = map[billID].systemTags.concat(systemTags || []) ;
map[billID].called = map[billID].called + (calledInfo && calledInfo.length ? calledInfo.length : 0);
map[billID].count = map[billID].count + 1;
} else {
map[billID] = {
remark : remark || [],
systemTags: systemTags || [],
called: calledInfo && calledInfo.length ? calledInfo.length : 0,
count: 1,
account: accountMap[accountID + ''],
group: groupMap[groupID + ''],
}
}
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
for(var k in map) {
console.dir(k)
data.push([k, map[k].account, map[k].group,map[k].count, map[k].called, (map[k].systemTags || []).join('、'), (map[k].remark || []).join('、')])
}
console.dir(data.length);
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./标签.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const bill = await db.getCollection('bills');
const agent = await db.getAgentCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const billID = '5bc70d358651710007979214';
const tobill = await bill.findOne({ _id : db.ObjectID(billID) });
console.dir(db.ObjectID(billID))
console.dir({ billID:billID });
let count = await dspRecognition.count({ billID:billID });
let discount = tobill.agent.discount;
let rep = await bill.update({ _id: db.ObjectID(billID) },{ $set: { 'agent.number' : (8 * count * discount).toFixed(1) , number: count * 8, pre: false, 'platform.number' : count * 8 }})
let _rep = await agent.update({ 'preNumber.billID': { '$in' : [ db.ObjectID(billID),billID ]} },{ $pull: { 'preNumber' : { billID : {'$in': [ db.ObjectID(billID),billID ] }} }})
console.dir(rep.result.nModified);
console.dir(rep.result.nModified);
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const bill = await db.getCollection('bills');
const agent = await db.getAgentCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const billID = '5bc70d358651710007979214';
const tobill = await bill.findOne({ _id : db.ObjectID(billID) });
let count = await dspRecognition.count({ billID:billID });
let discount = tobill.agent.discount;
let rep = await bill.update({ _id: db.ObjectID(billID) },{ $set: { 'agent.number' : (8 * count * discount).toFixed(1) , number: count * 8, pre: false, 'platform.number' : count * 8 }})
let _rep = await agent.update({ 'preNumber.billID': { '$in' : [ db.ObjectID(billID),billID ]} },{ $pull: { 'preNumber' : { billID : {'$in': [ db.ObjectID(billID),billID ] }} }})
console.dir(rep.result.nModified);
console.dir(rep.result.nModified);
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
async function task(argument) {
const agents = await db.getAgentCollection('account');
const accounts = await db.getCollection('account');
const bills = await db.getCollection('bills');
const arrs = await agents.find({}).toArray();
console.dir(arrs.length);
let _count = 0;
let all = [['代理商ID','代理商账户','代理商余额','折扣','直客账户','账户状态','直客余额']];
let arr = [];
let count = 0;
let _arrs = [];
arrs.forEach( ( { _id, email, discount, company, balance, oldbalance, preNumber } ) => {
count ++;
if(preNumber && preNumber.length){
_arrs.push({_id,preNumber})
}
});
_arrs.forEach(async ({_id,preNumber}) => {
preNumber.forEach(async ({ billID }) => {
let bill = await bills.findOne({ _id:billID, pre: false });
if(bill){
console.dir(bill._id + '-----' + bill.number);
//console.dir(bill.agent);
}
/* let { pre, number, agent } = bill;
console.dir({ pre, number, agent } );*/
})
//console.dir(preNumber.map( x => x.billID + ''))
});
}
async function getRechargeByAccount( accountID ) {
let recharges = await db
.getCollection('recharge');
let _recharges = await recharges.aggregate([
{
$match:{
"accountID": db.ObjectID(accountID),
"removed": { $ne: true }
}
},
{
$group:{
_id:null,
sum:{$sum:"$number"}
}
}]).toArray();
return ( (_recharges && _recharges.length) ? _recharges[0].sum : 0 );
}
async function getBillByAccount( accountID ) {
let consumes = await db
.getCollection('bills')
let _consumes = await consumes.aggregate([
{
$match:{
"accountID": db.ObjectID(accountID),
"removed": { $ne: true }
/* "createdAt": { '$gt': start, '$lte': end }*/
}
},
{
$group:{
_id: null,
sum: {$sum:"$number"}
}
}]).toArray();
return ( (_consumes && _consumes.length) ? _consumes[0].sum : 0 );
}
task();
var lians =["5be12d1c4a323a0007ee6dcf",
"5be1114c4a323a0007ee6d4d",
"5be10112d2dd060007e4ca52",
"5be0f5ccd2dd060007e4ca0f",
"5be0f03ed2dd060007e4c9e6",
"5be00a3b68829000077ecf99",
"5bdff5fe68829000077ecf12",
"5bdfdcdd68829000077ece9e",
"5bdfcfcd68829000077ece78",
"5bdfb2ed68829000077ece3b",
"5bdf984c68829000077ecd9a",
"5bdc2de268829000077ecc49",
"5bdc214d68829000077ecc33",
"5bdc1a2b68829000077ecc14",
"5bdc183568829000077ecc0e",
"5bdc15b468829000077ecc00",
"5bdc0f1b68829000077ecbdb",
"5bdbf8ac37d26a0007150b69",
"5bdbf24037d26a0007150b1c",
"5bdbbe9637d26a0007150a6b",
"5bdab39537d26a0007150936",
"5bda831b37d26a00071508c6",
"5bda7dd037d26a00071508c4",
"5bda786b37d26a00071508bd",
"5bda6f5137d26a0007150886",
"5bd99c9237d26a000715079d",
"5bd96af55f386400072cd550",
"5bd95ae25f386400072cd50e",
"5bd921135f386400072cd465",
"5bd835a8dfa3f5000769f0b3",
"5bd827acdfa3f5000769f084",
"5bd81ddadfa3f5000769f05f",
"5bd7fd4fdfa3f5000769efb2",
"5bd7f16edfa3f5000769ef73",
"5bd6a5f3521e9d0007b5f4f7",
"5bd2cfb344ce5e0007173538"];
var dians = ["TY00092120181102A",
"TY00091220181102A",
"TY00090220181102A",
"TY00089920181102A",
"TY00089320181101A",
"TY00088620181031A",
"TY00088220181031A",
"TY00088020181031A",
"TY00086120181030A",
"TY00085320181030A",
"TY00084820181030A",
"TY00084720181030A",
"TY00084620181030A",
"TY00080720181025A",
"TY00079920181025A",
"TY00079820181025A",
"TY00068220181016A",
"TY00068120181015A",
"TY00085020181030A",
"TY00079320181024A",
"TY00078120181023A",
"TY00077120181023A",
"TY00075220181022A",
"TY00071320181017A",
"TY00067220181015A",
"TY00065020181012A",
"TY00062720181010A",
"TY00062120181009A",
"TY00061520181009A",
"TY00059620181008A",
"TY00059120181008A",
"TY00058620180929A",
"TY00058420180929A",
"TY00049120180929A",
"TY00042320180929A"]
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const bills = await db.getCollection('bills');
let data = [['代理商','总余额','预扣账单/金额']];
let _count = 0;
let datas = await bills.find({ meta: { $in: dians} /*_id:{ $in: lians.map( x => db.ObjectID(x))}*/ }).toArray();
let tasks = [];
datas.forEach( async ({ _id, pre, meta, preNum, agent = null, accountID }) => {
//console.dir(accountID + '' + pre);
if(pre == false) {
console.dir(meta + accountID + '' + pre)
/*let count = preNum / 3;
let number = count * 8;
let _agent = agent;
_agent.number = number * agent.discount;
console.dir({ number: number, agent: _agent, pre: true });
tasks.push(new Promise(async (r,e) => {
console.dir({ _id: _id + ''});
r(await bills.update({_id:_id},{ $set: { number: number, agent: agent, pre: true }}) || 0);
}))*/
}
//console.dir(pre + meta)
});
}
function ISODateRange(date) {
const startAt = moment(date).format(`YYYY-MM-DD 00:00:00`)
, endAt = moment(date).add(1, 'd').format(`YYYY-MM-DD 00:00:00`)
return [new Date(startAt), new Date(endAt)];
}
task();
const cron = require('cron');
const config = require('../config');
const nodemailer = require('nodemailer');
const moment = require("moment");
const CronJob = cron.CronJob;
const _ = require('lodash');
const db = require('../db');
const fs = require('fs');
const path = '/Users/liusong/';
const job = new CronJob({
cronTime: '45 23 18 * * 0-6',
onTick: function () {
taskGo();
},
start: false
});
let date = moment().add(-1,'days').format('YYYYMMDD');
const statsTask = require('./tasks/statisticsTask');
async function taskGo () {
console.dir('begin go');
let start = ( end = date );
let timeQs = getTimeRange({ start, end, key:'updateTimestamp', type: 'millisecond' });
let qs = _.clone(timeQs);
/*
let taskQuery = _.clone(timeQs);
let callTaskQuery = getTimeRange({ start, end, key:'startTime', type: 'millisecond' });
let recognitionsQuery = _.clone(timeQs);
*/
await statsHandler(qs,date);
}
async function statsHandler(query,date) {
const dailyStats = await db.getCollection('dailyStats');
const arrs = await statsTask(query);
const txt = 'stats_' + date + '.log';
let pv = 0;
let uid = 0;
let pubObject = {};
arrs.forEach( async x => {
if(date === x._id.date) {
let uniqUid = (x.value.uids = typeof(x.value.uids) == 'string' ? 1 : _.uniq(x.value.uids).length);
if(pubObject[ x._id.pubID ]) {
pubObject[ x._id.pubID ].pv += x.value.pv;
pubObject[ x._id.pubID ].uid += uniqUid;
} else {
pubObject[ x._id.pubID ] = { pv : x.value.pv, uid: uniqUid };
}
let data = {
date: x._id.date,
slotID: x._id.slotID,
pubID: x._id.pubID,
pv: x.value.pv,
uid: uniqUid
};
pv += data.pv;
uid += data.uid;
let rep = await dailyStats.insert(data);
console.dir(rep);
if(rep.result && rep.result.ok && rep.ops && rep.ops.length){
log(txt, '插入一条记录: ' + rep.ops[0]._id );
} else {
log(txt, '插入失败: ' + rep );
}
} else {
log(txt, '筛选错误: ' + date + 'diff' + x._id.date);
}
});
Object.keys(pubObject).forEach( async (pubID) => {
let slotID = 'all';
let rep = await dailyStats.insert( _.merge(pubObject[pubID], { pubID, slotID ,date }) );
if(rep.result && rep.result.ok && rep.ops && rep.ops.length){
log(txt, '插入一条记录: slotID = all ' + rep.ops[0]._id );
} else {
log(txt, '插入失败: ' + rep );
}
});
let rep = await dailyStats.insert({
pv,
uid,
pubID: 'all',
slotID: 'all',
date
});
if(rep.result && rep.result.ok && rep.ops && rep.ops.length){
log(txt, '插入一条记录: pubID= all ; slotID = all ' + rep.ops[0]._id );
} else {
log(txt, '插入失败: ' + rep );
}
console.log('完成');
}
function log(txt, info){
fs.appendFile(path + txt, info + '\n',function(){
console.log(date + ':' + info);
});
}
function getTimeRange({ start, end, type, key}) {
if(/^[0-9]{8}$/.test(start) && /^[0-9]{8}$/.test(end) ) {
if(type === 'millisecond') {
return { [ key ]: { '$gt': parseInt(moment(start,'YYYYMMDD').startOf('day').format('x')), '$lte': parseInt(moment(end,'YYYYMMDD').endOf('day').format('x')) } };
} else {
return { [ key ]: { '$gt': moment(start,'YYYYMMDD').startOf('day').toDate(), '$lte': moment(end,'YYYYMMDD').endOf('day').toDate() } };
}
} else {
if(type === 'millisecond') {
return { [ key ]: { '$gt': parseInt(moment().add(-7,'days').startOf('day').format('x')), '$lte': parseInt(moment().endOf('day').format('x')) } };
} else {
return { [ key ]: { '$gt': moment().add(-7,'days').startOf('day').toDate(), '$lte': moment().endOf('day').toDate() } };
}
}
}
module.exports.start = function () {
job.start();
};
\ No newline at end of file
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
let data = [['unikey','订单ID','tag1','tag2','tag3','tag4','tag5','tag6','tag7','反馈标签']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
let arrs = await dspRecognition.find({createdDate:{'$gte':'20181008','$gte':'20181014'}}).limit(1000000000000).toArray();
console.dir(arrs.length);
let map = {};
arrs.forEach( async ({ tags, _id, unikey, groupID, billID, remark, systemTags, calledInfo, accountID }) => {
data.push([unikey,billID,tags[0],tags[1],tags[2],tags[3],tags[4],tags[5],tags[6],(systemTags && systemTags.length ? systemTags.join(',') : '')])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./标签.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
let map = function() {
var d = new Date(this.startTime + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit(d.getFullYear() + '' + doub(d.getMonth() + 1) + '' + doub(d.getDate()), { sum: 1 });
};
let reduce = function(k, vals) {
var result = { sum: 0 };
for(var i in vals) {
result.sum += vals[i].sum;
}
return result;
};
module.exports = async function (query) {
return db.collection('callTask').mapReduce(map, reduce, { query, out: { inline : 1 } } );
}
\ No newline at end of file
let map = function() {
var d = new Date(this.updateTimestamp + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit({ date: d.getFullYear() + '' + doub(d.getMonth() + 1) + '' + doub(d.getDate()), pubID: this.accountID },, { sum: 1 });
};
let reduce = function(k, vals) {
var result = { sum: 0 };
for(var i in vals) {
result.sum += vals[i].sum;
}
return result;
};
module.exports = async function (query) {
return db.collection('task').mapReduce(map, reduce, { query, out: { inline : 1 } } );
}
\ No newline at end of file
let map = function() {
var d = new Date(this.updateTimestamp + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit({ date: d.getFullYear() + '' + doub(d.getMonth() + 1) + '' + doub(d.getDate()), slotID: this.slotID, pubID: this.pubID }, { number: 1 });
};
let reduce = function(k, vals) {
var result = { number: 0 };
for(var i in vals) {
result.number += vals[i].number;
}
return result;
};
module.exports = async function (query) {
return db.collection('recognition').mapReduce(map, reduce, { query, out: { inline : 1 } } );
}
const db = require('../../db');
let map = function() {
var d = new Date(this.updateTimestamp + 8 * 60 * 60 * 1000);
var doub = function(num) {
if ( num <= 9 ) return "0" + num;
else return num;
}
emit({ date: d.getFullYear() + '' + doub(d.getMonth() + 1) + '' + doub(d.getDate()), slotID: this.slotID, pubID: this.pubID }, {pv: this.pv, uids: this.uid});
};
let reduce = function(k, vals) {
var result = { pv:0, uids: [] };
var uniqs = [];
for(var i in vals) {
result.pv += vals[i].pv;
result.uids = result.uids.concat(vals[i].uids)
}
return result;
};
module.exports = async function (query) {
const statistics = await db.getCollection('statistics');
return (await statistics.mapReduce(map, reduce, { query, out: { inline : 1 } } ));
}
const db = require('../db');
async function task(argument) {
const dspRecognition = await db.getCollection('dspRecognition');
var a = ["185****1902",
"132****1965",
"176****5508",
"186****7457",
"185****2758",
"130****0684",
"176****8616",
"185****7357",
"186****2188",
"185****2136",
"132****8507",
"185****9245",
"185****7530",
"185****9808",
"186****7288",
"185****6885",
"156****3555",
"132****2662",
"130****2060",
"185****7738",
"156****0532",
"185****0333",
"186****2613",
"175****6194",
"185****8182",
"186****1392",
"185****9615",
"156****3213",
"130****8313",
"185****5390",
"155****5009",
"186****9694",
"185****2775",
"132****2226",
"185****7721",
"155****3650",
"130****6183",
"186****7000",
"131****0350",
"131****3581",
"130****1777",
"176****2578",
"186****2058",
"185****3647",
"156****5178",
"130****3467",
"186****2522",
"156****1398",
"186****3527",
"185****6808",
"132****8808",
"185****2188",
"185****2588",
"130****9987",
"185****9689",
"176****0709",
"156****2740",
"156****2112",
"131****6586",
"130****8968",
"156****8192",
"185****1201",
"186****2309",
"132****4671",
"156****0550",
"185****5156",
"156****8991",
"132****7121",
"132****6550",
"185****3344",
"132****6601",
"185****3113",
"186****8618",
"186****5231",
"131****6612",
"130****0111",
"186****0902",
"186****9003",
"185****5107",
"156****7814",
"186****5217",
"156****7833",
"131****5106",
"185****7819",
"176****9936",
"132****8366",
"186****0765",
"186****0617",
"185****5057",
"155****0102",
"186****6854",
"131****0135",
"156****4767",
"176****0281",
"186****6716",
"186****0907",
"176****1776",
"186****3270",
"155****3903",
"186****1532",
"130****2596",
"185****3917",
"130****4838",
"186****5828",
"185****8101",
"185****2230",
"130****5825",
"185****5511",
"131****0378",
"175****6758",
"156****4948",
"185****3509",
"186****1984",
"131****4136",
"185****2123",
"186****2919",
"186****4387",
"131****3970",
"156****2709",
"186****6983",
"186****5343",
"130****6346",
"131****3612",
"185****8095",
"131****8660",
"186****1270",
"131****4444",
"131****6783",
"156****8013",
"186****4654",
"186****0057",
"175****9784",
"176****6600",
"186****2695",
"176****8106",
"186****5058",
"186****9813",
"185****2797",
"131****8327",
"176****6736",
"185****7133",
"132****8504",
"130****5550",
"186****5822",
"186****4915",
"155****0829",
"176****5207",
"156****7719",
"186****1109",
"186****5124",
"156****2942",
"156****7263",
"156****2051",
"186****3346",
"185****1305",
"185****1137",
"186****1468",
"176****4737",
"132****6171",
"130****3382",
"186****7312",
"186****4441",
"176****5002",
"130****9186",
"185****7112",
"176****9160",
"176****9806",
"186****6695",
"185****0830",
"176****0807",
"185****0852",
"186****3553",
"185****7377",
"185****5170",
"155****4999",
"186****5316",
"156****9581",
"185****8883",
"132****3009",
"132****3567",
"176****1903"]
var aa = ["185****6330",
"176****6921",
"185****7911",
"131****7609",
"186****9099",
"186****2326",
"176****7068",
"130****1311",
"185****4222",
"186****5804",
"185****9898",
"132****0808",
"186****4111",
"186****7901",
"130****6665",
"186****3262",
"185****9835",
"131****8111",
"186****7600",
"185****2143",
"186****7070",
"185****5599",
"156****9991",
"156****9333",
"185****8888",
"185****3123",
"186****2991",
"186****0470",
"156****2357",
"186****5693",
"186****1073",
"130****0603",
"186****0110",
"185****8589",
"186****1616",
"186****5240",
"186****0915",
"131****6088",
"186****7758",
"186****2933",
"185****2330",
"185****8666",
"186****0504",
"130****9666",
"176****1005",
"186****5622",
"185****0877",
"185****6225",
"132****8888",
"176****8750",
"185****3575",
"185****1098",
"185****8185",
"186****3686",
"185****3688",
"186****9737",
"186****3503",
"186****5617",
"132****3309",
"186****6197",
"176****3170",
"185****2369",
"186****4950",
"186****5283",
"185****9321",
"186****2603",
"131****1314",
"156****6262",
"186****3699",
"185****8597",
"185****1025",
"185****0427",
"185****4060",
"185****6350",
"156****1393",
"186****9993",
"186****1319",
"185****5580",
"130****8889",
"185****6885",
"176****7199",
"185****6111",
"185****6713",
"176****1962",
"176****6163",
"130****7319",
"185****7888",
"186****5772",
"156****1691",
"186****9888",
"130****4422",
"176****1560",
"156****8718",
"176****3003",
"186****7187",
"185****5605",
"186****1489",
"156****9966",
"186****9643",
"186****8183",
"186****5777",
"186****6219",
"186****0952",
"130****3555",
"186****7769",
"185****5993",
"186****2600",
"156****1852",
"186****5752",
"185****8955",
"186****9951",
"186****6061",
"176****5091",
"186****3061",
"186****4255",
"186****3320",
"185****2489",
"185****2328",
"131****8261",
"186****7338",
"156****7405",
"186****2012",
"186****3132",
"130****7567",
"185****8345",
"186****7552",
"131****6333",
"130****6069",
"186****0707",
"186****6561",
"156****1101",
"186****6546",
"185****7670",
"130****4444",
"186****8230",
"155****0288",
"186****3788",
"156****1579",
"185****9777",
"176****7656",
"131****0459",
"176****8387",
"185****5565",
"186****4966",
"185****8557",
"185****9999",
"185****5497",
"185****7588",
"185****9292",
"186****7050",
"130****3015",
"185****6643",
"131****2636",
"186****7457",
"156****8771",
"186****8521",
"186****1300",
"185****1911",
"186****8711",
"186****5005",
"186****9962",
"185****5534",
"176****3909",
"185****1010",
"186****5693",
"186****9022",
"186****8935",
"156****7510",
"156****7360",
"186****6666",
"131****0329",
"186****5115",
"176****1278",
"185****5811",
"130****9466",
"185****8572",
"186****2119",
"185****4877",
"185****9758",
"185****2859",
"186****3538",
"186****3322",
"185****8502",
"186****4149",
"185****7103",
"186****8739",
"186****8624",
"176****2722",
"131****0727",
"176****9619",
"185****0813",
"185****3668",
"186****1116",
"186****9553",
"186****7345",
"185****7386",
"156****7777",
"176****2781",
"185****0219",
"186****9378",
"185****8218",
"186****8819",
"186****7124",
"186****6717",
"186****9628",
"176****5100",
"131****7594",
"185****7099",
"186****7127",
"132****6000",
"176****7765",
"185****8511",
"186****1212",
"185****1882",
"185****3508",
"186****5103",
"186****8503",
"186****5690",
"185****7711",
"166****2504",
"176****3313",
"186****1115",
"186****7398",
"185****6129",
"176****3627",
"186****2028",
"185****8647",
"186****6367",
"131****3937",
"186****0600",
"131****9275",
"186****0504",
"185****1004",
"185****9085",
"186****4393",
"186****9591",
"185****8869",
"186****8266",
"176****5197",
"185****0886",
"185****8897",
"156****1858",
"132****5888",
"186****9733",
"185****4141",
"185****4555",
"185****9134",
"156****9285",
"186****8555",
"186****9273",
"186****0964",
"186****0330",
"185****4455",
"132****9393",
"131****6107",
"132****8407",
"186****9996",
"186****2517",
"185****5576",
"186****7878",
"186****8969"]
var aaa = ["186****9720",
"186****3958",
"185****8165",
"186****6377",
"186****5105",
"186****7233",
"131****4444",
"186****7568",
"131****7200",
"185****2688",
"131****2846",
"186****1199",
"176****6662",
"186****6563",
"186****5376",
"130****9278",
"131****1919",
"186****1669",
"186****6752",
"186****7995",
"185****4280",
"186****6220",
"185****2892",
"185****6313",
"186****5522",
"186****7827",
"156****8111",
"186****5099",
"186****8938",
"186****5900",
"186****0359",
"185****8999",
"186****6123",
"186****6988",
"185****7594",
"186****3276",
"130****8684",
"185****6534",
"185****1899",
"186****7791",
"186****5147",
"186****8456",
"186****0085",
"185****3888",
"186****1534",
"185****3955",
"131****5550",
"130****2222",
"186****2026",
"185****5431",
"185****0788",
"132****7766",
"186****3789",
"185****5835",
"156****5689",
"176****0559",
"186****9188",
"186****5968",
"132****6230",
"130****8889",
"186****7109",
"156****8698",
"186****6055",
"131****6328",
"130****4288",
"186****3323",
"186****2757",
"131****3147",
"186****3332",
"186****3733",
"156****2231",
"185****3323",
"186****5899",
"186****0222",
"132****7555",
"186****8028",
"186****8500",
"186****1105",
"186****8380",
"176****6686",
"186****5855",
"131****4431",
"186****2826",
"156****0659",
"185****7687",
"185****6330",
"186****6808",
"185****8683",
"186****7890",
"156****1932",
"185****3555",
"185****3999",
"185****7097",
"186****5955",
"185****6837",
"176****7695",
"130****0103",
"185****3044",
"132****3552",
"186****7277",
"186****7374",
"186****8697",
"185****6556",
"186****7826",
"186****1126",
"185****5860",
"130****4466",
"131****8500",
"186****3336",
"186****6613",
"186****1318",
"186****5947",
"186****2232",
"185****5512",
"131****4790",
"185****0629",
"131****1555",
"176****2388",
"131****3333",
"176****3091",
"186****5959",
"186****5888",
"186****1301",
"132****9999",
"130****0229",
"185****4040",
"186****7616",
"186****8599",
"130****8066",
"186****3976",
"185****9967",
"185****5919",
"155****0563",
"130****6100",
"131****5555",
"166****0796",
"130****2222",
"186****8598",
"185****0677",
"186****7440",
"186****0515",
"186****3221",
"186****1733",
"186****3062",
"132****6056",
"185****9588",
"186****6205",
"186****8895",
"185****1019",
"186****5666",
"186****5986",
"185****6166",
"186****2000",
"186****8111",
"186****8198",
"156****3086",
"185****0283",
"186****2699",
"176****7313",
"186****3808",
"186****8661",
"130****3765",
"130****1999",
"186****2848",
"186****6777",
"185****1030",
"130****5316",
"130****3333",
"132****5756",
"130****2999",
"186****3868",
"186****9811",
"131****1745",
"186****8083",
"186****3590",
"186****2777",
"186****8182",
"185****4527",
"176****9911",
"130****5201",
"186****0891",
"186****6364",
"186****0861",
"186****7770",
"186****6810",
"185****5758",
"185****5756",
"156****9085",
"185****6886",
"186****3057",
"131****2626",
"131****9922",
"185****8879",
"186****1590",
"186****7809",
"185****8629",
"186****3816",
"185****6605",
"176****6333",
"186****9567",
"156****0759",
"186****9778",
"185****2283",
"155****7200",
"186****3689",
"176****9316",
"185****4835",
"186****5660",
"185****9593",
"185****4564",
"156****0888",
"186****9150",
"186****8582",
"186****1933",
"186****1816",
"186****9033",
"185****0777",
"130****9800",
"185****9009",
"186****9503",
"186****2127",
"186****3824",
"185****1189",
"185****3958",
"176****9613",
"185****0101",
"186****9292",
"186****1015",
"185****3633",
"186****4000",
"186****7541",
"185****3869",
"186****6421",
"185****2330",
"156****8641",
"186****7830",
"186****1817",
"185****2320",
"186****7902",
"185****5588",
"132****3669",
"185****0595",
"176****5218",
"186****6924",
"131****8808",
"186****7007",
"176****8000",
"186****6609",
"185****8873",
"185****2138",
"186****7764",
"186****4695",
"176****0078",
"132****6100",
"186****4450",
"132****4962",
"166****7895",
"186****6027",
"185****8810",
"185****4560",
"186****8890",
"156****3367"]
console.dir(aaa.length);
let count = 0;
var map = {
"185****1902":"周先生",
"132****1965":"刘先生",
"176****5508":"赵先生",
"186****7457":"张先生",
"185****2758":"陈先生",
"130****0684":"尹先生",
"176****8616":"李先生",
"185****7357":"刘先生",
"186****2188":"宋先生",
"185****2136":"王先生",
"132****8507":"史先生",
"185****9245":"北未知",
"185****7530":"魏先生",
"185****9808":"北未知",
"186****7288":"李先生",
"185****6885":"宋女士",
"156****3555":"丁先生",
"132****2662":"王先生",
"130****2060":"张先生",
"185****7738":"吴女士",
"156****0532":"白女士",
"185****0333":"李先生",
"186****2613":"江先生",
"175****6194":"乐先生",
"185****8182":"付先生",
"186****1392":"段女士",
"185****9615":"张先生",
"156****3213":"周先生",
"130****8313":"李先生",
"185****5390":"孔先生",
"155****5009":"王女士",
"186****9694":"芮先生",
"185****2775":"刘先生",
"132****2226":"侯先生",
"185****7721":"北未知",
"155****3650":"吕先生",
"130****6183":"薛女士",
"186****7000":"宋女士",
"131****0350":"程先生",
"131****3581":"冀先生",
"130****1777":"赵女士",
"176****2578":"刘先生",
"186****2058":"陆先生",
"185****3647":"邱先生",
"156****5178":"耿先生",
"130****3467":"张先生",
"186****2522":"高先生",
"156****1398":"李先生",
"186****3527":"王先生",
"185****6808":"王先生",
"132****8808":"李女士",
"185****2188":"北未知",
"185****2588":"李先生",
"130****9987":"李先生",
"185****9689":"薄女士",
"176****0709":"辛先生",
"156****2740":"伊先生",
"156****2112":"李先生",
"131****6586":"姜先生",
"130****8968":"焦先生",
"156****8192":"王先生",
"185****1201":"许先生",
"186****2309":"潘女士",
"132****4671":"金女士",
"156****0550":"廖先生",
"185****5156":"臧女士",
"156****8991":"徐先生",
"132****7121":"刘先生",
"132****6550":"崔女士",
"185****3344":"李女士",
"132****6601":"李先生",
"185****3113":"闫女士",
"186****8618":"张女士",
"186****5231":"邢先生",
"131****6612":"董先生",
"130****0111":"何先生",
"186****0902":"卢先生",
"186****9003":"陈先生",
"185****5107":"张先生",
"156****7814":"王先生",
"186****5217":"安先生",
"156****7833":"李先生",
"131****5106":"白女士",
"185****7819":"鲍先生",
"176****9936":"于先生",
"132****8366":"王先生",
"186****0765":"北未知",
"186****0617":"史先生",
"185****5057":"王先生",
"155****0102":"宋先生",
"186****6854":"张先生",
"131****0135":"刘先生",
"156****4767":"肖先生",
"176****0281":"曹先生",
"186****6716":"刘女士",
"186****0907":"贺女士",
"176****1776":"陈先生",
"186****3270":"李先生",
"155****3903":"郭先生",
"186****1532":"兰女士",
"130****2596":"宋先生",
"185****3917":"李先生",
"130****4838":"张先生",
"186****5828":"王先生",
"185****8101":"张先生",
"185****2230":"王先生",
"130****5825":"丁先生",
"185****5511":"杜先生",
"131****0378":"辛先生",
"175****6758":"刘先生",
"156****4948":"于先生",
"185****3509":"柳先生",
"186****1984":"代女士",
"131****4136":"薛先生",
"185****2123":"刘女士",
"186****2919":"张女士",
"186****4387":"王女士",
"131****3970":"李先生",
"156****2709":"黄女士",
"186****6983":"尚先生",
"186****5343":"秦先生",
"130****6346":"乔先生",
"131****3612":"纪先生",
"185****8095":"李先生",
"131****8660":"刘先生",
"186****1270":"果先生",
"131****4444":"梁先生",
"131****6783":"罗先生",
"156****8013":"景女士",
"186****4654":"李先生",
"186****0057":"北未知",
"175****9784":"史先生",
"176****6600":"周女士",
"186****2695":"王先生",
"176****8106":"王先生",
"186****5058":"李先生",
"186****9813":"北未知",
"185****2797":"孙先生",
"131****8327":"张先生",
"176****6736":"夏先生",
"185****7133":"北未知",
"132****8504":"刘先生",
"130****5550":"李先生",
"186****5822":"刘先生",
"186****4915":"赵女士",
"155****0829":"王先生",
"176****5207":"任先生",
"156****7719":"陈先生",
"186****1109":"尤先生",
"186****5124":"王先生",
"156****2942":"黑先生",
"156****7263":"陈先生",
"156****2051":"徐先生",
"186****3346":"赵先生",
"185****1305":"贾先生",
"185****1137":"北未知",
"186****1468":"林先生",
"176****4737":"孙先生",
"132****6171":"侯先生",
"130****3382":"王先生",
"186****7312":"王先生",
"186****4441":"韩女士",
"176****5002":"印先生",
"130****9186":"张先生",
"185****7112":"高先生",
"176****9160":"张先生",
"176****9806":"贾先生",
"186****6695":"上未知",
"185****0830":"刘先生",
"176****0807":"王先生",
"185****0852":"张先生",
"186****3553":"刘先生",
"185****7377":"许先生",
"185****5170":"张先生",
"155****4999":"吕先生",
"186****5316":"谢先生",
"156****9581":"苏先生",
"185****8883":"王先生",
"132****3009":"北未知",
"132****3567":"罗先生",
"176****1903":"范先生"
}
var maps = {"185****6330":"肖先生",
"176****6921":"孙先生",
"185****7911":"张先生",
"131****7609":"刘先生",
"186****9099":"胡先生",
"186****2326":"赵先生",
"176****7068":"张先生",
"130****1311":"吴女士",
"185****4222":"李先生",
"186****5804":"石先生",
"185****9898":"翟先生",
"132****0808":"孙女士",
"186****4111":"刘女士",
"186****7901":"孟先生",
"130****6665":"靖女士",
"186****3262":"秦女士",
"185****9835":"孙先生",
"131****8111":"郑先生",
"186****7600":"李先生",
"185****2143":"北未知",
"186****7070":"徐女士",
"185****5599":"张先生",
"156****9991":"宋先生",
"156****9333":"李先生",
"185****8888":"张先生",
"185****3123":"庄先生",
"186****2991":"王先生",
"186****0470":"何女士",
"156****2357":"姜先生",
"186****5693":"周先生",
"186****1073":"罗先生",
"130****0603":"罗先生",
"186****0110":"赵先生",
"185****8589":"李先生",
"186****1616":"王先生",
"186****5240":"万女士",
"186****0915":"陈先生",
"131****6088":"周先生",
"186****7758":"李先生",
"186****2933":"李先生",
"185****2330":"北未知",
"185****8666":"董先生",
"186****0504":"王先生",
"130****9666":"纪先生",
"176****1005":"丁先生",
"186****5622":"李先生",
"185****0877":"匡先生",
"185****6225":"李先生",
"132****8888":"刘先生",
"176****8750":"曲先生",
"185****3575":"颜先生",
"185****1098":"李先生",
"185****8185":"张先生",
"186****3686":"张先生",
"185****3688":"郝先生",
"186****9737":"苏先生",
"186****3503":"李先生",
"186****5617":"高女士",
"132****3309":"李女士",
"186****6197":"多女士",
"176****3170":"郭先生",
"185****2369":"陈先生",
"186****4950":"相先生",
"186****5283":"兰先生",
"185****9321":"张先生",
"186****2603":"马先生",
"131****1314":"郑先生",
"156****6262":"褚先生",
"186****3699":"王先生",
"185****8597":"王先生",
"185****1025":"三未知",
"185****0427":"刘女士",
"185****4060":"汤先生",
"185****6350":"北未知",
"156****1393":"王女士",
"186****9993":"陈先生",
"186****1319":"彭先生",
"185****5580":"张先生",
"130****8889":"北未知",
"185****6885":"李先生",
"176****7199":"岑先生",
"185****6111":"李先生",
"185****6713":"郑先生",
"176****1962":"陈先生",
"176****6163":"贾先生",
"130****7319":"任先生",
"185****7888":"范先生",
"186****5772":"孙先生",
"156****1691":"高先生",
"186****9888":"刘先生",
"130****4422":"薄先生",
"176****1560":"王先生",
"156****8718":"谢先生",
"176****3003":"韩先生",
"186****7187":"张女士",
"185****5605":"裴先生",
"186****1489":"嘉先生",
"156****9966":"北未知",
"186****9643":"王先生",
"186****8183":"单先生",
"186****5777":"段女士",
"186****6219":"宋女士",
"186****0952":"王先生",
"130****3555":"王先生",
"186****7769":"北未知",
"185****5993":"姜先生",
"186****2600":"周先生",
"156****1852":"张先生",
"186****5752":"宋女士",
"185****8955":"李先生",
"186****9951":"田先生",
"186****6061":"王先生",
"176****5091":"张先生",
"186****3061":"郭先生",
"186****4255":"赵先生",
"186****3320":"薛先生",
"185****2489":"程女士",
"185****2328":"史先生",
"131****8261":"徐先生",
"186****7338":"吕先生",
"156****7405":"王先生",
"186****2012":"蔡先生",
"186****3132":"帅女士",
"130****7567":"霍先生",
"185****8345":"罗先生",
"186****7552":"袁先生",
"131****6333":"王女士",
"130****6069":"王女士",
"186****0707":"赵女士",
"186****6561":"柴先生",
"156****1101":"王先生",
"186****6546":"冯先生",
"185****7670":"刘先生",
"130****4444":"韩先生",
"186****8230":"徐先生",
"155****0288":"谭先生",
"186****3788":"滕女士",
"156****1579":"刘先生",
"185****9777":"王先生",
"176****7656":"杨先生",
"131****0459":"吝先生",
"176****8387":"贾先生",
"185****5565":"马先生",
"186****4966":"张先生",
"185****8557":"张女士",
"185****9999":"付先生",
"185****5497":"北未知",
"185****7588":"徐先生",
"185****9292":"孟先生",
"186****7050":"尚先生",
"130****3015":"曹先生",
"185****6643":"付先生",
"131****2636":"陆先生",
"186****7457":"池先生",
"156****8771":"郭先生",
"186****8521":"张先生",
"186****1300":"杨先生",
"185****1911":"吴先生",
"186****8711":"赵先生",
"186****5005":"张先生",
"186****9962":"李先生",
"185****5534":"史女士",
"176****3909":"易先生",
"185****1010":"孟先生",
"186****5693":"王先生",
"186****9022":"孙先生",
"186****8935":"张女士",
"156****7510":"王女士",
"156****7360":"刘先生",
"186****6666":"张先生",
"131****0329":"申先生",
"186****5115":"唐先生",
"176****1278":"李先生",
"185****5811":"刘先生",
"130****9466":"易先生",
"185****8572":"北未知",
"186****2119":"北未知",
"185****4877":"于先生",
"185****9758":"张先生",
"185****2859":"李先生",
"186****3538":"万先生",
"186****3322":"刘先生",
"185****8502":"郑先生",
"186****4149":"徐先生",
"185****7103":"北未知",
"186****8739":"段女士",
"186****8624":"万女士",
"176****2722":"陈先生",
"131****0727":"修女士",
"176****9619":"方女士",
"185****0813":"赵先生",
"185****3668":"赵先生",
"186****1116":"高先生",
"186****9553":"叶女士",
"186****7345":"李先生",
"185****7386":"北未知",
"156****7777":"林女士",
"176****2781":"宣先生",
"185****0219":"任先生",
"186****9378":"张先生",
"185****8218":"雷先生",
"186****8819":"荣先生",
"186****7124":"王先生",
"186****6717":"赵先生",
"186****9628":"张先生",
"176****5100":"李女士",
"131****7594":"宋先生",
"185****7099":"徐先生",
"186****7127":"阴先生",
"132****6000":"李先生",
"176****7765":"王先生",
"185****8511":"刘女士",
"186****1212":"王先生",
"185****1882":"李先生",
"185****3508":"李先生",
"186****5103":"李先生",
"186****8503":"赵先生",
"186****5690":"吴先生",
"185****7711":"鞠先生",
"166****2504":"郭先生",
"176****3313":"魏先生",
"186****1115":"李先生",
"186****7398":"曹先生",
"185****6129":"孙先生",
"176****3627":"刘先生",
"186****2028":"王女士",
"185****8647":"北未知",
"186****6367":"李先生",
"131****3937":"童先生",
"186****0600":"张先生",
"131****9275":"宋女士",
"186****0504":"陈先生",
"185****1004":"李先生",
"185****9085":"杨先生",
"186****4393":"张先生",
"186****9591":"马先生",
"185****8869":"郑先生",
"186****8266":"李先生",
"176****5197":"刘先生",
"185****0886":"孙先生",
"185****8897":"郭女士",
"156****1858":"杨先生",
"132****5888":"魏先生",
"186****9733":"隗先生",
"185****4141":"李先生",
"185****4555":"黄先生",
"185****9134":"李先生",
"156****9285":"张先生",
"186****8555":"李先生",
"186****9273":"宋先生",
"186****0964":"李先生",
"186****0330":"周先生",
"185****4455":"才先生",
"132****9393":"陈女士",
"131****6107":"刘先生",
"132****8407":"吴先生",
"186****9996":"张女士",
"186****2517":"赵女士",
"185****5576":"中未知",
"186****7878":"冯女士"}
var mapss ={
"186****9720":"张未知",
"186****3958":"夏先生",
"185****8165":"朱女士",
"186****6377":"许先生",
"186****5105":"徐先生",
"186****7233":"陈先生",
"131****4444":"刘先生",
"186****7568":"陶先生",
"131****7200":"冯先生",
"185****2688":"李先生",
"131****2846":"张女士",
"186****1199":"李先生",
"176****6662":"赵先生",
"186****6563":"王先生",
"186****5376":"赵女士",
"130****9278":"张先生",
"131****1919":"施先生",
"186****1669":"高先生",
"186****6752":"李先生",
"186****7995":"冯先生",
"185****4280":"李先生",
"186****6220":"张先生",
"185****2892":"廉先生",
"185****6313":"张女士",
"186****5522":"李先生",
"186****7827":"亓先生",
"156****8111":"朱先生",
"186****5099":"韩女士",
"186****8938":"刘先生",
"186****5900":"周先生",
"186****0359":"陈先生",
"185****8999":"张先生",
"186****6123":"童先生",
"186****6988":"殷先生",
"185****7594":"童先生",
"186****3276":"张女士",
"130****8684":"郭女士",
"185****6534":"李先生",
"185****1899":"黄先生",
"186****7791":"谭先生",
"186****5147":"易先生",
"186****8456":"马先生",
"186****0085":"王先生",
"185****3888":"赵先生",
"186****1534":"李女士",
"185****3955":"陈女士",
"131****5550":"王先生",
"130****2222":"李先生",
"186****2026":"薛先生",
"185****5431":"孙女士",
"185****0788":"邱先生",
"132****7766":"薛先生",
"186****3789":"庞先生",
"185****5835":"李先生",
"156****5689":"左先生",
"176****0559":"王先生",
"186****9188":"何先生",
"186****5968":"利未知",
"132****6230":"丛先生",
"130****8889":"石先生",
"186****7109":"吴先生",
"156****8698":"孙女士",
"186****6055":"陈女士",
"131****6328":"牛女士",
"130****4288":"陈女士",
"186****3323":"赵先生",
"186****2757":"董先生",
"131****3147":"闫先生",
"186****3332":"刘先生",
"186****3733":"西未知",
"156****2231":"吕先生",
"185****3323":"李女士",
"186****5899":"李先生",
"186****0222":"付先生",
"132****7555":"孟先生",
"186****8028":"丁先生",
"186****8500":"李女士",
"186****1105":"王女士",
"186****8380":"李先生",
"176****6686":"周先生",
"186****5855":"张先生",
"131****4431":"董女士",
"186****2826":"孙先生",
"156****0659":"窦女士",
"185****7687":"李先生",
"185****6330":"王先生",
"186****6808":"燕先生",
"185****8683":"段女士",
"186****7890":"刘先生",
"156****1932":"宋先生",
"185****3555":"李先生",
"185****3999":"姚女士",
"185****7097":"刘女士",
"186****5955":"程先生",
"185****6837":"赵女士",
"176****7695":"王先生",
"130****0103":"卢先生",
"185****3044":"李先生",
"132****3552":"余先生",
"186****7277":"岳先生",
"186****7374":"陈先生",
"186****8697":"万女士",
"185****6556":"甄先生",
"186****7826":"何女士",
"186****1126":"刘女士",
"185****5860":"曹先生",
"130****4466":"张先生",
"131****8500":"王先生",
"186****3336":"尤先生",
"186****6613":"马先生",
"186****1318":"滕女士",
"186****5947":"蔡女士",
"186****2232":"焦先生",
"185****5512":"高先生",
"131****4790":"温先生",
"185****0629":"王女士",
"131****1555":"张先生",
"176****2388":"韩先生",
"131****3333":"杨先生",
"176****3091":"居先生",
"186****5959":"王先生",
"186****5888":"王先生",
"186****1301":"许女士",
"132****9999":"安先生",
"130****0229":"赵先生",
"185****4040":"陈先生",
"186****7616":"索先生",
"186****8599":"许先生",
"130****8066":"张先生",
"186****3976":"陈女士",
"185****9967":"胡女士",
"185****5919":"王先生",
"155****0563":"郑先生",
"130****6100":"贾先生",
"131****5555":"徐先生",
"166****0796":"霍女士",
"130****2222":"谢女士",
"186****8598":"杨女士",
"185****0677":"张先生",
"186****7440":"陶先生",
"186****0515":"段女士",
"186****3221":"刘未知",
"186****1733":"张先生",
"186****3062":"殷先生",
"132****6056":"牛女士",
"185****9588":"魏先生",
"186****6205":"吴先生",
"186****8895":"刘先生",
"185****1019":"马先生",
"186****5666":"李先生",
"186****5986":"关先生",
"185****6166":"于先生",
"186****2000":"杨先生",
"186****8111":"张先生",
"186****8198":"刘先生",
"156****3086":"廖先生",
"185****0283":"阳未知",
"186****2699":"王先生",
"176****7313":"卢先生",
"186****3808":"王先生",
"186****8661":"李女士",
"130****3765":"丛先生",
"130****1999":"张先生",
"186****2848":"岳先生",
"186****6777":"吴女士",
"185****1030":"张先生",
"130****5316":"刘女士",
"130****3333":"刘先生",
"132****5756":"许先生",
"130****2999":"刘先生",
"186****3868":"陈先生",
"186****9811":"李先生",
"131****1745":"赵先生",
"186****8083":"王先生",
"186****3590":"赵先生",
"186****2777":"李女士",
"186****8182":"方先生",
"185****4527":"周女士",
"176****9911":"张先生",
"130****5201":"韩先生",
"186****0891":"刘先生",
"186****6364":"王先生",
"186****0861":"王女士",
"186****7770":"汪女士",
"186****6810":"贾先生",
"185****5758":"余女士",
"185****5756":"程先生",
"156****9085":"王女士",
"185****6886":"余女士",
"186****3057":"刘先生",
"131****2626":"毕先生",
"131****9922":"郭女士",
"185****8879":"孙先生",
"186****1590":"安女士",
"186****7809":"张女士",
"185****8629":"吴先生",
"186****3816":"冯先生",
"185****6605":"何先生",
"176****6333":"冯女士",
"186****9567":"郝先生",
"156****0759":"王先生",
"186****9778":"戚先生",
"185****2283":"刘女士",
"155****7200":"张先生",
"186****3689":"严先生",
"176****9316":"张女士",
"185****4835":"万女士",
"186****5660":"刘先生",
"185****9593":"高女士",
"185****4564":"陈女士",
"156****0888":"赵先生",
"186****9150":"初先生",
"186****8582":"张先生",
"186****1933":"李先生",
"186****1816":"柴先生",
"186****9033":"刘先生",
"185****0777":"洪女士",
"130****9800":"杨先生",
"185****9009":"郭先生",
"186****9503":"北未知",
"186****2127":"张先生",
"186****3824":"陈先生",
"185****1189":"王先生",
"185****3958":"郭先生",
"176****9613":"刘女士",
"185****0101":"北未知",
"186****9292":"贺先生",
"186****1015":"王先生",
"185****3633":"郭先生",
"186****4000":"白先生",
"186****7541":"曾先生",
"185****3869":"杨先生",
"186****6421":"王女士",
"185****2330":"赵先生",
"156****8641":"李先生",
"186****7830":"张先生",
"186****1817":"马先生",
"185****2320":"李先生",
"186****7902":"北未知",
"185****5588":"田先生",
"132****3669":"杨女士",
"185****0595":"赵先生",
"176****5218":"任先生",
"186****6924":"田先生",
"131****8808":"郑先生",
"186****7007":"赵先生",
"176****8000":"刘先生",
"186****6609":"高先生",
"185****8873":"张女士",
"185****2138":"郭女士",
"186****7764":"杨先生",
"186****4695":"张先生",
"176****0078":"刘女士",
"132****6100":"孙女士",
"186****4450":"曹先生",
"132****4962":"田先生",
"166****7895":"北未知",
"186****6027":"莫先生",
"185****8810":"孙女士",
"185****4560":"王女士",
"186****8890":"丰女士",
"156****3367":"宫女士"}
/*aaa.forEach(async (x) => {
let unikey = x;
let task = 'TM-FBDWLXJV01汽车20180921';
let origin = '400';
let accountID = '5b9088c1746c6a0007df75b6';
let fromID = "5b86427d2a744a0007ea4e1e";
let createdAt = Date.now();
let createdDate= "20180925";
let data = {unikey,task,origin,accountID,fromID,createdAt,createdDate};
let r = await dspRecognition.insert(data);
count ++
console.dir(r.ops[0].unikey);
console.dir(count);
})*/
Object.keys(mapss).forEach( async x => {
let mark = mapss[x];
console.dir(mark);
let r = await dspRecognition.update({unikey:x},{$set:{tags:[mark], age: mark}});
console.dir(r);
});
/*arrs.forEach( ( { _id, pubID }) => {
bills.update({ _id },{ $set: {
accountID: db.ObjectID(pubID)
}}, ( err, rep ) => {
console.dir(count++);
if(err) console.dir(err)
else {
console.dir(rep.result.nModified);
}
});
});*/
}
task();
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const dspRecognition = await db.getCollection('dspRecognition');
let unikeys = [
"2018092902265",
"2018092902266",
"2018092902268",
"2018092902269",
"2018092902272",
"2018092902274",
"2018092902287",
"2018092902275",
"2018092902290",
"2018092902291",
"2018092902292",
"2018092902171",
"2018092902293",
"2018092902172",
"2018092902294",
"2018092902296",
"2018092902297",
"2018092902299",
"2018092902173",
"2018092902176",
"2018092902177",
"2018092902303",
"2018092902211",
"2018092902180",
"2018092902215",
"2018092902218",
"2018092902219",
"2018092902277",
"2018092902280",
"2018092902185",
"2018092902187",
"2018092902188",
"2018092902189",
"2018092902194",
"2018092902195",
"2018092902143",
"2018092902145",
"2018092902147",
"2018092902148",
"2018092902222",
"2018092902224",
"2018092902225",
"2018092902249",
"2018092902250",
"2018092902252",
"2018092902253",
"2018092902255",
"2018092902256",
"2018092902257",
"2018092902258",
"2018092901981",
"2018092902261",
"2018092902263",
"2018092901982",
"2018092902264",
"2018092902198",
"2018092901983",
"2018092902149",
"2018092902150",
"2018092902151",
"2018092902153",
"2018092902154",
"2018092902158",
"2018092902238",
"2018092901870",
"2018092901935",
"2018092902160",
"2018092901871",
"2018092901863",
"2018092902196",
"2018092901864",
"2018092902162",
"2018092901850",
"2018092901936",
"2018092901851",
"2018092901987",
"2018092902131",
"2018092901852",
"2018092901991",
"2018092902242",
"2018092901992",
"2018092902243",
"2018092902134",
"2018092901993",
"2018092902136",
"2018092901854",
"2018092901995",
"2018092902245",
"2018092901955",
"2018092902246",
"2018092901856",
"2018092901956",
"2018092902200",
"2018092902116",
"2018092901858",
"2018092901958",
"2018092901861",
"2018092901959",
"2018092902202",
"2018092901960",
"2018092901905",
"2018092901839",
"2018092902163",
"2018092901906",
"2018092901961",
"2018092902204",
"2018092902205",
"2018092901964",
"2018092902166",
"2018092902207",
"2018092901916",
"2018092901859",
"2018092901862",
"2018092901831",
"2018092901832",
"2018092901835",
"2018092901847",
"2018092902167",
"2018092901848",
"2018092901810",
"2018092901833",
"2018092901834",
"2018092901836",
"2018092901837",
"2018092901840",
"2018092901842",
"2018092901846",
"2018092901820",
"2018092901843",
"2018092901844",
"2018092902284",
"2018092901849",
"2018092901816",
"2018092901815",
"2018092901814",
"2018092901811",
"2018092901808",
"2018092901813",
"2018092901819",
"2018092901818",
"2018092902137",
"2018092902139",
"2018092902059",
"2018092902060",
"2018092902065",
"2018092902004",
"2018092902005",
"2018092902006",
"2018092902008",
"2018092902011",
"2018092902023",
"2018092901907",
"2018092901908",
"2018092901909",
"2018092901910",
"2018092901911",
"2018092902227",
"2018092902229",
"2018092902236",
"2018092902101",
"2018092902103",
"2018092902068",
"2018092902069",
"2018092902000",
"2018092902001",
"2018092902041",
"2018092902042",
"2018092902015",
"2018092901968",
"2018092902044",
"2018092901969",
"2018092902047",
"2018092901970",
"2018092902048",
"2018092901976",
"2018092901977",
"2018092902050",
"2018092902239",
"2018092902241",
"2018092902169",
"2018092902121",
"2018092902122",
"2018092902123",
"2018092902124",
"2018092902125",
"2018092902126",
"2018092902127",
"2018092902128",
"2018092902129",
"2018092902118",
"2018092902119",
"2018092902120",
"2018092902111",
"2018092902112",
"2018092902113",
"2018092902114",
"2018092902087",
"2018092902088",
"2018092901828",
"2018092901830",
"2018092901806",
"2018092901807",
"2018092901804",
"2018092901805",
"2018092902089",
"2018092901821",
"2018092901822",
"2018092901823",
"2018092901824",
"2018092901825",
"2018092901826",
"2018092901827",
"2018101902765",
"2018101902767",
"2018101902768",
"2018101902769",
"2018101902771",
"2018101902772",
"2018101902782",
"2018101902774",
"2018101902776",
"2018101902777",
"2018101902747",
"2018101902750",
"2018101902751",
"2018101902783",
"2018101902785",
"2018101902786",
"2018101902787",
"2018101902801",
"2018101902803",
"2018101902804",
"2018101902806",
"2018092902053",
"2018101902809",
"2018101902796",
"2018092902056",
"2018101902798",
"2018101902793",
"2018101902759",
"2018092902024",
"2018092902058",
"2018092902016",
"2018092902017",
"2018092902018",
"2018101902755",
"2018101902757",
"2018101902736",
"2018101902737",
"2018101902716",
"2018101902719",
"2018101902722",
"2018101902723",
"2018101902724",
"2018101902710",
"2018101902702",
"2018101902742",
"2018101902743",
"2018101902715",
"2018101902712",
"2018101902713",
"2018101902728",
"2018101902657",
"2018101902658",
"2018101902673",
"2018101902660",
"2018101902677",
"2018101902662",
"2018101902680",
"2018101902682",
"2018101902683",
"2018101902730",
"2018101902646",
"2018101902595",
"2018101902598",
"2018101902733",
"2018101902734",
"2018101902600",
"2018101902699",
"2018101902706",
"2018101902707",
"2018101902708",
"2018101902709",
"2018101902604",
"2018101902608",
"2018101902613",
"2018101902686",
"2018101902634",
"2018101902636",
"2018101902690",
"2018101902692",
"2018101902694",
"2018101902697",
"2018101902648",
"2018101902644",
"2018101902616",
"2018101902619",
"2018101902621",
"2018101902625",
"2018101902627",
"2018101902629",
"2018101902631",
"2018101902632",
"2018101902527",
"2018101902551",
"2018101902573",
"2018092902193",
"2018101902575",
"2018101902579",
"2018101902580",
"2018101902581",
"2018101902582",
"2018101902482",
"2018101902509",
"2018101902510",
"2018101902478",
"2018101902479",
"2018101902484",
"2018101902485"];
console.dir(unikeys.length);
let arrs = await dspRecognition.find({ unikey: { '$in': unikeys}}).limit(100000).toArray();
console.dir(arrs.length);
arrs.forEach( async ({ tags, calledInfo }) => {
console.dir(tags);
console.dir(calledInfo.length);
});
}
task();
const db = require('../db');
const moment = require('moment');
async function task(argument) {
//const bills = await db.getCollection('bills');
const account = await db.getCollection('account')
const arrs = await account.find({}).toArray();
//console.dir(arrs.length);
arrs.forEach( async ( {_id,email,fromID} ) => {
console.dir(email);
if(fromID) {
let rep = await account.update({_id},{$set:{agentDiscount:{
"pipeDiscount" : 0.6,
"dataDiscount" : 0.3,
"agentID" : fromID}}})
console.dir(re.result);
}
});
}
task();
const db = require('../db');
const moment = require('moment');
async function task(argument) {
const recognition = await db.getCollection('dspRecognition');
const arrs = await recognition.find({unikey:{$exists:true, "$regex": /^.{14,}$/ } }).limit(10000000000000000).toArray();
let count = 0;
console.dir(arrs.length);
arrs.forEach( async item => {
// if(unikey.length == 15){
// console.dir(unikey);
// }
console.dir(item.unikey);
let n = '';
if(escape(item.unikey[0]) == 2) {
n = item.unikey.slice(0,6) + item.unikey.slice(7,14);
//console.dir(item.unikey.slice(7,14));
} else {
n = item.unikey.trim();
}
/*if(n.length == 13) {
let rep = await recognition.update({_id:item._id},{ $set:{ unikey: n } });
console.dir(rep.result.nModified);
}*/
//console.dir(n.length);
});
}
async function fixdate(argument) {
const recognition = await db.getCollection('recognition');
const arrs = await recognition.find({ date:{$exists:false} }).limit(10000000000000000).toArray();
let count = 0;
console.dir(arrs.length);
arrs.forEach( async item => {
// if(unikey.length == 15){
// console.dir(unikey);
// }
/*console.dir(item.unikey);
let n = '';
if(escape(item.unikey[0]) == 2) {
n = item.unikey.slice(0,6) + item.unikey.slice(7,14);
//console.dir(item.unikey.slice(7,14));
} else {
n = item.unikey.trim();
}*/
let date = moment(item.updateTimestamp).format('YYYYMMDD')
let rep = await recognition.update({_id:item._id},{ $set:{ date: date } });
console.dir(rep.result.nModified);
console.dir(count++);
/*if(n.length == 13) {
let rep = await recognition.update({_id:item._id},{ $set:{ unikey: n } });
console.dir(rep.result.nModified);
}*/
//console.dir(n.length);
});
}
//task();
fixdate();
const db = require('../db');
const moment = require('moment');
async function task(argument) {
const bills = await db.getCollection('bills');
const urlTask = await db.getCollection('urlTask');
const arrs = bills.find({type:"urlbuynumber",taskID:null})
let count = 0;
arrs.forEach( async ( item ) => {
let task = await urlTask.find({accountID:item.accountID + ''}).limit(1000).toArray();
for( var k in task ) {
let x = task[k];
if( moment(x.createdAt).format('YYYYMMDDHHmmss') === moment(item.createdAt).format('YYYYMMDDHHmmss')) {
console.dir(x.total);
console.dir(item.number);
let rep = await bills.update({_id:item._id},{$set:{ taskID:x._id }});
console.dir(rep.result);
}
}
});
}
task();
const fs = require('fs');
const BSON = require('bson');
const path = require('path');
const db_path = path.join(__dirname, './ip.db');
//const mongo = require(path.join(__dirname, './mongo'))();
module.exports = ipInfo = function ipInfo() {
const TOTAL_BLOCK_LENGTH = 2;
const INDEX_BLOCK_LENGTH = 5;
const ip = {};
ip.init = function () {
this.fd = fd = fs.openSync(db_path, 'r');
let buf = Buffer.alloc(TOTAL_BLOCK_LENGTH);
fs.readSync(fd, buf, 0, TOTAL_BLOCK_LENGTH, 0);
this.TOTAL = TOTAL = buf.readUInt16BE(0);
this.bson = new BSON();
};
ip.getInfoByIndex = function (index) {
let index_block_buf = Buffer.alloc(INDEX_BLOCK_LENGTH);
fs.readSync(this.fd, index_block_buf, 0, INDEX_BLOCK_LENGTH, index * INDEX_BLOCK_LENGTH + TOTAL_BLOCK_LENGTH);
let offset = index_block_buf.readUInt32BE(0);
let length = index_block_buf.readUInt8(4);
let data_block_buf = Buffer.alloc(length);
fs.readSync(this.fd, data_block_buf, 0, length, offset);
let data = this.bson.deserialize(data_block_buf);
return data;
};
ip.numify = function (_ip) {
const ips = _ip.split('.');
const res = ips[0] * Math.pow(10, 9) +
ips[1] * Math.pow(10, 6) +
ips[2] * Math.pow(10, 3) +
ips[3] * Math.pow(10, 0);
return res;
};
ip.binarySearch = function (ip) {
let target = this.numify(ip);
let high = this.TOTAL - 1, low = 0, mid = 0, info;
while (low <= high) {
mid = (low + high) >> 1;
info = this.getInfoByIndex(mid);
if (target > info.eip) low = mid + 1;
else if (target < info.sip) high = mid - 1;
else break;
}
return info;
};
ip.creatDbFile = async function () {
var { err, data: db } = await mongo.init();
if (err) return console.log(err);
var { err, data } = await mongo.find.toArray('ipCity', {}, {
raw: true,
// limit: 2,
});
if (err) return console.log(err);
const bufferArray = [];
ip.dataLength = dataLength = data.length;
let total_buf = Buffer.alloc(TOTAL_BLOCK_LENGTH);
total_buf.writeUInt16BE(dataLength, 0);
bufferArray[0] = total_buf;
let offset = TOTAL_BLOCK_LENGTH + INDEX_BLOCK_LENGTH * ip.dataLength;
for (let i = 0; i < dataLength; i++) {
let length = data[i].length;
let index_block_buf = Buffer.alloc(INDEX_BLOCK_LENGTH);
index_block_buf.writeUInt32BE(offset, 0);
index_block_buf.writeUInt8(length, 4);
bufferArray[1 + i] = index_block_buf;
offset += length;
let data_block_buf = Buffer.alloc(length, data[i]);
bufferArray[1 + ip.dataLength + i] = data_block_buf;
}
let buffer = Buffer.concat(bufferArray);
fs.writeFileSync(db_path, buffer);
console.log(db_path, 'write over:', dataLength, buffer.length);
}
return ip;
}
// const ip = ipInfo();
// ip.init();
// const res = ip.binarySearch('10.12.1.1');
// console.log(res);
\ No newline at end of file
{
"name": "statscronjob",
"version": "1.0.0",
"description": "this is a data collection cronjob for remarketing",
"main": "index.js",
"scripts": {
"test": "npm run start"
},
"repository": {
"type": "git",
"url": "git@git.yunpro.cn:liusong/statsCronJob.git"
},
"author": "phyllis",
"license": "ISC",
"dependencies": {
"cron": "^1.3.0",
"lodash": "^4.17.5",
"moment": "^2.22.1",
"mongodb": "^3.0.6",
"node-xlsx": "^0.12.1",
"nodemailer": "^4.6.4"
}
}
const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
const account = await db.getCollection('account');
const dspRecognition = await db.getCollection('dspRecognition');
const group = await db.getCollection('dspCallGroups');
let group_arrs = await group.find({}).limit(1000000000000).toArray();
let groupMap = {}
let data = [['unikey','tag1','tag2','反馈标签']];
let _count = 0;
let _arrs = await account.find({}).limit(1000000000000).toArray();
let accountMap = {};
_arrs.forEach(({email,company,_id}) => {
accountMap[ _id + ''] = email + '[' + company + ']'
})
let arrs = await dspRecognition.find({createdDate:{'$gte':'20181008','$gte':'20181014'}}).limit(1000000000000).toArray();
console.dir(arrs.length);
let map = {};
arrs.forEach( async ({ tags, _id, unikey, tags, groupID, billID, remark, systemTags, calledInfo, accountID }) => {
data.push([unikey,tags[0],tags[1],(systemTags && systemTags.length ? systemTags.join(',') : '')])
console.dir((++_count) + '==' + arrs.length);
if(_count === arrs.length) {
console.dir('ii');
var buffer = xlsx.build([{name: "mySheetName", data: data}]);
fs.writeFile('./标签.xlsx', buffer, function(err) {
console.dir(err + '====>')
if (err) {
throw err;
}
console.log('Hello.');
});
}
});
}
task();
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