瀏覽代碼

wip:提交

wangkaiyue 2 年之前
父節點
當前提交
4276415c08
共有 5 個文件被更改,包括 36 次插入42 次删除
  1. 0 7
      entity/mananger/aheadManager.go
  2. 0 7
      entity/mananger/customManager.go
  3. 35 26
      entity/power/power.go
  4. 0 1
      services/action.go
  5. 1 1
      vars/config.go

+ 0 - 7
entity/mananger/aheadManager.go

@@ -75,13 +75,6 @@ func (this *AheadManager) Click(userId string) bool {
 
 // CheckGroupUser 校验用户是否有资格展示
 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()
 	defer this.RUnlock()
 	_, exists = this.UserGroup[userId]

+ 0 - 7
entity/mananger/customManager.go

@@ -271,13 +271,6 @@ func (this *CustomManager) DoSearch() {
 
 // checkActivityUser 校验用户是否是活跃用户
 func (this *CustomManager) checkActivityUser(userId string) (exists bool) {
-	if len(vars.Config.TestUid) > 0 {
-		for _, uid := range vars.Config.TestUid {
-			if uid == userId {
-				return true
-			}
-		}
-	}
 	this.RLock()
 	defer this.RUnlock()
 	_, exists = this.UserGroup[userId]

+ 35 - 26
entity/power/power.go

@@ -5,7 +5,6 @@ import (
 	"app.yhyue.com/moapp/jybase/redis"
 	"encoding/json"
 	"fmt"
-	"go.mongodb.org/mongo-driver/bson/primitive"
 	"leadGeneration/public"
 	"leadGeneration/vars"
 )
@@ -52,8 +51,8 @@ func HasPower(userId string) bool {
 	return public.MainMysql.CountBySql("SELECT count(id) FROM bigmember_service_user WHERE s_userid=? AND s_serviceid =10 AND i_status =0", userId) > 0
 }
 
-// HasPower 是否有超前订阅权限
-// bigMember.power=10
+// HasAheadPower 是否有超前订阅权限
+// 大会员、商机管理及老的超级订阅
 func HasAheadPower(userId string) bool {
 	if userId == "" {
 		return false
@@ -70,31 +69,41 @@ func HasAheadPower(userId string) bool {
 		}
 		return nil
 	}()
-	if vipStatus != nil && vipStatus.Status > 0 {
-		return true
+	if vipStatus != nil {
+		//大会员、商机管理有权限
+		if vipStatus.Status > 0 || vipStatus.EntnicheStatus > 0 {
+			return true
+		}
+		//非超级订阅无权限
+		if vipStatus.VipStatus <= 0 {
+			return false
+		}
+		//判断超级订阅时间
+		res, _ := public.MQFW.FindById("user", userId, `{"l_vip_starttime":1}`)
+		if res != nil && len(*res) > 0 {
+			if common.Int64All((*res)["l_vip_starttime"]) < vars.Config.ContextOldVipLimit {
+				return true
+			}
+		}
+		return false
 	}
-	id, _ := primitive.ObjectIDFromHex(userId)
-	//查询权益
-	query := map[string]interface{}{
-		"$or": []map[string]interface{}{
-			{
-				"_id": id,
-				"i_member_status": map[string]interface{}{
-					"$gt": 0,
-				},
-			},
-			{
-				"_id": id,
-				"i_vip_status": map[string]interface{}{
-					"$gt": 0,
-				},
-				"l_vip_starttime": map[string]interface{}{
-					"$lte": vars.Config.ContextOldVipLimit,
-				},
-			},
-		},
+	//无缓存
+	res, _ := public.MQFW.FindById("user", userId, `{"l_vip_starttime":1,"i_vip_status":1,"i_member_status":1,"s_phone":1,"s_m_phone":1}`)
+	if res != nil && len(*res) > 0 {
+		if common.IntAll("i_member_status") > 0 {
+			return true
+		}
+		if common.IntAll("l_vip_starttime") > 0 && common.Int64All((*res)["l_vip_starttime"]) < vars.Config.ContextOldVipLimit {
+			return true
+		}
+		//查询是否是商机管理付费用户
+		if phone, _ := common.If((*res)["s_phone"] != nil, (*res)["s_phone"], (*res)["s_m_phone"]).(string); phone != "" {
+			if count := public.MainMysql.CountBySql(`SELECT count(1) FROM entniche_user u LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone=? and u.power=1 and i.status=1`, phone); count > 0 {
+				return true
+			}
+		}
 	}
-	return public.MQFW.Count("user", query) > 0
+	return false
 }
 
 // HasSubscribe 是否有订阅词

+ 0 - 1
services/action.go

@@ -32,7 +32,6 @@ func (this *LeadGeneration) GetDate() {
 		if aheadData := mananger.JyAheadManager.GetData(userId, keyWords, isNewUser, t); aheadData != nil && len(aheadData) > 0 {
 			rData["ahead"] = aheadData
 		}
-
 		//获取定制化报告数据
 		if customData := mananger.JyCustomManager.GetData(userId, keyWords, isNewUser); customData != nil && len(customData) > 0 {
 			rData["custom"] = customData

+ 1 - 1
vars/config.go

@@ -11,7 +11,7 @@ type config struct {
 	Ahead              AheadConfig  `json:"ahead"`              //超前项目配置
 	Custom             CustomConfig `json:"custom"`             //定制化报告配置
 	TestUid            []string     `json:"testUid"`            //测试用户id
-	ContextOldVipLimit int          `json:"contextOldVipLimit"` //旧版超级订阅超前订阅时间
+	ContextOldVipLimit int64        `json:"contextOldVipLimit"` //旧版超级订阅超前订阅时间
 }
 
 type AheadConfig struct {