wangchuanjin 4 năm trước cách đây
mục cha
commit
86a59d3453

+ 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)
+		_, _, lists := bidsearch.GetPcBidSearchData("", "", "", subtype, "", "", "", "", "", "", "", 1, bidsearch.SearchPageSize_PC, false, nil, bidSearch_field_1, "")
 		if lists != nil && len(*lists) > 5 {
 			*lists = (*lists)[0:6]
 			for _, v := range *lists {
@@ -415,7 +415,7 @@ func (f *PcIndex) SearchResult(at, name string) error {
 
 			} else {
 				//关键词
-				_, _, datas = bidsearch.GetPcBidSearchData(keywords, "", "", "", key_industry, "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, false, nil, bidSearch_field_1)
+				_, _, datas = bidsearch.GetPcBidSearchData(keywords, "", "", "", key_industry, "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, false, nil, bidSearch_field_1, "")
 				if datas != nil && len(*datas) > limitcount {
 					*datas = (*datas)[0:limitcount]
 				}

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

@@ -113,7 +113,7 @@ func (p *Pcsearch) ProposedProject() error {
 	if len(s_word) > 0 {
 		status = 2
 		var count int64
-		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1)
+		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, "", "", "", "", "", "", "", 0, bidsearch.SearchPageSize_PC, true, nil, bidSearch_field_1, "")
 		listSize := 0
 		if list != nil {
 			listSize = len(*list)
@@ -292,7 +292,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 	secondKWS := ""
 	if len(s_word) > 0 || len(industry) > 0 {
 		status = 2
-		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, queryItems, bidSearch_field_1)
+		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, queryItems, bidSearch_field_1, p.GetString("notkey"))
 		listSize := 0
 		if list != nil {
 			listSize = len(*list)
@@ -309,7 +309,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 			if secondSearch {
 				secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address)
 				findfields := `"title"`
-				qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass))
+				qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), p.GetString("notkey"))
 				secRel := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, 0, 2*bidsearch.SearchPageSize_PC, 0, false)
 				if secRel != nil {
 					public.BidListConvert(industry, secRel)
@@ -451,7 +451,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)

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

@@ -151,7 +151,7 @@ func (m *Front) PcAjaxReq() {
 	if len(s_word) > 0 || len(industry) > 0 {
 		if reqType == "filter" {
 			if status == 1 {
-				count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, queryItems, field)
+				count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, queryItems, field, m.GetString("notkey"))
 			}
 		} else if reqType == "bidSearch" {
 			//全文检索限制
@@ -166,7 +166,7 @@ func (m *Front) PcAjaxReq() {
 				if limitFlag {
 					if start == 0 {
 						limit_count := public.Lst.TotalPage * bidsearch.SearchPageSize_PC
-						count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, limit_count, true, queryItems, field)
+						count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, limit_count, true, queryItems, field, m.GetString("notkey"))
 						if totalPage > int64(public.Lst.TotalPage) {
 							totalPage = int64(public.Lst.TotalPage)
 						}
@@ -175,7 +175,7 @@ func (m *Front) PcAjaxReq() {
 						}
 					}
 				} else {
-					count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, start, bidsearch.SearchPageSize_PC, true, queryItems, field)
+					count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, start, bidsearch.SearchPageSize_PC, true, queryItems, field, m.GetString("notkey"))
 				}
 				listSize := 0
 				if list != nil {
@@ -192,7 +192,7 @@ func (m *Front) PcAjaxReq() {
 					if secondSearch {
 						secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address)
 						findfields := `"title"`
-						qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass))
+						qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), m.GetString("notkey"))
 						secRel := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, 0, 2*bidsearch.SearchPageSize_PC, 0, false)
 						if secRel != nil {
 							public.BidListConvert(industry, secRel)
@@ -223,7 +223,7 @@ func (m *Front) PcAjaxReq() {
 				})
 			}
 		} else if reqType == "lastNews" {
-			_, list = getLastNewsData(s_word, area, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, tabularflag, start, false, true)
+			_, list = getLastNewsData(s_word, area, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, tabularflag, start, false, true, "")
 		}
 	}
 	if list != nil && len(*list) > 0 {
@@ -276,10 +276,10 @@ func (m *Front) PcAjaxReq() {
 	})
 }
 
