浏览代码

Merge branch 'master' into hotfix/v4.9.43.7

yuelujie 9 月之前
父节点
当前提交
0243333813

+ 1 - 0
src/jfw/front/front.go

@@ -856,6 +856,7 @@ func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ stri
 		"s_nickname":  s_nickname,
 		"s_nickname":  s_nickname,
 		"s_headimage": sessionVal["s_avatar"],
 		"s_headimage": sessionVal["s_avatar"],
 		"phone":       sessionVal["phone"],
 		"phone":       sessionVal["phone"],
+		"registedate": sessionVal["registedate"],
 	}
 	}
 	if openid, _ := (*person)["s_m_openid"].(string); openid != "" {
 	if openid, _ := (*person)["s_m_openid"].(string); openid != "" {
 		infoData["openid"] = se.EncodeString(openid)
 		infoData["openid"] = se.EncodeString(openid)

+ 1 - 0
src/jfw/front/login.go

@@ -211,6 +211,7 @@ func (l *Login) Login() error {
 					}
 					}
 					_id := mongodb.Save("user", data)
 					_id := mongodb.Save("user", data)
 					if _id != "" {
 					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.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())
 						jy.ClearPhoneIdentSession(l.Session())

+ 15 - 0
src/jfw/front/websocket.go

@@ -150,6 +150,21 @@ func GetWsByCode(param []string) bool {
 				//jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId)  不可用
 				//jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId)  不可用
 				//您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.
 				//您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.
 			}
 			}
+			// 新用户注册 记录来源
+			sourceLabel := redis.GetStr("limitation", fmt.Sprintf("firstVisitTagByWX_%s", session.Id()))
+			if sourceLabel != "" && openid != "" {
+				//来源不为空,且 注册时间 在5分钟内
+				registeDate := qutil.Int64All(infoData["registedate"])
+				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 {
 		if wss.Conn == nil {
 			return true
 			return true

+ 1 - 1
src/jfw/modules/publicapply/src/detail/dao/baseInfo.go

@@ -110,7 +110,7 @@ func (b *BaseInfo) BidBaseInfo() (bi *entity.BidInfo, err error) {
 		} else if isVip && !isOldVip {
 		} else if isVip && !isOldVip {
 			bi.CanRead = true
 			bi.CanRead = true
 			return "new_vip_pay" //新版超级订阅不能看 采购意向 和 拟建
 			return "new_vip_pay" //新版超级订阅不能看 采购意向 和 拟建
-		} else if SeeDetailLimit(nil, b.UserInfo.UserId, b.Id) {
+		} else if SeeDetailLimit(nil, b.UserInfo, b.Id) {
 			bi.CanRead = true
 			bi.CanRead = true
 			return "saleLeads_free" //未留资 三篇非采购意向信息;留资后同pay
 			return "saleLeads_free" //未留资 三篇非采购意向信息;留资后同pay
 		} else {
 		} else {

+ 40 - 1
src/jfw/modules/publicapply/src/detail/dao/bidding.go

@@ -22,6 +22,7 @@ import (
 	"regexp"
 	"regexp"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
+	"sync"
 	"time"
 	"time"
 )
 )
 
 
@@ -157,14 +158,50 @@ func CNode(userId string) bool {
 	return false
 	return false
 }
 }
 
 
+var (
+	limitLogsLock  = sync.Mutex{}
+	limitLogsChan  = make(chan struct{}, 4)
+	limitLogsCount = 30
+	limitLogsData  []map[string]interface{}
+)
+
+// 免费未留资用户查看公告超过免费次数限制记录
+func SeeDetailLimitLogs(sessUser util.SessUserInfo, sid string) {
+	limitLogsChan <- struct{}{}
+	defer func() {
+		<-limitLogsChan
+	}()
+	//保存日志
+	limitLogsLock.Lock()
+	limitLogsData = append(limitLogsData, map[string]interface{}{
+		"mgoUserId":    sessUser.MgoUserId,
+		"phone":        sessUser.Phone,
+		"positionId":   sessUser.PositionId,
+		"positionType": sessUser.PositionType,
+		"openId":       sessUser.OpenId,
+		"biddingId":    sid,
+		"createDate":   time.Now().Unix(),
+	})
+	if len(limitLogsData) > limitLogsCount {
+		tmp := limitLogsData
+		limitLogsData = make([]map[string]interface{}, 0)
+		sb := db.Mgo_Log.SaveBulk("detail_limit_logs", tmp...)
+		if !sb {
+			log.Println("免费用户 访问 详情页 超限制日志存储 异常")
+		}
+	}
+	limitLogsLock.Unlock()
+}
+
 // 查看公告详情次数限制
 // 查看公告详情次数限制
-func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
+func SeeDetailLimit(obj map[string]interface{}, sessUser util.SessUserInfo, sid string) bool {
 	if obj != nil {
 	if obj != nil {
 		subTypeStr, _ := obj["subtype"].(string)
 		subTypeStr, _ := obj["subtype"].(string)
 		if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
 		if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
 			return false
 			return false
 		}
 		}
 	} else {
 	} else {
+		userId := sessUser.UserId
 		watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
 		watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
 		//检验是否留资
 		//检验是否留资
 		if CNode(userId) {
 		if CNode(userId) {
@@ -185,6 +222,8 @@ func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
 							return true
 							return true
 						}
 						}
 					}
 					}
+					//超过限制次数 记录
+					go SeeDetailLimitLogs(sessUser, sid)
 					return false
 					return false
 				}
 				}
 			}
 			}