瀏覽代碼

Merge commit '8672c6b7aed9f0e95c3fef3798e843b5d4fef10a' into feature/v1.5.21

* commit '8672c6b7aed9f0e95c3fef3798e843b5d4fef10a':
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
  绑定手机号用户调整
Jianghan 8 月之前
父節點
當前提交
479e517d6c
共有 2 個文件被更改,包括 90 次插入134 次删除
  1. 89 133
      clueSync/jobutil.go
  2. 1 1
      clueSync/main.go

+ 89 - 133
clueSync/jobutil.go

@@ -761,154 +761,110 @@ func saleLeads() {
 
 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" and source != "0105" and source != "0104" and source != "0103" and source != "0102"`, selectTimeEnd)
+	timeUnix := time.Now().Unix()
+	selectTimeStart := time.Unix(timeUnix-1800, 0).Format("2006-01-02 15:04:05")
+	selectTimeEnd := time.Unix(timeUnix, 0).Format("2006-01-02 15:04:05")
+	sql := fmt.Sprintf(`SELECT
+		a.phone,b.uid,a.baseinfo_id,b.l_registedate,a.createtime,b.id,b.userid
+	FROM
+		dwd_f_userbase_contacts a
+	INNER JOIN dwd_f_userbase_baseinfo b ON
+	    b.status= 1 
+		AND a.phone = b.phone and a.baseinfo_id= b.uid and     a.source  ="0101"
+  		and  a.phone  is  not   NULL  
+		and   a.createtime   >="%s"
+		and   a.createtime   <"%s"
+		and  a.is_delete=1  
+		ORDER BY    a.createtime `, selectTimeStart, selectTimeEnd)
 	data := TiDb.SelectBySql(sql)
-
 	if data != nil && *data != nil && len(*data) > 0 {
-		abhList := []map[string]interface{}{}
 		for _, v := range *data {
 			phone := common.ObjToString(v["phone"])
 			uId := common.ObjToString(v["uid"])
 			userId := common.ObjToString(v["userid"])
-			//判断用户是否有小程序切使用过剑鱼其他产品
-			s_platform := gconv.String(v["s_platform"])
-			login_positionid := gconv.Int64(v["login_positionid"])
-			if s_platform == "xcx" && login_positionid == 0 {
-				log.Println(phone, uId, userId, "用户是否有小程序且未使用过剑鱼其他产品")
-				continue
-			}
 			registedate := common.ObjToString(v["l_registedate"])
 			name := common.ObjToString(v["name"])
 			nowTime := time.Now().Format(date.Date_Full_Layout)
-			source := common.ObjToString(v["source"])
-			if phone != "" {
-				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
-				if contactsData == nil || len(*contactsData) == 0 {
-					contactsData2 := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1", uId)
-					if contactsData2 != nil && len(*contactsData2) > 0 {
-						log.Println("userbase uid不为空 新增通讯录", uId)
-						TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
-							"status":      1,
-							"is_delete":   1,
-							"createtime":  nowTime,
-							"updatetime":  nowTime,
-							"phone":       phone,
-							"baseinfo_id": uId,
-							"SOURCE":      source,
-						})
-					} else {
-						registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
-						count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
-						log.Println("userbase uid 线索数量 ", count)
-						log.Println("userbase uid 注册时间 ", registedates)
-						if time.Now().Unix()-registedates.Unix() > int64(db.RegTimes)*86400 {
-							if count == 0 {
-								clueId := int64(0)
-								sql := fmt.Sprintf(`select * from freeClubSign where mogUserId="%s" and sub_again_date > "%s" `, userId, selectTimeEnd)
-								data := BiService.SelectBySql(sql)
-								if len(*data) > 0 && userId != "" {
-									clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-										"userid":            userId,
-										"uid":               uId,
-										"is_assign":         0,
-										"comeintime":        nowTime,
-										"createtime":        nowTime,
-										"updatetime":        nowTime,
-										"cluename":          phone,
-										"top_cluetype":      "532",
-										"sub_cluetype":      "670",
-										"trailstatus":       "01",
-										"name":              name,
-										"phone":             phone,
-										"comeintime_open":   nowTime,
-										"comeinsource_open": 1,
-										"FREEZE_TIME":       nowTime,
-									})
-								} else {
-									clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-										"userid":            userId,
-										"uid":               uId,
-										"is_assign":         0,
-										"comeintime":        nowTime,
-										"createtime":        nowTime,
-										"updatetime":        nowTime,
-										"cluename":          phone,
-										"top_cluetype":      "532",
-										"sub_cluetype":      "475",
-										"trailstatus":       "01",
-										"name":              name,
-										"phone":             phone,
-										"comeintime_open":   nowTime,
-										"comeinsource_open": 1,
-										"FREEZE_TIME":       nowTime,
-									})
-								}
-								if clueId > 0 {
-									TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
-										"status":      1,
-										"is_delete":   1,
-										"createtime":  nowTime,
-										"updatetime":  nowTime,
-										"phone":       phone,
-										"baseinfo_id": uId,
-										"SOURCE":      source,
-									})
-									TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
-										"clue_id":     clueId,
-										"position_id": -1,
-										"change_type": "创建线索",
-										"new_value":   "系统自动创建",
-										"createtime":  nowTime,
-										"BCPCID":      common.GetRandom(32),
-										"operator_id": -1,
-									})
-								}
-							} else {
-								TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
-									"status":      1,
-									"is_delete":   1,
-									"createtime":  nowTime,
-									"updatetime":  nowTime,
-									"phone":       phone,
-									"baseinfo_id": uId,
-									"SOURCE":      source,
-								})
-							}
+			layout := "2006-01-02 15:04:05"
+			createtime := gconv.String(v["createtime"])
+			createtimeInt64, _ := time.Parse(layout, createtime)
+			registedateInt64, _ := time.Parse(layout, registedate)
+			count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
+			if createtimeInt64.Unix()-registedateInt64.Unix() < int64(db.RegTimes)*86400 {
+				if count == 0 {
+					//注册少于7天、走新增
+					data := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{
+						"id": gconv.Int64(v["id"]),
+					}, "", "")
+					if data != nil && len(*data) > 0 {
+						ok1, ok2, _ := FormatData(v, "users")
+						if !ok1 {
+							log.Println("线索卡点", "userbase uid", v, uId)
 						} else {
-							if count == 0 {
-								ok1, ok2, ok3 := FormatData(v, "users")
-								if !ok3 {
-									//安博会数据
-									abhList = append(abhList, v)
-									continue
-								}
-								if !ok1 {
-									log.Println("线索卡点", "userbase uid", v, uId)
-								} else {
-									if !ok2 {
-										log.Println("用户分配已达上限", "userbase uid", v, uId)
-									}
-								}
-							} else {
-								TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
-									"status":      1,
-									"is_delete":   1,
-									"createtime":  nowTime,
-									"updatetime":  nowTime,
-									"phone":       phone,
-									"baseinfo_id": uId,
-									"SOURCE":      source,
-								})
+							if !ok2 {
+								log.Println("用户分配已达上限", "userbase uid", v, uId)
 							}
 						}
 					}
 				}
