Browse Source

定时任务修改

WH01243 10 months ago
parent
commit
d58c623e1f
2 changed files with 72 additions and 36 deletions
  1. 1 1
      clueSync/job.go
  2. 71 35
      clueSync/jobutil.go

+ 1 - 1
clueSync/job.go

@@ -82,7 +82,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 				belong_to = common.ObjToString((*userInfo)["belong_to"])
 			}
 			if item == "xcxusers" {
-				sourceCode = common.ObjToString(data["s_sourceid"])
+				sourceCode = common.ObjToString(data["industry"])
 				if sourceCode == "" {
 					log.Println("留资没有source", phone)
 					return true, true

+ 71 - 35
clueSync/jobutil.go

@@ -561,7 +561,7 @@ func users() {
 	//新用户注册后5分钟内进入线索 C
 	log.Println("新注册用户定时任务开始")
 	selectTimeEnd := cfg.LastUserId
-	sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where createtime > "%s" and source = "0101" and status != 2  order by  createtime asc`, selectTimeEnd)
+	sql := fmt.Sprintf(`select * from woxianzai1 where createtime > "%s" and source = "0101" and status != 2  order by  createtime asc`, selectTimeEnd)
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for k, v := range *data {
@@ -589,34 +589,56 @@ 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 and  clue_operate_status!=1 order by  createtime asc`, selectXcxTimeEnd)
+	xcxSql := fmt.Sprintf(`SELECT DISTINCT
+	aa.mgo_id as  userId,
+	cc.NAME as   industry ,
+	aa.phone,
+	IF
+			( aa.phone_time IS NULL, aa.create_time, aa.phone_time ) as  time 
+FROM
+	debris_product.miniprogram_user aa
+	INNER JOIN debris_product.miniprogram bb ON (
+		aa.phone <> '' 
+	AND
+	IF
+		( aa.phone_time IS NULL, aa.create_time, aa.phone_time )>= '2024-09-01 08:18:19' 
+		AND aa.miniprogram_code = bb.CODE 
+	)
+	INNER JOIN debris_product.industry cc ON ( bb.industry_code = cc.CODE ) 
+WHERE
+	NOT EXISTS (
+	SELECT
+		1 
+	FROM
+		debris_product.miniprogram_user a
+		INNER JOIN debris_product.miniprogram b ON (
+			aa.unionid = a.unionid 
+			AND aa.miniprogram_code = a.miniprogram_code 
+			AND aa.id != a.id 
+		AND
+		IF
+			( a.phone_time IS NULL, a.create_time, a.phone_time )< '%s' 
+			AND a.miniprogram_code = b.CODE 
+		)
+	INNER JOIN debris_product.miniprogram_user c ON ( a.unionid = c.unionid AND b.CODE = c.miniprogram_code ))
+	ORDER BY time
+	`, selectXcxTimeEnd)
 	xcxData := TiDb.SelectBySql(xcxSql)
 	if xcxData != nil && *xcxData != nil && len(*xcxData) > 0 {
 		for k, v := range *xcxData {
 			//判断用户是否有小程序切使用过剑鱼其他产品
-			s_platform := gconv.String(v["s_platform"])
-			login_positionid := gconv.Int64(v["login_positionid"])
-			updatetime := common.ObjToString(v["updatetime"])
-			if s_platform == "xcx" && login_positionid == 0 {
-				log.Println(gconv.String(v["id"]), "用户是否有小程序且未使用过剑鱼其他产品")
+			updatetime := common.ObjToString(v["time"])
+			ok1, ok2 := FormatData(v, "xcxusers")
+			if !ok1 {
+				common.WriteSysConfig(&cfg)
+				log.Println("小程序用户分配线索卡点", "xcxusers", v, selectXcxTimeEnd)
+				break
 			} else {
-				ok1, ok2 := FormatData(v, "xcxusers")
-				if !ok1 {
+				if !ok2 {
+					log.Println("小程序用户分配已达上限", "xcxusers", v, selectXcxTimeEnd)
 					common.WriteSysConfig(&cfg)
-					log.Println("小程序用户分配线索卡点", "xcxusers", v, selectXcxTimeEnd)
 					break
-				} else {
-					if !ok2 {
-						log.Println("小程序用户分配已达上限", "xcxusers", v, selectXcxTimeEnd)
-						common.WriteSysConfig(&cfg)
-						break
-					}
 				}
-				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 {
@@ -952,19 +974,31 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 			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"])
-				}
-			}
+		level = "S"
+		pcode = "532"
+		code = "477"
+		topname = "其他"
+		switch sourceCode {
+		case "环境采购":
+			pcode = "532"
+			code = "696"
+			subname = `首次使用“环境”小程序`
+		case "物业":
+			pcode = "532"
+			code = "693"
+			subname = `首次使用“物业”小程序`
+		case "印务商机":
+			pcode = "532"
+			code = "697"
+			subname = `首次使用“印务”小程序`
+		case "家具":
+			pcode = "532"
+			code = "695"
+			subname = `首次使用“家具”小程序`
+		case "车辆租赁":
+			pcode = "532"
+			code = "694"
+			subname = `首次使用“车辆”小程序`
 		}
 	} else if item == "allocation" {
 		pcode = "532"
@@ -1193,8 +1227,10 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 		query += ` assign_level like "%B%"`
 	} else if mode == "D" {
 		query += ` assign_level like "%D%"`
-	} else {
+	} else if mode == "C" {
 		query += ` assign_level like "%C%"`
+	} else if mode == "S" {
+		query += ` assign_level like "%S%"`
 	}
 	data := TiDb.SelectBySql(query)
 	if data != nil && len(*data) > 0 {