|
@@ -5,6 +5,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/robfig/cron/v3"
|
|
"github.com/robfig/cron/v3"
|
|
"leadGeneration/entity/activeUsers"
|
|
"leadGeneration/entity/activeUsers"
|
|
|
|
+ "leadGeneration/entity/power"
|
|
"leadGeneration/entity/search"
|
|
"leadGeneration/entity/search"
|
|
"leadGeneration/public"
|
|
"leadGeneration/public"
|
|
"leadGeneration/vars"
|
|
"leadGeneration/vars"
|
|
@@ -42,12 +43,10 @@ func InitAheadManager(conf vars.AheadConfig) *AheadManager {
|
|
// GetData 获取查询数据
|
|
// GetData 获取查询数据
|
|
func (this *AheadManager) GetData(userId, keyWords string, isNew bool, t int64) map[string]interface{} {
|
|
func (this *AheadManager) GetData(userId, keyWords string, isNew bool, t int64) map[string]interface{} {
|
|
if !(isNew || this.checkGroupUser(userId)) {
|
|
if !(isNew || this.checkGroupUser(userId)) {
|
|
- log.Println("无查看权益")
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
//校验每日请求次数
|
|
//校验每日请求次数
|
|
cacheKey := fmt.Sprintf(AheadRequestFrequencyCacheKey, time.Now().Format(public.TimeFormat), t, userId)
|
|
cacheKey := fmt.Sprintf(AheadRequestFrequencyCacheKey, time.Now().Format(public.TimeFormat), t, userId)
|
|
- log.Printf("已查看:%d", redis.GetInt(AheadCacheDb, cacheKey))
|
|
|
|
if this.Conf.DailyTimes <= redis.GetInt(AheadCacheDb, cacheKey) {
|
|
if this.Conf.DailyTimes <= redis.GetInt(AheadCacheDb, cacheKey) {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -75,13 +74,6 @@ func (this *AheadManager) Click(userId string) bool {
|
|
|
|
|
|
// CheckGroupUser 校验用户是否有资格展示
|
|
// CheckGroupUser 校验用户是否有资格展示
|
|
func (this *AheadManager) checkGroupUser(userId string) (exists bool) {
|
|
func (this *AheadManager) checkGroupUser(userId string) (exists bool) {
|
|
- if len(vars.Config.TestUid) > 0 {
|
|
|
|
- for _, uid := range vars.Config.TestUid {
|
|
|
|
- if uid == userId {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
this.RLock()
|
|
this.RLock()
|
|
defer this.RUnlock()
|
|
defer this.RUnlock()
|
|
_, exists = this.UserGroup[userId]
|
|
_, exists = this.UserGroup[userId]
|
|
@@ -133,6 +125,26 @@ func (this *AheadManager) getUserGroup() (userIds []string) {
|
|
userIds = append(userIds, uId)
|
|
userIds = append(userIds, uId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //是否有新增测试用户
|
|
|
|
+ if len(vars.Config.TestUid) > 0 {
|
|
|
|
+ var newTest []string
|
|
|
|
+ for _, uid := range vars.Config.TestUid {
|
|
|
|
+ has := false
|
|
|
|
+ for _, id := range userIds {
|
|
|
|
+ if uid == id {
|
|
|
|
+ has = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !has && !power.HasAheadPower(uid) {
|
|
|
|
+ newTest = append(newTest, uid)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(newTest) > 0 {
|
|
|
|
+ userIds = append(userIds, newTest...)
|
|
|
|
+ activeUsers.SaveBatchGroup(newTest, 0, this.BatchFlag, "testUser")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//无数据则重新生成用户群组数据
|
|
//无数据则重新生成用户群组数据
|
|
if len(userIds) == 0 {
|
|
if len(userIds) == 0 {
|
|
@@ -155,7 +167,9 @@ func (this *AheadManager) getUserGroup() (userIds []string) {
|
|
defer wg.Done()
|
|
defer wg.Done()
|
|
if len(vars.Config.TestUid) > 0 {
|
|
if len(vars.Config.TestUid) > 0 {
|
|
for _, uid := range vars.Config.TestUid {
|
|
for _, uid := range vars.Config.TestUid {
|
|
- testUserGroup = append(testUserGroup, uid)
|
|
|
|
|
|
+ if !power.HasAheadPower(uid) {
|
|
|
|
+ testUserGroup = append(testUserGroup, uid)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
activeUsers.SaveBatchGroup(testUserGroup, 0, this.BatchFlag, "testUser")
|
|
activeUsers.SaveBatchGroup(testUserGroup, 0, this.BatchFlag, "testUser")
|