xuzhiheng vor 2 Jahren
Ursprung
Commit
fc2d064edf
7 geänderte Dateien mit 256 neuen und 153 gelöschten Zeilen
  1. 1 0
      clueSync/autoTask.go
  2. 1 0
      clueSync/config.go
  3. 1 0
      clueSync/config.json
  4. 202 135
      clueSync/job.go
  5. 2 0
      clueSync/main.go
  6. 31 0
      clueSync/subscribeAll.go
  7. 18 18
      telemarketingEtl/timetask/task.go

+ 1 - 0
clueSync/autoTask.go

@@ -279,6 +279,7 @@ func autoExitSea() {
 					"clue_id":      clueId,
 					"comeintime":   nowTime,
 					"comeinsource": 2,
+					"level":        4,
 				})
 				return ok1 && recordId > -1 && recordId1 > -1 && recordId2 > -1 && recordId3 > -1 && recordId4 > -1 && recordId5 > -1
 			}) {

+ 1 - 0
clueSync/config.go

@@ -23,6 +23,7 @@ type (
 		LastSubscribeId string `json:"lastSubscribeId"`
 		XlsxNum         string `json:"xlsxNum"`
 		CountLimit      int64  `json:"countLimit"`
+		RegTimes        int    `json:"regTimes"`
 		RedisServer     string `json:"redisServer"`
 		TiDb            struct {
 			Host        string `json:"host"`

+ 1 - 0
clueSync/config.json

@@ -14,6 +14,7 @@
 	"lastSubscribeId": "64473e36c572141d78ec7a03",
 	"countLimit": 1000,
 	"xlsxNum": "1",
+	"regTimes": 7,
 	"redisServer":"192.168.3.206:1712",
 	"tiDb": {
 		"host": "192.168.3.149",

+ 202 - 135
clueSync/job.go

@@ -111,55 +111,89 @@ func userbase() {
 			if phone != "" {
 				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
 				if contactsData == nil || len(*contactsData) == 0 {
-					registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
-					count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where phone = ?", phone)
-					if time.Now().Unix()-registedates.Unix() > 7*86400 {
-						if count == 0 {
-							FormatData(v, "users")
-						} 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,
-							})
-						}
+					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 {
-						if count == 0 {
-							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": "",
-								"sub_cluetype": "",
-								"trailstatus":  "01",
-								"name":         name,
-								"phone":        phone,
-							})
-							if clueId > 0 {
-								TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
-									"clue_id":      clueId,
+						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(cfg.RegTimes)*86400 {
+							if count == 0 {
+								clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
+									"userid":       userId,
+									"uid":          uId,
+									"is_assign":    0,
 									"comeintime":   nowTime,
-									"comeinsource": 2,
+									"createtime":   nowTime,
+									"updatetime":   nowTime,
+									"cluename":     phone,
+									"top_cluetype": "379",
+									"sub_cluetype": "380",
+									"trailstatus":  "01",
+									"name":         name,
+									"phone":        phone,
+								})
+								if clueId > 0 {
+									TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
+										"clue_id":      clueId,
+										"comeintime":   nowTime,
+										"comeinsource": 2,
+									})
+									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,
 								})
 							}
 						} 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 count == 0 {
+								FormatData(v, "users")
+							} 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,
+								})
+							}
 						}
 					}
 				}
@@ -397,7 +431,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64, source int) bool {
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
 	nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
-	clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
+	clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5, uodateId6 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
 	// BCPCID := common.GetRandom(32)
 	if TiDb.ExecTx("保存线索", func(tx *sql.Tx) bool {
 		//线索
@@ -476,7 +510,29 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
 			"BCPCID":      common.GetRandom(32),
 			"operator_id": -1,
 		})
-		return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1
+		uodateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			"clue_id":      clueId,
+			"position_id":  positionId,
+			"change_field": "top_cluetype",
+			"change_type":  "基本信息变更",
+			"old_value":    "/",
+			"new_value":    topname,
+			"createtime":   nowTime,
+			"BCPCID":       common.GetRandom(32),
+			"operator_id":  -1,
+		})
+		uodateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			"clue_id":      clueId,
+			"position_id":  positionId,
+			"change_field": "sub_cluetype",
+			"change_type":  "基本信息变更",
+			"old_value":    "/",
+			"new_value":    subname,
+			"createtime":   nowTime,
+			"BCPCID":       common.GetRandom(32),
+			"operator_id":  -1,
+		})
+		return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
 	}) {
 		log.Println("线索分配成功")
 		if TiDb.Count("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}) == 0 {
@@ -492,7 +548,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
 		}
 		return true
 	} else {
-		log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
+		log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5, uodateId6, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
 		return false
 	}
 }
