|
@@ -22,6 +22,7 @@ import (
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "sync"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -157,14 +158,50 @@ func CNode(userId string) bool {
|
|
|
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 {
|
|
|
subTypeStr, _ := obj["subtype"].(string)
|
|
|
if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
+ userId := sessUser.UserId
|
|
|
watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
|
|
|
//检验是否留资
|
|
|
if CNode(userId) {
|
|
@@ -185,6 +222,8 @@ func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
+ //超过限制次数 记录
|
|
|
+ go SeeDetailLimitLogs(sessUser, sid)
|
|
|
return false
|
|
|
}
|
|
|
}
|