Forráskód Böngészése

用户新增变更记录

WH01243 1 éve
szülő
commit
69e7d5ce3a
3 módosított fájl, 38 hozzáadás és 16 törlés
  1. 1 1
      clueSync/everything.go
  2. 8 1
      clueSync/job.go
  3. 29 14
      clueSync/jobutil.go

+ 1 - 1
clueSync/everything.go

@@ -230,7 +230,7 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
 	}
 	if item == "orders" {
 		sales_leads_source = "订单未支付"
-	} else if item == "users" {
+	} else if item == "users" || item == "xcxusers" {
 		return false
 	} else if item == "saleLeads" {
 		sales_leads_source = sourceName

+ 8 - 1
clueSync/job.go

@@ -57,7 +57,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 				}
 			}
 		}
-	} else if item == "users" { //注册用户
+	} else if item == "users" || item == "xcxusers" { //注册用户
 		userId = mongodb.BsonIdToSId(data["userid"])
 		//新用户没有uid、source要等5分钟
 		cluename = common.ObjToString(data["company_name"])
@@ -80,6 +80,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 				source = common.ObjToString((*userInfo)["source"])
 				belong_to = common.ObjToString((*userInfo)["belong_to"])
 			}
+			if item == "xcxusers" {
+				sourceCode = common.ObjToString(data["s_sourceid"])
+			}
+			if sourceCode == "" {
+				log.Println("留资没有source", phone)
+				return true, true
+			}
 		}
 	} else if item == "saleLeads" { //留资
 		userId = common.ObjToString(data["userid"])

+ 29 - 14
clueSync/jobutil.go

@@ -592,7 +592,7 @@ func users() {
 	}
 	common.WriteSysConfig(&cfg)
 	selectXcxTimeEnd := cfg.LastXcxUserId
-	xcxSql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where s_platform ="xcx"  and   updatetime> "%s"  and source = "0101" and status != 2`, selectXcxTimeEnd)
+	xcxSql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where s_platform ="xcx"  and   updatetime> "%s"  and source = "0101" and status != 2 and  clue_operate_status!=1`, selectXcxTimeEnd)
 	xcxData := TiDb.SelectBySql(xcxSql)
 	if xcxData != nil && *xcxData != nil && len(*xcxData) > 0 {
 		for k, v := range *xcxData {
@@ -603,31 +603,30 @@ func users() {
 				log.Println(gconv.String(v["id"]), "用户是否有小程序且未使用过剑鱼其他产品")
 				continue
 			}
-			//判断线索是否存在
-			uid := gconv.String(v["uid"])
-			if count := TiDb.CountBySql("dwd_f_crm_clue_info", map[string]interface{}{"uid": uid}, "", ""); count > 0 {
-				log.Println(gconv.String(v["id"]), "小程序用户线索已存在", uid, count)
-				continue
-			}
 			updatetime := common.ObjToString(v["updatetime"])
-			ok1, ok2 := FormatData(v, "users")
+			ok1, ok2 := FormatData(v, "xcxusers")
 			if !ok1 {
 				common.WriteSysConfig(&cfg)
-				log.Println("小程序用户分配线索卡点", "users", v, selectTimeEnd)
+				log.Println("小程序用户分配线索卡点", "xcxusers", v, selectXcxTimeEnd)
 				break
 			} else {
 				if !ok2 {
-					log.Println("小程序用户分配已达上限", "users", v, selectTimeEnd)
+					log.Println("小程序用户分配已达上限", "xcxusers", v, selectXcxTimeEnd)
 					common.WriteSysConfig(&cfg)
 					break
 				}
 			}
-			if k == len(*data)-1 {
+			TiDb.Update("dwd_f_userbase_baseinfo", map[string]interface{}{
+				"id": gconv.Int64(v["id"]),
+			}, map[string]interface{}{
+				"clue_operate_status": 1,
+			})
+			if k == len(*xcxData)-1 {
 				cfg.LastXcxUserId = updatetime
 			}
 		}
 	}
-
+	common.WriteSysConfig(&cfg)
 	log.Println("新注册用户定时任务结束")
 }
 
@@ -940,6 +939,21 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 			code = "618"
 			subname = "7天后到期"
 		}
+	} else if item == "xcxusers" {
+		level = "C"
+		if sourceCode != "" {
+			codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"source": 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}, "", "")
@@ -969,8 +983,6 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 				isOk = true
 				positionId = common.Int64All((*cdata)["position_id"])
 				noticePositionId = positionId
-				seatNumber = common.ObjToString((*cdata)["seatNumber"])
-				log.Println("positionId seatNumber ", positionId, seatNumber)
 				if positionId > 0 {
 					pdata := TiDb.SelectBySql(`select * from dwd_f_crm_personnel_management where seat_number is not null and seat_number != ""`)
 					if pdata != nil {
@@ -1013,6 +1025,9 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 					return
 				}
 			}
+			seatNumber = common.ObjToString((*cdata)["seatNumber"])
+			log.Println("positionId seatNumber ", positionId, seatNumber)
+
 		}
 	}
 	query := `select * from dwd_f_crm_personnel_management where assign_type = 1 and`