@@ -503,6 +559,11 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 	//trailstatus = 无意向 为变更线索状态
 	//没有变更所属人查任务车,有车不变
 	trailstatus := common.ObjToString(data["trailstatus"])
+	trailstatusTime := common.ObjToString(data["trailstatus_time"])
+	var trailstatusTimes time.Time
+	if trailstatusTime != "" {
+		trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
+	}
 	clueId := common.Int64All(data["id"])
 	is_assign := common.IntAll(data["is_assign"])
 	oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
@@ -561,7 +622,6 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 	recordCount := TiDb.CountBySql(`select count(1) from dwd_f_crm_trail_content where clue_id = ? and createtime > ?`, clueId, t.AddDate(0, 0, -count).Format(date.Date_Full_Layout))
 	//
 	clueUpdateData := map[string]interface{}{
-		"is_assign":    1,
 		"updatetime":   nowTime,
 		"top_cluetype": top_cluetype,
 		"sub_cluetype": sub_cluetype,
@@ -593,17 +653,21 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		clueUpdateData["role"] = role
 	}
 	if trailstatus == "00" || old_position_id == 0 || is_assign != 1 {
-		clueUpdateData["seatNumber"] = seatNumber
-		clueUpdateData["position_id"] = positionId
-		clueUpdateData["comeintime"] = nowTime
-		seaUpdateData["seatNumber"] = seatNumber
-		seaUpdateData["position_id"] = positionId
-		seaUpdateData["comeintime"] = nowTime
-		insertSeaData["seatNumber"] = seatNumber
-		insertSeaData["position_id"] = positionId
-		for _, v := range saleData {
-			if common.ObjToString(data["seatNumber"]) == common.ObjToString(v["seatNumber"]) {
-				oldsaleName = common.ObjToString(v["name"])
+		if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+		} else {
+			clueUpdateData["seatNumber"] = seatNumber
+			clueUpdateData["position_id"] = positionId
+			clueUpdateData["comeintime"] = nowTime
+			clueUpdateData["is_assign"] = 1
+			seaUpdateData["seatNumber"] = seatNumber
+			seaUpdateData["position_id"] = positionId
+			seaUpdateData["comeintime"] = nowTime
+			insertSeaData["seatNumber"] = seatNumber
+			insertSeaData["position_id"] = positionId
+			for _, v := range saleData {
+				if common.ObjToString(data["seatNumber"]) == common.ObjToString(v["seatNumber"]) {
+					oldsaleName = common.ObjToString(v["name"])
+				}
 			}
 		}
 	} else {
@@ -611,13 +675,20 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		insertSeaData["position_id"] = old_position_id
 	}
 	if trailstatus != "08" && is_assign == 0 {
-		clueUpdateData["trailstatus"] = "01"
+		if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+		} else {
+			clueUpdateData["trailstatus"] = "01"
+			clueUpdateData["trailstatus_time"] = nowTime
+		}
 	}
 	if (trailstatus != "08" && recordCount <= 0) || is_assign == 0 {
-		seaUpdateData["is_task"] = 1
-		seaUpdateData["task_time"] = nowTime
-		seaUpdateData["tasktime"] = taskTime
-		seaUpdateData["taskstatus"] = 0
+		if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+		} else {
+			seaUpdateData["is_task"] = 1
+			seaUpdateData["task_time"] = nowTime
+			seaUpdateData["tasktime"] = taskTime
+			seaUpdateData["taskstatus"] = 0
+		}
 	}
 	ok, ok1, ok2, seaId := true, true, true, int64(0)
 	updateId1, updateId2, updateId3, updateId4, updateId5 := int64(0), int64(0), int64(0), int64(0), int64(0)
