|
@@ -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,
|