xuzhiheng 2 роки тому
батько
коміт
616b305bcc
2 змінених файлів з 10 додано та 6 видалено
  1. 7 5
      clueSync/job.go
  2. 3 1
      clueSync/main.go

+ 7 - 5
clueSync/job.go

@@ -92,14 +92,14 @@ func users() {
 func userbase() {
 	log.Println("userbase定时任务开始")
 	selectTimeEnd := time.Unix(time.Now().Unix()-1800, 0).Format("2006-01-02 15:04:05")
-	sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s"`, selectTimeEnd)
+	sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s" and source > 0`, selectTimeEnd)
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
 			phone := common.ObjToString(v["phone"])
 			uid := common.ObjToString(v["uid"])
 			if phone != "" {
-				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1 and status != 0", uid)
+				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and phone = ? and is_delete = 1", uid, phone)
 				if contactsData == nil || len(*contactsData) == 0 {
 					FormatData(v, "users")
 				}
@@ -219,7 +219,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 			if userInfo != nil && len(*userInfo) > 0 {
 				uId = common.ObjToString((*userInfo)["uid"])
 				source = common.IntAll((*userInfo)["source"])
-				userId = common.ObjToString((*userInfo)["userid"])
+				// userId = common.ObjToString((*userInfo)["userid"])
 			}
 		}
 	} else if item == "saleLeads" {
@@ -521,14 +521,16 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		"taskstatus":   0,
 		"tasksource":   "线索来源自动更新" + "-" + topname + "-" + subname,
 	}
-	if item != "orders" {
+	if cluename != "" {
+		clueUpdateData["cluename"] = cluename
+	}
+	if item != "orders" && item != "users" {
 		clueUpdateData["name"] = name
 		clueUpdateData["position"] = position
 		clueUpdateData["department"] = department
 		clueUpdateData["industry"] = industry
 		clueUpdateData["follow_project_area"] = follow_project_area
 		clueUpdateData["role"] = role
-		clueUpdateData["cluename"] = cluename
 	}
 	if trailstatus == "00" || old_position_id == 0 || is_assign != 1 {
 		clueUpdateData["seatNumber"] = seatNumber

+ 3 - 1
clueSync/main.go

@@ -86,7 +86,7 @@ func main() {
 			saleLeads()
 		})
 		c.Start()
-		userbase()
+		// userbase()
 		cc := cron.New()
 		cc.AddFunc(cfg.CornExp1, func() {
 			userbase()
@@ -160,5 +160,7 @@ func main() {
 		getAreaCode("6447753fb4f3c077da9d5336")
 	} else if *mode == 11 {
 		trail()
+	} else if *mode == 12 {
+		userbase()
 	}
 }