|
@@ -1,110 +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"
|
|
|
- "encoding/json"
|
|
|
- "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() {
|
|
|
- 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(), ¶m)
|
|
|
- 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)
|
|
|
+ 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(), ¶m)
|
|
|
+ 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)
|
|
|
}
|