wangshan пре 1 недеља
родитељ
комит
17a3b4a45d
1 измењених фајлова са 11 додато и 12 уклоњено
  1. 11 12
      filter/xweb/visitFilter.go

+ 11 - 12
filter/xweb/visitFilter.go

@@ -112,15 +112,17 @@ func SetSevenSourceByRedis(sess *httpsession.Session, source string) bool {
 // 继承过滤器方法 优先级 短地址 < seo < sem < 渠道合作商
 func (l *VisitFilter) Do() bool {
 	var (
-		rawQuery      = l.R.URL.RawQuery
-		refer         = l.R.Referer()
-		source        string
-		sevenSource   = GetSevenSourceByRedis(l.Session)
-		userId        = common.InterfaceToStr(l.SessVal["userId"])
-		loginCacheKey = fmt.Sprintf("login_log_%s_%s", userId, date.NowFormat(date.Date_yyyyMMdd))
+		rawQuery    = l.R.URL.RawQuery
+		refer       = l.R.Referer()
+		source      string
+		sevenSource = GetSevenSourceByRedis(l.Session)
+		userId      = common.InterfaceToStr(l.SessVal["userId"])
 	)
-	if b, _ := redis.Exists(RedisCode, loginCacheKey); b {
-		return true
+	if userId != "" {
+		loginCacheKey := fmt.Sprintf("login_log_%s_%s", userId, date.NowFormat(date.Date_yyyyMMdd))
+		if b, _ := redis.Exists(RedisCode, loginCacheKey); b {
+			return true
+		}
 	}
 	//1、未登录 且 sevenSource 为空
 	//2、已登录 且 未存登录日志
@@ -176,9 +178,6 @@ func (l *VisitFilter) Do() bool {
 				matches := re.FindStringSubmatch(refer)
 				if len(matches) >= 2 {
 					source = matches[1]
-					if l.SessVal["RSource"] == nil {
-						l.Session.Set("RSource", source)
-					}
 					break
 				}
 			}
@@ -192,7 +191,7 @@ func (l *VisitFilter) Do() bool {
 		}
 		if source != "" {
 			if l.SessVal["RSource"] == nil {
-				l.Session.Set("RSource", refer)
+				l.Session.Set("RSource", source)
 			}
 		}
 		fmt.Printf("seo: %s, 参数: %s\n", rawQuery, source)