소스 검색

fix:我的数量增加业主数量

duxin 1 년 전
부모
커밋
6039ffe56a

+ 18 - 1
src/jfw/modules/bigmember/src/config.json

@@ -190,5 +190,22 @@
   "msgMaxCount": 20000,
   "analysisPDFPhone": "13027620557",
   "payUserCollLimit":5000,
-  "freeUserCollLimit":100
+  "freeUserCollLimit":100,
+  "followCustomer": {
+    "member": {
+      "default": 10,
+      "24": 100,
+      "25": 500
+    },
+    "vip": {
+      "new": 10,
+      "old": 10
+    },
+    "ent": {
+      "new": 10,
+      "old": 10
+    },
+    "entService": 10,
+    "free": 0
+  }
 }

+ 13 - 0
src/jfw/modules/bigmember/src/config/config.go

@@ -80,6 +80,19 @@ type config struct {
 	AnalysisPDFPhone    string   `json:"analysisPDFPhone"`
 	PayUserCollLimit    int64    `json:"payUserCollLimit"`  //付费用户收藏数量最大限制
 	FreeUserCollLimit   int64    `json:"freeUserCollLimit"` //免费用户收藏数量最大限制
+	FollowCustomer      struct {
+		Member map[string]int //大会员 default 10个,商机版2.0 100个,专家版2.0 500个
+		Vip    struct {       //超级订阅 新老版都是10个
+			New int
+			Old int
+		}
+		Ent struct { //商机管理 新老版都是10个
+			New int
+			Old int
+		}
+		EntService int //企业管理服务 10个
+		Free       int //免费用户 0个
+	}
 }
 
 type CustomerInfo struct {

+ 94 - 7
src/jfw/modules/bigmember/src/service/analysis/businessIntelligence.go

@@ -7,6 +7,7 @@ import (
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
 	"errors"
 	"fmt"
 	"github.com/gogf/gf/v2/util/gconv"
@@ -113,7 +114,7 @@ func (l *BusinessIntelligence) MeMonitoring() {
 	userId := gconv.String(l.GetSession("userId"))
 	rData := func() interface{} {
 		data := make(map[string]int64)
-		for _, s := range []string{"claimCount", "collectCount", "projectFollowCount", "entFollowCount"} {
+		for _, s := range []string{"claimCount", "collectCount", "projectFollowCount", "entFollowCount", "ownerMonitoring"} {
 			l.MeListCount(s, userId, data)
 		}
 		return data
@@ -138,28 +139,114 @@ func (l *BusinessIntelligence) MeListCount(classify string, userid string, data
 	case "collectCount": //收藏
 		isPay := Power(l.Session())
 		maxCount := qutil.If(isPay, config.Config.PayUserCollLimit, config.Config.FreeUserCollLimit).(int64)
-		allCount := db.Base.CountBySql(fmt.Sprintf(`select count(*) from jianyu.bdcollection where userid ='%s'`, userid))
-		count = qutil.If(allCount > maxCount, maxCount, allCount).(int64)
+		if maxCount > 0 {
+			allCount := db.Base.CountBySql(fmt.Sprintf(`select count(*) from jianyu.bdcollection where userid ='%s'`, userid))
+			count = qutil.If(allCount > maxCount, maxCount, allCount).(int64)
+		}
 		return
 	case "projectFollowCount": //项目关注
 		followProjectManager, err := entity.CreateProjectFollowManager(l.Session())
 		if err != nil {
 			return
 		}
-		allCount := db.Base.CountBySql(`select count(*) from follow_project_monitor where s_userid= ?`, userid)
 		maxNum := gconv.Int64(followProjectManager.MaxNum)
-		count = qutil.If(allCount > maxNum, maxNum, allCount).(int64)
+		if maxNum > 0 {
+			allCount := db.Base.CountBySql(`select count(*) from follow_project_monitor where s_userid= ?`, userid)
+			count = qutil.If(allCount > maxNum, maxNum, allCount).(int64)
+		}
 		return
 	case "entFollowCount": //企业关注
 		followEntManager, err := entity.CreateEntFollowManager(l.Session())
 		if err != nil {
 			return
 		}
-		allCount := db.Base.CountBySql(fmt.Sprintf(`SELECT count(*) FROM follow_ent_monitor WHERE  s_userid="%s" `, userid))
 		maxNum := gconv.Int64(followEntManager.MaxNum)
-		count = qutil.If(allCount > maxNum, maxNum, allCount).(int64)
+		if maxNum > 0 {
+			allCount := db.Base.CountBySql(fmt.Sprintf(`SELECT count(*) FROM follow_ent_monitor WHERE  s_userid="%s" `, userid))
+			count = qutil.If(allCount > maxNum, maxNum, allCount).(int64)
+		}
 		return
+	case "ownerMonitoring":
+		userInfo := jy.GetBigVipUserBaseMsg(l.Session(), *config.Middleground)
+		userid = qutil.If(userInfo.Pid != "", userInfo.Pid, userid).(string)
+		userSession := util.GetUserBaseInfo(l.Session())
+		BigMsg := config.Middleground.PowerCheckCenter.Check("10000", userSession.MgoUserId, userSession.BaseUserId, userSession.AccountId, userSession.EntId, userSession.PositionType, userSession.PositionId)
+		maxCount, _ := getCustomerLimit(BigMsg)
+		if maxCount > 0 {
+			allCount := db.Mgo.Count("follow_customer", map[string]interface{}{
+				"userId": userid,
+			})
+			count = qutil.Int64All(qutil.If(allCount > maxCount, maxCount, allCount))
+		}
+		return
+	}
+}
+
+// 获取关注项目数量限制
+// limitStatus 1 -超级订阅用户 2-非超级订阅(例如:大会员、新老版商机管理、企业管理服务用户)
+func getCustomerLimit(userInfo *powercheck.CheckResp) (count int, limitStatus int) {
+	if userInfo.Free.IsFree {
+		return config.Config.FollowCustomer.Free, 0
+	}
+	limitStatus = 2
+	// 大会员
+	if userInfo.Member.Status > 0 {
+		//P303 业主监控  老版大会员权限调整2024.2.4 发版之前的大会员
+		if userInfo.Member.StartTime < 1707051600 {
+			for i := 0; i < len(userInfo.Member.MemberPowerList); i++ {
+				if userInfo.Member.MemberPowerList[i] == 7 {
+					userInfo.Member.MemberPowerList = append(userInfo.Member.MemberPowerList, 25) //业主监控专家版500
+					break
+				}
+			}
+		}
+		var flag bool
+		for i := 0; i < len(userInfo.Member.MemberPowerList); i++ {
+			serviceId := userInfo.Member.MemberPowerList[i]
+			if c, b := config.Config.FollowCustomer.Member[fmt.Sprintf("%v", serviceId)]; b {
+				count = c
+				flag = true
+				break
+			}
+		}
+		if !flag {
+			count = config.Config.FollowCustomer.Member["default"]
+		}
+	}
+	// 商机管理
+	if userInfo.Entniche.Status > 0 && userInfo.Entniche.PowerSource < 1 {
+		// 新商机管理
+		if userInfo.Entniche.IsNew > 0 {
+			if config.Config.FollowCustomer.Ent.New > count {
+				count = config.Config.FollowCustomer.Ent.New
+			}
+		} else if config.Config.FollowCustomer.Ent.Old > count {
+			// 旧商机管理
+			count = config.Config.FollowCustomer.Ent.Old
+		}
+	}
+
+	// 企业服务
+	if userInfo.Entniche.Status > 0 && userInfo.Entniche.PowerSource > 0 {
+		if config.Config.FollowCustomer.EntService > count {
+			count = config.Config.FollowCustomer.EntService
+		}
+	}
+	// 超级订阅
+	if userInfo.Vip.Status > 0 {
+		// 新超级订阅
+		if userInfo.Vip.Upgrade > 0 {
+			if config.Config.FollowCustomer.Vip.New > count {
+				limitStatus = 1
+				count = config.Config.FollowCustomer.Vip.New
+			}
+		} else if config.Config.FollowCustomer.Vip.Old > count {
+			// 旧超级订阅
+			limitStatus = 1
+			count = config.Config.FollowCustomer.Vip.Old
+		}
 	}
+	return
 }
 
 // 是否是付费用户 -bool: true:是 fasle:不是

+ 33 - 4
src/jfw/modules/bigmember/src/util/power.go

@@ -10,8 +10,8 @@ import (
 	"time"
 )
 
-//后期
-//获取用户主账号userid
+// 后期
+// 获取用户主账号userid
 func MainUserId(session *httpsession.Session) (string, string, int) {
 	bigMsg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
 	if bigMsg.Data.Member.Pid == "" {
@@ -21,7 +21,7 @@ func MainUserId(session *httpsession.Session) (string, string, int) {
 	return bigMsg.Data.Member.Pid, bigMsg.Data.Free.Phone, bigMsg.Status
 }
 
-//获取该用户所有主账号+子账号
+// 获取该用户所有主账号+子账号
 func AllAccount(session *httpsession.Session) []string {
 	mainId, _, _ := MainUserId(session)
 	account := []string{mainId}
@@ -34,7 +34,7 @@ func AllAccount(session *httpsession.Session) []string {
 	return account
 }
 
-//招标文件解读次数
+// 招标文件解读次数
 func IsBidfilePower(session *httpsession.Session) (int, bool) {
 	overdue := false
 	count := 0
@@ -58,3 +58,32 @@ func GetTime(layout, t string) time.Time {
 	times, _ := time.ParseInLocation(layout, t, time.Local)
 	return times
 }
+
+// SessUserInfo 从session获取用户基本信息
+type SessUserInfo struct {
+	BaseUserId   int64
+	AccountId    int64
+	EntId        int64
+	PositionType int64
+	PositionId   int64
+	EntUserId    int64
+	Phone        string
+	MgoUserId    string
+	UserId       string
+}
+
+// GetUserBaseInfo 获取用户基本信息从session
+func GetUserBaseInfo(sess *httpsession.Session) SessUserInfo {
+	getSession := sess.GetMultiple()
+	return SessUserInfo{
+		MgoUserId:    qutil.ObjToString(getSession["mgoUserId"]),
+		BaseUserId:   qutil.Int64All(getSession["base_user_id"]),
+		AccountId:    qutil.Int64All(getSession["accountId"]),
+		EntId:        qutil.Int64All(getSession["entId"]),
+		PositionType: qutil.Int64All(getSession["positionType"]),
+		PositionId:   qutil.Int64All(getSession["positionId"]),
+		Phone:        qutil.ObjToString(getSession["phone"]),
+		UserId:       qutil.ObjToString(getSession["userId"]),
+		EntUserId:    qutil.Int64All(getSession["entUserId"]),
+	}
+}