Browse Source

fix:提交程序报错

wangkaiyue 3 years ago
parent
commit
426f144396
2 changed files with 294 additions and 292 deletions
  1. 2 1
      src/jfw/front/shorturl.go
  2. 292 291
      src/jfw/modules/app/src/app/front/shorturl.go

+ 2 - 1
src/jfw/front/shorturl.go

@@ -438,7 +438,8 @@ func CNode(userId string) bool {
 //查看公告详情次数限制
 func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
 	watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
-	if strings.Contains(obj["subtype"].(string), "拟建") || strings.Contains(obj["subtype"].(string), "采购意向") {
+	subTypeStr, _ := obj["subtype"].(string)
+	if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
 		return false
 	} else {
 		//检验是否留资

+ 292 - 291
src/jfw/modules/app/src/app/front/shorturl.go

@@ -1,344 +1,345 @@
 package front
 
 import (
-    "database/sql"
-    "fmt"
-    "jfw/config"
-    "strconv"
-    "strings"
-    "time"
+	"database/sql"
+	"fmt"
+	"jfw/config"
+	"strconv"
+	"strings"
+	"time"
 
-    //"math/rand"
-    . "app/jyutil"
-    "jfw/public"
-    "log"
-    "qfw/util"
-    "qfw/util/jy"
-    "qfw/util/redis"
+	//"math/rand"
+	. "app/jyutil"
+	"jfw/public"
+	"log"
+	"qfw/util"
+	"qfw/util/jy"
+	"qfw/util/redis"
 
-    "github.com/go-xweb/xweb"
+	"github.com/go-xweb/xweb"
 )
 
 type Short struct {
-    *xweb.Action
-    article     xweb.Mapper `xweb:"/jyapp/article/(\\w+)/(.*).html"` //([pm])
-    replication xweb.Mapper `xweb:"/jyapp/shorturl/replication"`     //用户复制操作记录入库
+	*xweb.Action
+	article     xweb.Mapper `xweb:"/jyapp/article/(\\w+)/(.*).html"` //([pm])
+	replication xweb.Mapper `xweb:"/jyapp/shorturl/replication"`     //用户复制操作记录入库
 }
 
 func init() {
-    xweb.AddAction(&Short{})
+	xweb.AddAction(&Short{})
 }
 
 var DateFullLayout = "2006-01-02 15:04:05"
 var suffix_msgt = "_SX"
 
 func (s *Short) Article(stype, id string) error {
-    //先判断是否有session
-    userId, _ := s.GetSession("userId").(string)
+	//先判断是否有session
+	userId, _ := s.GetSession("userId").(string)
 
-    if userId == "" {
-        return s.Redirect("/jyapp/free/swordfish/about", 302)
-    }
-    disWord := s.GetString("disWord")
-    belongUserId := GetbelongUserId(disWord, userId)
-    b, _ := redis.Exists("sso", "req_"+userId)
-    if b {
-        return s.Redirect("/jyapp/free/mob/err")
-    }
+	if userId == "" {
+		return s.Redirect("/jyapp/free/swordfish/about", 302)
+	}
+	disWord := s.GetString("disWord")
+	belongUserId := GetbelongUserId(disWord, userId)
+	b, _ := redis.Exists("sso", "req_"+userId)
+	if b {
+		return s.Redirect("/jyapp/free/mob/err")
+	}
 
-    isVip, isEntniche, i_member_status, email := UserPermission(userId)
-    s.T["isVip"] = isVip
-    s.T["member_status"] = i_member_status
-    s.T["email"] = email
-    s.T["isEntniche"] = isEntniche
-    s.T["isMember"] = i_member_status > 0
-    surl := s.GetString("url")
-    kds := s.GetString("keywords")
-    industry := s.GetString("industry")
-    var sid string
-    sid_openid := util.CommonDecodeArticle(stype, id)
-    if len(sid_openid) == 0 {
-        return s.Redirect("/jyapp/free/swordfish/about", 302)
-    } else {
-        sid = sid_openid[0]
-    }
+	isVip, isEntniche, i_member_status, email := UserPermission(userId)
+	s.T["isVip"] = isVip
+	s.T["member_status"] = i_member_status
+	s.T["email"] = email
+	s.T["isEntniche"] = isEntniche
+	s.T["isMember"] = i_member_status > 0
+	surl := s.GetString("url")
+	kds := s.GetString("keywords")
+	industry := s.GetString("industry")
+	var sid string
+	sid_openid := util.CommonDecodeArticle(stype, id)
+	if len(sid_openid) == 0 {
+		return s.Redirect("/jyapp/free/swordfish/about", 302)
+	} else {
+		sid = sid_openid[0]
+	}
 
-    s.T["keywords"] = kds
-    var obj map[string]interface{}
-    obj = wxvisitD(sid, userId, isVip || isEntniche || i_member_status > 0)
-    if isVip || i_member_status > 0 || isEntniche {
-        s.T["canRead"] = true
-    } else {
-        watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
-        if strings.Contains(obj["subtype"].(string), "拟建") || strings.Contains(obj["subtype"].(string), "采购意向") {
-            s.T["canRead"] = false
-        } else {
-            if seeRes := redis.Get("other", watchKey); seeRes != nil && seeRes != "" {
-                if resVal, _ := seeRes.(string); resVal != "" {
-                    sidss := strings.Split(resVal, "_")
-                    canRead := config.Sysconfig["canReadNotice"]
-                    if len(sidss) < util.IntAll(canRead) {
-                        s.T["canRead"] = true
-                        sidss = append(sidss, sid)
-                        arrs := RemoveDuplicatesAndEmpty(sidss)
-                        newVal := strings.Join(arrs, "_")
-                        redis.Put("other", watchKey, newVal, jy.GetExpire())
-                    } else {
-                        s.T["canRead"] = false
-                        for _, v := range sidss {
-                            if sid == v {
-                                s.T["canRead"] = true
-                                break
-                            }
-                        }
-                    }
-                }
-            } else {
-                redis.Put("other", watchKey, sid, jy.GetExpire())
-                s.T["canRead"] = true
-            }
-            //检验是否留资
-            ok := CNode(userId)
-            if ok {
-                s.T["canRead"] = true
-            }
-        }
-    }
+	s.T["keywords"] = kds
+	var obj map[string]interface{}
+	obj = wxvisitD(sid, userId, isVip || isEntniche || i_member_status > 0)
+	if isVip || i_member_status > 0 || isEntniche {
+		s.T["canRead"] = true
+	} else {
+		watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
+		subTypeStr, _ := obj["subtype"].(string)
+		if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
+			s.T["canRead"] = false
+		} else {
+			if seeRes := redis.Get("other", watchKey); seeRes != nil && seeRes != "" {
+				if resVal, _ := seeRes.(string); resVal != "" {
+					sidss := strings.Split(resVal, "_")
+					canRead := config.Sysconfig["canReadNotice"]
+					if len(sidss) < util.IntAll(canRead) {
+						s.T["canRead"] = true
+						sidss = append(sidss, sid)
+						arrs := RemoveDuplicatesAndEmpty(sidss)
+						newVal := strings.Join(arrs, "_")
+						redis.Put("other", watchKey, newVal, jy.GetExpire())
+					} else {
+						s.T["canRead"] = false
+						for _, v := range sidss {
+							if sid == v {
+								s.T["canRead"] = true
+								break
+							}
+						}
+					}
+				}
+			} else {
+				redis.Put("other", watchKey, sid, jy.GetExpire())
+				s.T["canRead"] = true
+			}
+			//检验是否留资
+			ok := CNode(userId)
+			if ok {
+				s.T["canRead"] = true
+			}
+		}
+	}
 
-    if len(obj) > 0 {
-        if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
-            article_id := util.CommonDecodeArticle(stype, id)[0]
-            key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId)
-            if redis.Incr("other", key) == 1 {
-                redis.SetExpire("other", key, 60*60*24)
-                err := jy.Publish(public.Mgo_Log, config.Sysconfig["nsq"].(string), jy.Jyweb_article_open, belongUserId, jy.Jyapp_node1)
-                if err != nil {
-                    log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, belongUserId)
-                } /* else {
-                	//integral_article_ +userId+ 三级页id
-                	redis.Put("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId), "1", 60*60*24)
-                }*/
-            }
-        }
-        //获取打赏文案
-        //util.ReadConfig(&config.Sysconfig)
-        s.T["rewardText"], s.T["advertText"] = getRewardText()
-        s.T["advertImg"] = config.Sysconfig["advertImg"]
-        s.T["advertName"] = config.Sysconfig["advertName"]
-        s.T["advertUrl"] = config.Sysconfig["advertUrl"]
-        obj["industry"] = industry
-        obj["ucbsId"] = util.EncodeArticleId2ByCheck("ucbs#" + userId + "#" + id)
-        if obj["entidlist"] != nil { //大会员中标企业跳转至画像
-            if winner := util.ObjToString(obj["winner"]); winner != "" {
-                s_winner := util.ObjToString(obj["s_winner"])
-                idObjs, _ := obj["entidlist"].([]interface{})
-                winnerId := ""
-                if names := strings.Split(s_winner, ","); len(names) > 1 {
-                    index := 0
-                    for i := 0; i < len(names); i++ {
-                        if names[i] == winner {
-                            index = i
-                            break
-                        }
-                    }
-                    if len(idObjs) > index {
-                        winnerId = util.ObjToString(idObjs[index])
-                    }
-                } else { //中标企业仅一个
-                    if len(idObjs) > 0 {
-                        winnerId = util.ObjToString(idObjs[0])
-                    }
-                }
-                if winnerId != "" && winnerId != "-" {
-                    obj["entId"] = util.EncodeArticleId2ByCheck(winnerId)
-                }
-            }
-        }
-        s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
-        if obj["winnertel"] == nil && isbid(obj["subtype"]) {
-            obj["winner_enttel"] = getwinnertel(obj["winner"])
-        }
-        if !(isVip || i_member_status > 0 || isEntniche) { //非会员不展示电话字段
-            if obj["winnertel"] != nil {
-                obj["winnertel"] = "无权限"
-            }
-            if obj["winner_enttel"] != "" {
-                obj["winner_enttel"] = "无权限"
-            }
-        }
+	if len(obj) > 0 {
+		if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
+			article_id := util.CommonDecodeArticle(stype, id)[0]
+			key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId)
+			if redis.Incr("other", key) == 1 {
+				redis.SetExpire("other", key, 60*60*24)
+				err := jy.Publish(public.Mgo_Log, config.Sysconfig["nsq"].(string), jy.Jyweb_article_open, belongUserId, jy.Jyapp_node1)
+				if err != nil {
+					log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, belongUserId)
+				} /* else {
+					//integral_article_ +userId+ 三级页id
+					redis.Put("other", fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, userId), "1", 60*60*24)
+				}*/
+			}
+		}
+		//获取打赏文案
+		//util.ReadConfig(&config.Sysconfig)
+		s.T["rewardText"], s.T["advertText"] = getRewardText()
+		s.T["advertImg"] = config.Sysconfig["advertImg"]
+		s.T["advertName"] = config.Sysconfig["advertName"]
+		s.T["advertUrl"] = config.Sysconfig["advertUrl"]
+		obj["industry"] = industry
+		obj["ucbsId"] = util.EncodeArticleId2ByCheck("ucbs#" + userId + "#" + id)
+		if obj["entidlist"] != nil { //大会员中标企业跳转至画像
+			if winner := util.ObjToString(obj["winner"]); winner != "" {
+				s_winner := util.ObjToString(obj["s_winner"])
+				idObjs, _ := obj["entidlist"].([]interface{})
+				winnerId := ""
+				if names := strings.Split(s_winner, ","); len(names) > 1 {
+					index := 0
+					for i := 0; i < len(names); i++ {
+						if names[i] == winner {
+							index = i
+							break
+						}
+					}
+					if len(idObjs) > index {
+						winnerId = util.ObjToString(idObjs[index])
+					}
+				} else { //中标企业仅一个
+					if len(idObjs) > 0 {
+						winnerId = util.ObjToString(idObjs[0])
+					}
+				}
+				if winnerId != "" && winnerId != "-" {
+					obj["entId"] = util.EncodeArticleId2ByCheck(winnerId)
+				}
+			}
+		}
+		s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
+		if obj["winnertel"] == nil && isbid(obj["subtype"]) {
+			obj["winner_enttel"] = getwinnertel(obj["winner"])
+		}
+		if !(isVip || i_member_status > 0 || isEntniche) { //非会员不展示电话字段
+			if obj["winnertel"] != nil {
+				obj["winnertel"] = "无权限"
+			}
+			if obj["winner_enttel"] != "" {
+				obj["winner_enttel"] = "无权限"
+			}
+		}
 