@@ -629,30 +700,23 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		if is_assign == 1 {
 			ok1 = TiDb.UpdateByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, seaUpdateData)
 		} else {
-			ok2 = TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
-			seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
+			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+			} else {
+				ok2 = TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
+				seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
+			}
 		}
 		//变更记录
 		if (trailstatus == "00" || old_position_id == 0) && is_assign == 1 {
-			updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-				"clue_id":      clueId,
-				"position_id":  positionId,
-				"change_field": "position_id",
-				"change_type":  "所属人变更",
-				"old_value":    common.If(oldsaleName != "", oldsaleName, "/"),
-				"new_value":    common.If(saleName != "", saleName, "/"),
-				"createtime":   nowTime,
-				"BCPCID":       common.GetRandom(32),
-				"operator_id":  -1,
-			})
-			if trailstatus == "00" {
-				updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+			} else if old_position_id == 0 {
+				updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.Int64All(data["position_id"]),
-					"change_field": "trailstatus",
-					"change_type":  "基本信息变更",
-					"old_value":    "无意向客户",
-					"new_value":    "流失",
+					"position_id":  positionId,
+					"change_field": "position_id",
+					"change_type":  "所属人变更",
+					"old_value":    common.If(oldsaleName != "", oldsaleName, "/"),
+					"new_value":    common.If(saleName != "", saleName, "/"),
 					"createtime":   nowTime,
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
@@ -662,74 +726,72 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 					"position_id":  positionId,
 					"change_field": "trailstatus",
 					"change_type":  "基本信息变更",
-					"old_value":    "商机线索",
+					"old_value":    CodeTrail[trailstatus],
 					"new_value":    "新增",
 					"createtime":   nowTime,
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
 				})
-				updateId4 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			} else {
+				updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  positionId,
+					"change_field": "position_id",
+					"change_type":  "所属人变更",
+					"old_value":    common.If(oldsaleName != "", oldsaleName, "/"),
+					"new_value":    common.If(saleName != "", saleName, "/"),
+					"createtime":   nowTime,
+					"BCPCID":       common.GetRandom(32),
+					"operator_id":  -1,
+				})
+				updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":      clueId,
+					"position_id":  common.Int64All(data["position_id"]),
 					"change_field": "trailstatus",
 					"change_type":  "基本信息变更",
 					"old_value":    "无意向客户",
-					"new_value":    "商机线索",
+					"new_value":    "流失",
 					"createtime":   nowTime,
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
 				})
-			} else if old_position_id == 0 {
 				updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  positionId,
 					"change_field": "trailstatus",
 					"change_type":  "基本信息变更",
-					"old_value":    CodeTrail[trailstatus],
+					"old_value":    "商机线索",
 					"new_value":    "新增",
 					"createtime":   nowTime,
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
 				})
-			} else {
-				if common.Int64All(data["position_id"]) > 0 {
-					updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-						"clue_id":      clueId,
-						"position_id":  common.Int64All(data["position_id"]),
-						"change_field": "trailstatus",
-						"change_type":  "基本信息变更",
-						"old_value":    "商机线索",
-						"new_value":    "流失",
-						"createtime":   nowTime,
-						"BCPCID":       common.GetRandom(32),
-						"operator_id":  -1,
-					})
-				}
-				updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+				updateId4 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  positionId,
 					"change_field": "trailstatus",
 					"change_type":  "基本信息变更",
