Browse Source

邀请用户

WH01243 8 tháng trước cách đây
mục cha
commit
49b083ff11
5 tập tin đã thay đổi với 97 bổ sung1 xóa
  1. 1 0
      clueSync/config.go
  2. 25 1
      clueSync/config.json
  3. 19 0
      clueSync/job.go
  4. 51 0
      clueSync/jobutil.go
  5. 1 0
      clueSync/main.go

+ 1 - 0
clueSync/config.go

@@ -30,6 +30,7 @@ type (
 		AllocationRatio         float64 `json:"allocationRatio"`
 		ActiveTime              string  `json:"activeTime"`
 		RebindTime              string  `json:"rebindTime"`
+		InviteTime              string  `json:"inviteTime"`
 	}
 	DB struct {
 		CornExp1      int64  `json:"cornexp1"`

+ 25 - 1
clueSync/config.json

@@ -1 +1,25 @@
-{"lastOrderId":258784,"lastOrderClueId":"2024-05-25 02:23:21","lastUserId":"2024-05-20 15:40:02","lastXcxUserId":"2024-07-09 14:59:37","lastId":"66cd4d3ae83797f8bf5e7ca2","lastOrderTime":"2023-04-25 00:00:00","lastUserTime":"2024-07-09 11:54:02","lastSubscribeId":"645470af172d9e8dcc5c507a","lastMessageTime":"2024-06-20 17:54:18","lastkcTime":"","lastEverythingTime":"","lastEventRegTime":"","lastReadClueTime":"","bigSaleTime":1718241923,"bigOrderTime":"2024-06-12 17:01:39","marketSaleTime":1708160200,"advisoryCommitteeTime":1724136683,"allocationTime":"2024-07-01 14:59:37","allocationRatio":2,"activeTime":"2024-07-01 14:59:37","rebindTime":"2024-08-27 16:10:27"}
+{
+  "lastOrderId": 258784,
+  "lastOrderClueId": "2024-05-25 02:23:21",
+  "lastUserId": "2024-05-20 15:40:02",
+  "lastXcxUserId": "2024-07-09 14:59:37",
+  "lastId": "66cd4d3ae83797f8bf5e7ca2",
+  "lastOrderTime": "2023-04-25 00:00:00",
+  "lastUserTime": "2024-07-09 11:54:02",
+  "lastSubscribeId": "64547124b487f52aade52c80",
+  "lastMessageTime": "2024-06-20 17:54:18",
+  "lastkcTime": "",
+  "lastEverythingTime": "",
+  "lastEventRegTime": "",
+  "lastReadClueTime": "",
+  "bigSaleTime": 1718241923,
+  "bigOrderTime": "2024-06-12 17:01:39",
+  "marketSaleTime": 1708160200,
+  "advisoryCommitteeTime": 1724136683,
+  "selectionDepartmentTime": 0,
+  "allocationTime": "2024-07-01 14:59:37",
+  "allocationRatio": 2,
+  "activeTime": "2024-07-01 14:59:37",
+  "rebindTime": "2024-08-27 16:10:27",
+  "inviteTime": "2024-11-10 10:47:16"
+}

+ 19 - 0
clueSync/job.go

@@ -59,6 +59,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 			}
 		}
 	} else if item == "users" || item == "xcxusers" { //注册用户
+		if Mgo.Count("user_share", map[string]interface{}{
+			"shared_uid": userId,
+		}) > 0 {
+			return true, true, true
+		}
 		userId = mongodb.BsonIdToSId(data["userid"])
 		//新用户没有uid、source要等5分钟
 		cluename = common.ObjToString(data["company_name"])
@@ -218,6 +223,20 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		// cluename = common.ObjToString(data["companyName"])
 		phone = common.ObjToString(data["phone"])
 		sourceId = common.Int64All(data["sourceId"])
+	} else if item == "invite" {
+		query["userid"] = userId
+		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
+		if userInfo != nil && len(*userInfo) > 0 {
+			uId = common.ObjToString((*userInfo)["uid"])
+			source = common.ObjToString((*userInfo)["source"])       //用户来源
+			belong_to = common.ObjToString((*userInfo)["belong_to"]) //用户归属
+		} else {
+			log.Println("邀请用户,用户归集没数据", data)
+			return true, true, true
+		}
+		cluename = common.ObjToString((*userInfo)["company_name"])
+		phone = common.ObjToString((*userInfo)["phone"])
+		sourceCode = common.ObjToString(data["sourceCode"])
 	}
 	log.Println(222, cluename)
 	if cluename == "" && item != "message" && item != "orders" && item != "readClue" && item != "rebind" && item != "allocation" {

+ 51 - 0
clueSync/jobutil.go

@@ -1039,6 +1039,18 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 		if pcodeData != nil && len(*pcodeData) > 0 {
 			subname = common.ObjToString((*pcodeData)["name"])
 		}
+	} else if item == "invite" {
+		codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": sourceCode}, "", "")
+		if codeData != nil && len(*codeData) > 0 {
+			pcode = common.ObjToString((*codeData)["pcode"])
+			code = common.ObjToString((*codeData)["code"])
+			level = common.ObjToString((*codeData)["clue_level"])
+			subname = common.ObjToString((*codeData)["name"])
+			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": pcode}, "", "")
+			if pcodeData != nil && len(*pcodeData) > 0 {
+				topname = common.ObjToString((*pcodeData)["name"])
+			}
+		}
 	} else {
 		if sourceCode != "" {
 			codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"source": sourceCode}, "", "")
@@ -1864,3 +1876,42 @@ func sendEmailIfSuccessful(err error, fileName, detailName, dir string) {
 		log.Println("send mail success", fileName, email)
 	}
 }
+func inviteUser() {
+	log.Println("邀请用户处理开始")
+	//判断节假日
+	runOk := getRunOk()
+	if !runOk {
+		log.Println("不是工作日,任务暂停")
+		return
+	}
+	rebindTimeEnd := cfg.InviteTime
+	sql := fmt.Sprintf(`select * from user_statistics where createTime > "%s" order by  createTime asc`, rebindTimeEnd)
+	//sql := fmt.Sprintf(`select * from user_statistics where createTime = "%s" order by  createTime asc`, rebindTimeEnd)
+	data := BiService.SelectBySql(sql)
+	if data != nil && *data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			rebindTimeEnd = common.ObjToString(v["createTime"])
+			event := gconv.Int64(v["event"])
+			switch event {
+			case 1:
+				v["sourceCode"] = "736"
+			case 2:
+				v["sourceCode"] = "737"
+			case 3:
+				v["sourceCode"] = "738"
+			}
+			v["user_id"] = gconv.String(v["userId"])
+			ok1, ok2, _ := FormatData(v, "invite")
+			if !ok1 {
+				log.Println("线索卡点", "invite", v, rebindTimeEnd)
+			} else {
+				if !ok2 {
+					log.Println("用户分配已达上限", "invite", v, rebindTimeEnd)
+				}
+			}
+		}
+		cfg.InviteTime = rebindTimeEnd
+		common.WriteSysConfig(&cfg)
+	}
+	log.Println("邀请用户处理结束")
+}

+ 1 - 0
clueSync/main.go

@@ -168,6 +168,7 @@ func main() {
 			SelectionDepartment() //运营部线索
 			rebind()              //取关重新关注处理
 			activeUsers()         //活跃用户处理
+			inviteUser()          //邀请用户
 		})
 		//每天8点30
 		c := cron.New()