Ver código fonte

feat:PC端城市搜索

wangshan 3 anos atrás
pai
commit
6a9ea5614b

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

@@ -350,6 +350,7 @@ func (d *DataExport) SuperSearchExport() error {
 		SelectIds:    strings.TrimSpace(d.GetString("selectIds")), //选择信息id
 		Notkey:       d.GetString("notkey"),                       //排除词
 		FileExists:   d.GetString("fileExists"),                   //是否有附件
+		City:         d.GetString("city"),                         //城市
 	}
 	//数据回显
 	d.SetSession("Echo_timeslot", d.GetString("timeslot"))
@@ -366,6 +367,7 @@ func (d *DataExport) SuperSearchExport() error {
 	d.SetSession("Echo_hasWinnertel", reqData.Haswinnertel)
 	d.SetSession("Echo_notkey", reqData.Notkey)
 	d.SetSession("Echo_fileExists", reqData.FileExists)
+	d.SetSession("Echo_city", reqData.City)
 
 	saveData := reqData.PassBidSearchExport()
 	saveData["selectType"] = strings.Join(jy.GetVipState(public.Mysql, public.MQFW, userId).

+ 2 - 2
src/jfw/front/pcIndex.go

@@ -151,7 +151,7 @@ func GetNewArticle(typ int) (list []map[string]interface{}) {
 	if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
 		list = util.ObjArrToMapArr(l)
 	} else {
-		_, _, lists := bidsearch.GetPcBidSearchData("", "", "", subtype, "", "", "", "", "", "", "", "", 1, bidsearch.SearchPageSize_PC, false, nil, bidSearch_field_1, "", false)
+		_, _, lists := bidsearch.GetPcBidSearchData("", "", "", "", subtype, "", "", "", "", "", "", "", "", 1, bidsearch.SearchPageSize_PC, false, nil, bidSearch_field_1, "", false)
 		if lists != nil && len(*lists) > 5 {
 			*lists = (*lists)[0:6]
 			for _, v := range *lists {
@@ -442,7 +442,7 @@ func (f *PcIndex) SearchResult(at, name string) error {
 				// if datas != nil && len(*datas) > limitcount {
 				// 	*datas = (*datas)[0:limitcount]
 				// } else {
-				_, _, datas = bidsearch.GetPcBidSearchData(keywords, "", "", "", key_industry, "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1, "", false)
+				_, _, datas = bidsearch.GetPcBidSearchData(keywords, "", "", "", "", key_industry, "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1, "", false)
 				if datas != nil && len(*datas) > limitcount {
 					*datas = (*datas)[0:limitcount]
 				}

+ 8 - 4
src/jfw/front/supsearch.go

@@ -119,7 +119,7 @@ func (p *Pcsearch) ProposedProject() error {
 	var count int64
 	if len(s_word) > 0 {
 		status = 2
-		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, "", "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1, "", false)
+		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, "", publishtime, subtype, "", "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1, "", false)
 		listSize := 0
 		if list != nil {
 			listSize = len(*list)
@@ -261,6 +261,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 	var hasBuyerTel, hasWinnerTel string = "", "" //是否有采购单位电话、是否有中标单位电话 y:有 n:没有
 	var buyerclass string = ""                    //采购单位类别
 	var notkey string = ""                        //排除词
+	var city string = ""                          //城市 付费用户可用
 
 	selectType := p.GetString("selectType")
 	if selectType == "" {
@@ -271,6 +272,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 		buyerclass = p.GetString("buyerclass")
 		hasBuyerTel, hasWinnerTel = p.GetString("buyertel"), p.GetString("winnertel")
 		notkey = p.GetString("notkey")
+		city = p.GetString("city") //城市 付费用户可用
 	}
 	//历史导出数据回显
 	if strings.Contains(p.Url(), "?goback") {
@@ -288,6 +290,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 		industry = util.ObjToString(p.GetSession("Echo_industry"))
 		notkey = util.ObjToString(p.GetSession("Echo_notkey"))
 		fileExists = util.ObjToString(p.GetSession("Echo_fileExists"))
+		city = util.ObjToString(p.GetSession("Echo_city"))
 	}
 
 	b_word, s_word := "", ""
@@ -301,7 +304,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 	secondKWS := ""
 	if len(s_word) > 0 || len(industry) > 0 {
 		status = 2
-		secondKWS, _, _, _, secondFlag, count, totalPage, list = bidsearch.SearchData("pc", p.Request, 1, util.ObjToString(p.GetSession("userId")), secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, 0, bidsearch.SearchPageSize_PC, true, queryItems, bidSearch_field_1, notkey, isPayedUser)
+		secondKWS, _, _, _, secondFlag, count, totalPage, list = bidsearch.SearchData("pc", p.Request, 1, util.ObjToString(p.GetSession("userId")), secondKWS, s_word, area, city, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, 0, bidsearch.SearchPageSize_PC, true, queryItems, bidSearch_field_1, notkey, isPayedUser)
 	} else {
 		p.DisableHttpCache()
 		p.T["list"] = PCS_list("") //Newbids("")[0]
@@ -332,8 +335,9 @@ func (p *Pcsearch) PcSearchIndex() error {
 		p.T["buyerclass"] = buyerclass
 		p.T["buyertel"] = hasBuyerTel
 		p.T["winnertel"] = hasWinnerTel
-		p.T["fileExists"] = fileExists
 		p.T["notkey"] = notkey
+		p.T["fileExists"] = fileExists
+		p.T["city"] = city
 		p.SetSession("paramkey", b_word)
 		switch publishtime {
 		case "lately-7":
@@ -397,7 +401,7 @@ func Newbids(p string) []interface{} {
 		}
 
 		for i := 0; i < 10; i++ {
-			_, list = getLastNewsData("", "", "", subtype, "", "", "", "", "", "", "", "Y", intns[i], true, false, "")
+			_, list = getLastNewsData("", "", "", "", subtype, "", "", "", "", "", "", "", "Y", intns[i], true, false, "")
 			for k, v := range *list {
 				v["k"] = (k + 1) + i*50
 				t := time.Unix(util.Int64All(v["publishtime"]), 0)

+ 8 - 4
src/jfw/front/swordfish.go

@@ -111,12 +111,14 @@ func (m *Front) PcAjaxReq() {
 		isPayedUser               bool
 		queryItems                []string
 		start                     int
+		city                      string //城市
 	)
 	isPayedUser, publishtime, queryItems, currentPage, start = bidsearch.PublicSearch(userId, selectType, publishtime, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]), currentPage)
 	if isPayedUser {
 		buyerclass = m.GetString("buyerclass")
 		hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
 		notkey = m.GetString("notkey")
+		city = m.GetString("city")
 	}
 	m.SetSession("selectType", selectType)
 	//只有前20条 有全字段,
@@ -148,7 +150,7 @@ func (m *Front) PcAjaxReq() {
 			}
 		}
 		if isLimit == 1 {
-			_, _, _, pcAjaxFlag, secondFlag, count, totalPage, list = bidsearch.SearchData("pc", m.Request, currentPage, util.ObjToString(m.GetSession("userId")), secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, bidsearch.SearchPageSize_PC, true, queryItems, field, notkey, isPayedUser)
+			_, _, _, pcAjaxFlag, secondFlag, count, totalPage, list = bidsearch.SearchData("pc", m.Request, currentPage, util.ObjToString(m.GetSession("userId")), secondKWS, s_word, area, city, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, bidsearch.SearchPageSize_PC, true, queryItems, field, notkey, isPayedUser)
 		}
 	}
 	_secondList, _totalPage, _ := bidsearch.LisetData(1, currentPage, list, secondFlag, config.Seoconfig, isPayedUser) //只有前20条
@@ -171,10 +173,10 @@ func (m *Front) PcAjaxReq() {
 	})
 }
 
-func getLastNewsData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, tabularflag string, start int, isGetCount bool, highlight bool, notkey string) (count int64, list *[]map[string]interface{}) {
+func getLastNewsData(searchvalue, area, city, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, tabularflag string, start int, isGetCount bool, highlight bool, notkey string) (count int64, list *[]map[string]interface{}) {
 	//最新招标信息
 	findfields := `"title"`
-	qstr := bidsearch.GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
+	qstr := bidsearch.GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, bidsearch.GetBidSearchQuery(area, city, publishtime, subtype, "", buyerclass), notkey)
 	if isGetCount && start == 0 {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
@@ -345,6 +347,7 @@ func (m *Front) WxsearchlistPaging() {
 			var buyerclass string = ""                    //采购单位类别
 			var notkey string = ""                        //排除词
 			var fileExists = m.GetString("fileExists")    //是否有附件--所有用户都可用此功能 0:全部;1:有附件;-1:无附件
+			var city string = ""                          //城市
 
 			vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
 			isPayedUser = vipStatus.IsPayedUser()
@@ -359,6 +362,7 @@ func (m *Front) WxsearchlistPaging() {
 				buyerclass = m.GetString("buyerclass")
 				hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
 				notkey = m.GetString("notkey")
+				city = m.GetString("city")
 			} else {
 				//免费用户最多500条数据
 				if pageNum > bidsearch.SearchMaxPageNum_WX {
@@ -381,7 +385,7 @@ func (m *Front) WxsearchlistPaging() {
 				}
 			}
 			if isLimit == 1 {
-				secondKWS, b_word, a_word, _, secondFlag, _, _, list = bidsearch.SearchData("wx", m.Request, pageNum, util.ObjToString(m.GetSession("userId")), secondKWS, searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, pageNum, bidsearch.SearchPageSize_APP, true, queryItems, filed, notkey, isPayedUser)
+				secondKWS, b_word, a_word, _, secondFlag, _, _, list = bidsearch.SearchData("wx", m.Request, pageNum, util.ObjToString(m.GetSession("userId")), secondKWS, searchvalue, scope, city, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, fileExists, pageNum, bidsearch.SearchPageSize_APP, true, queryItems, filed, notkey, isPayedUser)
 			}
 			//新增历史记录
 			arrs = bidsearch.AddHistory(history, searchvalue)

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

@@ -35,7 +35,7 @@ const (
 )
 
 //GetWxsearchlistData 移动端招标信息搜索
-func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, pageNum, pageSize int, selectTypeArr []string, field, notkey string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
+func GetWxsearchlistData(keywords, scope, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, pageNum, pageSize int, selectTypeArr []string, field, notkey string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
 	var hightlightContent bool = false //是否高亮正文
 	for _, v := range selectTypeArr {
 		if v == "detail" {
@@ -53,7 +53,7 @@ func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minpri
 	} else {
 		findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
 	}
-	qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass), notkey)
+	qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(scope, city, publishtime, subtype, winner, buyerclass), notkey)
 	if hightlightContent { //全文搜索
 		list = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
 	} else { //标题搜索
@@ -69,7 +69,7 @@ func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minpri
 }
 
 //GetPcBidSearchData pc端招标信息搜索
-func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed bool) (count, totalPage int64, list *[]map[string]interface{}) {
+func GetPcBidSearchData(searchvalue, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed bool) (count, totalPage int64, list *[]map[string]interface{}) {
 	var findfields string
 	var hightlightContent bool = false //是否高亮正文
 	for _, v := range selectTypeArr {
@@ -83,7 +83,7 @@ func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minpr
 	} else {
 		findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
 	}
-	qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass), notkey)
+	qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, winner, buyerclass), notkey)
 	if isGetCount && qstr != "" && start == 0 {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
@@ -107,7 +107,7 @@ func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minpr
 	return
 }
 
-func GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass string) string {
+func GetBidSearchQuery(area, city, publishtime, subtype, winner, buyerclass string) string {
 	query := ``
 	if area != "" {
 		query += `{"terms":{"area":[`
@@ -119,6 +119,20 @@ func GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass string) st
 		}
 		query += `]}}`
 	}
+	//
+	if city != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		query += `{"terms":{"city":[`
+		for k, v := range strings.Split(city, ",") {
+			if k > 0 {
+				query += `,`
+			}
+			query += `"` + v + `"`
+		}
+		query += `]}}`
+	}
 	if publishtime != "" {
 		if len(query) > 0 {
 			query += ","
@@ -333,7 +347,7 @@ func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit
 }
 
 //所有的再次分词查询 只查标题
-func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}) (string, string, string, string, *[]map[string]interface{}) {
+func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}) (string, string, string, string, *[]map[string]interface{}) {
 	var pcAjaxFlag string
 	secondSearch := false
 	var secRel *[]map[string]interface{} = list
@@ -346,7 +360,7 @@ func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxp
 	if secondSearch {
 		if secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address); secondKWS != "" {
 			findfields := `"title"`
-			qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
+			qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, "", buyerclass), notkey)
 			secRel = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, 0, 2*SearchPageSize_PC, 0, false)
 			if secRel != nil && len(*secRel) > 0 {
 				public.BidListConvert(industry, secRel)
@@ -462,21 +476,21 @@ func LisetData(stype, pageNum int, list *[]map[string]interface{}, secondFlag st
 	return secondList, totalPage, hasNextPage
 }
 
-func SearchData(platform string, request *http.Request, currentPage int, userId, secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser bool) (second, b_word, a_word, pcAjaxFlag, secondFlag string, count, totalPage int64, list *[]map[string]interface{}) {
+func SearchData(platform string, request *http.Request, currentPage int, userId, secondKWS, s_word, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser bool) (second, b_word, a_word, pcAjaxFlag, secondFlag string, count, totalPage int64, list *[]map[string]interface{}) {
 	var searchvalue = s_word
 	number := util.If(platform == "app" || platform == "wx", 1, 0)
 	if platform == "app" || platform == "wx" {
-		list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, SearchPageSize_APP, queryItems, field, notkey)
+		list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, SearchPageSize_APP, queryItems, field, notkey)
 		if list != nil && len(*list) != 0 {
 			count = int64(len(*list))
 		}
 	} else {
-		count, totalPage, list = GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
+		count, totalPage, list = GetPcBidSearchData(s_word, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
 	}
 
 	if len([]rune(s_word)) > 3 && int(count) < SearchPageSize_PC && start == number {
 		var paramList = list
-		s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
+		s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
 	}
 
 	listSize := 0
@@ -486,12 +500,14 @@ func SearchData(platform string, request *http.Request, currentPage int, userId,
 	public.SaveUserSearchLog(request, userId, -1, platform, "超级搜索", map[string]interface{}{
 		"search_word":        util.If(platform == "app" || platform == "wx", searchvalue, s_word),
 		"search_area":        area,
+		"search_city":        city,
 		"search_price":       []string{minprice, maxprice},
 		"search_publishtime": publishtime,
 		"search_type":        subtype,
 		"search_industry":    industry,
 		"pagenum":            currentPage,
 		"pagesize":           listSize,
+		"fileExists":         fileExists,
 	})
 	return
 }

+ 1 - 0
src/jfw/public/dataexport.go

@@ -109,6 +109,7 @@ type BidSearchExport struct {
 	SelectIds    string //选择单条信息id
 	Notkey       string //排除词
 	FileExists   string //是否有附件
+	City         string //城市
 }
 
 func (this *BidSearchExport) PassBidSearchExport() (returnData map[string]interface{}) {