Browse Source

fix:大会员客户监控兼容商检管理权限

duxin 3 years ago
parent
commit
d8465587a4

+ 5 - 1
src/jfw/modules/publicapply/src/config.json

@@ -46,5 +46,9 @@
     "followPushRpc": "127.0.0.1:8759",
     "followPushRpc": "127.0.0.1:8759",
     "file_number": 10,
     "file_number": 10,
     "smsServiceRpc":"127.0.0.1:932",
     "smsServiceRpc":"127.0.0.1:932",
-    "fileSignBool":true
+    "fileSignBool":true,
+    "followCustomer": {
+      "customerNumb": 50,
+      "enterpriseNumb": 500
+    }
 }
 }

+ 4 - 0
src/jfw/modules/publicapply/src/config/config.go

@@ -23,6 +23,10 @@ type config struct {
 	FollowPushRpc         string
 	FollowPushRpc         string
 	SmsServiceRpc         string
 	SmsServiceRpc         string
 	FileSignBool          bool
 	FileSignBool          bool
+	FollowCustomer        struct {
+		CustomerNumb   int
+		EnterpriseNumb int
+	}
 }
 }
 type BidColl struct {
 type BidColl struct {
 	PayUserCollLimit      int    //付费用户收藏数量最大限制
 	PayUserCollLimit      int    //付费用户收藏数量最大限制

+ 40 - 1
src/jfw/modules/publicapply/src/customer/entity/entiy.go

@@ -1,6 +1,7 @@
 package entity
 package entity
 
 
 import (
 import (
+	"config"
 	"db"
 	"db"
 	"fmt"
 	"fmt"
 	qu "qfw/util"
 	qu "qfw/util"
@@ -13,6 +14,7 @@ import (
 
 
 type CustomerOperation struct {
 type CustomerOperation struct {
 	UserId   string `json:"userId"`
 	UserId   string `json:"userId"`
+	EntId    int    `json:"entId"`
 	Name     string `json:"name"`
 	Name     string `json:"name"`
 	Province string `json:"province"`
 	Province string `json:"province"`
 	City     string `json:"city"`
 	City     string `json:"city"`
@@ -91,9 +93,12 @@ func (this *CustomerOperation) CList(pageSize, pageNo, entUserId int, keyword, i
 	//大会员客户关注上限
 	//大会员客户关注上限
 	BigMsg := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
 	BigMsg := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
 	entVip := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo)
 	entVip := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo)
-
 	customerMap := map[string]interface{}{}
 	customerMap := map[string]interface{}{}
 	if entVip.EntnicheStatus > 0 {
 	if entVip.EntnicheStatus > 0 {
+		//非大会员商机管理用户兼容查询商机管理权限
+		if BigMsg.Customers < config.Config.FollowCustomer.CustomerNumb {
+			BigMsg.Customers = config.Config.FollowCustomer.CustomerNumb
+		}
 		customerList := db.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)
 		customerList := db.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)
 		for _, value := range *customerList {
 		for _, value := range *customerList {
 			customerMap[qu.ObjToString(value["name"])] = value["customer_id"]
 			customerMap[qu.ObjToString(value["name"])] = value["customer_id"]
@@ -175,6 +180,10 @@ func (this *CustomerOperation) CheckPower() string {
 			if count >= userPower.Customers {
 			if count >= userPower.Customers {
 				msg = fmt.Sprintf("对不起,您最多可关注%d个客户", userPower.Customers)
 				msg = fmt.Sprintf("对不起,您最多可关注%d个客户", userPower.Customers)
 			}
 			}
+		} else if entUser := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo); entUser.EntnicheStatus > 0 {
+			//兼容商机管理用户权限搜索
+			return EntCheckPower(this.UserId, this.EntId)
+
 		} else {
 		} else {
 			msg = "暂无关注客户权限"
 			msg = "暂无关注客户权限"
 		}
 		}
@@ -182,6 +191,36 @@ func (this *CustomerOperation) CheckPower() string {
 	return msg
 	return msg
 }
 }
 
 
+func EntCheckPower(userId string, entId int) (msg string) {
+	query := map[string]interface{}{
+		"ent_id": entId,
+	}
+
+	res, _ := db.Mgo.Find(fc, query, nil, `{"name":1}`, false, -1, -1)
+	if len((*res)) > config.Config.FollowCustomer.EnterpriseNumb {
+		data := map[string]interface{}{}
+		i := 0
+		for _, value := range *res {
+			if data[qu.ObjToString(value["name"])] == nil {
+				i++
+				data[qu.ObjToString(value["name"])] = 1
+			}
+		}
+		if i >= config.Config.FollowCustomer.EnterpriseNumb {
+			msg = fmt.Sprintf("您的企业关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.EnterpriseNumb)
+		}
+	}
+
+	query = map[string]interface{}{
+		"userId": userId,
+	}
+	delete(query, "ent_id")
+	count := db.Mgo.Count(fc, query)
+	if count >= config.Config.FollowCustomer.EnterpriseNumb {
+		msg = fmt.Sprintf("您的关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.CustomerNumb)
+	}
+	return
+}
 func (this *CustomerOperation) Coperation() (B bool) {
 func (this *CustomerOperation) Coperation() (B bool) {
 	queryMap := map[string]interface{}{
 	queryMap := map[string]interface{}{
 		"userId": this.UserId,
 		"userId": this.UserId,

+ 2 - 0
src/jfw/modules/publicapply/src/customer/service/service.go

@@ -100,6 +100,8 @@ func (this *ServiceStruct) CstAtt() {
 			return Result{Data: nil, Error_msg: Error_msg_1003}
 			return Result{Data: nil, Error_msg: Error_msg_1003}
 		}
 		}
 		cotion.UserId = userId
 		cotion.UserId = userId
+		cotion.EntId = qu.IntAll(this.GetSession("entId"))
+
 		msg := cotion.CheckPower()
 		msg := cotion.CheckPower()
 		if !cotion.B && msg != "" {
 		if !cotion.B && msg != "" {
 			return Result{Data: false, Error_msg: msg}
 			return Result{Data: false, Error_msg: msg}