Преглед на файлове

wip:激活活动过滤器

wangshan преди 1 година
родител
ревизия
cc28d29a26
променени са 4 файла, в които са добавени 57 реда и са изтрити 33 реда
  1. 5 1
      src/active.json
  2. 26 22
      src/jfw/config/active.go
  3. 14 0
      src/jfw/filter/phonefilter.go
  4. 12 10
      src/jfw/modules/app/src/app/filter/phonefilter.go

+ 5 - 1
src/active.json

@@ -16,5 +16,9 @@
 		"wxEr":81,
 		"startTime":"2022-05-01 12:00:00",
 		"endTime":"2022-05-31 23:59:59"
-	}
+	},
+  "activateInfo": {
+    "name": "激活活动",
+    "endTime": 1725120000
+  }
 }

+ 26 - 22
src/jfw/config/active.go

@@ -1,37 +1,41 @@
 package config
 
 import (
-	util "app.yhyue.com/moapp/jybase/common"
+    util "app.yhyue.com/moapp/jybase/common"
 )
 
-//系统配置
+// 系统配置
 type activeConfig struct {
-	Live_Preheat_Start int64         `json:"live_Preheat_Start"` //预热活动开始时间
-	Live_Preheat_End   int64         `json:"live_Preheat_End"`   //预热活动结束时间
-	Live_Active_Start  int64         `json:"live_Active_Start"`  //直播活动开始时间
-	Live_Active_End    int64         `json:"live_Active_End"`    //直播活动结束时间
-	Live_Ing_Start     int64         `json:"live_Ing_Start"`     //直播开始时间
-	Live_Ing_End       int64         `json:"live_Ing_End"`       //直播结束时间
-	Live_After_Date    int64         `json:"live_After_Date"`    //直播活动结束后 活动已结束提示时间段(暂定一个月) 一个月后 跳转到VIP介绍页
-	ActiveDiscount     float64       `json:"activeDiscount"`     //直播活动折扣
-	DoubleEleven       *doubleEleven `json:"doubleEleven"`       //双十一
-	Lottery            string        `json:"lottery"`            //抽奖跳转连接
-	MayActive          struct {
-		WxEr      int64  `json:"wxEr"`
-		StartTime string `json:"startTime"`
-		EndTime   string `json:"endTime"`
-	} `json:"mayActive"` //五月运营统计二维码
-	//ShortUrl           map[string]string `json:"shortUrl"`           //短地址跳转
+    Live_Preheat_Start int64         `json:"live_Preheat_Start"` //预热活动开始时间
+    Live_Preheat_End   int64         `json:"live_Preheat_End"`   //预热活动结束时间
+    Live_Active_Start  int64         `json:"live_Active_Start"`  //直播活动开始时间
+    Live_Active_End    int64         `json:"live_Active_End"`    //直播活动结束时间
+    Live_Ing_Start     int64         `json:"live_Ing_Start"`     //直播开始时间
+    Live_Ing_End       int64         `json:"live_Ing_End"`       //直播结束时间
+    Live_After_Date    int64         `json:"live_After_Date"`    //直播活动结束后 活动已结束提示时间段(暂定一个月) 一个月后 跳转到VIP介绍页
+    ActiveDiscount     float64       `json:"activeDiscount"`     //直播活动折扣
+    DoubleEleven       *doubleEleven `json:"doubleEleven"`       //双十一
+    Lottery            string        `json:"lottery"`            //抽奖跳转连接
+    MayActive          struct {
+        WxEr      int64  `json:"wxEr"`
+        StartTime string `json:"startTime"`
+        EndTime   string `json:"endTime"`
+    } `json:"mayActive"` //五月运营统计二维码
+    //ShortUrl           map[string]string `json:"shortUrl"`           //短地址跳转
+    ActivateInfo struct {
+        Name    string `json:"name"`
+        EndTime int64  `json:"endTime"`
+    }
 }
 
-//双十一活动
+// 双十一活动
 type doubleEleven struct {
-	Active_Start int64
-	Active_End   int64
+    Active_Start int64
+    Active_End   int64
 }
 
 var ActiveConfig activeConfig
 
 func init() {
-	util.ReadConfig("./active.json", &ActiveConfig)
+    util.ReadConfig("./active.json", &ActiveConfig)
 }

+ 14 - 0
src/jfw/filter/phonefilter.go

@@ -1,6 +1,7 @@
 package filter
 
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/jyutil"
@@ -8,6 +9,7 @@ import (
 	"net/http"
 	"net/url"
 	"regexp"
+	"strconv"
 	"strings"
 	"time"
 
@@ -85,6 +87,18 @@ func (l *phoneFilter) Do() bool {
 				l.Session.SetMultiple(sessionVal)
 				return false
 			}
+			//小程序 激活活动
+			if urls.MatchString(l.R.URL.Path) {
+				if config.ActiveConfig.ActivateInfo.EndTime > time.Now().Unix() {
+					if paths := strings.Split(l.R.URL.RequestURI(), "miniprogram="); len(paths) > 0 {
+						if viewTime := encrypt.SE.Decode4Hex(paths[1]); viewTime != "" {
+							if vt, err := strconv.ParseInt(viewTime, 10, 64); err != nil && time.Now().Unix()-vt < 86400 { //一天的时间
+								return false
+							}
+						}
+					}
+				}
+			}
 			regtime := qu.Int64All((*person)["l_registedate"])
 			reg := time.Unix(regtime, 0)
 			//新用户时间

+ 12 - 10
src/jfw/modules/app/src/app/filter/phonefilter.go

@@ -79,6 +79,18 @@ func (l *phoneFilter) Do() bool {
 				l.Session.Set("phone", s_phone)
 				return false
 			}
+			//小程序 激活活动
+			if articleUrl.MatchString(l.R.URL.Path) {
+				if Active.ActivateInfo.EndTime > time.Now().Unix() {
+					if paths := strings.Split(l.R.URL.RequestURI(), "miniprogram="); len(paths) > 0 {
+						if viewTime := encrypt.SE.Decode4Hex(paths[1]); viewTime != "" {
+							if vt, err := strconv.ParseInt(viewTime, 10, 64); err != nil && time.Now().Unix()-vt < 86400 { //一天的时间
+								return false
+							}
+						}
+					}
+				}
+			}
 			regtime := qu.Int64All((*person)["l_registedate"])
 			reg := time.Unix(regtime, 0)
 			//新用户时间
@@ -91,16 +103,6 @@ func (l *phoneFilter) Do() bool {
 					return true
 				}
 				if articleUrl.MatchString(l.R.URL.Path) {
-					//小程序 激活活动
-					if Active.ActivateInfo.EndTime > time.Now().Unix() {
-						if paths := strings.Split(l.R.URL.RequestURI(), "miniprogram="); len(paths) > 0 {
-							if viewTime := encrypt.SE.Decode4Hex(paths[1]); viewTime != "" {
-								if vt, err := strconv.ParseInt(viewTime, 10, 64); err != nil && time.Now().Unix()-vt < 30 {
-									return false
-								}
-							}
-						}
-					}
 					bindPopNum := redis.Incr(dbname, key)
 					if bindPopNum == qu.Int64All(config.Sysconfig["firstBindPop"]) ||
 						bindPopNum > qu.Int64All(config.Sysconfig["maxBindPop"]) {