|
@@ -282,25 +282,20 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit, stype int64, currentPage int) (bool, string, []string, int, int) {
|
|
|
+func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit int64, currentPage int) (bool, string, []string, int, int) {
|
|
|
var start int
|
|
|
vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
|
|
|
isPayedUser := vipStatus.IsPayedUser()
|
|
|
queryItems := vipStatus.GetQueryItems(selectType, bidSearchOldUserLimit)
|
|
|
|
|
|
if isPayedUser {
|
|
|
- if stype == 1 || stype == 3 {
|
|
|
- if currentPage > SearchMaxPageNum_PAYED {
|
|
|
- currentPage = SearchMaxPageNum_PAYED
|
|
|
- }
|
|
|
+ if currentPage > SearchMaxPageNum_PAYED {
|
|
|
+ currentPage = SearchMaxPageNum_PAYED
|
|
|
}
|
|
|
} else {
|
|
|
- if stype == 1 || stype == 3 {
|
|
|
- if currentPage > SearchMaxPageNum_PC {
|
|
|
- currentPage = SearchMaxPageNum_PC
|
|
|
- }
|
|
|
+ if currentPage > SearchMaxPageNum_PC {
|
|
|
+ currentPage = SearchMaxPageNum_PC
|
|
|
}
|
|
|
-
|
|
|
//时间自定义选择默认是vip 大会员 等权限
|
|
|
if len(strings.Split(publishtime, "_")) == 2 {
|
|
|
publishtime = ""
|
|
@@ -326,9 +321,9 @@ func IntegratedData(stype int, s_word, secondKWS, industry, minprice, maxprice,
|
|
|
findfields := `"title"`
|
|
|
qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
|
|
|
secRel := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, 0, 2*SearchPageSize_PC, 0, false)
|
|
|
- if secRel != nil {
|
|
|
+ if secRel != nil && len(*secRel) > 0 {
|
|
|
public.BidListConvert(industry, secRel)
|
|
|
- if stype == 3 {
|
|
|
+ if stype == 3 || stype == 4 {
|
|
|
for _, v := range *secRel {
|
|
|
v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
}
|
|
@@ -339,14 +334,11 @@ func IntegratedData(stype int, s_word, secondKWS, industry, minprice, maxprice,
|
|
|
} else {
|
|
|
list = secRel
|
|
|
}
|
|
|
- if len(*secRel) > 0 {
|
|
|
- if secondKWS != "" {
|
|
|
- s_word += "+" + secondKWS
|
|
|
- }
|
|
|
- secondFlag = "T"
|
|
|
- pcAjaxFlag = "T"
|
|
|
+ secondFlag = "T"
|
|
|
+ pcAjaxFlag = "T"
|
|
|
+ if secondKWS != "" {
|
|
|
+ s_word += "+" + secondKWS
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return s_word, pcAjaxFlag, secondFlag, secondKWS
|
|
|
}
|
|
@@ -384,15 +376,17 @@ func classify(stp, area, industry string, configData map[string]interface{}) (st
|
|
|
return tpadd, areaadd, induadd
|
|
|
}
|
|
|
|
|
|
+//list != nil && len(*list) == bidsearch.SearchPageSize_APP && pageNum < util.If(isPayedUser, bidsearch.SearchMaxPageNum_PAYED, bidsearch.SearchMaxPageNum_APP).(int)
|
|
|
//数据格式化处理
|
|
|
-func LisetData(stype int, list *[]map[string]interface{}, secondFlag string, configData map[string]interface{}) ([]map[string]interface{}, int64) {
|
|
|
+func LisetData(stype, pageNum int, list *[]map[string]interface{}, secondFlag string, configData map[string]interface{}, isPayedUser bool) ([]map[string]interface{}, int64, bool) {
|
|
|
var (
|
|
|
- secondList []map[string]interface{}
|
|
|
- totalPage int64
|
|
|
+ secondList []map[string]interface{}
|
|
|
+ totalPage int64
|
|
|
+ hasNextPage bool
|
|
|
)
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
- for _, v := range *list {
|
|
|
- if stype != 3 {
|
|
|
+ if stype != 3 && stype != 4 {
|
|
|
+ for _, v := range *list {
|
|
|
if v["_id"] != nil {
|
|
|
v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
|
|
|
}
|
|
@@ -426,17 +420,30 @@ func LisetData(stype int, list *[]map[string]interface{}, secondFlag string, con
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return secondList, totalPage
|
|
|
+
|
|
|
+ if list != nil && len(*list) == SearchPageSize_WX {
|
|
|
+ hasNextPage = true
|
|
|
+ }
|
|
|
+ if isPayedUser && pageNum >= SearchMaxPageNum_PAYED {
|
|
|
+ hasNextPage = false
|
|
|
+ } else if !isPayedUser && pageNum >= SearchMaxPageNum_WX {
|
|
|
+ hasNextPage = false
|
|
|
+ }
|
|
|
+ return secondList, totalPage, hasNextPage
|
|
|
}
|
|
|
|
|
|
+//1 2 pc 3 app 4 wx
|
|
|
func SearchData(stype int, request *http.Request, currentPage int, userId, secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel 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 (
|
|
|
- platform string
|
|
|
- number int
|
|
|
+ platform string
|
|
|
+ searchvalue = s_word
|
|
|
)
|
|
|
+ number := util.If(stype == 3 || stype == 4, 1, 0)
|
|
|
if stype == 3 {
|
|
|
platform = "app"
|
|
|
- number = 1
|
|
|
+ list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, start, SearchPageSize_APP, queryItems, field, notkey)
|
|
|
+ } else if stype == 4 {
|
|
|
+ platform = "wx"
|
|
|
list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, start, SearchPageSize_APP, queryItems, field, notkey)
|
|
|
} else {
|
|
|
platform = "pc"
|
|
@@ -451,7 +458,7 @@ func SearchData(stype int, request *http.Request, currentPage int, userId, secon
|
|
|
s_word, pcAjaxFlag, secondFlag, second = IntegratedData(stype, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, list)
|
|
|
}
|
|
|
public.SaveUserSearchLog(request, userId, -1, platform, "超级搜索", map[string]interface{}{
|
|
|
- "search_word": s_word,
|
|
|
+ "search_word": util.If(stype == 3 || stype == 4, searchvalue, s_word),
|
|
|
"search_area": area,
|
|
|
"search_price": []string{minprice, maxprice},
|
|
|
"search_publishtime": publishtime,
|
|
@@ -462,3 +469,22 @@ func SearchData(stype int, request *http.Request, currentPage int, userId, secon
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func AddHistory(history, searchvalue string) []string {
|
|
|
+ arrs := strings.Split(history, ",")
|
|
|
+ //新增历史记录
|
|
|
+ if history == "" {
|
|
|
+ arrs = make([]string, 0)
|
|
|
+ }
|
|
|
+ for k, v := range arrs {
|
|
|
+ if v == strings.TrimSpace(searchvalue) {
|
|
|
+ arrs = append(arrs[:k], arrs[k+1:]...)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ arrs = append(arrs, searchvalue)
|
|
|
+ if len(arrs) > 10 {
|
|
|
+ arrs = arrs[1:11]
|
|
|
+ }
|
|
|
+ return arrs
|
|
|
+}
|