Forráskód Böngészése

feat:搜索初始化信息

wangshan 2 éve
szülő
commit
eb124e17cb

+ 41 - 15
jyBXCore/rpc/entity/search.go

@@ -11,6 +11,7 @@ import (
 	"jyBXCore/rpc/service"
 	"jyBXCore/rpc/util"
 	"strings"
+	"time"
 )
 
 var (
@@ -89,7 +90,7 @@ func (kws *KeyWordsSearch) DefaultSearchParamsAuto(in *bxcore.SearchReq) {
 	//缓存数据 默认查询分组 searchGroup = 1 ,
 	//不查超前信息--招标信息类型为拟建和采购意向的信息
 	in.SearchGroup = 1
-	in.Subtype = IC.C.DefaultTopTypes[in.SearchGroup]
+	in.Subtype = IC.C.DefaultTopTypes[in.SearchGroup-1]
 	in.TopType = ""
 	in.City = ""
 	in.Industry = ""
@@ -99,8 +100,8 @@ func (kws *KeyWordsSearch) DefaultSearchParamsAuto(in *bxcore.SearchReq) {
 	in.BuyerClass = ""
 	in.Price = ""
 	in.SelectType = "title"
-	in.PublishTime = ""
 	in.Province = ""
+	//in.PublishTime = ""
 }
 
 // SaveKeyWordsToHistory 保存历史记录
@@ -119,24 +120,54 @@ func (kws *KeyWordsSearch) SaveKeyWordsToHistory(in *bxcore.SearchReq) {
 
 // SearchParamsHandle 搜索条件 处理
 func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) {
+	//判断用户身份
+	userInfo := util.GetVipState(IC.MainMysql, IC.Mgo, in.UserId, in.EntId)
+	//是否是付费用户
+	in.IsPay = userInfo.IsPayedUser()
+	//搜索范围
+	queryItems := userInfo.GetQueryItems(in.SelectType, IC.C.BidSearchOldUserLimit)
+	in.SelectType = strings.Join(queryItems, ",")
 	// in.SearchGroup 搜索分组 搜索分组:默认0:全部;1:招标采购公告;2:超前项目
-	if in.SearchGroup < 0 {
-		in.SearchGroup = 0
+	if in.SearchGroup < 0 || in.SearchGroup > 2 {
+		in.SearchGroup = 1
+	}
+	//判断是否能使用超前项目  老版超级订阅、大会员、商机管理有权限
+	if !(userInfo.IsOldVip || userInfo.BigMember > 0 || userInfo.EntMember > 0) {
+		in.SearchGroup = 1
+		//Subtype 包含:拟建,采购意向,则需要排除
+		if in.Subtype != "" {
+			var subtype []string
+			for _, sv := range strings.Split(in.Subtype, ",") {
+				if sv == "拟建" || sv == "采购意向" {
+					continue
+				}
+				subtype = append(subtype, sv)
+			}
+			in.Subtype = MC.If(len(subtype) > 0, strings.Join(subtype, ","), "").(string)
+		}
 	}
 	//信息类型参数为空  根据搜索分组 初始化信息类型
 	if in.TopType == "" && in.Subtype == "" {
-		in.Subtype = MC.If(in.SearchGroup > 0, IC.C.DefaultTopTypes[in.SearchGroup], "").(string)
+		in.Subtype = MC.If(in.SearchGroup > 0, IC.C.DefaultTopTypes[in.SearchGroup-1], "").(string)
 	}
 	// in.SearchMode 搜索模式 搜索模式:0:精准搜索;1:模糊搜索
 	// 精准搜索:不分词,完全匹配;(中间带空格的关键词组自动分词)
 	// 模糊搜索:对用户输入的单个关键词进行分词处理,但必须都存在;
-	if in.SearchMode < 0 {
+	if in.SearchMode < 0 || in.SearchMode > 1 {
 		in.SearchMode = 0
 	}
 	// in.WordsMode 搜索关键词模式;默认0:包含所有,1:包含任意
-	if in.WordsMode < 0 {
+	if in.WordsMode < 0 || in.WordsMode > 1 {
 		in.WordsMode = 0
 	}
+	//查询时间publishTime
+	if in.PublishTime == "" {
+		//付费用户最新5年;免费用户最新3年
+		in.PublishTime = fmt.Sprintf("%d-%d", time.Now().AddDate(-3, 0, 0).Unix(), time.Now().Unix())
+		if userInfo.IsPayedUser() {
+			in.PublishTime = fmt.Sprintf("%d-%d", time.Now().AddDate(-5, 0, 0).Unix(), time.Now().Unix())
+		}
+	}
 	//默认每页数据量
 	if in.PageSize <= 0 {
 		in.PageSize = 50
@@ -154,12 +185,14 @@ func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) {
 		in.SelectType = "title,content"
 	}
 	//免费用户:高级筛选 采购单位类型、采购单位联系方式、中标企业联系方式、排除词、城市
-	if in.UserType == "fType" {
+	if !userInfo.IsPayedUser() {
 		in.BuyerClass = ""
 		in.BuyerTel = ""
 		in.WinnerTel = ""
 		in.ExclusionWords = ""
 		in.City = ""
+		in.SearchGroup = MC.If(in.SearchGroup > 1, 0, in.SearchGroup).(int64) //搜索分组:默认0:全部;1:招标采购公告;2:超前项目
+		in.ExclusionWords = ""
 	}
 	//判断是否有关键词
 	if in.KeyWords != "" {
@@ -199,13 +232,6 @@ func (kws *KeyWordsSearch) SearchParamsHandle(in *bxcore.SearchReq) {
 		}
 		in.ExclusionWords = strings.Join(exclusionWords, IC.C.JYKeyMark) //util.MatchSpace.ReplaceAllString(in.ExclusionWords, IC.C.JYKeyMark)
 	}
-	//判断用户身份
-	userInfo := util.GetVipState(IC.MainMysql, IC.Mgo, in.UserId)
-	//是否是付费用户
-	in.IsPay = userInfo.IsPayedUser()
-	//搜索范围
-	queryItems := userInfo.GetQueryItems(in.SelectType, IC.C.BidSearchOldUserLimit)
-	in.SelectType = strings.Join(queryItems, ",")
 }
 
 // GetBidSearchList 非空搜索 查询

+ 1 - 1
jyBXCore/rpc/etc/bxcore.yaml

@@ -38,7 +38,7 @@ DefaultBidInfo: #默认搜索
   Count: 500 #查询数据量
   PayCount: 5000 #付费用户查询数据量
 DefaultTopTypes:
-  - 拟建,采购意向,招标预告,招标公告,招标结果,招标信用信息
   - 招标预告,招标公告,招标结果,招标信用信息
   - 拟建,采购意向
 JYKeyMark: +剑鱼+
+ContextOldVipLimit: 1664553600

+ 4 - 3
jyBXCore/rpc/internal/config/config.go

@@ -8,7 +8,7 @@ import (
 type Config struct {
 	zrpc.RpcServerConf
 	WebRpcPort            int64
-	BidSearchOldUserLimit int64
+	BidSearchOldUserLimit int64 //老用户 使用付费功能
 	LabelUrl              struct {
 		Area     string
 		SType    string
@@ -41,8 +41,9 @@ type Config struct {
 		Count    int
 		PayCount int
 	} //招标信息初始化
-	DefaultTopTypes []string //信息类型初始值
-	JYKeyMark       string   //关键词分组标识
+	DefaultTopTypes    []string //信息类型初始值
+	JYKeyMark          string   //关键词分组标识
+	ContextOldVipLimit int64    //老版超级订阅 超前项目权限
 }
 
 type Db struct {

+ 32 - 33
jyBXCore/rpc/model/es/search.go

@@ -60,7 +60,6 @@ func GetSearchQuery(in *bxcore.SearchReq, mustQuery string) (qstr string) {
 		}
 	}
 	if in.Industry != "" {
-		//industrys := strings.Split(in.Industry, ",")
 		musts = append(musts, fmt.Sprintf(queryBoolMust, `"`+strings.ReplaceAll(in.Industry, ",", `","`)+`"`))
 	}
 	//价格
@@ -181,76 +180,76 @@ func GetBidSearchQuery(in *bxcore.SearchReq) string {
 		query = fmt.Sprintf(queryBoolShould, query)
 	}
 	//发布时间
-	publishtime := in.PublishTime
-	if publishtime != "" && len(strings.Split(publishtime, "-")) > 1 {
+	publishTime := in.PublishTime
+	if publishTime != "" && len(strings.Split(publishTime, "-")) > 1 {
 		if len(query) > 0 {
 			query += ","
 		}
-		starttime := strings.Split(publishtime, "-")[0]
-		endtime := strings.Split(publishtime, "-")[1]
-		query += `{"range":{"publishtime":{`
-		if starttime != "" {
-			query += `"gte":` + starttime
+		startTime := strings.Split(publishTime, "-")[0]
+		endTime := strings.Split(publishTime, "-")[1]
+		query += `{"range":{"publishTime":{`
+		if startTime != "" {
+			query += `"gte":` + startTime
 		}
-		if starttime != "" && endtime != "" {
+		if startTime != "" && endTime != "" {
 			query += `,`
 		}
-		if endtime != "" {
-			query += `"lt":` + endtime
+		if endTime != "" {
+			query += `"lt":` + endTime
 		}
 		query += `}}}`
 	}
 	//信息类型-二级
 	subtype := in.Subtype
-	toptype := MC.If(in.TopType != "", strings.Split(in.TopType, ","), []string{}).([]string)
-	alltype := ``
+	topType := MC.If(in.TopType != "", strings.Split(in.TopType, ","), []string{}).([]string)
+	allType := ``
 	//二级分类
 	if subtype != "" {
 		var typeInt = 0
-		alltype += `{"terms":{"subtype":[`
+		allType += `{"terms":{"subtype":[`
 		for k, v := range strings.Split(subtype, ",") {
-			if ttype := MC.If(topTypeMap[v] != "" && in.TopType == "", topTypeMap[v], "").(string); ttype != "" {
-				toptype = append(toptype, ttype)
+			if tType := MC.If(topTypeMap[v] != "" && in.TopType == "", topTypeMap[v], "").(string); tType != "" {
+				topType = append(topType, tType)
 				typeInt += 1
 				continue
 			}
 			if k > typeInt {
-				alltype += `,`
+				allType += `,`
 			}
-			alltype += `"` + v + `"`
+			allType += `"` + v + `"`
 		}
-		alltype += `]}}`
+		allType += `]}}`
 	}
 	//信息类型  一级分类
-	logx.Info("toptype:", toptype)
-	if len(toptype) > 0 {
-		if alltype != "" {
-			alltype += ","
+	logx.Info("topType:", topType)
+	if len(topType) > 0 {
+		if allType != "" {
+			allType += ","
 		}
-		alltype += `{"terms":{"toptype":[`
-		for k, v := range toptype {
+		allType += `{"terms":{"toptype":[`
+		for k, v := range topType {
 			if k > 0 {
-				alltype += `,`
+				allType += `,`
 			}
-			alltype += `"` + v + `"`
+			allType += `"` + v + `"`
 		}
-		alltype += `]}}`
+		allType += `]}}`
 	}
 
-	if alltype != "" {
+	if allType != "" {
 		if query != "" {
 			query += ","
 		}
-		query += fmt.Sprintf(queryBoolShould, alltype)
+		query += fmt.Sprintf(queryBoolShould, allType)
 	}
 	//采购单位类型
-	buyerclass := in.BuyerClass
-	if buyerclass != "" {
+	buyerClass := in.BuyerClass
+	if buyerClass != "" {
 		if len(query) > 0 {
 			query += ","
 		}
 		query += `{"terms":{"buyerclass":[`
-		for k, v := range strings.Split(buyerclass, ",") {
+		for k, v := range strings.Split(buyerClass, ",") {
 			if k > 0 {
 				query += `,`
 			}

+ 1 - 1
jyBXCore/rpc/util/search.go

@@ -244,7 +244,7 @@ func SearchListFormat(industry string, repl *[]map[string]interface{}, b bool) (
 			}
 			searchList.Detail = detail
 		}
-		searchList.Id = ME.EncodeArticleId2ByCheck(MC.ObjToString(v["id"]))                                         //ME.EncodeArticleId2ByCheck(MC.ObjToString(v["id"]))                                         //加密信息id
+		searchList.Id = ME.EncodeArticleId2ByCheck(MC.ObjToString(v["_id"]))                                        //ME.EncodeArticleId2ByCheck(MC.ObjToString(v["_id"]))                                         //加密信息id
 		searchList.Area = MC.ObjToString(v["area"])                                                                 //地区
 		searchList.AreaUrl = IC.LabelMap[searchList.Area].Url                                                       //地区分类链接
 		searchList.BuyerClass = MC.ObjToString(v["buyerclass"])                                                     //采购单位类型

+ 24 - 18
jyBXCore/rpc/util/userInfo.go

@@ -4,6 +4,7 @@ import (
 	MC "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
+	IC "jyBXCore/rpc/init"
 	"strings"
 )
 
@@ -12,10 +13,12 @@ type VipState struct {
 	VipState     int64 //超级订阅状态(1普通 2升级版)
 	BigMember    int64 //大会员状态
 	EntMember    int64 //商机管理用户状态
-	registerData int64 //注册时间
+	RegisterData int64 //注册时间
+	IsOldVip     bool  //老版超级订阅  超前项目
+	IsNewEnt     bool  //新版商机管理
 }
 
-func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string) (vs *VipState) {
+func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string, entId int64) (vs *VipState) {
 	vs = &VipState{}
 	if userId == "" {
 		return
@@ -23,31 +26,34 @@ 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 := MC.Int64All((*data)["i_vip_status"])
-		if i_vip_status > 1 {
+		iVipStatus := MC.Int64All((*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 {
+				oBuys := oVipJY["o_buyset"].(map[string]interface{})
+				if oBuys["upgrade"] != nil {
 					vs.VipState = 2
 				}
 			}
 		}
-		if i_member_status := MC.Int64All((*data)["i_member_status"]); i_member_status > 0 {
-			vs.BigMember = i_member_status
+		if iMemberStatus := MC.Int64All((*data)["i_member_status"]); 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 {
+		if phone != "" && entId > 0 {
+			if entInfos := mysql.SelectBySql(`select * from entniche_info where phone = ? and power =1 and status = 1 and id = ?`, phone, entId); entInfos != nil && *entInfos != nil && len(*entInfos) > 0 {
+				entInfo := (*entInfos)[0]
 				vs.EntMember = 1
+				vs.IsNewEnt = MC.Int64All(entInfo["isNew"]) > 0
 			}
 		}
-		vs.registerData, _ = ((*data)["l_registedate"]).(int64)
+		vs.RegisterData, _ = ((*data)["l_registedate"]).(int64)
+		vs.IsOldVip = vs.VipState > 0 && vs.RegisterData < IC.C.ContextOldVipLimit
 	}
 	return
 }
@@ -82,7 +88,7 @@ func (vs *VipState) GetQueryItems(selectType string, limitOldTime int64) (items
 		return
 	}
 	//老用户 使用付费功能
-	isOldUser := vs.registerData != 0 && vs.registerData < limitOldTime
+	isOldUser := vs.RegisterData != 0 && vs.RegisterData < limitOldTime
 	for _, t := range strings.Split(selectType, ",") {
 		if t == "winner" && isOldUser {
 			items = append(items, "mwinner")