-					"old_value":    "商机线索",
-					"new_value":    "新增",
+					"old_value":    "无意向客户",
+					"new_value":    "商机线索",
 					"createtime":   nowTime,
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
 				})
 			}
 		} else if trailstatus != "08" && is_assign == 0 {
-			updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-				"clue_id":      clueId,
-				"position_id":  positionId,
-				"change_field": "position_id",
-				"change_type":  "所属人变更",
-				"old_value":    common.If(oldsaleName != "", oldsaleName, "/"),
-				"new_value":    common.If(saleName != "", saleName, "/"),
-				"createtime":   nowTime,
-				"BCPCID":       common.GetRandom(32),
-				"operator_id":  -1,
-			})
-			if trailstatus != "01" {
+			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+			} else if trailstatus != "01" {
+				updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":      clueId,
+					"position_id":  positionId,
+					"change_field": "position_id",
+					"change_type":  "所属人变更",
+					"old_value":    common.If(oldsaleName != "", oldsaleName, "/"),
+					"new_value":    common.If(saleName != "", saleName, "/"),
+					"createtime":   nowTime,
+					"BCPCID":       common.GetRandom(32),
+					"operator_id":  -1,
+				})
 				updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  positionId,
@@ -754,16 +816,21 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 				})
 			}
 		}
+		log.Println("trailstatusTime ", trailstatusTime)
+		log.Println("trailstatusTimes.Unix() ", trailstatusTimes.Unix(), time.Now().Unix()-trailstatusTimes.Unix())
 		if trailstatus != "08" && recordCount <= 0 {
-			updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-				"clue_id":     clueId,
-				"position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
-				"change_type": "加入任务车",
-				"new_value":   "线索来源自动更新" + "-" + topname + "-" + subname,
-				"createtime":  nowTime,
-				"BCPCID":      common.GetRandom(32),
-				"operator_id": -1,
-			})
+			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
+			} else {
+				updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":     clueId,
+					"position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"change_type": "加入任务车",
+					"new_value":   "线索来源自动更新" + "-" + topname + "-" + subname,
+					"createtime":  nowTime,
+					"BCPCID":      common.GetRandom(32),
+					"operator_id": -1,
+				})
+			}
 		}
 		BCPCID := common.GetRandom(32)
 		old_name := common.ObjToString(data["name"])
@@ -791,7 +858,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			if old_name != name && name != "" {
 				updateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "name",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_name != "", old_name, "/"),
@@ -804,7 +871,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			if old_position != position && position != "" {
 				updateId7 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "position",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_position != "", old_position, "/"),
@@ -817,7 +884,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			if old_department != department && department != "" {
 				updateId8 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "department",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_department != "", old_department, "/"),
@@ -830,7 +897,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			if old_role != role && role != "" {
 				updateId9 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "role",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_role != "", old_role, "/"),
@@ -853,7 +920,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 				new_area = strings.Join(new_area_arr, ",")
 				updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "follow_project_area",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_area != "", old_area, "/"),
@@ -866,7 +933,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			if old_cluename != cluename && cluename != "" {
 				updateId11 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
-					"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+					"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 					"change_field": "cluename",
 					"change_type":  "基本信息变更",
 					"old_value":    common.If(old_cluename != "", old_cluename, "/"),
@@ -880,7 +947,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		if old_top_cluetype != top_cluetype {
 			updateId12 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 				"clue_id":      clueId,
-				"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+				"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 				"change_field": "top_cluetype",
 				"change_type":  "基本信息变更",
 				"old_value":    common.If(old_topname != "", old_topname, "/"),
@@ -893,7 +960,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		if old_sub_cluetype != sub_cluetype {
 			updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 				"clue_id":      clueId,
-				"position_id":  common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
+				"position_id":  common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
 				"change_field": "sub_cluetype",
 				"change_type":  "基本信息变更",
 				"old_value":    common.If(old_subname != "", old_subname, "/"),

+ 2 - 0
clueSync/main.go

@@ -162,5 +162,7 @@ func main() {
 		trail()
 	} else if *mode == 12 {
 		userbase()
+	} else if *mode == 13 {
+		eventSync()
 	}
 }

+ 31 - 0
clueSync/subscribeAll.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	"regexp"
 	"strings"
 	"time"
 
@@ -176,3 +177,33 @@ func FormatSubscribeAllData(data map[string]interface{}) {
 		}
 	}
 }
