ソースを参照

Merge branch 'feature/v4.9.12_ws' of qmx/jy into feature/v4.9.12

wangshan 1 年間 前
コミット
c73fe8c1ee

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

@@ -36,6 +36,7 @@ var urls = []*regexp.Regexp{
 	regexp.MustCompile("^/jySite/.*"),
 	regexp.MustCompile("^/jyapp/initialize/whiteList"),
 	regexp.MustCompile("^/jyapp/transit/.*"),
+	regexp.MustCompile("^/jyapp/new/.*"),
 }
 
 type loginFilter struct {

+ 32 - 7
src/jfw/modules/app/src/app/front/login.go

@@ -230,10 +230,15 @@ func (l *Login) Login() error {
 						"s_platform": "app",
 						"s_sourceid": channelCode,
 					}
-					// 新用户注册 记录活动来源
-					activity := l.GetString("activity")
-					if activity != "" {
-						data["s_rsource"] = activity
+					// 新用户注册 记录来源
+					sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+					if sourceLabel != "" {
+						data["s_rsource"] = sourceLabel
+					} else {
+						activity := l.GetString("activity")
+						if activity != "" {
+							data["s_rsource"] = activity
+						}
 					}
 					//注册邮箱
 					email := l.GetString("email")
@@ -241,7 +246,6 @@ func (l *Login) Login() error {
 						data["s_email"] = email
 					}
 					data["s_regsource"] = isAndroidOrIOS(l.Header("User-Agent"))
-
 					if resp := config.Middleground.UserCenter.UserAdd(pb.UserAddReq{
 						Appid: "10000",
 						Phone: phone,
@@ -253,8 +257,12 @@ func (l *Login) Login() error {
 					}
 					_id := mongodb.Save("user", data)
 					if _id != "" {
+						if sourceLabel != "" {
+							go func() {
+								redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+							}()
+						}
 						userInfo["isNewUser"] = true
-
 						jy.ClearPhoneIdentSession(l.Session())
 						returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
 						if disWord != "" {
@@ -573,10 +581,13 @@ func (l *Login) Register() error {
 					"s_company":     s_entname,
 					"s_sourceid":    channelCode,
 				}
+				sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+				if sourceLabel != "" {
+					data["s_rsource"] = sourceLabel
+				}
 				email := l.GetString("email")
 				registerclient := jy.NewRegister(jyutil.Compatible.Mgo, jyutil.Compatible.BaseService, jyutil.Compatible.MainMysql, jyutil.Compatible.Middleground)
 				_, errStr = registerclient.PublicRegister(phone, email, isAndroidOrIOS(l.Header("User-Agent")), data, func(saveid string) {
-
 					go func() {
 						if disWord != "" {
 							redisDis := redis.GetStr("other", "DIS_"+disWord[1:])
@@ -611,6 +622,11 @@ func (l *Login) Register() error {
 					})
 				})
 				if errStr == "y" {
+					if sourceLabel != "" {
+						go func() {
+							redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+						}()
+					}
 					returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
 					//剑鱼币
 					jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
@@ -772,6 +788,10 @@ func (l *Login) WxLogin() {
 				"s_jyname":   jy.GetUserName("newother", config.Sysconfig["namePrefix"].(string)), //剑鱼昵称
 				"s_sourceid": channelCode,
 			}
+			sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+			if sourceLabel != "" {
+				newUser["s_rsource"] = sourceLabel
+			}
 			//注册邮箱
 			email := l.GetString("email")
 			if jy.IsEmail(email) {
@@ -793,6 +813,11 @@ func (l *Login) WxLogin() {
 			}
 
 			if _id := mongodb.Save("user", newUser); _id != "" {
+				if sourceLabel != "" {
+					go func() {
+						redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
+					}()
+				}
 				returnSign = afterLogin(newUser, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
 				if disWord != "" {
 					redisDis := redis.GetStr("other", "DIS_"+disWord[1:])

+ 28 - 0
src/jfw/modules/app/src/app/front/wx.go

@@ -0,0 +1,28 @@
+package front
+
+import (
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/redis"
+	"fmt"
+)
+
+// 基于统计流量数据以及用户信息收录,新公众号:剑鱼标讯网,新建首页地址
+var (
+	cacheTimeOut = 3 * 24 * 60 * 60 //三天
+)
+
+type WX struct {
+	*xweb.Action
+	index xweb.Mapper `xweb:"/jyapp/new/(.*)"`
+}
+
+func init() {
+	xweb.AddAction(&WX{})
+}
+
+// 微信首页地址
+func (w *WX) Index(pageLabel string) error {
+	//w.Session().Set("firstVisitTagByWX", pageLabel)
+	redis.Put("limitation", fmt.Sprintf("firstVisitTagByWX_%s", w.Session().Id()), pageLabel, cacheTimeOut) //app 登录注册 用户标识
+	return w.Redirect("/jy_mobile/tabbar/home")
+}

+ 9 - 0
src/jfw/modules/publicapply/src/oneclick/entity/entity.go

@@ -359,6 +359,10 @@ func (o *OneClickInfo) phoneLogin(phone string) (map[string]interface{}, error)
 				"s_platform": platform,
 				"s_sourceid": channelCode,
 			}
+			sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", o.Session.Id()))
+			if sourceLabel != "" {
+				data["s_rsource"] = sourceLabel
+			}
 			// 新注册用户
 			if o.Activity != "" {
 				data["s_rsource"] = o.Activity
@@ -366,6 +370,11 @@ func (o *OneClickInfo) phoneLogin(phone string) (map[string]interface{}, error)
 			data["s_regsource"] = isAndroidOrIOS(client)
 			_id := db.Mgo.Save("user", data)
 			if _id != "" {
+				if sourceLabel != "" {
+					go func() {
+						redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", o.Session.Id()))
+					}()
+				}
 				userInfo["isNewUser"] = true
 				//用户中台同步
 				func(userid string) {