소스 검색

行为信息

xuzhiheng 2 년 전
부모
커밋
b884d73cbf
3개의 변경된 파일90개의 추가작업 그리고 14개의 파일을 삭제
  1. 4 3
      clueSync/autoTask.go
  2. 60 5
      clueSync/job.go
  3. 26 6
      telemarketingEtl/entity/dwd_f_userbase_event_info.go

+ 4 - 3
clueSync/autoTask.go

@@ -166,10 +166,12 @@ func autoExitSea() {
 			nowTime := time.Now().Format(date.Date_Full_Layout)
 			is_assign := common.IntAll(v["is_assign"])
 			if TiDb.ExecTx("退出线索", func(tx *sql.Tx) bool {
-				recordId := TiDb.UpdateOrDeleteBySqlByTx(tx, `UPDATE dwd_f_crm_clue_info SET is_assign = -1,position_id = null,seatNumber = null WHERE id = ?`, clueId)
+				recordId := TiDb.UpdateOrDeleteBySqlByTx(tx, `UPDATE dwd_f_crm_clue_info SET is_assign = -1,position_id = null,seatNumber = null,updatetime = ? WHERE id = ?`, nowTime, clueId)
 				ok1 := true
 				if is_assign == 1 {
 					ok1 = TiDb.DeleteByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId})
+				} else if is_assign == 0 {
+					ok1 = TiDb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
 				}
 				recordId1 := TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
@@ -211,7 +213,6 @@ func autoExitSea() {
 					"BCPCID":      common.GetRandom(32),
 					"operator_id": -1,
 				})
-				log.Println(ok1, recordId, recordId1, recordId2, recordId3, recordId4)
 				return ok1 && recordId > -1 && recordId1 > -1 && recordId2 > -1 && recordId3 > -1 && recordId4 > -1
 			}) {
 				log.Println("自动退出线索成功")
@@ -229,7 +230,7 @@ func autoExitSea() {
 			nowTime := time.Now().Format(date.Date_Full_Layout)
 			is_assign := common.IntAll(v["is_assign"])
 			if TiDb.ExecTx("自动退海", func(tx *sql.Tx) bool {
-				recordId := TiDb.UpdateOrDeleteBySqlByTx(tx, `UPDATE dwd_f_crm_clue_info SET is_assign = 0,position_id = null,seatNumber = null  WHERE id = ?`, clueId)
+				recordId := TiDb.UpdateOrDeleteBySqlByTx(tx, `UPDATE dwd_f_crm_clue_info SET is_assign = 0,position_id = null,seatNumber = null,updatetime = ?  WHERE id = ?`, nowTime, clueId)
 				ok1 := true
 				if is_assign == 1 {
 					ok1 = TiDb.DeleteByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId})

+ 60 - 5
clueSync/job.go

@@ -97,11 +97,66 @@ func userbase() {
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
 			phone := common.ObjToString(v["phone"])
-			uid := common.ObjToString(v["uid"])
+			uId := common.ObjToString(v["uid"])
+			userId := common.ObjToString(v["userid"])
+			registedate := common.ObjToString(v["l_registedate"])
+			name := common.ObjToString(v["name"])
+			nowTime := time.Now().Format(date.Date_Full_Layout)
+			source := common.IntAll(v["source"])
 			if phone != "" {
-				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and phone = ? and is_delete = 1", uid, phone)
+				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
 				if contactsData == nil || len(*contactsData) == 0 {
-					FormatData(v, "users")
+					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,
+							})
+						}
+					} 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,
+									"comeintime":   nowTime,
+									"comeinsource": 2,
+								})
+							}
+						} 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,
+							})
+						}
+					}
 				}
 			}
 		}
@@ -550,7 +605,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		insertSeaData["seatNumber"] = old_seatNumber
 		insertSeaData["position_id"] = old_position_id
 	}