+
+func eventSync() {
+	AppBuyPortraitReg := regexp.MustCompile("^/jyapp/big/page/unit_portrayal")
+	AppArticleReg := regexp.MustCompile("^/jyapp/article/(content|bdprivate|mailprivate)")
+	AppEntPortraitReg := regexp.MustCompile("^/jyapp/big/page/ent_portrait")
+	AppClientReg := regexp.MustCompile("^^/jyapp/big/page/client_portrayal")
+	TiDb.SelectByBath(1000, func(l *[]map[string]interface{}) bool {
+		for _, v := range *l {
+			url_ := common.ObjToString(v["url"])
+			id := common.Int64All(v["id"])
+			if AppBuyPortraitReg.MatchString(url_) {
+				url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
+			} else if AppArticleReg.MatchString(url_) {
+				url_ = strings.ReplaceAll(url_, "/jyapp", "")
+			} else if AppEntPortraitReg.MatchString(url_) {
+				url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
+			} else if AppClientReg.MatchString(url_) {
+				url_ = strings.ReplaceAll(url_, "/jyapp/big/page/client_portrayal?entName=", "/swordfish/page_big_pc/unit_portrayal/")
+			}
+			ok := TiDb.Update("dwd_f_userbase_event_info", map[string]interface{}{"id": id}, map[string]interface{}{"url": url_})
+			if ok {
+				log.Println("修改成功 ", id, url_)
+			} else {
+				log.Println("修改失败 ", id, url_)
+			}
+		}
+		return true
+	}, `SELECT * from dwd_f_userbase_event_info where platform = 1`)
+	log.Println("app刷行为信息链接结束")
+}

+ 18 - 18
telemarketingEtl/timetask/task.go

@@ -91,8 +91,8 @@ func Run() {
 		searchInfoTask := gcfg.Instance().MustGet(gctx.New(), "searchInfoTask", "").String()
 		visitInfoTask := gcfg.Instance().MustGet(gctx.New(), "visitInfoTask", "").String()
 		openSeaTask := gcfg.Instance().MustGet(gctx.New(), "openSeaTask", "").String()
-		deleteOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "deleteOpenSeaTask", "").String()
-		returnOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "returnOpenSeaTask", "").String()
+		// deleteOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "deleteOpenSeaTask", "").String()
+		// returnOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "returnOpenSeaTask", "").String()
 		//
 		_, err = gcron.Add(ctx, eventInfoTask, func(ctx context.Context) {
 			TaskEventInfo()
@@ -123,22 +123,22 @@ func Run() {
 			panic(err)
 		}
 		//
-		_, err = gcron.Add(ctx, deleteOpenSeaTask, func(ctx context.Context) {
-			log.Println("开始DeleteOpenSea")
-			entity.DeleteOpenSea()
-			log.Println("结束DeleteOpenSea")
-		}, "DeleteOpenSea")
-		if err != nil {
-			panic(err)
-		}
+		// _, err = gcron.Add(ctx, deleteOpenSeaTask, func(ctx context.Context) {
+		// 	log.Println("开始DeleteOpenSea")
+		// 	entity.DeleteOpenSea()
+		// 	log.Println("结束DeleteOpenSea")
+		// }, "DeleteOpenSea")
+		// if err != nil {
+		// 	panic(err)
+		// }
 		//
-		_, err = gcron.Add(ctx, returnOpenSeaTask, func(ctx context.Context) {
-			log.Println("开始ReturnOpenSea")
-			entity.ReturnOpenSea()
-			log.Println("结束ReturnOpenSea")
-		}, "ReturnOpenSea")
-		if err != nil {
-			panic(err)
-		}
+		// _, err = gcron.Add(ctx, returnOpenSeaTask, func(ctx context.Context) {
+		// 	log.Println("开始ReturnOpenSea")
+		// 	entity.ReturnOpenSea()
+		// 	log.Println("结束ReturnOpenSea")
+		// }, "ReturnOpenSea")
+		// if err != nil {
+		// 	panic(err)
+		// }
 	}
 }