Browse Source

feat:电脑端采购单位 中标单位 代理机构

wangshan 1 năm trước cách đây
mục cha
commit
2186f9b20f
3 tập tin đã thay đổi với 59 bổ sung6 xóa
  1. 37 2
      src/jfw/front/searchOptimize.go
  2. 12 1
      src/jfw/front/supsearch.go
  3. 10 3
      src/jfw/front/swordfish.go

+ 37 - 2
src/jfw/front/searchOptimize.go

@@ -23,7 +23,7 @@ import (
 
 const (
 	multiMatch              = `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
-	query                   = `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
+	query                   = `{"query":{"bool":{"filter":[%s],"must_not":[%s]}}}`
 	queryBoolShould         = `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	queryBoolMustBoolShould = `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
 	queryBoolMust           = `{"bool":{"must":[{"terms":{"s_subscopeclass":[%s]}}]}}`
@@ -97,13 +97,16 @@ type SearchOptimize struct {
 	Changehand          int           `json:"changehand"`     // 换手率
 	Scale               string        `json:"scale"`          //价格区间
 	Isfile              int           `json:"isfile"`         //有无附件
+	Buyer               string        `json:"buyer"`          //采购单位
+	Winner              string        `json:"winner"`         //中标企业
+	Agency              string        `json:"agency"`         //代理机构
 
 }
 
 // NewSearchOptimize  初始化
 func NewSearchOptimize(userId, phone, province, city, district, subtype, topType, publishTime, selectType, price, industry, buyerClass, buyerTel, winnerTel, fileExists, keyWords, additionalWords, exclusionWords, platform, territorialization, expireTime, propertyForm, subinformation string,
 	pageNum, pageSize, searchGroup, searchMode, wordsMode int, period, scale string, changehand, isfile int,
-	userInfo jy.VipState, searchTypeSwitch bool, r *http.Request, accountId, entAccountId, entId, entUserId int64) *SearchOptimize {
+	userInfo jy.VipState, searchTypeSwitch bool, r *http.Request, accountId, entAccountId, entId, entUserId int64, buyer, winner, agency string) *SearchOptimize {
 	IsPay := userInfo.IsPayedUser()
 	if territorialization == "BIProperty" {
 		res := config.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
@@ -154,6 +157,9 @@ func NewSearchOptimize(userId, phone, province, city, district, subtype, topType
 		Changehand:       changehand,
 		Scale:            scale,
 		Isfile:           isfile,
+		Buyer:            buyer,
+		Winner:           winner,
+		Agency:           agency,
 	}
 	so.SearchParamsHandle()
 	return so
@@ -430,6 +436,18 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
 	}
 	switchBool := strings.Contains(findFields, "detail") && strings.Contains(findFields, "title") && so.SearchTypeSwitch
 
+	//采购单位
+	if so.Buyer != "" {
+		musts = append(musts, GetMatchArrSql("buyer.mbuyer", strings.Split(so.Buyer, ",")...))
+	}
+	//中标单位
+	if so.Winner != "" {
+		musts = append(musts, GetMatchArrSql("s_winner.mwinner", strings.Split(so.Winner, ",")...))
+	}
+	//代理机构
+	if so.Agency != "" {
+		musts = append(musts, GetMatchArrSql("agency.magency", strings.Split(so.Agency, ",")...))
+	}
 	//此时关键词中间有+进行隔离
 	if so.KeyWords != "" {
 		var (
@@ -1170,3 +1188,20 @@ func IndustryFormat(industry, subScopeClass string) (newIndustry string) {
 	}
 	return
 }
+
+var GetMatchArrSql = func(field string, val ...string) (sql string) {
+	if len(val) == 0 {
+		return
+	}
+	var arr []string
+	for _, s := range val {
+		if s == "" {
+			continue
+		}
+		arr = append(arr, fmt.Sprintf(`{"match_phrase": {"%s": "%s"}}`, field, s))
+	}
+	if len(arr) == 0 {
+		return ""
+	}
+	return fmt.Sprintf(`{"bool": {"should": [%s],"minimum_should_match": 1}}`, strings.Join(arr, ","))
+}

+ 12 - 1
src/jfw/front/supsearch.go

@@ -402,6 +402,9 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		city                      = ""     //城市 付费用户可用
 		district                  = ""
 		regionMap                 = ""
+		buyer                     = ""
+		winner                    = ""
+		agency                    = ""
 	)
 	// 领域化标识
 	territorialization := p.GetString("bid_field")
@@ -428,6 +431,10 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		city = p.GetString("city") //城市 付费用户可用
 		district = p.GetString("district")
 		regionMap = p.GetString("regionMap")
+		//P492招标采购搜索匹配采购单位等优化
+		buyer = p.GetString("buyer")   //采购单位
+		winner = p.GetString("winner") //中标企业
+		agency = p.GetString("agency") //招标代理机构
 	}
 	//历史导出数据回显
 	if strings.Contains(p.Url(), "?goback") {
@@ -478,6 +485,10 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		wordsMode = util.IntAll(sessVal["Echo_wordsMode"])                  //搜索关键词模式;默认0:包含所有关键词;1:包含任意关键词。
 		additionalWords = util.ObjToString(sessVal["Echo_additionalWords"]) //关键词:附加关键词(副:五组,每组最多15个字符 每组,号隔开)
 		queryItems = userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
+		//P492招标采购搜索匹配采购单位等优化
+		buyer = util.ObjToString(sessVal["Echo_buyer"])
+		winner = util.ObjToString(sessVal["Echo_winner"])
+		agency = util.ObjToString(sessVal["Echo_agency"])
 	}
 	keywordsLimit := util.IntAllDef(config.Sysconfig["keywordsLimit"], 35)
 	searchLimit := public.IsSearchLimit(queryItems)
@@ -522,7 +533,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
 		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, "", "", "",
 			0, pageSize, searchGroup, searchMode, wordsMode, "", "", 0, 0,
-			*userInfo, searchTypeSwitch, p.Request, accountId, entAccountId, entId, entUserId)
+			*userInfo, searchTypeSwitch, p.Request, accountId, entAccountId, entId, entUserId, buyer, winner, agency)
 		heightKeys = so.HeightKeys //主关键词和附加词合并,多组空格隔开,作为前端渲染高亮关键词使用
 		//关键词  行业 附加词
 		//放开用户不输入关键词可搜索 --P297需求

