Jelajahi Sumber

Merge branch 'dev/2.9.38_fu' of jianyu/ent_new into feature/v2.9.38

fuwencai 1 tahun lalu
induk
melakukan
d261f0ee44

+ 15 - 2
entniche_new/src/config.json

@@ -6,8 +6,21 @@
     "normal": 10
   },
   "followCustomer": {
-    "customerNumb": 10,
-    "enterpriseNumb": 500
+    "member": {
+      "default": 10,
+      "24": 100,
+      "25": 500
+    },
+    "vip": {
+      "new": 10,
+      "old": 10
+    },
+    "ent": {
+      "new": 10,
+      "old": 10
+    },
+    "entService": 10,
+    "free": 0
   },
   "claimCustomer": {
     "customerNumb": 500

+ 11 - 2
entniche_new/src/config/config.go

@@ -45,8 +45,17 @@ type config struct {
 		BigVip int
 	}
 	FollowCustomer struct {
-		CustomerNumb   int
-		EnterpriseNumb int
+		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个
 	}
 	FollowPushRpc    string
 	ItemsNumber      int64

+ 5 - 2
entniche_new/src/service/customer/customer.go

@@ -1234,6 +1234,9 @@ func (this *CustomerAction) CstList() {
 		userId, _ := this.GetSession("userId").(string)
 		entUserId := qutil.IntAll(this.GetSession("entUserId"))
 		cotion := NewCustomerOperation()
+		userInfo := jy.GetBigVipUserBaseMsg(this.Session(), *config.Middleground)
+		cotion.UserId = qutil.If(userInfo.Pid != "", userInfo.Pid, userId).(string)
+		cotion.Session = this.Session()
 		cotion.UserId = userId
 		cotion.EntUserId = entUserId
 		searchCode := this.GetString("searchCode")
@@ -1246,7 +1249,7 @@ func (this *CustomerAction) CstList() {
 		if pageNo < 0 {
 			pageNo = 0
 		}
-		res, count := cotion.CList(searchCode, isCliam, entUserId)
+		res, maxNum, count := cotion.CList(searchCode, isCliam, entUserId)
 		customerName := []string{}
 		for _, value := range res {
 			customerName = append(customerName, value.Name)
@@ -1279,7 +1282,7 @@ func (this *CustomerAction) CstList() {
 			"list":     cInfoArr,
 			"total":    len(res),
 			"count":    count,
-			"countMax": config.Config.FollowCustomer.CustomerNumb,
+			"countMax": maxNum,
 		}}
 	}()
 	this.ServeJson(r)

+ 120 - 34
entniche_new/src/service/customer/entiy.go

@@ -6,8 +6,10 @@ import (
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
 	"database/sql"
 	"entniche_new/src/config"
+	"entniche_new/src/util"
 	"fmt"
 	"log"
 	"strings"
@@ -34,6 +36,7 @@ type CustomerOperation struct {
 	Mold       int    `json:"mold"`     //1 认领 0 关注
 	Reason     string `json:"reason"`   //原因
 	Industry   string `json:"industry"` //原因
+	Session    *httpsession.Session
 }
 
 func NewCustomerOperation() CustomerOperation {
@@ -60,6 +63,7 @@ type CustomerInfo struct {
 	WProvince  string  `json:"wProvince"`
 	PNCount    int     `json:"pNCount"`
 	CustomerId string  `json:"customerId"`
+	Unread     int     `json:"unread"`
 }
 
 // 不是我的客户
@@ -97,13 +101,20 @@ func (this *CustomerOperation) Exclude() (B bool) {
 }
 
 // 我的关注客户列表
-func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId int) ([]*CustomerInfo, int) {
+func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId int) ([]*CustomerInfo, int, int) {
 	var cinfoarr = []*CustomerInfo{}
 	entnames := []string{}
 	count := 0
 	query := map[string]interface{}{
 		"userId": this.UserId,
 	}
+	o := util.GetUserBaseInfo(this.Session)
+	BigMsg := config.Middleground.PowerCheckCenter.Check("10000", o.MgoUserId, o.BaseUserId, o.AccountId, o.EntId, o.PositionType, o.PositionId)
+	if BigMsg == nil {
+		log.Println("获取用户身份信息异常:", BigMsg)
+		return []*CustomerInfo{}, 0, 0
+	}
+	countLimit, _ := getCustomerLimit(BigMsg)
 	//count = MQFW.Count(fc, query)
 	customerList := Mysql.SelectBySql("SELECT ec.name,euu.customer_id FROM entniche_user_customer euu LEFT JOIN entniche_customer ec ON ec.id = euu.customer_id  WHERE user_id = ? AND (source_type =1 or source_type =4) ", entUserId)
 	customerMap := map[string]interface{}{}
@@ -111,7 +122,7 @@ func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId
 		customerMap[qutil.ObjToString(value["name"])] = value["customer_id"]
 	}
 
-	clist, ok := MQFW.Find(fc, query, `{"date":-1}`, `{"name":1,"date":1}`, false, 0, config.Config.FollowCustomer.CustomerNumb)
+	clist, ok := MQFW.Find(fc, query, `{"date":-1}`, `{"name":1,"date":1}`, false, 0, countLimit)
 	if ok && clist != nil && len(*clist) > 0 {
 		count = len(*clist)
 		for _, v := range *clist {
@@ -130,9 +141,15 @@ func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId
 			}
 			entnames = append(entnames, v["name"].(string))
 			date := v["date"]
+			updateTime := qutil.IntAll(v["updatetime"])
+			// p303 有项目更新时间取项目更新时间 否则取关注时间
+			if updateTime != 0 {
+				date = updateTime
+			}
 			cinfoarr = append(cinfoarr, &CustomerInfo{
 				Name:       v["name"].(string),
 				Followdate: FormatDateWithObj(&date, "2006/01/02"),
+				Unread:     qutil.IntAll(v["unread"]),
 			})
 		}
 	}
@@ -154,7 +171,74 @@ func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId
 			}
 		}
 	}
