Browse Source

搜索多维度查询

wangkaiyue 4 năm trước cách đây
mục cha
commit
c7ce467820

+ 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, "", 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, "title", 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]
 				}

+ 50 - 3
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, "", 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)
@@ -248,12 +248,59 @@ func (p *Pcsearch) PcSearchIndex() error {
 	//高级筛选 仅vip用户可查询
 	var hasBuyerTel, hasWinnerTel string = "", "" //是否有采购单位电话、是否有中标单位电话 y:有 n:没有
 	var buyerclass string = ""                    //采购单位类别
+	var selectTypeArr []string                    //筛选查询内容
+	selectType := p.GetString("selectType")
 	isPayedUser := jy.GetVipState(public.Mysql, public.MQFW, userId).IsPayedUser()
 	if isPayedUser {
 		buyerclass = p.GetString("buyerclass")
 		hasBuyerTel, hasWinnerTel = p.GetString("buyertel"), p.GetString("winnertel")
+
+		switch selectType {
+		case "content":
+			selectTypeArr = append(selectTypeArr, "detail")
+			break
+		case "buyer":
+			selectTypeArr = append(selectTypeArr, "mbuyer")
+			break
+		case "winner":
+			selectTypeArr = append(selectTypeArr, "mwinner")
+			break
+		case "agency":
+			selectTypeArr = append(selectTypeArr, "magency")
+			break
+		case "file":
+			selectTypeArr = append(selectTypeArr, "filetext")
+			break
+		case "all":
+			selectTypeArr = append(selectTypeArr, "title", "detail", "mbuyer", "mwinner", "magency", "filetext")
+			break
+		}
+	} else {
+		if selectType == "winner" || selectType == "all" {
+			isOldUser := func() bool { //查询是否是老用户
+				user, _ := public.MQFW.FindById("user", userId, `{"l_registedate":1}`)
+				if user == nil || len(*user) == 0 {
+					return false
+				}
+				registerData, ok := (*user)["l_registedate"].(int64)
+				if ok && registerData < 9999 {
+					return true
+				}
+				return false
+			}()
+			if selectType == "all" {
+				if isOldUser {
+					selectTypeArr = append(selectTypeArr, "title", "detail", "mwinner")
+				}
+			} else if isOldUser { //查询中标企业且是老用户
+				selectTypeArr = append(selectTypeArr, "mwinner")
+			}
+		} else if selectType == "content" {
+			selectTypeArr = append(selectTypeArr, "detail")
+		}
 	}
-	selectType := "title"
+	//selectType := "title"
+	//全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
 
 	//历史导出数据回显
 	if strings.Contains(p.Url(), "?goback") {
@@ -281,7 +328,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, selectType, bidSearch_field_1)
+		count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, selectTypeArr, bidSearch_field_1)
 		listSize := 0
 		if list != nil {
 			listSize = len(*list)

+ 95 - 7
src/jfw/front/swordfish.go

@@ -119,11 +119,56 @@ func (m *Front) PcAjaxReq() {
 	//高级筛选 仅vip用户可查询
 	var hasBuyerTel, hasWinnerTel string = "", "" //是否有采购单位电话、是否有中标单位电话 y:有 n:没有
 	var buyerclass string = ""                    //采购单位类别
-
+	var selectTypeArr []string                    //筛选查询内容
 	if jy.GetVipState(public.Mysql, public.MQFW, userId).IsPayedUser() {
 		buyerclass = m.GetString("buyerclass")
 		hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
+
+		switch selectType {
+		case "content":
+			selectTypeArr = append(selectTypeArr, "detail")
+			break
+		case "buyer":
+			selectTypeArr = append(selectTypeArr, "mbuyer")
+			break
+		case "winner":
+			selectTypeArr = append(selectTypeArr, "mwinner")
+			break
+		case "agency":
+			selectTypeArr = append(selectTypeArr, "magency")
+			break
+		case "file":
+			selectTypeArr = append(selectTypeArr, "filetext")
+			break
+		case "all":
+			selectTypeArr = append(selectTypeArr, "title", "detail", "mbuyer", "mwinner", "magency", "filetext")
+			break
+		}
+	} else {
+		if selectType == "winner" || selectType == "all" {
+			isOldUser := func() bool { //查询是否是老用户
+				user, _ := public.MQFW.FindById("user", userId, `{"l_registedate":1}`)
+				if user == nil || len(*user) == 0 {
+					return false
+				}
+				registerData, ok := (*user)["l_registedate"].(int64)
+				if ok && registerData < 9999 {
+					return true
+				}
+				return false
+			}()
+			if selectType == "all" {
+				if isOldUser {
+					selectTypeArr = append(selectTypeArr, "title", "detail", "mwinner")
+				}
+			} else if isOldUser { //查询中标企业且是老用户
+				selectTypeArr = append(selectTypeArr, "mwinner")
+			}
+		} else if selectType == "content" {
+			selectTypeArr = append(selectTypeArr, "detail")
+		}
 	}
+
 	m.SetSession("selectType", selectType)
 	//只有前20条 有全字段,
 	if subtype != "拟建" && currentPage != 1 {
@@ -150,7 +195,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, selectType, field)
+				count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, bidsearch.SearchPageSize_PC, true, selectTypeArr, field)
 			}
 		} else if reqType == "bidSearch" {
 			//全文检索限制
@@ -165,7 +210,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, selectType, field)
+						count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, 0, limit_count, true, selectTypeArr, field)
 						if totalPage > int64(public.Lst.TotalPage) {
 							totalPage = int64(public.Lst.TotalPage)
 						}
