|
@@ -22,6 +22,7 @@ import (
|
|
"regexp"
|
|
"regexp"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "sync"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -157,6 +158,34 @@ 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(userId, sid string) {
|
|
|
|
+ limitLogsChan <- struct{}{}
|
|
|
|
+ defer func() {
|
|
|
|
+ <-limitLogsChan
|
|
|
|
+ }()
|
|
|
|
+ //保存日志
|
|
|
|
+ limitLogsLock.Lock()
|
|
|
|
+ limitLogsData = append(limitLogsData, map[string]interface{}{
|
|
|
|
+ "userId": userId,
|
|
|
|
+ "biddingId": sid,
|
|
|
|
+ "createDate": time.Now().Unix(),
|
|
|
|
+ })
|
|
|
|
+ if len(limitLogsData) > limitLogsCount {
|
|
|
|
+ tmp := limitLogsData
|
|
|
|
+ limitLogsData = make([]map[string]interface{}, 0)
|
|
|
|
+ db.Mgo_Log.SaveBulk("detail_limit_logs", tmp...)
|
|
|
|
+ }
|
|
|
|
+ limitLogsLock.Unlock()
|
|
|
|
+}
|
|
|
|
+
|
|
// 查看公告详情次数限制
|
|
// 查看公告详情次数限制
|
|
func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
|
|
func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
|
|
if obj != nil {
|
|
if obj != nil {
|
|
@@ -185,6 +214,8 @@ func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //超过限制次数 记录
|
|
|
|
+ go SeeDetailLimitLogs(userId, sid)
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|