|
@@ -1,269 +1,272 @@
|
|
|
package entity
|
|
|
|
|
|
import (
|
|
|
- "config"
|
|
|
- "db"
|
|
|
- "fmt"
|
|
|
- qu "qfw/util"
|
|
|
- "qfw/util/elastic"
|
|
|
- "qfw/util/jy"
|
|
|
- "qfw/util/redis"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
+ "config"
|
|
|
+ "db"
|
|
|
+ "fmt"
|
|
|
+ qu "qfw/util"
|
|
|
+ "qfw/util/elastic"
|
|
|
+ "qfw/util/jy"
|
|
|
+ "qfw/util/redis"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type CustomerOperation struct {
|
|
|
- UserId string `json:"userId"`
|
|
|
- EntId int `json:"entId"`
|
|
|
- Name string `json:"name"`
|
|
|
- Province string `json:"province"`
|
|
|
- City string `json:"city"`
|
|
|
- B bool `json:"b"` //true 取关;默认 false 关注。
|
|
|
+ UserId string `json:"userId"`
|
|
|
+ EntId int `json:"entId"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Province string `json:"province"`
|
|
|
+ City string `json:"city"`
|
|
|
+ B bool `json:"b"` //true 取关;默认 false 关注。
|
|
|
}
|
|
|
|
|
|
func NewCustomerOperation() CustomerOperation {
|
|
|
- return CustomerOperation{}
|
|
|
+ return CustomerOperation{}
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
- fc = "follow_customer" //关注客户表
|
|
|
- ec = "exclude_customer" //不是我的客户表
|
|
|
- redisName = "other"
|
|
|
- redisListKey = "customer_list_%s"
|
|
|
- redisCountKey = "customer_count_%s"
|
|
|
- redisExcludeKey = "customer_exclude_%s"
|
|
|
- redisCRIndex = "CRIndex_C_%s" //首页潜在客户关注
|
|
|
+ fc = "follow_customer" //关注客户表
|
|
|
+ ec = "exclude_customer" //不是我的客户表
|
|
|
+ redisName = "other"
|
|
|
+ redisListKey = "customer_list_%s"
|
|
|
+ redisCountKey = "customer_count_%s"
|
|
|
+ redisExcludeKey = "customer_exclude_%s"
|
|
|
+ redisCRIndex = "CRIndex_C_%s" //首页潜在客户关注
|
|
|
)
|
|
|
|
|
|
type CustomerInfo struct {
|
|
|
- Name string `json:"name"`
|
|
|
- Province string `json:"province"`
|
|
|
- Buyerclass string `json:"buyerclass"`
|
|
|
- Followdate string `json:"followdate"`
|
|
|
- CustomerId string `json:"customerId"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Province string `json:"province"`
|
|
|
+ Buyerclass string `json:"buyerclass"`
|
|
|
+ Followdate string `json:"followdate"`
|
|
|
+ CustomerId string `json:"customerId"`
|
|
|
}
|
|
|
|
|
|
// 是否关注此企业客户
|
|
|
func (this *CustomerOperation) CheckIsFollow() bool {
|
|
|
- return db.Mgo.Count(fc, map[string]interface{}{
|
|
|
- "userId": this.UserId,
|
|
|
- "name": this.Name,
|
|
|
- }) > 0
|
|
|
+ return db.Mgo.Count(fc, map[string]interface{}{
|
|
|
+ "userId": this.UserId,
|
|
|
+ "name": this.Name,
|
|
|
+ }) > 0
|
|
|
}
|
|
|
|
|
|
// 不是我的客户
|
|
|
func (this *CustomerOperation) Exclude() (B bool) {
|
|
|
- timeNow := time.Now()
|
|
|
- updateMap := map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "date": timeNow.Unix(),
|
|
|
- "userId": this.UserId,
|
|
|
- "name": this.Name,
|
|
|
- "province": this.Province,
|
|
|
- "city": this.City,
|
|
|
- },
|
|
|
- }
|
|
|
- B = db.Mgo.Update(ec, map[string]interface{}{
|
|
|
- "userId": this.UserId,
|
|
|
- "name": this.Name,
|
|
|
- }, updateMap, true, false)
|
|
|
- if B {
|
|
|
- redis.Del(redisName, fmt.Sprintf(redisCRIndex, this.UserId))
|
|
|
- redis.Del(redisName, fmt.Sprintf(redisExcludeKey, this.UserId))
|
|
|
- //删除首页客户缓存
|
|
|
- redis.DelByCodePattern(redisName, fmt.Sprintf("CRIndex_new_%s_*", this.UserId))
|
|
|
- }
|
|
|
- return B
|
|
|
+ timeNow := time.Now()
|
|
|
+ updateMap := map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "date": timeNow.Unix(),
|
|
|
+ "userId": this.UserId,
|
|
|
+ "name": this.Name,
|
|
|
+ "province": this.Province,
|
|
|
+ "city": this.City,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ B = db.Mgo.Update(ec, map[string]interface{}{
|
|
|
+ "userId": this.UserId,
|
|
|
+ "name": this.Name,
|
|
|
+ }, updateMap, true, false)
|
|
|
+ if B {
|
|
|
+ redis.Del(redisName, fmt.Sprintf(redisCRIndex, this.UserId))
|
|
|
+ redis.Del(redisName, fmt.Sprintf(redisExcludeKey, this.UserId))
|
|
|
+ //删除首页客户缓存
|
|
|
+ redis.DelByCodePattern(redisName, fmt.Sprintf("CRIndex_new_%s_*", this.UserId))
|
|
|
+ }
|
|
|
+ return B
|
|
|
}
|
|
|
|
|
|
// 列表
|
|
|
func (this *CustomerOperation) CList(pageSize, pageNo, entUserId int, keyword, isCliam string) ([]*CustomerInfo, int, int, int) {
|
|
|
- var cinfoarr, cinfoarrAll = []*CustomerInfo{}, []*CustomerInfo{}
|
|
|
- entnames := []string{}
|
|
|
- total := 0
|
|
|
- query := map[string]interface{}{
|
|
|
- "userId": this.UserId,
|
|
|
- }
|
|
|
- total = redis.GetInt(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
- if total < 1 {
|
|
|
- total = db.Mgo.Count(fc, query)
|
|
|
- redis.Put(redisName, fmt.Sprintf(redisCountKey, this.UserId), total, 2*60*60)
|
|
|
- }
|
|
|
+ var cinfoarr, cinfoarrAll = []*CustomerInfo{}, []*CustomerInfo{}
|
|
|
+ entnames := []string{}
|
|
|
+ total := 0
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "userId": this.UserId,
|
|
|
+ }
|
|
|
+ total = redis.GetInt(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
+ if total < 1 {
|
|
|
+ total = db.Mgo.Count(fc, query)
|
|
|
+ redis.Put(redisName, fmt.Sprintf(redisCountKey, this.UserId), total, 2*60*60)
|
|
|
+ }
|
|
|
|
|
|
- //大会员客户关注上限
|
|
|
- BigMsg := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
|
|
|
- entVip := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo)
|
|
|
- customerMap := map[string]interface{}{}
|
|
|
- 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)
|
|
|
- for _, value := range *customerList {
|
|
|
- customerMap[qu.ObjToString(value["name"])] = value["customer_id"]
|
|
|
- }
|
|
|
- }
|
|
|
+ //大会员客户关注上限
|
|
|
+ BigMsg := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo)
|
|
|
+ entVip := jy.GetEntnicheState(this.UserId, db.Mysql, db.Mgo)
|
|
|
+ customerMap := map[string]interface{}{}
|
|
|
+ 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)
|
|
|
+ for _, value := range *customerList {
|
|
|
+ customerMap[qu.ObjToString(value["name"])] = value["customer_id"]
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- clist, ok := db.Mgo.Find(fc, query, `{"date":-1}`, `{"name":1,"date":1}`, false, 0, BigMsg.Customers)
|
|
|
- if ok && clist != nil && len(*clist) > 0 {
|
|
|
- total = len(*clist)
|
|
|
- for _, v := range *clist {
|
|
|
- if keyword != "" && !strings.Contains(qu.ObjToString(v["name"]), keyword) {
|
|
|
- continue
|
|
|
- }
|
|
|
- switch isCliam {
|
|
|
- case "0":
|
|
|
- if customerMap[qu.ObjToString(v["name"])] != nil {
|
|
|
- continue
|
|
|
- }
|
|
|
- case "1":
|
|
|
- if customerMap[qu.ObjToString(v["name"])] == nil {
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
- entnames = append(entnames, v["name"].(string))
|
|
|
- date := v["date"]
|
|
|
- cinfoarrAll = append(cinfoarrAll, &CustomerInfo{
|
|
|
- Name: v["name"].(string),
|
|
|
- Followdate: qu.FormatDateWithObj(&date, "2006/01/02"),
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- if (pageNo+1)*pageSize >= len(cinfoarrAll) {
|
|
|
- cinfoarr = cinfoarrAll[pageNo*pageSize:]
|
|
|
- } else {
|
|
|
- cinfoarr = cinfoarrAll[pageNo*pageSize : (pageNo+1)*pageSize]
|
|
|
- }
|
|
|
- count := len(cinfoarrAll)
|
|
|
- entinfolist := GetEntCusInfo(entnames)
|
|
|
- if len(entinfolist) > 0 {
|
|
|
- L:
|
|
|
- for _, v := range entinfolist {
|
|
|
- for _, ev := range cinfoarr {
|
|
|
- (*ev).CustomerId = qu.SE.Encode2HexByCheck(fmt.Sprint(customerMap[(*ev).Name]))
|
|
|
- if (*ev).Name == qu.ObjToString(v["buyer_name"]) {
|
|
|
- (*ev).Province = qu.ObjToString(v["province"])
|
|
|
- (*ev).Buyerclass = qu.ObjToString(v["buyerclass"])
|
|
|
- continue L
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return cinfoarr, total, BigMsg.Customers, count
|
|
|
+ clist, ok := db.Mgo.Find(fc, query, `{"date":-1}`, `{"name":1,"date":1}`, false, 0, BigMsg.Customers)
|
|
|
+ if ok && clist != nil && len(*clist) > 0 {
|
|
|
+ total = len(*clist)
|
|
|
+ for _, v := range *clist {
|
|
|
+ if keyword != "" && !strings.Contains(qu.ObjToString(v["name"]), keyword) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ switch isCliam {
|
|
|
+ case "0":
|
|
|
+ if customerMap[qu.ObjToString(v["name"])] != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ case "1":
|
|
|
+ if customerMap[qu.ObjToString(v["name"])] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ entnames = append(entnames, v["name"].(string))
|
|
|
+ date := v["date"]
|
|
|
+ cinfoarrAll = append(cinfoarrAll, &CustomerInfo{
|
|
|
+ Name: v["name"].(string),
|
|
|
+ Followdate: qu.FormatDateWithObj(&date, "2006/01/02"),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ count := len(cinfoarrAll)
|
|
|
+ if count > 0 {
|
|
|
+ if (pageNo+1)*pageSize >= len(cinfoarrAll) {
|
|
|
+ cinfoarr = cinfoarrAll[pageNo*pageSize:]
|
|
|
+ } else {
|
|
|
+ cinfoarr = cinfoarrAll[pageNo*pageSize : (pageNo+1)*pageSize]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ entinfolist := GetEntCusInfo(entnames)
|
|
|
+ if len(entinfolist) > 0 {
|
|
|
+ L:
|
|
|
+ for _, v := range entinfolist {
|
|
|
+ for _, ev := range cinfoarr {
|
|
|
+ (*ev).CustomerId = qu.SE.Encode2HexByCheck(fmt.Sprint(customerMap[(*ev).Name]))
|
|
|
+ if (*ev).Name == qu.ObjToString(v["buyer_name"]) {
|
|
|
+ (*ev).Province = qu.ObjToString(v["province"])
|
|
|
+ (*ev).Buyerclass = qu.ObjToString(v["buyerclass"])
|
|
|
+ continue L
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cinfoarr, total, BigMsg.Customers, count
|
|
|
}
|
|
|
|
|
|
var pcquery = `{"query": {"bool": {"must": [{"terms": {"%s": [%s]}}],"must_not": [],"should": []}},"sort": []}`
|
|
|
|
|
|
// 获取企业-客户信息
|
|
|
func GetEntCusInfo(entnames []string) []map[string]interface{} {
|
|
|
- query := fmt.Sprintf(pcquery, "buyer_name", `"`+strings.Join(entnames, `","`)+`"`)
|
|
|
- list := *elastic.Get("buyer", "buyer", query)
|
|
|
- return list
|
|
|
+ query := fmt.Sprintf(pcquery, "buyer_name", `"`+strings.Join(entnames, `","`)+`"`)
|
|
|
+ list := *elastic.Get("buyer", "buyer", query)
|
|
|
+ return list
|
|
|
}
|
|
|
|
|
|
// 权限查询
|
|
|
func (this *CustomerOperation) CheckPower() string {
|
|
|
- msg := ""
|
|
|
- if this.UserId == "" {
|
|
|
- msg = "登录异常"
|
|
|
- } else {
|
|
|
- //查询是否是大会员
|
|
|
- if userPower := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo); userPower.Status > 0 {
|
|
|
- count := redis.GetInt(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
- if count < 1 {
|
|
|
- query := map[string]interface{}{
|
|
|
- "userId": this.UserId,
|
|
|
- }
|
|
|
- count = db.Mgo.Count(fc, query)
|
|
|
- }
|
|
|
- if count >= 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)
|
|
|
+ msg := ""
|
|
|
+ if this.UserId == "" {
|
|
|
+ msg = "登录异常"
|
|
|
+ } else {
|
|
|
+ //查询是否是大会员
|
|
|
+ if userPower := jy.GetBigVipUserBaseMsg(this.UserId, db.Mysql, db.Mgo); userPower.Status > 0 {
|
|
|
+ count := redis.GetInt(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
+ if count < 1 {
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "userId": this.UserId,
|
|
|
+ }
|
|
|
+ count = db.Mgo.Count(fc, query)
|
|
|
+ }
|
|
|
+ if count >= 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 {
|
|
|
- msg = "暂无关注客户权限"
|
|
|
- }
|
|
|
- }
|
|
|
- return msg
|
|
|
+ } else {
|
|
|
+ msg = "暂无关注客户权限"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return msg
|
|
|
}
|
|
|
|
|
|
func EntCheckPower(userId string, entId int) (msg string) {
|
|
|
- query := map[string]interface{}{
|
|
|
- "ent_id": entId,
|
|
|
- }
|
|
|
+ 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)
|
|
|
- }
|
|
|
- }
|
|
|
+ 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
|
|
|
+ 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) {
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "userId": this.UserId,
|
|
|
- "name": this.Name,
|
|
|
- }
|
|
|
- //取关
|
|
|
- if this.B {
|
|
|
- B = db.Mgo.Del(fc, queryMap)
|
|
|
- } else {
|
|
|
- timeNow := time.Now()
|
|
|
- updateMap := map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "date": timeNow.Unix(),
|
|
|
- "userId": this.UserId,
|
|
|
- "name": this.Name,
|
|
|
- "province": this.Province,
|
|
|
- "city": this.City,
|
|
|
- },
|
|
|
- }
|
|
|
- B = db.Mgo.Update(fc, queryMap, updateMap, true, false)
|
|
|
- }
|
|
|
- redis.Del(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
- if B {
|
|
|
- go func(userId string) {
|
|
|
- //删除首页客户缓存
|
|
|
- redis.DelByCodePattern(redisName, fmt.Sprintf("CRIndex_new_%s_*", userId))
|
|
|
- //首页潜在客户缓存
|
|
|
- redis.Del(redisName, fmt.Sprintf(redisCRIndex, this.UserId))
|
|
|
- //更新redis 客户数据
|
|
|
- clist, ok := db.Mgo.Find(fc, map[string]interface{}{
|
|
|
- "userId": userId,
|
|
|
- }, nil, `{"name":1}`, false, -1, -1)
|
|
|
- // fmt.Println(clist)
|
|
|
- if ok && clist != nil && len(*clist) > 0 {
|
|
|
- names := []string{}
|
|
|
- for _, v := range *clist {
|
|
|
- names = append(names, v["name"].(string))
|
|
|
- }
|
|
|
- if len(names) > 0 {
|
|
|
- redis.Put(redisName, fmt.Sprintf(redisListKey, userId), strings.Join(names, ","), 2*60*60)
|
|
|
- }
|
|
|
- }
|
|
|
- }(this.UserId)
|
|
|
- }
|
|
|
- return B
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
+ "userId": this.UserId,
|
|
|
+ "name": this.Name,
|
|
|
+ }
|
|
|
+ //取关
|
|
|
+ if this.B {
|
|
|
+ B = db.Mgo.Del(fc, queryMap)
|
|
|
+ } else {
|
|
|
+ timeNow := time.Now()
|
|
|
+ updateMap := map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "date": timeNow.Unix(),
|
|
|
+ "userId": this.UserId,
|
|
|
+ "name": this.Name,
|
|
|
+ "province": this.Province,
|
|
|
+ "city": this.City,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ B = db.Mgo.Update(fc, queryMap, updateMap, true, false)
|
|
|
+ }
|
|
|
+ redis.Del(redisName, fmt.Sprintf(redisCountKey, this.UserId))
|
|
|
+ if B {
|
|
|
+ go func(userId string) {
|
|
|
+ //删除首页客户缓存
|
|
|
+ redis.DelByCodePattern(redisName, fmt.Sprintf("CRIndex_new_%s_*", userId))
|
|
|
+ //首页潜在客户缓存
|
|
|
+ redis.Del(redisName, fmt.Sprintf(redisCRIndex, this.UserId))
|
|
|
+ //更新redis 客户数据
|
|
|
+ clist, ok := db.Mgo.Find(fc, map[string]interface{}{
|
|
|
+ "userId": userId,
|
|
|
+ }, nil, `{"name":1}`, false, -1, -1)
|
|
|
+ // fmt.Println(clist)
|
|
|
+ if ok && clist != nil && len(*clist) > 0 {
|
|
|
+ names := []string{}
|
|
|
+ for _, v := range *clist {
|
|
|
+ names = append(names, v["name"].(string))
|
|
|
+ }
|
|
|
+ if len(names) > 0 {
|
|
|
+ redis.Put(redisName, fmt.Sprintf(redisListKey, userId), strings.Join(names, ","), 2*60*60)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(this.UserId)
|
|
|
+ }
|
|
|
+ return B
|
|
|
}
|