xuzhiheng 2 年之前
父节点
当前提交
813d51110c
共有 3 个文件被更改,包括 31 次插入29 次删除
  1. 1 1
      clueSync/autoTask.go
  2. 7 5
      clueSync/tag.go
  3. 23 23
      telemarketingEtl/entity/dwd_f_crm_open_sea.go

+ 1 - 1
clueSync/autoTask.go

@@ -63,7 +63,7 @@ func autoTask() {
 				WHERE trailstatus = ?`
 		argsSelect := []interface{}{trailstatus}
 		intime := ""
-		sql += " AND a.comeintime <?"
+		sql += " AND comeintime <?"
 		// nt := nexttime.(time.Time)
 		nt := t.AddDate(0, 0, -statusMap[trailstatus])
 		intime = nt.Format(date.Date_Full_Layout)

+ 7 - 5
clueSync/tag.go

@@ -19,22 +19,24 @@ func tagAllSync() {
 	//dwd_f_userbase_order_info -->product_type=VIP订阅 vip_endtime 一周内到期、一月内到期 -->userid  暂时不要了
 	//dwd_f_userbase_event_info -->createtime查昨天有没有数据, 有数据-昨日浏览过 没数据-昨日未浏览 -->userid
 	log.Println("用户标签定时任务开始")
-	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
+	count := 0
+	TiDb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
 		for _, v := range *l {
-			FormatTag(v)
+			count++
+			FormatTag(v, count)
 		}
 		return true
 	}, `select l_registedate,userid,uid from dwd_f_userbase_baseinfo`)
 	log.Println("用户标签定时任务结束")
 }
 
-func FormatTag(data map[string]interface{}) {
+func FormatTag(data map[string]interface{}, count int) {
 	registedate := common.ObjToString(data["l_registedate"])
 	userId := common.ObjToString(data["userid"])
 	uId := common.ObjToString(data["uid"])
-	log.Println(uId, registedate)
+	log.Println("第", count, "条:", uId, registedate, userId)
 	if registedate == "" || uId == "" || userId == "" {
-		log.Println("缺少信息")
+		log.Println("缺少信息 ", registedate, uId, userId)
 		return
 	}
 	date, search_areass, search_wordss, product_types, subscribe_keywords, subscribe_areas := "", "", "", "", "", ""

+ 23 - 23
telemarketingEtl/entity/dwd_f_crm_open_sea.go

@@ -396,7 +396,7 @@ func ThreeOpenSea(oneA, oneB, oneC, twoA, twoB, twoC, twoD map[string]bool) map[
 		wh := strings.Join(whs, ",")
 		config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET level_open = 3,clue_level='D' WHERE id in (`+wh+`)`, ids...)
 		return true
-	}, `SELECT id,userid FROM dwd_f_crm_clue_info`)
+	}, `SELECT id,userid FROM dwd_f_crm_clue_info where is_assign = 0`)
 	log.Println("三级公海end")
 	return m
 }
@@ -431,25 +431,25 @@ func AddOpenSea(m map[string]bool, level int, clue_level string) {
 // 自动退出公海
 // 线索状态为“空号停机”自动从线索池删除。
 // 空号停机 删除私海, 线索表分配状态改成 -1
-func DeleteOpenSea() {
-	config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
-		ids := []interface{}{}
-		for _, v := range *l {
-			id := v["id"]
-			ids = append(ids, id)
-		}
-		whs := []string{}
-		for i := 0; i < len(ids); i++ {
-			whs = append(whs, "?")
-		}
-		wh := strings.Join(whs, ",")
-		count := config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_assign = -1 WHERE id in (`+wh+`)`, ids...)
-		if count > 0 {
-			return true
-		}
-		return true
-	}, `select id from dwd_f_crm_clue_info where trailstatus = ?`, "02")
-}
+// func DeleteOpenSea() {
+// 	config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
+// 		ids := []interface{}{}
+// 		for _, v := range *l {
+// 			id := v["id"]
+// 			ids = append(ids, id)
+// 		}
+// 		whs := []string{}
+// 		for i := 0; i < len(ids); i++ {
+// 			whs = append(whs, "?")
+// 		}
+// 		wh := strings.Join(whs, ",")
+// 		count := config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_assign = -1 WHERE id in (`+wh+`)`, ids...)
+// 		if count > 0 {
+// 			return true
+// 		}
+// 		return true
+// 	}, `select id from dwd_f_crm_clue_info where trailstatus = ?`, "02")
+// }
 
 //自动退回公海
 /*
@@ -661,7 +661,7 @@ func GetOneSeaC(oneClassA, oneClassB map[string]bool) map[string]bool {
 			m[clueid] = true
 		}
 		return true
-	}, `select id from dwd_f_crm_clue_info where comeinsource_open in(2,3,4)`)
+	}, `select id from dwd_f_crm_clue_info where is_assign = 0 and comeinsource_open in(2,3,4)`)
 	return m
 }
 
@@ -697,7 +697,7 @@ func Recycle() {
 	recycleB := g.Cfg().MustGet(ctx, "recycleB").Int()
 	tB := t.AddDate(0, 0, -recycleB)
 	for sql, clue_level := range map[string]interface{}{
-		fmt.Sprintf(`select id from dwd_f_crm_clue_info where comeinsource_open=%v and comeintime_open > "%s" ;`, 2, tA.Format(date.Date_Full_Layout)): "A",
+		fmt.Sprintf(`select id from dwd_f_crm_clue_info where comeinsource_open=%v and is_assign = 0 and comeintime_open > "%s" ;`, 2, tA.Format(date.Date_Full_Layout)): "A",
 		fmt.Sprintf(`SELECT a.uid,b.phone,c.createTime,a.id FROM dwd_f_crm_clue_info a 
 					LEFT JOIN dwd_f_userbase_contacts b ON b.baseinfo_id=a.uid
 					LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = b.phone
@@ -716,7 +716,7 @@ func Recycle() {
 					whs = append(whs, "?")
 				}
 				wh := strings.Join(whs, ",")
-				config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_open_sea SET level = 4,clue_level = "`+fmt.Sprint(clue_level)+`" WHERE id in (`+wh+`)`, ids...)
+				config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET level_open = 4,clue_level = "`+fmt.Sprint(clue_level)+`" WHERE id in (`+wh+`)`, ids...)
 				return true
 			}, sql)
 		}(sql)