Browse Source

wip:手机号绑定

wangshan 1 năm trước cách đây
mục cha
commit
88a68bbb39
2 tập tin đã thay đổi với 49 bổ sung26 xóa
  1. 47 25
      src/jfw/front/singleLogin.go
  2. 2 1
      src/jfw/jyutil/jyutil.go

+ 47 - 25
src/jfw/front/singleLogin.go

@@ -2,6 +2,7 @@ package front
 
 import (
 	qutil "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	mgdb "app.yhyue.com/moapp/jybase/mongodb"
@@ -81,33 +82,54 @@ func (this *SingleLogin) KeyPhrases(key string) error {
 					mgoUserId = qutil.InterfaceToStr(sess["mgoUserId"])
 				}
 			}
-			if positionType == 0 {
-				var (
-					cacheKey  = ""
-					cacheBool bool
-					userInfo  = jy.GetBigVipUserBaseMsg(this.Session(), *config.Middleground)
-				)
-				//非超级订阅 非大会员用户
-				switch {
-				case strings.Contains(key, "v_"):
-					if userInfo.VipStatus > 0 {
-						redirectUrl = fmt.Sprintf(setPage, "v")
-					} else {
-						redirectUrl = fmt.Sprintf(vPay, time.Now().Unix())
-						cacheBool = true
-					}
-				case strings.Contains(key, "m_"):
-					if userInfo.Status > 0 {
-						redirectUrl = fmt.Sprintf(setPage, "m")
-					} else {
-						redirectUrl = mPay
-						cacheBool = true
+			if userId != "" && positionType == 0 {
+				//绑定手机号判断
+				var isBind bool
+				if phone := qutil.InterfaceToStr(this.GetSession("phone")); phone == "" {
+					//注册时间
+					regTime := qutil.Int64All(this.GetSession("registedate"))
+					//新用户时间
+					accountMergeOnline, _ := config.Sysconfig["accountMergeOnline"].(string)
+					if accountMergeOnline != "" && regTime > 0 {
+						reg := time.Unix(regTime, 0)
+						onLineTime, _ := time.ParseInLocation(Date_Full_Layout, accountMergeOnline, time.Local)
+						//如果未绑定手机号,老用户不用强制绑定;新用户需要绑定手机号
+						if !onLineTime.After(reg) {
+							isBind = true
+						}
 					}
 				}
-				if cacheBool {
-					cacheKey = fmt.Sprintf("key_phrases_%s_%s", strings.Split(key, "_")[0], userId)
-					if b := redis.Put(redisLimitation, cacheKey, key, 4*60*60); !b {
-						log.Println("关键词组 访问记录 缓存存储 异常", cacheKey)
+				//绑定手机号
+				if isBind {
+					redirectUrl = "/front/account/phone/bind?mode=mergeBind&redirectTo=" + encodeURIComponent(this.Request.URL.String())
+				} else {
+					var (
+						cacheKey  = ""
+						cacheBool bool
+						userInfo  = jy.GetBigVipUserBaseMsg(this.Session(), *config.Middleground)
+					)
+					//非超级订阅 非大会员用户
+					switch {
+					case strings.Contains(key, "v_"):
+						if userInfo.VipStatus > 0 {
+							redirectUrl = fmt.Sprintf(setPage, "v")
+						} else {
+							redirectUrl = fmt.Sprintf(vPay, time.Now().Unix())
+							cacheBool = true
+						}
+					case strings.Contains(key, "m_"):
+						if userInfo.Status > 0 {
+							redirectUrl = fmt.Sprintf(setPage, "m")
+						} else {
+							redirectUrl = mPay
+							cacheBool = true
+						}
+					}
+					if cacheBool {
+						cacheKey = fmt.Sprintf("key_phrases_%s_%s", strings.Split(key, "_")[0], userId)
+						if b := redis.Put(redisLimitation, cacheKey, key, 4*60*60); !b {
+							log.Println("关键词组 访问记录 缓存存储 异常", cacheKey)
+						}
 					}
 				}
 			}

+ 2 - 1
src/jfw/jyutil/jyutil.go

@@ -167,7 +167,8 @@ func GetSessionVal(q map[string]interface{}) (*map[string]interface{}, map[strin
 	}
 	sessionVal["phone"] = phone
 	sessionVal["i_unlimited"] = util.IntAll((*person)["i_unlimited"])
-	sessionVal["base_user_id"] = util.IntAll((*person)["base_user_id"]) //用户中台的uid
+	sessionVal["base_user_id"] = util.IntAll((*person)["base_user_id"])   //用户中台的uid
+	sessionVal["registedate"] = util.Int64All((*person)["l_registedate"]) //注册时间
 	return person, sessionVal
 }