@@ -174,7 +219,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, selectType, field)
+					count, totalPage, list = bidsearch.GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, start, bidsearch.SearchPageSize_PC, true, selectTypeArr, field)
 				}
 				listSize := 0
 				if list != nil {
@@ -437,10 +482,53 @@ func (m *Front) WxsearchlistPaging() {
 			//高级筛选 仅vip用户可查询
 			var hasBuyerTel, hasWinnerTel string = "", "" //是否有采购单位电话、是否有中标单位电话 y:有 n:没有
 			var buyerclass string = ""                    //采购单位类别
-
+			var selectTypeArr []string
 			if jy.GetVipState(public.Mysql, public.MQFW, userId).IsPayedUser() { //超级订阅、大会员、商机管理
 				buyerclass = m.GetString("buyerclass")
 				hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
+				switch selectType {
+				case "content":
+					selectTypeArr = append(selectTypeArr, "detail")
+					break
+				case "buyer":
+					selectTypeArr = append(selectTypeArr, "mbuyer")
+					break
+				case "winner":
+					selectTypeArr = append(selectTypeArr, "mwinner")
+					break
+				case "agency":
+					selectTypeArr = append(selectTypeArr, "magency")
+					break
+				case "file":
+					selectTypeArr = append(selectTypeArr, "filetext")
+					break
+				case "all":
+					selectTypeArr = append(selectTypeArr, "title", "detail", "mbuyer", "mwinner", "magency", "filetext")
+					break
+				}
+			} else {
+				if selectType == "winner" || selectType == "all" {
+					isOldUser := func() bool { //查询是否是老用户
+						user, _ := public.MQFW.FindById("user", userId, `{"l_registedate":1}`)
+						if user == nil || len(*user) == 0 {
+							return false
+						}
+						registerData, ok := (*user)["l_registedate"].(int64)
+						if ok && registerData < 9999 {
+							return true
+						}
+						return false
+					}()
+					if selectType == "all" {
+						if isOldUser {
+							selectTypeArr = append(selectTypeArr, "title", "detail", "mwinner")
+						}
+					} else if isOldUser { //查询中标企业且是老用户
+						selectTypeArr = append(selectTypeArr, "mwinner")
+					}
+				} else if selectType == "content" {
+					selectTypeArr = append(selectTypeArr, "detail")
+				}
 			}
 
 			//全文检索限制
@@ -455,10 +543,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, selectType, 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, selectTypeArr, filed)
 					}
 				} else {
-					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_WX, selectType, filed)
+					list, b_word, a_word, s_word = bidsearch.GetWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, "", buyerclass, hasBuyerTel, hasWinnerTel, pageNum, bidsearch.SearchPageSize_WX, selectTypeArr, filed)
 				}
 				listSize := 0
 				if list != nil {

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

@@ -273,10 +273,53 @@ func (m *Front) WxsearchlistPaging() {
 			//高级筛选 仅vip用户可查询
 			var hasBuyerTel, hasWinnerTel string = "", "" //是否有采购单位电话、是否有中标单位电话 y:有 n:没有
 			buyerclass := ""                              //采购单位类别
-
+			var selectTypeArr []string
 			if jy.GetVipState(public.Mysql, public.MQFW, userid).IsPayedUser() {
 				buyerclass = m.GetString("buyerclass")
 				hasBuyerTel, hasWinnerTel = m.GetString("buyertel"), m.GetString("winnertel")
+				switch selectType {
+				case "content":
+					selectTypeArr = append(selectTypeArr, "detail")
+					break
+				case "buyer":
+					selectTypeArr = append(selectTypeArr, "mbuyer")
+					break
+				case "winner":
+					selectTypeArr = append(selectTypeArr, "mwinner")
+					break
+				case "agency":
+					selectTypeArr = append(selectTypeArr, "magency")
+					break
+				case "file":
+					selectTypeArr = append(selectTypeArr, "filetext")
+					break
+				case "all":
+					selectTypeArr = append(selectTypeArr, "title", "detail", "mbuyer", "mwinner", "magency", "filetext")
+					break
+				}
+			} else {
+				if selectType == "winner" || selectType == "all" {
+					isOldUser := func() bool { //查询是否是老用户
+						user, _ := public.MQFW.FindById("user", userid, `{"l_registedate":1}`)
+						if user == nil || len(*user) == 0 {
+							return false
+						}
+						registerData, ok := (*user)["l_registedate"].(int64)
+						if ok && registerData < 9999 {
+							return true
+						}
+						return false
+					}()
+					if selectType == "all" {
+						if isOldUser {
+							selectTypeArr = append(selectTypeArr, "title", "detail", "mwinner")
+						}
+					} else if isOldUser { //查询中标企业且是老用户
+						selectTypeArr = append(selectTypeArr, "mwinner")
+					}
+				} else if selectType == "content" {
+					selectTypeArr = append(selectTypeArr, "detail")
+				}
 			}
 			if jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW).CheckBigVipBackPower("search") {
 				winner = m.GetString("winner")
@@ -298,10 +341,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, selectType, 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, selectTypeArr, feld)
 					}
 				} 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, selectType, 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, selectTypeArr, feld)
 				}
 				listSize := 0
 				if list != nil {

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

@@ -30,22 +30,20 @@ const (
 )
 
 //GetWxsearchlistData 移动端招标信息搜索
-func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, pageNum, pageSize int, selectType, field string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
-	b_word, a_word, s_word = jy.InterceptSearchKW(keywords, selectType == "all", len(industry) == 0)
+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) {
+	b_word, a_word, s_word = jy.InterceptSearchKW(keywords, selectTypeArr != nil && len(selectTypeArr) > 1, len(industry) == 0)
 	if len(b_word) == 0 {
 		return list, b_word, a_word, s_word
 	}
-	findfields := `"title"`
-	if selectType == "all" {
-		findfields = `"title","detail"`
-	}
-	qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass))
-	if selectType == "all" { //全文搜索
-		list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
-	} else { //标题搜索
-		list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, false)
+	var findfields string
+	if selectTypeArr == nil || len(selectTypeArr) == 0 {
+		findfields = `"title"`
+	} else {
+		findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
 	}
 
