Sfoglia il codice sorgente

注册渠道获取

WH01243 1 mese fa
parent
commit
38a052fc1f
2 ha cambiato i file con 39 aggiunte e 24 eliminazioni
  1. 0 24
      clueSync/job.go
  2. 39 0
      clueSync/jobutil.go

+ 0 - 24
clueSync/job.go

@@ -2265,27 +2265,3 @@ var phoneRegex = regexp.MustCompile(`^1[3-9]\d{9}$`)
 func ValidatePhone(phone string) bool {
 	return phoneRegex.MatchString(phone)
 }
-
-// 获取用户渠道信息
-func GetUserChannel(uid string) string {
-	channel := ""
-	userId := ""
-	data := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{
-		"uid":    uid,
-		"status": 1,
-	}, "userid", "")
-	if data != nil {
-		userId = gconv.String((*data)["userid"])
-	}
-	if userId == "" {
-		return channel
-	}
-	//查找注册日志表
-	registerData, _ := MgoLog.FindOne("register_log", map[string]interface{}{
-		"userid": userId,
-	})
-	if registerData != nil {
-		channel = gconv.String((*registerData)["source"])
-	}
-	return channel
-}

+ 39 - 0
clueSync/jobutil.go

@@ -568,6 +568,14 @@ func users() {
 		for k, v := range *data {
 			//判断用户是否有小程序切使用过剑鱼其他产品
 			createtime := common.ObjToString(v["createtime"])
+			changeCode := GetUserChannel(gconv.String(v["userid"]))
+			if changeCode != "" {
+				TiDb.Update("", map[string]interface{}{
+					"userid": gconv.String(v["userid"]),
+				}, map[string]interface{}{
+					"belong_to": changeCode,
+				})
+			}
 			ok1, ok2, _ := FormatData(v, "users")
 			if !ok1 {
 				log.Println("线索卡点", "users", v, selectTimeEnd)
@@ -762,6 +770,14 @@ func userbase() {
 			phone := common.ObjToString(v["phone"])
 			uId := common.ObjToString(v["uid"])
 			userId := common.ObjToString(v["userid"])
+			changeCode := GetUserChannel(userId)
+			if changeCode != "" {
+				TiDb.Update("", map[string]interface{}{
+					"userid": userId,
+				}, map[string]interface{}{
+					"belong_to": changeCode,
+				})
+			}
 			registedate := common.ObjToString(v["l_registedate"])
 			name := common.ObjToString(v["name"])
 			nowTime := time.Now().Format(date.Date_Full_Layout)
@@ -1789,3 +1805,26 @@ func nextYearActivity() {
 	}
 	log.Println("开年活动处理结束")
 }
+
+// 获取用户渠道信息
+func GetUserChannel(uid string) string {
+	if uid == "" {
+		return ""
+	}
+	codeArr := []string{}
+	if len(UserChannel) > 0 {
+		for i := range UserChannel {
+			codeArr = append(codeArr, fmt.Sprintf(`"%s"`, i))
+		}
+	}
+	//查找注册日志表
+	courceData := ThirdParty.SelectBySql(fmt.Sprintf(`select  channel_code   from   user_source     where  user_id  =""  and   channel_code  in   ()   ORDER BY   create_time  desc   limit   10  `))
+	if courceData != nil && len(*courceData) > 0 {
+		channelCode := gconv.String((*courceData)[0]["channel_code"])
+		data, exit := UserChannel[channelCode]
+		if exit {
+			return gconv.String(data["clueCode"])
+		}
+	}
+	return ""
+}