-	return cinfoarr, count
+	return cinfoarr, count, countLimit
+}
+
+// 获取关注项目数量限制
+// 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 < 1706976000 {
+			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
 }
 
 // 获取企业-客户信息
@@ -173,38 +257,40 @@ func (this *CustomerOperation) CheckPower(mold int, entUserId int, name string,
 	//商机管理 兼容同为大会员用户时 取最大的个人关注上限
 	//bigmsg := jy.GetBigVipUserBaseMsg(this.UserId, Mysql, MQFW)
 	bigmsg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
-	if bigmsg.Customers < config.Config.FollowCustomer.CustomerNumb {
-		bigmsg.Customers = config.Config.FollowCustomer.CustomerNumb
-	}
+	//if bigmsg.Customers < config.Config.FollowCustomer.CustomerNumb {
+	//	bigmsg.Customers = config.Config.FollowCustomer.CustomerNumb
+	//}
 	if mold == 0 {
-		query := map[string]interface{}{
-			"ent_id": ent_id,
-		}
-		res, _ := MQFW.Find(fc, query, nil, `{"name":1}`, false, -1, -1)
-		log.Println(config.Config.FollowCustomer.EnterpriseNumb)
-		//大会员兼商机管理用户 走大会员校验 跳过商机管理企业数量上限校验 客户监控权限500 商机管理用户10
-		if len((*res)) > config.Config.FollowCustomer.EnterpriseNumb && bigmsg.Customers <= config.Config.FollowCustomer.CustomerNumb {
-			data := map[string]interface{}{}
-			i := 0
-			for _, value := range *res {
-				if data[qutil.ObjToString(value["name"])] == nil {
-					i++
-					data[qutil.ObjToString(value["name"])] = 1
-				}
-			}
-			if i >= config.Config.FollowCustomer.EnterpriseNumb {
-				msg = fmt.Sprintf("您的企业关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.EnterpriseNumb)
-			}
-		}
-
-		query = map[string]interface{}{
-			"userId": this.UserId,
-		}
-		delete(query, "ent_id")
-		count := MQFW.Count(fc, query)
-		if count >= bigmsg.Customers {
-			msg = fmt.Sprintf("您的关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.CustomerNumb)
-		}
+		// 商机管理关注接口已废弃 走公共程序统一的关注接口
+		return fmt.Sprintf("无效接口")
+		//query := map[string]interface{}{
+		//	"ent_id": ent_id,
+		//}
+		//res, _ := MQFW.Find(fc, query, nil, `{"name":1}`, false, -1, -1)
+		//log.Println(config.Config.FollowCustomer.EnterpriseNumb)
+		////大会员兼商机管理用户 走大会员校验 跳过商机管理企业数量上限校验 客户监控权限500 商机管理用户10
+		//if len((*res)) > config.Config.FollowCustomer.EnterpriseNumb && bigmsg.Customers <= config.Config.FollowCustomer.CustomerNumb {
+		//	data := map[string]interface{}{}
+		//	i := 0
+		//	for _, value := range *res {
+		//		if data[qutil.ObjToString(value["name"])] == nil {
+		//			i++
+		//			data[qutil.ObjToString(value["name"])] = 1
+		//		}
+		//	}
+		//	if i >= config.Config.FollowCustomer.EnterpriseNumb {
+		//		msg = fmt.Sprintf("您的企业关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.EnterpriseNumb)
+		//	}
+		//}
+		//
+		//query = map[string]interface{}{
+		//	"userId": this.UserId,
+		//}
+		//delete(query, "ent_id")
+		//count := MQFW.Count(fc, query)
+		//if count >= bigmsg.Customers {
+		//	msg = fmt.Sprintf("您的关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.CustomerNumb)
+		//}
 	} else {
 		// 判断是不是商机管理服务
 		var entNum, personNum int64 // 企业认领人数限制、个人认领人数限制

+ 33 - 0
entniche_new/src/util/userInfo.go

@@ -0,0 +1,33 @@
+package util
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+)
+
+// SessUserInfo 从session获取用户基本信息
+type SessUserInfo struct {
+	BaseUserId   int64
+	AccountId    int64
+	EntId        int64
+	PositionType int64
+	PositionId   int64
+	Phone        string
+	MgoUserId    string
+	UserId       string
+}
+
+// GetUserBaseInfo 获取用户基本信息从session
+func GetUserBaseInfo(sess *httpsession.Session) SessUserInfo {
+	getSession := sess.GetMultiple()
+	return SessUserInfo{
+		MgoUserId:    common.ObjToString(getSession["mgoUserId"]),
+		BaseUserId:   common.Int64All(getSession["base_user_id"]),
+		AccountId:    common.Int64All(getSession["accountId"]),
+		EntId:        common.Int64All(getSession["entId"]),
+		PositionType: common.Int64All(getSession["positionType"]),
+		PositionId:   common.Int64All(getSession["positionId"]),
+		Phone:        common.ObjToString(getSession["phone"]),
+		UserId:       common.ObjToString(getSession["userId"]),
+	}
+}