-func getLastNewsData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, tabularflag string, start int, isGetCount bool, highlight bool) (count int64, list *[]map[string]interface{}) {
+func getLastNewsData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, buyerclass, hasBuyerTel, hasWinnerTel, 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, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass))
+	qstr := bidsearch.GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
 	if isGetCount {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
@@ -474,10 +474,10 @@ func (m *Front) WxsearchlistPaging() {
 				s_word := ""
 				if limitFlag {
 					if pageNum == 1 {
-						list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, public.Lst.TotalPage*bidsearch.SearchPageSize_WX, queryItems, filed)
+						list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, public.Lst.TotalPage*bidsearch.SearchPageSize_WX, queryItems, filed, m.GetString("notkey"))
 					}
 				} else {
-					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_WX, queryItems, filed)
+					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_WX, queryItems, filed, m.GetString("notkey"))
 				}
 				listSize := 0
 				if list != nil {

+ 3 - 3
src/jfw/modules/app/src/app/front/swordfish.go

@@ -301,10 +301,10 @@ func (m *Front) WxsearchlistPaging() {
 				s_word := ""
 				if limitFlag {
 					if pageNum == 1 {
-						list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, pageNum, public.Lst.TotalPage*bidsearch.SearchPageSize_APP, queryItems, feld)
+						list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, pageNum, public.Lst.TotalPage*bidsearch.SearchPageSize_APP, queryItems, feld, m.GetString("notkey"))
 					}
 				} else {
-					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_APP, queryItems, feld)
+					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_APP, queryItems, feld, m.GetString("notkey"))
 				}
 				listSize := 0
 				if list != nil {
@@ -321,7 +321,7 @@ func (m *Front) WxsearchlistPaging() {
 					if secondSearch {
 						secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address)
 						findfields := `"title"`
-						qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass))
+						qstr := bidsearch.GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, bidsearch.GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass), m.GetString("notkey"))
 						secRel = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, feld, 0, 2*bidsearch.SearchPageSize_APP, 0, false)
 						if secRel != nil && len(*secRel) > 0 {
 							public.BidListConvert(industry, secRel)

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

@@ -30,7 +30,7 @@ const (
 )
 
 //GetWxsearchlistData 移动端招标信息搜索
-func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, pageNum, pageSize int, selectTypeArr []string, field string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
+func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel 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" {
@@ -48,7 +48,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, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass))
+	qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass), notkey)
 	if hightlightContent { //全文搜索
 		list = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
 	} else { //标题搜索
@@ -64,7 +64,7 @@ func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minpri
 }
 
 //GetPcBidSearchData pc端招标信息搜索
-func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, start, pageSize int, isGetCount bool, selectTypeArr []string, field string) (count, totalPage int64, list *[]map[string]interface{}) {
+func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string) (count, totalPage int64, list *[]map[string]interface{}) {
 	var findfields string
 	var hightlightContent bool = false //是否高亮正文
 	for _, v := range selectTypeArr {
@@ -78,7 +78,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, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass))
+	qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass), notkey)
 	if isGetCount && qstr != "" && start == 0 {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
@@ -191,7 +191,7 @@ func GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass string) st
 	return query
 }
 
-func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, mustquery string) (qstr string) {
+func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, mustquery, notkey string) (qstr string) {
 	multi_match := `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
 	query := `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
@@ -205,10 +205,10 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
 		musts = append(musts, mustquery)
 	}
 	if keyword != "" {
-		multi_match = fmt.Sprintf(multi_match, "%s", findfields)
+		keyword_multi_match := fmt.Sprintf(multi_match, "%s", findfields)
 		shoulds := []string{}
 		for _, v := range strings.Split(keyword, "+") {
-			shoulds = append(shoulds, fmt.Sprintf(multi_match, elastic.ReplaceYH(v)))
+			shoulds = append(shoulds, fmt.Sprintf(keyword_multi_match, elastic.ReplaceYH(v)))
 		}
 		musts = append(musts, fmt.Sprintf(elastic.NgramMust, strings.Join(shoulds, ",")))
 	}
@@ -260,6 +260,18 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
 			musts = append(musts, fmt.Sprintf(query_missing, "winnertel"))
 		}
 	}
+	if notkey = strings.TrimSpace(notkey); notkey != "" {
+		notkey_multi_match := fmt.Sprintf(multi_match, "%s", findfields)
+		notkey_must_not := []string{}
+		for _, v := range strings.Split(notkey, " ") {
+			v = strings.TrimSpace(v)
+			if v == "" {
+				continue
+			}
+			notkey_must_not = append(notkey_must_not, fmt.Sprintf(notkey_multi_match, elastic.ReplaceYH(v)))
+		}
+		must_not = append(must_not, fmt.Sprintf(query_bool_should, strings.Join(notkey_must_not, ","), 1))
+	}
 	qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(must_not, ","))
 	return
 }

+ 11 - 0
src/jfw/public/public.go

@@ -274,3 +274,14 @@ func isEmail(value string) bool {
 	var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
 	return emailPattern.MatchString(value)
 }
+
+func GetDataPkgPhone(userId string) string {
+	lastPhone := ""
+	userData, _ := MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
+	if userData != nil && len(*userData) > 0 {
+		if lastPhone == "" {
+			lastPhone, _ = util.If((*userData)["s_phone"] != nil, (*userData)["s_phone"], (*userData)["s_m_phone"]).(string)
+		}
+	}
+	return lastPhone
+}