清理客户数据
mongoimport -h 10.30.41.83 --port 27018 -d crm_mshuoke_com -c t_tmp_customers --type csv --headerline --file /usr/src/20180109_清理手机号码.csv
(2 + 3) x 5 = 2x5 + 3x5
db.t_tmp_customers.find().forEach(function(x) {db.getCollection("project_customers_"+x.project_id).find({$and: [{"电话号码":x.mobile+""},{$or: [{ "comments.qc.status": { $in: ["qcGood", "qcFair", null] } },{ "comments.qced": "no" }]},{ "comments.sales_funnel_value": 5 },{ "comments.updatedAt": { $gt: ISODate("2018-01-01T00:00:01Z")} }]}).forEach(function(xi) { if(xi["电话号码"]) { db.t_tmp_customers.update({project_id:x.project_id,mobile:x.mobile},{$set:{flag:1}},false:true); } }); });
//客户数据成单的设置flag:1
db.t_tmp_customers.find({flag:{$ne:1}}).forEach(function(x) { db.getCollection("project_customers_"+x.project_id).update({"电话号码":x.mobile+""},{$set:{flag:"delete"}}); });