-        s.T["obj"] = obj
-        s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail)
-        s.T["isIosExam"], s.T["isIosExamPhone"], _, _ = IosExamInfo(s.Action, false, false)
-        content, _ := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
-        return s.SetBody(content)
-    }
-    if surl != "" {
-        return s.Redirect(surl)
-    }
-    return s.Redirect("/jyapp/free/mob/err")
+		s.T["obj"] = obj
+		s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail)
+		s.T["isIosExam"], s.T["isIosExamPhone"], _, _ = IosExamInfo(s.Action, false, false)
+		content, _ := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
+		return s.SetBody(content)
+	}
+	if surl != "" {
+		return s.Redirect(surl)
+	}
+	return s.Redirect("/jyapp/free/mob/err")
 }
 
 func CNode(userId string) bool {
-    if hasRetainedCapital(userId, "jyarticle_see3_plus") {
-        return true
-    }
-    rM := map[string]interface{}{}
-    rdata, ok := mongodb.Find("saleLeads", map[string]interface{}{
-        "userid": userId,
-    }, `{"createtime":-1}`, nil, false, 0, 10)
-    if rdata != nil && len(*rdata) > 0 && ok {
-        for _, v := range *rdata {
-            for kk, vv := range v {
-                if vv == nil {
-                    continue
-                }
-                if rM[kk] != nil {
-                    continue
-                }
-                rM[kk] = vv
-            }
-        }
-        delete(rM, "_id")
-        delete(rM, "userid")
-        delete(rM, "createtime")
-        delete(rM, "client")
-    }
-    if userinfo, ok := mongodb.FindById("user", userId, `{"s_phone":1,"s_m_phone":1,"s_myemail":1,"s_company":1,"o_jy":1,"o_vipjy":1}`); userinfo != nil && ok && len(*userinfo) > 0 {
-        s_phone := util.ObjToString((*userinfo)["s_phone"])
-        phone := util.If(s_phone == "", util.ObjToString((*userinfo)["s_m_phone"]), s_phone)
-        if rM["phone"] == nil || rM["phone"] == "" {
-            rM["phone"] = phone
-        }
-        if rM["company"] == nil || rM["company"] == "" {
-            rM["company"] = util.ObjToString((*userinfo)["s_company"])
-        }
-    }
-    if rM["name"] != nil && rM["name"] != "" && rM["phone"] != nil && rM["phone"] != "" && rM["company"] != nil && rM["company"] != "" && rM["position"] != nil && rM["position"] != "" {
+	if hasRetainedCapital(userId, "jyarticle_see3_plus") {
+		return true
+	}
+	rM := map[string]interface{}{}
+	rdata, ok := mongodb.Find("saleLeads", map[string]interface{}{
+		"userid": userId,
+	}, `{"createtime":-1}`, nil, false, 0, 10)
+	if rdata != nil && len(*rdata) > 0 && ok {
+		for _, v := range *rdata {
+			for kk, vv := range v {
+				if vv == nil {
+					continue
+				}
+				if rM[kk] != nil {
+					continue
+				}
+				rM[kk] = vv
+			}
+		}
+		delete(rM, "_id")
+		delete(rM, "userid")
+		delete(rM, "createtime")
+		delete(rM, "client")
+	}
+	if userinfo, ok := mongodb.FindById("user", userId, `{"s_phone":1,"s_m_phone":1,"s_myemail":1,"s_company":1,"o_jy":1,"o_vipjy":1}`); userinfo != nil && ok && len(*userinfo) > 0 {
+		s_phone := util.ObjToString((*userinfo)["s_phone"])
+		phone := util.If(s_phone == "", util.ObjToString((*userinfo)["s_m_phone"]), s_phone)
+		if rM["phone"] == nil || rM["phone"] == "" {
+			rM["phone"] = phone
+		}
+		if rM["company"] == nil || rM["company"] == "" {
+			rM["company"] = util.ObjToString((*userinfo)["s_company"])
+		}
+	}
+	if rM["name"] != nil && rM["name"] != "" && rM["phone"] != nil && rM["phone"] != "" && rM["company"] != nil && rM["company"] != "" && rM["position"] != nil && rM["position"] != "" {
 
-        if rM["position"] != "总裁" && rM["position"] != "总经理" && (rM["branch"] == nil || rM["branch"] == "") {
-            return false
-        }
-        return true
+		if rM["position"] != "总裁" && rM["position"] != "总经理" && (rM["branch"] == nil || rM["branch"] == "") {
+			return false
+		}
+		return true
 
-    }
-    return false
+	}
+	return false
 }
 
 func GetbelongUserId(disWord, userId string) (belongUserId string) {
-    if disWord != "" {
-        redisDis := redis.GetStr("other", "DIS_"+disWord[1:])
-        if redisDis != "" {
-            suffix := disWord[len(disWord)-3:]
-            //公告三级页处理
-            if suffix == suffix_msgt {
-                effectiveTimeStr := strings.Split(redisDis, "##")[3]
-                effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
-                //是否计算佣金
-                if time.Now().Unix() <= effectiveTime {
-                    belongUserId = strings.Split(redisDis, "##")[1]
-                    public.Mysql.ExecTx("口号使用", func(tx *sql.Tx) bool {
-                        //口号是否使用过
-                        wordInfo := public.Mysql.Find("dis_word", map[string]interface{}{"userId": userId, "password": disWord}, "id", "", 0, 0)
-                        if len((*wordInfo)) == 0 {
-                            //新增口号使用
-                            start_time := time.Now().Format(DateFullLayout)
-                            termValidityInt, _ := strconv.Atoi(fmt.Sprint(config.Sysconfig["termValidity"]))
-                            stop_time := TimeProcessing(time.Now().Format(DateFullLayout), termValidityInt).Format(DateFullLayout)
-                            insert := map[string]interface{}{
-                                "password":      disWord,
-                                "userId":        userId,
-                                "belong_userid": belongUserId,
-                                "start_time":    start_time,
-                                "stop_time":     stop_time,
-                            }
-                            insert_1 := public.Mysql.InsertByTx(tx, "dis_word", insert) //口号使用表
-                            log.Println("插入口号使用表", insert_1)
-                        }
-                        return true
-                    })
-                }
-            }
-        }
-    }
-    return
+	if disWord != "" {
+		redisDis := redis.GetStr("other", "DIS_"+disWord[1:])
+		if redisDis != "" {
+			suffix := disWord[len(disWord)-3:]
+			//公告三级页处理
+			if suffix == suffix_msgt {
+				effectiveTimeStr := strings.Split(redisDis, "##")[3]
+				effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
+				//是否计算佣金
+				if time.Now().Unix() <= effectiveTime {
+					belongUserId = strings.Split(redisDis, "##")[1]
+					public.Mysql.ExecTx("口号使用", func(tx *sql.Tx) bool {
+						//口号是否使用过
+						wordInfo := public.Mysql.Find("dis_word", map[string]interface{}{"userId": userId, "password": disWord}, "id", "", 0, 0)
+						if len((*wordInfo)) == 0 {
+							//新增口号使用
+							start_time := time.Now().Format(DateFullLayout)
+							termValidityInt, _ := strconv.Atoi(fmt.Sprint(config.Sysconfig["termValidity"]))
+							stop_time := TimeProcessing(time.Now().Format(DateFullLayout), termValidityInt).Format(DateFullLayout)
+							insert := map[string]interface{}{
+								"password":      disWord,
+								"userId":        userId,
+								"belong_userid": belongUserId,
+								"start_time":    start_time,
+								"stop_time":     stop_time,
+							}
+							insert_1 := public.Mysql.InsertByTx(tx, "dis_word", insert) //口号使用表
+							log.Println("插入口号使用表", insert_1)
+						}
+						return true
+					})
+				}
+			}
+		}
+	}
+	return
 }
 
 func TimeProcessing(hour interface{}, duration int) time.Time {
-    todayZero, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprint(hour), time.Local)
-    mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
-    t := todayZero.Add(mm)
-    return t
+	todayZero, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprint(hour), time.Local)
+	mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
+	t := todayZero.Add(mm)
+	return t
 }
 
 //三级页复制操作记录
 func (s *Short) Replication() {
-    mongodb.Save("copyaction", map[string]interface{}{
-        "userid":     s.GetSession("userId").(string),
-        "createtime": time.Now().Unix(),
-        "url":        s.Request.Referer(),
-        "client":     s.Header("User-Agent"),
-    })
+	mongodb.Save("copyaction", map[string]interface{}{
+		"userid":     s.GetSession("userId").(string),
+		"createtime": time.Now().Unix(),
+		"url":        s.Request.Referer(),
+		"client":     s.Header("User-Agent"),
+	})
 }
 
 func isbid(typ interface{}) bool {
-    if typ != nil {
-        subtype := util.ObjToString(typ)
-        if subtype == "中标" || subtype == "合同" || subtype == "成交" {
-            return true
-        }
-    }
-    return false
+	if typ != nil {
+		subtype := util.ObjToString(typ)
+		if subtype == "中标" || subtype == "合同" || subtype == "成交" {
+			return true
+		}
+	}
+	return false
 }
 
 func getwinnertel(company interface{}) string {
-    if company != nil {
-        data, _ := public.Mgo_Ent.FindOne("winner_enterprise", map[string]interface{}{
-            "company_name": util.ObjToString(company),
-        })
-        if (*data)["company_phone"] != nil {
-            return util.ObjToString((*data)["company_phone"])
-        }
-    }
-    return ""
+	if company != nil {
+		data, _ := public.Mgo_Ent.FindOne("winner_enterprise", map[string]interface{}{
+			"company_name": util.ObjToString(company),
+		})
+		if (*data)["company_phone"] != nil {
+			return util.ObjToString((*data)["company_phone"])
+		}
+	}
+	return ""
 }
 
 func UserPermission(userId string) (isVip, isEntniche bool, i_member_status int, email string) {
-    var phone string
-    data, ok := mongodb.FindById("user", userId, `{"i_vip_status":1,"i_member_status":1,"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
-    if ok && data != nil && len(*data) > 0 {
-        i_vip_status := util.IntAll((*data)["i_vip_status"])
-        if i_vip_status > 0 {
-            isVip = true
-        }
-        i_member_status = util.IntAllDef((*data)["i_member_status"], 0)
-        email = util.ObjToStringDef((*data)["s_myemail"], "")
-        if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
-            phone = s_phone
-        } else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
-            phone = s_m_phone
-        }
-    }
-    if public.Mysql.CountBySql(`select count(1) from entniche_user where phone=? and power=1`, phone) > 0 {
-        isEntniche = true
-    }
-    return
+	var phone string
+	data, ok := mongodb.FindById("user", userId, `{"i_vip_status":1,"i_member_status":1,"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
+	if ok && data != nil && len(*data) > 0 {
+		i_vip_status := util.IntAll((*data)["i_vip_status"])
+		if i_vip_status > 0 {
+			isVip = true
+		}
+		i_member_status = util.IntAllDef((*data)["i_member_status"], 0)
+		email = util.ObjToStringDef((*data)["s_myemail"], "")
+		if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
+			phone = s_phone
+		} else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
+			phone = s_m_phone
+		}
+	}
+	if public.Mysql.CountBySql(`select count(1) from entniche_user where phone=? and power=1`, phone) > 0 {
+		isEntniche = true
+	}
+	return
 }
 func RemoveDuplicatesAndEmpty(a []string) (ret []string) {
-    a_len := len(a)
-    for i := 0; i < a_len; i++ {
-        if (i > 0 && a[i-1] == a[i]) || len(a[i]) == 0 {
-            continue
-        }
-        ret = append(ret, a[i])
-    }
-    return
+	a_len := len(a)
+	for i := 0; i < a_len; i++ {
+		if (i > 0 && a[i-1] == a[i]) || len(a[i]) == 0 {
+			continue
+		}
+		ret = append(ret, a[i])
+	}
+	return
 }
 
 //该节点是否留资
 func hasRetainedCapital(uid, source string) bool {
-    if count, err := mongodb.CountByErr("saleLeads", map[string]interface{}{"userid": uid, "source": source}); err != nil || count > 0 {
-        return true
-    }
-    return false
+	if count, err := mongodb.CountByErr("saleLeads", map[string]interface{}{"userid": uid, "source": source}); err != nil || count > 0 {
+		return true
+	}
+	return false
 }