Browse Source

小程序用户处理

WH01243 1 year ago
parent
commit
9f731b9423
3 changed files with 40 additions and 1 deletions
  1. 1 0
      clueSync/config.go
  2. 2 1
      clueSync/config.json
  3. 37 0
      clueSync/jobutil.go

+ 1 - 0
clueSync/config.go

@@ -11,6 +11,7 @@ type (
 		LastOrderId        int     `json:"lastOrderId"`
 		LastOrderClueId    string  `json:"lastOrderClueId"`
 		LastUserId         string  `json:"lastUserId"`
+		LastXcxUserId      string  `json:"lastXcxUserId"`
 		LastId             string  `json:"lastId"`
 		LastOrderTime      string  `json:"lastOrderTime"`
 		LastUserTime       string  `json:"lastUserTime"`

+ 2 - 1
clueSync/config.json

@@ -15,5 +15,6 @@
   "bigOrderTime": "2024-06-12 17:01:39",
   "marketSaleTime": 1708160200,
   "allocationTime": "2024-07-01 14:59:37",
-  "allocationRatio": 2
+  "allocationRatio": 2,
+  "lastXcxUserId": "2024-07-09 14:59:37"
 }

+ 37 - 0
clueSync/jobutil.go

@@ -591,6 +591,43 @@ 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)
+	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"])
+			if s_platform == "xcx" && login_positionid == 0 {
+				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")
+			if !ok1 {
+				common.WriteSysConfig(&cfg)
+				log.Println("线索卡点", "users", v, selectTimeEnd)
+				break
+			} else {
+				if !ok2 {
+					log.Println("用户分配已达上限", "users", v, selectTimeEnd)
+					common.WriteSysConfig(&cfg)
+					break
+				}
+			}
+			if k == len(*data)-1 {
+				cfg.LastXcxUserId = updatetime
+			}
+		}
+	}
+
 	log.Println("新注册用户定时任务结束")
 }