+ 10 - 3
src/jfw/front/swordfish.go

@@ -187,6 +187,10 @@ func (m *Front) PcAjaxReq() {
 		isLimit                   = 1
 		list                      []*map[string]interface{}
 		heightKeys                string //需要高亮的关键词
+		//P492招标采购搜索匹配采购单位等优化
+		buyer  string //采购单位
+		winner string //中标企业
+		agency string //招标代理机构
 	)
 	queryItems = userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 	isPayedUser = userInfo.IsPayedUser()
@@ -195,6 +199,10 @@ func (m *Front) PcAjaxReq() {
 		hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
 		notkey = m.GetString("notkey")
 		city = m.GetString("city")
+		//P492招标采购搜索匹配采购单位等优化
+		buyer = m.GetString("buyer")   //采购单位
+		winner = m.GetString("winner") //中标企业
+		agency = m.GetString("agency") //招标代理机构
 	}
 	// p329  非反爬白名单用户不放开  需要处理通用词
 	onList, _ := jyutil.IsOnTheWhitelist(m.Session())
@@ -223,7 +231,7 @@ func (m *Front) PcAjaxReq() {
 		}
 		if isLimit == 1 {
 			searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
-			so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId)
+			so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId, buyer, winner, agency)
 			if so.PageNum < 0 && so.PageSize < 0 {
 				log.Printf("查询参数超出范围,有可能是异常请求; 用户id:%s;用户手机号:%s \n", userId, phone)
 			} else {
@@ -234,9 +242,8 @@ func (m *Front) PcAjaxReq() {
 		}
 	} else {
 		searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
-		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId)
+		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId, buyer, winner, agency)
 		list, count, total = so.GetBidSearchListByCache()
-
 	}
 	if userId == "" {
 		for _, v := range list {