|
@@ -38,7 +38,7 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
|
if entid == "" {//redis 未存
|
|
|
savetoerr := true
|
|
|
- if agencyperson != "" || agencytel != "" {
|
|
|
+ if agencytel != "" {
|
|
|
v := map[string]interface{}{
|
|
|
"contact_person": agencyperson,
|
|
|
"phone": agencytel,
|
|
@@ -64,19 +64,34 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if agencyperson != "" || agencytel != "" {
|
|
|
- v := map[string]interface{}{
|
|
|
- "contact_person": agencyperson,
|
|
|
- "phone": agencytel,
|
|
|
- "topscopeclass": comRepTopscopeclass(topscopeclass),
|
|
|
- "infoid": infoid,
|
|
|
+ if agencytel != "" {
|
|
|
+ is_exist:=false //电话是否存在
|
|
|
+ for _,v := range ps{
|
|
|
+ if v["phone"]==agencytel{
|
|
|
+ is_exist = true
|
|
|
+ if agencyperson!=""&&v["contact_person"]!=agencyperson {
|
|
|
+ v["contact_person"]=agencyperson
|
|
|
+ v["infoid"] = infoid
|
|
|
+ bs, _ := json.Marshal(ps)//替换数据,更新
|
|
|
+ redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !is_exist {
|
|
|
+ v := map[string]interface{}{
|
|
|
+ "contact_person": agencyperson,
|
|
|
+ "phone": agencytel,
|
|
|
+ "topscopeclass": comRepTopscopeclass(topscopeclass),
|
|
|
+ "infoid": infoid,
|
|
|
+ }
|
|
|
+ MongoTo.UpdateById(agencyent, entid,
|
|
|
+ map[string]interface{}{
|
|
|
+ "$set": v,
|
|
|
+ "$push": map[string]interface{}{"contact": v},
|
|
|
+ },
|
|
|
+ )
|
|
|
}
|
|
|
- MongoTo.UpdateById(agencyent, entid,
|
|
|
- map[string]interface{}{
|
|
|
- "$set": v,
|
|
|
- "$push": map[string]interface{}{"contact": v},
|
|
|
- },
|
|
|
- )
|
|
|
}
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|
|
@@ -113,27 +128,43 @@ func historyagency(db, fromcoll string) {
|
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
|
b, _ := redis.ExistRedis("agency", agencybd, agency)
|
|
|
if b {//redis 存在
|
|
|
- if agencyperson != "" || agencytel != "" {
|
|
|
+ if agencytel != "" {
|
|
|
strs, _ := redis.GetRedisStr("agency", agencybd, agency)
|
|
|
- ps := []interface{}{}
|
|
|
+ ps := []map[string]interface{}{}
|
|
|
err := json.Unmarshal([]byte(strs), &ps)
|
|
|
if err == nil {
|
|
|
- v := map[string]interface{}{
|
|
|
- "contact_person": agencyperson,
|
|
|
- "phone": agencytel,
|
|
|
- "topscopeclass": comRepTopscopeclass(topscopeclass),
|
|
|
- "infoid": _id,
|
|
|
+ is_exist:=false //电话是否存在
|
|
|
+ for _,v := range ps{
|
|
|
+ if v["phone"]==agencytel{
|
|
|
+ is_exist = true
|
|
|
+ if agencyperson!=""&&v["contact_person"]!=agencyperson {
|
|
|
+ v["contact_person"]=agencyperson
|
|
|
+ v["infoid"] = _id
|
|
|
+ bs, _ := json.Marshal(ps)//替换数据,更新
|
|
|
+ redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if !is_exist {
|
|
|
+ v := map[string]interface{}{
|
|
|
+ "contact_person": agencyperson,
|
|
|
+ "phone": agencytel,
|
|
|
+ "topscopeclass": comRepTopscopeclass(topscopeclass),
|
|
|
+ "infoid": _id,
|
|
|
+ }
|
|
|
+ ps = append(ps, v)
|
|
|
+ bs, _ := json.Marshal(ps)
|
|
|
+ redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
|
}
|
|
|
- ps = append(ps, v)
|
|
|
- bs, _ := json.Marshal(ps)
|
|
|
- redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
|
} else {
|
|
|
log.Println("jsonErr", err)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
val := []map[string]interface{}{}
|
|
|
- if agencyperson != "" || agencytel != "" {
|
|
|
+ if agencytel != "" {
|
|
|
tmp := map[string]interface{}{
|
|
|
"contact_person": agencyperson,
|
|
|
"phone": agencytel,
|