|
@@ -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 // 企业认领人数限制、个人认领人数限制
|