@@ -856,6 +856,7 @@ func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ stri
"s_nickname": s_nickname,
"s_headimage": sessionVal["s_avatar"],
"phone": sessionVal["phone"],
+ "registedate": sessionVal["registedate"],
}
if openid, _ := (*person)["s_m_openid"].(string); openid != "" {
infoData["openid"] = se.EncodeString(openid)
@@ -211,6 +211,7 @@ func (l *Login) Login() error {
_id := mongodb.Save("user", data)
if _id != "" {
+ redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", l.Session().Id()))
//用户日志保存
jy.SaveUserLog(public.Mgo_Log, _id, phone, "phone", "pc", source, "", gconv.String(l.GetSession("RSource")), gconv.String(sessVal["RSource"]), qutil.GetIp(l.Request), l.UserAgent(), "jybx", "")
jy.ClearPhoneIdentSession(l.Session())
@@ -150,6 +150,21 @@ func GetWsByCode(param []string) bool {
//jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId) 不可用
//您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.
+ // 新用户注册 记录来源
+ sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", session.Id()))
+ //来源不为空,且 注册时间 在5分钟内
+ registeDate := qutil.Int64All(infoData["registedate"])
+ if sourceLabel != "" && openid != "" {
+ if time.Now().Unix()-registeDate < 300 {
+ if ok := public.MQFW.Update("user", map[string]interface{}{
+ "s_m_openid": openid,
+ }, &map[string]interface{}{"$set": &map[string]interface{}{"s_rsource": sourceLabel}}, false, false); !ok {
+ log.Println("用户更新来源异常:", openid, "-来源:", sourceLabel)
+ } else {
+ redis.Del("limitation", fmt.Sprintf("firstVisitTagByWX_%s", session.Id()))
+ }
if wss.Conn == nil {
return true