+	qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass))
+	list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, false)
 	if list != nil {
 		public.BidListConvert(industry, list)
 		for _, v := range *list {
@@ -56,26 +54,43 @@ 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, selectType, 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 string) (count, totalPage int64, list *[]map[string]interface{}) {
 	//selectType:全文搜索(all)、标题搜索(title)
-	findfields := `"title"`
-	if selectType == "all" {
-		findfields = `"title","detail"`
+	//全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
+	var findfields string
+	if selectTypeArr == nil || len(selectTypeArr) == 0 {
+		findfields = `"title"`
+	} else {
+		findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
 	}
+	//switch selectType {
+	//case "content":
+	//	findfields = `"detail"`
+	//	break
+	//case "buyer":
+	//	findfields = `"mbuyer"`
+	//	break
+	//case "winner":
+	//	findfields = `"mwinner"`
+	//	break
+	//case "agency":
+	//	findfields = `"magency"`
+	//	break
+	//case "file":
+	//	findfields = `"filetext"`
+	//	break
+	//case "all":
+	//	findfields = `"title","detail","mbuyer","mwinner","magency","filetext"`
+	//	break
+	//default:
+	//	findfields = `"title"`
+	//}
 	qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass))
 	if isGetCount && qstr != "" && start == 0 {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
 	if !isGetCount || count > 0 || start > 0 {
-		var repl *[]map[string]interface{}
-		if selectType == "all" {
-			//全文搜索
-			repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, start, pageSize, 115, true)
-		} else {
-			//标题搜索
-			repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, start, pageSize, 0, false)
-
-		}
+		repl := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, start, pageSize, 0, false)
 		if repl != nil && *repl != nil && len(*repl) > 0 {
 			public.BidListConvert(industry, repl)
 			list = repl