|
@@ -253,3 +253,69 @@ func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]inter
|
|
|
data["mobilephone"] = timesMobilePhone
|
|
|
return data
|
|
|
}
|
|
|
+
|
|
|
+func putbuyerreids() {
|
|
|
+ sess := MongoTo.GetMgoConn()
|
|
|
+ defer MongoTo.Close()
|
|
|
+ it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{}).Select(bson.M{"buyer_name": 1}).Iter()
|
|
|
+ index := 0
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
|
+ id := mongo.BsonTOStringId(tmp["_id"])
|
|
|
+ buyer_name, _ := tmp["buyer_name"].(string)
|
|
|
+ redis.PutRedis("buyer", 2, buyer_name, id, -1)
|
|
|
+ tmp = map[string]interface{}{}
|
|
|
+ if index%1000 == 0 {
|
|
|
+ log.Println(id, index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func putbuyerreids__s() {
|
|
|
+ sess := MongoTo.GetMgoConn()
|
|
|
+ defer MongoTo.Close()
|
|
|
+ it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{}).Select(bson.M{"buyer_name": 1}).Iter()
|
|
|
+ index := 0
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
|
+ buyer_name, _ := tmp["buyer_name"].(string)
|
|
|
+ ts, _ := MongoTo.Find("buyer_enterprise", map[string]interface{}{"buyer_name": buyer_name}, nil, bson.M{"buyer_name": 1})
|
|
|
+ if len(ts) > 1 {
|
|
|
+ id := mongo.BsonTOStringId(ts[0]["_id"])
|
|
|
+ log.Println(buyer_name, id)
|
|
|
+ MongoTo.DeleteById("buyer_enterprise", id)
|
|
|
+ }
|
|
|
+ if index%10000 == 0 {
|
|
|
+ log.Println(index)
|
|
|
+ }
|
|
|
+ tmp = map[string]interface{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func modifybuyer() {
|
|
|
+ sess := MongoTo.GetMgoConn()
|
|
|
+ defer MongoTo.Close()
|
|
|
+ it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{"institute_type": "事业单位"}).Iter()
|
|
|
+ index := 0
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
|
+ id := mongo.BsonTOStringId(tmp["_id"])
|
|
|
+ buyer_name, _ := tmp["buyer_name"].(string)
|
|
|
+ bys, _ := MongoTo.Find(
|
|
|
+ "buyer_enterprise",
|
|
|
+ map[string]interface{}{"buyer_name": buyer_name}, nil,
|
|
|
+ bson.M{"institute_type": 1, "buyer_name": 1},
|
|
|
+ )
|
|
|
+ for _, by := range bys {
|
|
|
+ byid := mongo.BsonTOStringId(by["_id"])
|
|
|
+ institute_type, _ := by["institute_type"].(string)
|
|
|
+ if institute_type == "企业" {
|
|
|
+ MongoTo.Save("buyer_tmp", tmp)
|
|
|
+ delete(tmp, "_id")
|
|
|
+ MongoTo.UpdateById("buyer_enterprise", byid, map[string]interface{}{
|
|
|
+ "$set": tmp,
|
|
|
+ })
|
|
|
+ MongoTo.DeleteById("buyer_enterprise", id)
|
|
|
+ log.Println(id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmp = map[string]interface{}{}
|
|
|
+ }
|
|
|
+}
|