+				continue
+			}
+			registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
+			log.Println("userbase uid 线索数量 ", count)
+			log.Println("userbase uid 注册时间 ", registedates)
+			if count == 0 {
+				clueId := int64(0)
+				sql := fmt.Sprintf(`select * from freeClubSign where mogUserId="%s" and sub_again_date > "%s" `, userId, selectTimeEnd)
+				data := BiService.SelectBySql(sql)
+				if len(*data) > 0 && userId != "" {
+					clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
+						"userid":            userId,
+						"uid":               uId,
+						"is_assign":         0,
+						"comeintime":        nowTime,
+						"createtime":        nowTime,
+						"updatetime":        nowTime,
+						"cluename":          phone,
+						"top_cluetype":      "532",
+						"sub_cluetype":      "670",
+						"trailstatus":       "01",
+						"name":              name,
+						"phone":             phone,
+						"comeintime_open":   nowTime,
+						"comeinsource_open": 1,
+						"FREEZE_TIME":       nowTime,
+					})
+				} else {
+					clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
+						"userid":            userId,
+						"uid":               uId,
+						"is_assign":         0,
+						"comeintime":        nowTime,
+						"createtime":        nowTime,
+						"updatetime":        nowTime,
+						"cluename":          phone,
+						"top_cluetype":      "532",
+						"sub_cluetype":      "475",
+						"trailstatus":       "01",
+						"name":              name,
+						"phone":             phone,
+						"comeintime_open":   nowTime,
+						"comeinsource_open": 1,
+						"FREEZE_TIME":       nowTime,
+					})
+				}
+				if clueId > 0 {
+					TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": -1,
+						"change_type": "创建线索",
+						"new_value":   "系统自动创建",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": -1,
+					})
+				}
 			}
-		}
-		if len(abhList) > 0 {
-			//安博会发邮件高翔
-			ABHEmail("user", abhList)
 		}
 	}
 	log.Println("userbase定时任务结束")

+ 1 - 1
clueSync/main.go

@@ -158,6 +158,7 @@ func main() {
 		})
 		//5分钟一次
 		go p.VarTimeTask.RunInTimeSection("5分钟定时任务1", db.CornExp2Start, db.CornExp2End, db.CornExp2, func(dayFirst bool) {
+
 			users()               //新注册用户进线索
 			saleLeads()           //留资进线索
 			eventReg()            //渠道
@@ -195,7 +196,6 @@ func main() {
 			autoExitSea()      //自动退海
 			Thaw()             //自动解冻处理
 			subscribeAddSync() //订阅增量
-			rderAcceptance()   //工单生成
 		})
 		//5分钟一次
 		go p.VarTimeTask.RunInTimeLoop("5分钟定时任务3", "", "", db.CornExp6, true, true, nil, func() {