wangshan 2 жил өмнө
parent
commit
ad1027664d

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

@@ -414,7 +414,8 @@ func (d *DataExport) SuperSearchExport() error {
 		WordsMode:       wordsMode,                                   //搜索关键词模式;默认0:包含所有,1:包含任意
 		AdditionalWords: d.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 	}
-	selectType := strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId).GetQueryItems(d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
+	entId := util.IntAll(d.GetSession("entId"))
+	selectType := strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId, entId).GetQueryItems(d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	//数据回显
 	d.SetSession("Echo_timeslot", d.GetString("timeslot"))
 	d.SetSession("Echo_keywords", reqData.Keywords)

+ 11 - 2
src/jfw/front/supsearch.go

@@ -241,12 +241,13 @@ func (p *Pcsearch) GetNewBids() error {
 	bidField := p.GetString("bid_field")
 	userId, _ := p.GetSession("userId").(string)
 	baseUserId, _ := p.GetSession("base_user_id").(string)
+	entId := util.IntAll(p.GetSession("entId"))
 	// 如果是领域化数据
 	if bidField != "" {
 		if domainPageType, ok := DomainPageType[bidField]; ok {
 			pageType = domainPageType
 		}
-		vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
+		vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 		if (vipStatus.BigMember <= 0 && vipStatus.VipState <= 0) || (!jy.HasBidFieldPower(config.ResourceApi.HasPowers, fmt.Sprint(util.Int64All(baseUserId)), MedicalFunctionCode)) {
 			p.ServeJson(map[string]interface{}{
 				"list":      []map[string]interface{}{},
@@ -344,6 +345,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	userId, _ := p.GetSession("userId").(string)
 	phone, _ := p.GetSession("phone").(string)
 	baseUserId := p.GetSession("base_user_id")
+	entId := util.IntAll(p.GetSession("entId"))
 	noLoginBl := false
 	if userId == "" {
 		//未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
@@ -364,7 +366,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	if selectType == "" {
 		selectType = "title,content"
 	}
-	userInfo := jy.GetVipState(public.Mysql, public.MQFW, userId)
+	userInfo := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 	queryItems := userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 	isPayedUser := userInfo.IsPayedUser()
 	//isPayedUser, publishtime, queryItems, _, _ := bidsearch.PublicSearch(userId, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), 0, pageSize)
@@ -517,6 +519,13 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	p.T["wordsMode"] = wordsMode
 	p.T["additionalWords"] = additionalWords
 	p.T["total"] = total
+
+	p.T["isVip"] = userInfo.VipState > 0
+	p.T["isMember"] = userInfo.BigMember > 0
+	p.T["isEntniche"] = userInfo.EntMember > 0
+	p.T["isEntnicheNew"] = userInfo.IsNewEnt
+	p.T["isEntService"] = userInfo.EntService
+	p.T["isOldVip"] = userInfo.VipState > 0 && userInfo.RegisterData < util.Int64All(config.Sysconfig["contextOldVipLimit"])
 	//
 	if userId != "" {
 		//企业画像 权限

+ 9 - 5
src/jfw/front/swordfish.go

@@ -84,6 +84,7 @@ func (m *Front) PcAjaxReq() {
 	tabularflag := m.GetString("tabularflag")
 	userId := util.ObjToString(m.GetSession("userId"))
 	phone := util.ObjToString(m.GetSession("phone"))
+	entId := util.IntAll(m.GetSession("entId"))
 	baseUserId := m.GetSession("base_user_id")
 	currentPage, _ := m.GetInteger("pageNumber")
 	pageSize, _ := m.GetInteger("pageSize")
@@ -95,7 +96,7 @@ func (m *Front) PcAjaxReq() {
 		//判断用户是否登录进行表格查询,否则返回基本数据
 		tabularflag = ""
 	}
-	userInfo := jy.GetVipState(public.Mysql, public.MQFW, userId)
+	userInfo := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 	if territorialization != "" { // 如果是领域化数据 判断是否是付费用户 是否有权限
 		if (userInfo.BigMember <= 0 && userInfo.VipState <= 0) || (!jy.HasBidFieldPower(config.ResourceApi.HasPowers, fmt.Sprint(util.Int64All(baseUserId)), MedicalFunctionCode)) {
 			m.ServeJson(map[string]interface{}{
@@ -190,6 +191,7 @@ func (m *Front) PcAjaxReq_Bak() {
 	bidField := m.GetString("bid_field") // 领域类型 0101- 医疗
 	tabularflag := m.GetString("tabularflag")
 	userId := util.ObjToString(m.GetSession("userId"))
+	entId := util.IntAll(m.GetSession("entId"))
 	baseUserId := m.GetSession("base_user_id")
 	currentPage, _ := m.GetInteger("pageNumber")
 	pageSize, _ := m.GetInteger("pageSize")
@@ -202,7 +204,7 @@ func (m *Front) PcAjaxReq_Bak() {
 	}
 	reqType := m.GetString("reqType")
 	if bidField != "" { // 如果是领域化数据 判断是否是付费用户 是否有权限
-		vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
+		vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 		if (vipStatus.BigMember <= 0 && vipStatus.VipState <= 0) || (!jy.HasBidFieldPower(config.ResourceApi.HasPowers, fmt.Sprint(util.Int64All(baseUserId)), MedicalFunctionCode)) {
 			m.ServeJson(map[string]interface{}{
 				"list": []map[string]interface{}{},
@@ -249,7 +251,7 @@ func (m *Front) PcAjaxReq_Bak() {
 		start                     int
 		city                      string //城市
 	)
-	isPayedUser, publishtime, queryItems, currentPage, start = bidsearch.PublicSearch(userId, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), currentPage, pageSize)
+	isPayedUser, publishtime, queryItems, currentPage, start = bidsearch.PublicSearch(userId, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), currentPage, pageSize, entId)
 	if isPayedUser {
 		buyerclass = m.GetString("buyerclass")
 		hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
@@ -467,6 +469,7 @@ func (m *Front) Getpage() error {
 func (m *Front) WxsearchlistPaging() {
 	defer util.Catch()
 	userId, _ := m.GetSession("userId").(string)
+	entId := util.IntAll(m.GetSession("entId"))
 	var list *[]map[string]interface{}
 	var b_word, a_word, secondFlag, secondKWS string
 	var secondList []map[string]interface{}
@@ -506,7 +509,7 @@ func (m *Front) WxsearchlistPaging() {
 			var fileExists = m.GetString("fileExists")    //是否有附件--所有用户都可用此功能 0:全部;1:有附件;-1:无附件
 			var city string = ""                          //城市
 
-			vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
+			vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 			isPayedUser = vipStatus.IsPayedUser()
 			queryItems := vipStatus.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 			if isPayedUser {
@@ -1953,7 +1956,8 @@ func (f *Front) HistorypushPaging() error {
 func (m *Front) Subscribe() error {
 	isBuyed := false
 	if userId, _ := m.GetSession("userId").(string); userId != "" {
-		vStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
+		entId := util.IntAll(m.GetSession("entId"))
+		vStatus := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 		isBuyed = vStatus.VipState > 0
 	}
 	m.T["isBuyed"] = isBuyed

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

@@ -375,8 +375,9 @@ func (wd *WsDataExport) SearchExport() error {
 		WordsMode:       wordsMode,                                    //搜索关键词模式;默认0:包含所有,1:包含任意
 		AdditionalWords: wd.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 	}
+	entId := util.IntAll(wd.GetSession("entId"))
 	saveData := reqData.PassBidSearchExport()
-	saveData["selectType"] = strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId).
+	saveData["selectType"] = strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId, entId).
 		GetQueryItems(wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	saveData["s_openid"] = openid
 	saveData["s_userid"] = userId

+ 2 - 1
src/jfw/modules/app/src/app/front/swordfish.go

@@ -227,6 +227,7 @@ func (m *Front) WxsearchlistPaging() {
 	pageNum, _ := m.GetInteger("pageNum")
 	searchvalue := strings.TrimSpace(m.GetString("searchvalue"))
 	userid := util.ObjToString(m.GetSession("userId"))
+	entId := util.IntAll(m.GetSession("entId"))
 	if userid != "" {
 		//历史记录
 		history := redis.GetStr("other", "s_"+userid)
@@ -264,7 +265,7 @@ func (m *Front) WxsearchlistPaging() {
 		var notkey string = ""                        //排除词
 		fileExists = m.GetString("fileExists")        //是否有附件--所有用户都可用此功能 0:全部;1:有附件;-1:无附件
 
-		isPayedUser, publishtime, queryItems, pageNum, _ = bidsearch.PublicSearch(userid, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), pageNum, 50)
+		isPayedUser, publishtime, queryItems, pageNum, _ = bidsearch.PublicSearch(userid, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), pageNum, 50, entId)
 		if isPayedUser {
 			buyerclass = m.GetString("buyerclass")
 			hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")

+ 2 - 2
src/jfw/modules/app/src/app/front/ws_dataExport.go

@@ -356,9 +356,9 @@ func (wd *WsDataExport) SearchExport() error {
 		WordsMode:       wordsMode,                                    //搜索关键词模式;默认0:包含所有,1:包含任意
 		AdditionalWords: wd.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 	}
-
+	entId := util.IntAll(wd.GetSession("entId"))
 	saveData := reqData.PassBidSearchExport()
-	saveData["selectType"] = strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId).
+	saveData["selectType"] = strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId, entId).
 		GetQueryItems(wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	saveData["s_openid"] = openid
 	saveData["s_userid"] = userId

+ 2 - 2
src/jfw/modules/common/src/qfw/util/bidsearch/search.go

@@ -387,9 +387,9 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
 	return
 }
 
-func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit int64, currentPage, pageSize int) (bool, string, []string, int, int) {
+func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit int64, currentPage, pageSize, entId int) (bool, string, []string, int, int) {
 	var start int
-	vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
+	vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId, entId)
 	isPayedUser := vipStatus.IsPayedUser()
 	queryItems := vipStatus.GetQueryItems(selectType, bidSearchOldUserLimit)
 

+ 25 - 16
src/jfw/modules/common/src/qfw/util/jy/payUser.go

@@ -20,9 +20,11 @@ type VipState struct {
 	BigMember    int   //大会员状态
 	EntMember    int   //商机管理用户状态
 	RegisterData int64 //注册时间
+	IsNewEnt     bool  //新版商机管理
+	EntService   bool  //企业服务权限
 }
 
-func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string) (vs *VipState) {
+func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string, entId int) (vs *VipState) {
 	vs = &VipState{}
 	if userId == "" {
 		return
@@ -30,28 +32,35 @@ func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string) (vs *
 	phone := ""
 	data, ok := mg.FindById("user", userId, `"i_member_status":1,"i_vip_status":1,"s_m_phone":1,"s_phone":1,"o_vipjy":1,"l_registedate":1`)
 	if data != nil && len(*data) > 0 && ok {
-		i_vip_status := qu.IntAll((*data)["i_vip_status"])
-		if i_vip_status > 1 {
+		iVipStatus := qu.IntAll((*data)["i_vip_status"])
+		if iVipStatus > 1 {
 			vs.VipState = 1
-			ovipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
-			if ovipjy["o_buyset"] != nil {
-				o_buyset := ovipjy["o_buyset"].(map[string]interface{})
-				if o_buyset["upgrade"] != nil {
+			oVipJY, _ := (*data)["o_vipjy"].(map[string]interface{})
+			if oVipJY["o_buyset"] != nil {
+				oBuySet := oVipJY["o_buyset"].(map[string]interface{})
+				if oBuySet["upgrade"] != nil {
 					vs.VipState = 2
 				}
 			}
 		}
-		if i_member_status := qu.IntAllDef((*data)["i_member_status"], 0); i_member_status > 0 {
-			vs.BigMember = i_member_status
+		if iMemberStatus := qu.IntAllDef((*data)["i_member_status"], 0); iMemberStatus > 0 {
+			vs.BigMember = iMemberStatus
 		}
-		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 sPhone, _ := (*data)["s_phone"].(string); sPhone != "" {
+			phone = sPhone
+		} else if sMPhone, _ := (*data)["s_m_phone"].(string); sMPhone != "" {
+			phone = sMPhone
 		}
-		if phone != "" {
-			if mysql.CountBySql(`select count(1) from entniche_user where phone = ? and power =1`, phone) > 0 {
-				vs.EntMember = 1
+		if phone != "" && entId > 0 {
+			entNicheInfos := mysql.SelectBySql(`SELECT i.status,i.isNew,i.power_source,r.role_id,u.power FROM (entniche_user u LEFT JOIN entniche_user_role r ON r.user_id = u.id)  LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone = ? and i.id = ? `, phone, entId)
+			//商机管理用户信息判断
+			if entNicheInfos != nil && len(*entNicheInfos) > 0 {
+				entNicheInfo := (*entNicheInfos)[0]
+				if qu.IntAll(entNicheInfo["status"]) > 0 && (qu.IntAll(entNicheInfo["power"]) == 1 || qu.IntAll(entNicheInfo["role_id"]) > 0) {
+					vs.EntMember = 1
+				}
+				vs.IsNewEnt = qu.Int64All(entNicheInfo["isNew"]) > 0
+				vs.EntService = qu.Int64All(entNicheInfo["power_source"]) > 0
 			}
 		}
 		vs.RegisterData, _ = ((*data)["l_registedate"]).(int64)

+ 4 - 2
src/jfw/modules/publicapply/src/attachmentdow/service/service.go

@@ -33,8 +33,9 @@ func (u *Dow) SupplyInfoFileDownload() {
 			return Result{Data: nil, Error_msg: "未登录"}
 		}
 
+		entId := qu.IntAll(u.GetSession("entId"))
 		BaseMsg := jy.GetBigVipUserBaseMsg(userid, db.Mysql, db.Mgo)
-		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid)
+		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid, entId)
 		isPower := false
 		//大会员下载权限判断
 		if BaseMsg.Status > 0 && BaseMsg.PowerMap[3] {
@@ -118,8 +119,9 @@ func (u *Dow) Subdow() {
 			return Result{Data: nil, Error_msg: "未登录"}
 		}
 
+		entId := qu.IntAll(u.GetSession("entId"))
 		BaseMsg := jy.GetBigVipUserBaseMsg(userid, db.Mysql, db.Mgo)
-		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid)
+		vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userid, entId)
 
 		var (
 			mon string

+ 13 - 14
src/jfw/modules/publicapply/src/userbase/entity/entity.go

@@ -1,18 +1,17 @@
 package entity
 
 import (
-	"config"
-	"db"
-	"encoding/json"
-	"fmt"
-	"net/url"
-	"qfw/util"
-	"qfw/util/jy"
-	"qfw/util/redis"
-	"strings"
-	"time"
-	"userbase/initjson"
-	. "userbase/initjson"
+    "config"
+    "db"
+    "encoding/json"
+    "fmt"
+    "net/url"
+    "qfw/util"
+    "qfw/util/jy"
+    "qfw/util/redis"
+    "strings"
+    "time"
+    "userbase/initjson"
 )
 
 type UserInfo struct {
@@ -180,7 +179,7 @@ func IsPower(name, userId string) (b bool) {
 }
 
 // HasIndustryTag  是否有行业标签
-func HasIndustryTag(userId string) bool {
+func HasIndustryTag(userId string, entId int) bool {
 	cacheKey := fmt.Sprintf("industryTag_%s", userId) // 缓存的key
 	cacheTimeout := 60 * 3                            // 缓存的时间-三分钟
 	//// 查缓存
@@ -188,7 +187,7 @@ func HasIndustryTag(userId string) bool {
 		return res.(bool)
 	}
 	var hasTag bool
-	vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userId)
+	vipStatus := jy.GetVipState(db.Mysql, db.Mgo, userId, entId)
 	if vipStatus.VipState > 0 || vipStatus.BigMember > 0 || vipStatus.EntMember > 0 { // 仅免费用户查询
 		redis.Put("newother", cacheKey, hasTag, cacheTimeout)
 		return hasTag