-	if trailstatus != "08" {
+	if trailstatus != "08" && is_assign == 0 {
 		clueUpdateData["trailstatus"] = "01"
 	}
 	if (trailstatus != "08" && recordCount <= 0) || is_assign == 0 {
@@ -697,7 +752,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		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", positionId, common.Int64All(data["position_id"])),
+				"position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
 				"change_type": "加入任务车",
 				"new_value":   "线索来源自动更新" + "-" + topname + "-" + subname,
 				"createtime":  nowTime,

+ 26 - 6
telemarketingEtl/entity/dwd_f_userbase_event_info.go

@@ -169,6 +169,11 @@ func EventInfoAdd(start, end int64) {
 					eventtype = INFO
 					//截取id
 					ur := ArticleId.FindStringSubmatch(url_)
+					//变更url
+					if table != "jy_logs" {
+						url_ = strings.ReplaceAll(url_, "/jyapp", "")
+					}
+					//
 					if len(ur) > 1 {
 						uarr := BDecodeArticleId2ByCheck(ur[1], encrypt.SE, encrypt.SE2)
 						if len(uarr) > 0 {
@@ -195,6 +200,11 @@ func EventInfoAdd(start, end int64) {
 					if len(na) > 1 {
 						name = util.Unescape(na[1])
 					}
+					//变更url
+					if table != "jy_logs" {
+						url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
+					}
+					//
 				} else if PcEntIntelligentceMonitorReg.MatchString(url_) && !strings.Contains(refer, "/swordfish/page_big_pc/free/ent_follow") {
 					eventtype = ENTPORTRAIT
 					na := PcEntPortraitNameReg.FindStringSubmatch(url_)
@@ -211,6 +221,11 @@ func EventInfoAdd(start, end int64) {
 						entId := util.DecodeId(eId)
 						name = GetEntNameByEntId(entId)
 					}
+					//变更url
+					if table != "jy_logs" {
+						url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
+					}
+					//
 				} else if ProductIndexReg.MatchString(url_) {
 					eventtype = PRODUCTINDEX
 				} else if PcClientReg.MatchString(url_) && strings.Contains(refer, "/swordfish/page_big_pc/my_client") {
@@ -219,6 +234,11 @@ func EventInfoAdd(start, end int64) {
 				} else if AppClientReg.MatchString(url_) {
 					eventtype = CLIENT
 					name = AppClient(url_)
+					//变更url
+					if table != "jy_logs" {
+						url_ = strings.ReplaceAll(url_, "/jyapp/big/page/client_portrayal?entName=", "/swordfish/page_big_pc/unit_portrayal/")
+					}
+					//
 				} else if PcProjectMonitorReg.MatchString(url_) {
 					eventtype = PROJECTPROGRESS
 					name = ProjectProgress(url_)
@@ -300,8 +320,8 @@ func GetEntNameByEntId(entId string) (name string) {
 	return gconv.String((*entinfo)["company_name"])
 }
 
-//潜在项目预测
-//返回title 和 href
+// 潜在项目预测
+// 返回title 和 href
 func Forecast(urls string) (title, href string) {
 	//获取id
 	re := regexp.MustCompile(`id=([^&]+)`)
@@ -323,7 +343,7 @@ func Forecast(urls string) (title, href string) {
 	return "", ""
 }
 
-//关注项目
+// 关注项目
 func ProjectProgress(urls string) (title string) {
 	//获取id
 	re := regexp.MustCompile(`sid=([^&]+)`)
@@ -350,7 +370,7 @@ func ProjectProgress(urls string) (title string) {
 	return gconv.String((*res)["projectname"])
 }
 
-//企业情报监控
+// 企业情报监控
 func EntFollow(urls string) string {
 	re := regexp.MustCompile(`/[^/]+/[^/]+/[^/]+/(.*)`)
 
@@ -397,7 +417,7 @@ func AppClient(urls string) string {
 	return util.GetQueryParam(urls, "entName")
 }
 
-//return title href
+// return title href
 func GetInfoByBid(bid string) (string, string) {
 	title, href := "", ""
 	res, _ := config.MgoBid.FindById("bidding", bid, `{"title":1,"href":1}`)
@@ -414,7 +434,7 @@ func GetInfoByBid(bid string) (string, string) {
 	return title, href
 }
 
-//短地址解密,二次解密带校验和
+// 短地址解密,二次解密带校验和
 func BDecodeArticleId2ByCheck(id string, s1, s2 *encrypt.SimpleEncrypt) []string {
 	if !strings.Contains(id, "+") { //新加密算法解密
 		id, _ = url.QueryUnescape(id)