Quellcode durchsuchen

feat:p583 app 判断是否关注接口调整

fuwencai vor 1 Jahr
Ursprung
Commit
85573c6682

+ 5 - 3
src/jfw/modules/app/p583.http

@@ -1,4 +1,4 @@
-GET http://127.0.0.1:89/jyapp/m/RV4=
+GET http://127.0.0.1:89/jyapp/m/RVw=
 Content-Type: application/json
 
 {}
@@ -6,8 +6,10 @@ Content-Type: application/json
 ###
 POST http://127.0.0.1:89/jyapp/checkSubscribe
 Content-Type: application/json
-Cookie: SESSIONID=1e0073c005557c42e6198e53ef6ca273449a84e0
 
-{}
+{
+  "id":"RQ=="
+
+}
 
 ###

+ 2 - 2
src/jfw/modules/app/src/active.json

@@ -12,10 +12,10 @@
   },
   "activateInfo": {
     "name": "激活活动",
-    "endTime": 1725120000,
+    "endTime": 1625120000,
     "appID": "wx37f06c38292f7d82",
     "envVersion": "trial",
-    "endUrl": "",
+    "endUrl": "https://mp.weixin.qq.com/s?__biz=Mzk0MjIyMzY2Nw==&mid=2247497288&idx=1&sn=06e3b7145af4d46d5410a340413870c6&chksm=c2c4ce14f5b34702761205555b871b96223a9f6ff4133a3654b3aa804b9024312cc43ff44fd5#rd",
     "url": "/frontRouter/activity/free/open-mini-program.html",
     "to": [
       {

+ 1 - 0
src/jfw/modules/app/src/app/filter/loginfilter.go

@@ -38,6 +38,7 @@ var urls = []*regexp.Regexp{
 	regexp.MustCompile("^/jyapp/transit/.*"),
 	regexp.MustCompile("^/jyapp/new/.*"),
 	regexp.MustCompile("^/jyapp/m/.*"),
+	regexp.MustCompile("^/jyapp/checkSubscribe$"),
 }
 
 type loginFilter struct {

+ 90 - 68
src/jfw/modules/app/src/app/front/activity.go

@@ -1,88 +1,110 @@
 package front
 
 import (
-	"app.yhyue.com/moapp/jybase/api"
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"errors"
-	"fmt"
-	"jy/src/jfw/modules/app/src/app/config"
-	"jy/src/jfw/modules/app/src/app/jyutil"
-	"net/url"
-	"time"
+    "app.yhyue.com/moapp/jybase/api"
+    "app.yhyue.com/moapp/jybase/common"
+    "app.yhyue.com/moapp/jybase/encrypt"
+    "app.yhyue.com/moapp/jybase/go-xweb/xweb"
+    "encoding/json"
+    "errors"
+    "fmt"
+    "jy/src/jfw/modules/app/src/app/config"
+    "jy/src/jfw/modules/app/src/app/jyutil"
+    "net/url"
+    "time"
 )
 
 type Activity struct {
-	*xweb.Action
-	mini           xweb.Mapper `xweb:"/jyapp/m/(.*)"`         // /min/0013 p583短地址
-	checkSubscribe xweb.Mapper `xweb:"/jyapp/checkSubscribe"` // 是否关注 p583短地址
+    *xweb.Action
+    mini           xweb.Mapper `xweb:"/jyapp/m/(.*)"`         // /min/0013 p583短地址
+    checkSubscribe xweb.Mapper `xweb:"/jyapp/checkSubscribe"` // 是否关注 p583短地址
 }
 
 func init() {
-	xweb.AddAction(&Activity{})
+    xweb.AddAction(&Activity{})
 }
 
 // Mini  p583 用户短信激活短地址
 func (s *Activity) Mini(args string) {
-	if time.Now().Unix() > config.Active.ActivateInfo.EndTime {
-		s.Redirect(config.Active.ActivateInfo.EndUrl)
-		return
-	}
+    if time.Now().Unix() > config.Active.ActivateInfo.EndTime {
+        s.Redirect(config.Active.ActivateInfo.EndUrl)
+        return
+    }
 
-	sidStr := encrypt.SE.DecodeString(args)
-	if sidStr == "" {
-		s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
-		return
-	}
-	if len(sidStr) < 2 {
-		s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
-	}
-	step := common.IntAll(sidStr[len(sidStr)-1:])
-	id := common.IntAll(sidStr[:len(sidStr)-1])
-	encryId := url.QueryEscape(encrypt.SE.EncodeString(sidStr[:len(sidStr)-1]))
-	if step > len(config.Active.ActivateInfo.To) || id == 0 || common.IntAll(id) == 0 {
-		s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
-		return
-	}
-	stepIndex := step - 1 //
-	isFirst, b := jyutil.UpdateActivateCount(common.IntAll(id), step)
-	if !b {
-		s.ServeJson(api.NewResult(nil, errors.New("稍后再试")))
-	}
-	// 获取用户id
-	userId, positionID := jyutil.GetActivateUser(id)
-	// 判断用户关注未关注
-	s.T["appid"] = config.Active.ActivateInfo.AppID
-	s.T["env_version"] = config.Active.ActivateInfo.EnvVersion
-	if config.Active.ActivateInfo.To[stepIndex].Path.Default == "" {
-		if jyutil.IsSubscribe(userId) {
-			s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Sub
-			s.T["query"] = fmt.Sprintf(config.Active.ActivateInfo.To[stepIndex].Query.Sub, encryId)
-		} else {
-			s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Unsub
-			s.T["query"] = fmt.Sprintf(config.Active.ActivateInfo.To[stepIndex].Query.Unsub, encryId)
-		}
-	} else {
-		if isFirst {
-			// 没有点过则送7天会员
-			jyutil.GiveVip(userId, positionID, s.Request.UserAgent())
-		}
-		s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Default
-		s.T["query"] = config.Active.ActivateInfo.To[stepIndex].Query.Default
-	}
-	s.Render(config.Active.ActivateInfo.Url, &s.T)
-	return
+    sidStr := encrypt.SE.DecodeString(args)
+    if sidStr == "" {
+        s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
+        return
+    }
+    if len(sidStr) < 2 {
+        s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
+    }
+    step := common.IntAll(sidStr[len(sidStr)-1:])
+    id := common.IntAll(sidStr[:len(sidStr)-1])
+    encryId := url.QueryEscape(encrypt.SE.EncodeString(sidStr[:len(sidStr)-1]))
+    if step > len(config.Active.ActivateInfo.To) || id == 0 || common.IntAll(id) == 0 {
+        s.ServeJson(api.NewResult(nil, errors.New("参数异常")))
+        return
+    }
+    stepIndex := step - 1 //
+    isFirst, b := jyutil.UpdateActivateCount(common.IntAll(id), step)
+    if !b {
+        s.ServeJson(api.NewResult(nil, errors.New("稍后再试")))
+    }
+    // 获取用户id
+    userId, positionID := jyutil.GetActivateUser(id)
+    // 判断用户关注未关注
+    s.T["appid"] = config.Active.ActivateInfo.AppID
+    s.T["env_version"] = config.Active.ActivateInfo.EnvVersion
+    if config.Active.ActivateInfo.To[stepIndex].Path.Default == "" {
+        if jyutil.IsSubscribe(userId) {
+            s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Sub
+            s.T["query"] = fmt.Sprintf(config.Active.ActivateInfo.To[stepIndex].Query.Sub, encryId)
+        } else {
+            s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Unsub
+            s.T["query"] = fmt.Sprintf(config.Active.ActivateInfo.To[stepIndex].Query.Unsub, encryId)
+        }
+    } else {
+        if isFirst {
+            // 没有点过则送7天会员
+            jyutil.GiveVip(userId, positionID, s.Request.UserAgent())
+        }
+        s.T["path"] = config.Active.ActivateInfo.To[stepIndex].Path.Default
+        s.T["query"] = config.Active.ActivateInfo.To[stepIndex].Query.Default
+    }
+    s.Render(config.Active.ActivateInfo.Url, &s.T)
+    return
 
 }
 
 // CheckSubscribe 是否关注
 func (s *Activity) CheckSubscribe() {
-	userInfo := common.ObjToMap(s.Session().Get("user"))
-	if userInfo == nil || common.InterfaceToStr((*userInfo)["_id"]) == "" {
-		s.ServeJson(api.NewResult(nil, errors.New("需要登录")))
-		return
-	}
-	status := jyutil.IsSubscribe(common.InterfaceToStr((*userInfo)["_id"]))
-	s.ServeJson(api.NewResult(status, nil))
+    defer common.Catch()
+    r := func() api.Result {
+        if s.Method() != "POST" {
+            return api.Result{Data: nil, Error_msg: api.Error_msg_1005}
+        }
+        //接收参数
+        // 查询
+        if string(s.Body()) == "" {
+            return api.Result{Data: nil, Error_msg: api.Error_msg_1003}
+        }
+        param := struct {
+            Id string
+        }{}
+        //接收参数
+        err := json.Unmarshal(s.Body(), &param)
+        if err != nil || param.Id == "" {
+            return api.Result{Data: nil, Error_msg: api.Error_msg_1003}
+        }
+        auId := param.Id
+        id := common.IntAll(encrypt.SE.DecodeString(auId))
+        if id == 0 {
+            return api.Result{Data: nil, Error_msg: api.Error_msg_1003}
+        }
+        userId, _ := jyutil.GetActivateUser(id)
+        status := jyutil.IsSubscribe(common.InterfaceToStr(userId))
+        return api.Result{Data: status}
+    }()
+    s.ServeJson(r)
 }