|
@@ -1,482 +1,499 @@
|
|
|
package bidsearch
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
- "jfw/public"
|
|
|
- "log"
|
|
|
- "net/http"
|
|
|
- "qfw/util"
|
|
|
- "qfw/util/elastic"
|
|
|
- "qfw/util/jy"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
+ "fmt"
|
|
|
+ "jfw/public"
|
|
|
+ "log"
|
|
|
+ "net/http"
|
|
|
+ "qfw/util"
|
|
|
+ "qfw/util/elastic"
|
|
|
+ "qfw/util/jy"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
//pc、微信、app 招标信息搜索
|
|
|
|
|
|
const (
|
|
|
- INDEX = "bidding"
|
|
|
- TYPE = "bidding"
|
|
|
- bidSearch_sort = `{"publishtime":-1}`
|
|
|
+ INDEX = "bidding"
|
|
|
+ TYPE = "bidding"
|
|
|
+ bidSearch_sort = `{"publishtime":-1}`
|
|
|
|
|
|
- //招标搜索分页--每页显示数量
|
|
|
- SearchPageSize_APP = 50
|
|
|
- SearchPageSize_WX = 50
|
|
|
- SearchPageSize_PC = 50
|
|
|
- //招标搜索分页--最大页数
|
|
|
- SearchMaxPageNum_APP = 10
|
|
|
- SearchMaxPageNum_WX = 10
|
|
|
- SearchMaxPageNum_PC = 10 //免费用户500条记录
|
|
|
- SearchMaxPageNum_PAYED = 100 //付费用户5000条记录
|
|
|
+ //招标搜索分页--每页显示数量
|
|
|
+ SearchPageSize_APP = 50
|
|
|
+ SearchPageSize_WX = 50
|
|
|
+ SearchPageSize_PC = 50
|
|
|
+ //招标搜索分页--最大页数
|
|
|
+ SearchMaxPageNum_APP = 10
|
|
|
+ SearchMaxPageNum_WX = 10
|
|
|
+ SearchMaxPageNum_PC = 10 //免费用户500条记录
|
|
|
+ SearchMaxPageNum_PAYED = 100 //付费用户5000条记录
|
|
|
|
|
|
- bidSearch_field_1 = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass"`
|
|
|
- bidSearch_field = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
|
|
|
+ bidSearch_field_1 = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass"`
|
|
|
+ bidSearch_field = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
|
|
|
)
|
|
|
|
|
|
//GetWxsearchlistData 移动端招标信息搜索
|
|
|
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" {
|
|
|
- hightlightContent = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- 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
|
|
|
- }
|
|
|
- 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), notkey)
|
|
|
- if hightlightContent { //全文搜索
|
|
|
- list = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
|
|
|
- } else { //标题搜索
|
|
|
- list = elastic.GetAllByNgram(INDEX, TYPE, qstr, ``, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, false)
|
|
|
- }
|
|
|
- if list != nil {
|
|
|
- public.BidListConvert(industry, list)
|
|
|
- for _, v := range *list {
|
|
|
- v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
- }
|
|
|
- }
|
|
|
- return list, b_word, a_word, s_word
|
|
|
+ var hightlightContent bool = false //是否高亮正文
|
|
|
+ for _, v := range selectTypeArr {
|
|
|
+ if v == "detail" {
|
|
|
+ hightlightContent = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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), notkey)
|
|
|
+ if hightlightContent { //全文搜索
|
|
|
+ list = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
|
|
|
+ } else { //标题搜索
|
|
|
+ list = elastic.GetAllByNgram(INDEX, TYPE, qstr, ``, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, false)
|
|
|
+ }
|
|
|
+ if list != nil {
|
|
|
+ public.BidListConvert(industry, list)
|
|
|
+ for _, v := range *list {
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list, b_word, a_word, s_word
|
|
|
}
|
|
|
|
|
|
//GetPcBidSearchData pc端招标信息搜索
|
|
|
func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel 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 {
|
|
|
- if v == "detail" {
|
|
|
- hightlightContent = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- if selectTypeArr == nil || len(selectTypeArr) == 0 {
|
|
|
- findfields = `"title"`
|
|
|
- } else {
|
|
|
- findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
- }
|
|
|
- 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)
|
|
|
- }
|
|
|
- if !isGetCount || count > 0 || start > 0 {
|
|
|
- var repl *[]map[string]interface{}
|
|
|
- if hightlightContent {
|
|
|
- repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, start, pageSize, 115, true)
|
|
|
- } else {
|
|
|
- repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, ``, bidSearch_sort, field, start, pageSize, 0, false)
|
|
|
- }
|
|
|
- if repl != nil && *repl != nil && len(*repl) > 0 {
|
|
|
- public.BidListConvert(industry, repl)
|
|
|
- list = repl
|
|
|
- }
|
|
|
- }
|
|
|
- limitCount := util.If(ispayed, int64(SearchPageSize_PC*SearchMaxPageNum_PAYED), int64(SearchPageSize_PC*SearchMaxPageNum_PC)).(int64)
|
|
|
- if count > limitCount {
|
|
|
- count = limitCount
|
|
|
- }
|
|
|
- totalPage = (count + int64(SearchPageSize_PC) - 1) / int64(SearchPageSize_PC)
|
|
|
- return
|
|
|
+ var findfields string
|
|
|
+ var hightlightContent bool = false //是否高亮正文
|
|
|
+ for _, v := range selectTypeArr {
|
|
|
+ if v == "detail" {
|
|
|
+ hightlightContent = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if selectTypeArr == nil || len(selectTypeArr) == 0 {
|
|
|
+ findfields = `"title"`
|
|
|
+ } else {
|
|
|
+ findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ if !isGetCount || count > 0 || start > 0 {
|
|
|
+ var repl *[]map[string]interface{}
|
|
|
+ if hightlightContent {
|
|
|
+ repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, start, pageSize, 115, true)
|
|
|
+ } else {
|
|
|
+ repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, ``, bidSearch_sort, field, start, pageSize, 0, false)
|
|
|
+ }
|
|
|
+ if repl != nil && *repl != nil && len(*repl) > 0 {
|
|
|
+ public.BidListConvert(industry, repl)
|
|
|
+ list = repl
|
|
|
+ }
|
|
|
+ }
|
|
|
+ limitCount := util.If(ispayed, int64(SearchPageSize_PC*SearchMaxPageNum_PAYED), int64(SearchPageSize_PC*SearchMaxPageNum_PC)).(int64)
|
|
|
+ if count > limitCount {
|
|
|
+ count = limitCount
|
|
|
+ }
|
|
|
+ totalPage = (count + int64(SearchPageSize_PC) - 1) / int64(SearchPageSize_PC)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass string) string {
|
|
|
- query := ``
|
|
|
- if area != "" {
|
|
|
- query += `{"terms":{"area":[`
|
|
|
- for k, v := range strings.Split(area, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
- }
|
|
|
- if publishtime != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- starttime, endtime := "", ""
|
|
|
- now := time.Now()
|
|
|
- if publishtime == "lately-7" { //最近7天
|
|
|
- starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
|
|
|
- } else if publishtime == "lately-30" { //最近30天
|
|
|
- starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
|
|
|
- } else if publishtime == "thisyear" { //最近一年
|
|
|
- starttime = fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
|
- endtime = fmt.Sprint(now.Unix())
|
|
|
- } else {
|
|
|
- starttime = strings.Split(publishtime, "_")[0]
|
|
|
- endtime = strings.Split(publishtime, "_")[1]
|
|
|
- etTime := time.Now()
|
|
|
- if endtime != "" {
|
|
|
- et, _ := strconv.ParseInt(endtime, 0, 64)
|
|
|
- etTime = time.Unix(et, 0)
|
|
|
- }
|
|
|
- endtime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
|
|
|
- }
|
|
|
- query += `{"range":{"publishtime":{`
|
|
|
- if starttime != "" {
|
|
|
- query += `"gte":` + starttime
|
|
|
- }
|
|
|
- if starttime != "" && endtime != "" {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- if endtime != "" {
|
|
|
- query += `"lt":` + endtime
|
|
|
- }
|
|
|
- query += `}}}`
|
|
|
- }
|
|
|
- if subtype != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"terms":{"subtype":[`
|
|
|
- for k, v := range strings.Split(subtype, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
- }
|
|
|
- if winner != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"terms":{"s_winner":[`
|
|
|
- for k, v := range strings.Split(winner, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
- }
|
|
|
- if buyerclass != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"terms":{"buyerclass":[`
|
|
|
- for k, v := range strings.Split(buyerclass, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
- }
|
|
|
- return query
|
|
|
+ query := ``
|
|
|
+ if area != "" {
|
|
|
+ query += `{"terms":{"area":[`
|
|
|
+ for k, v := range strings.Split(area, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ if publishtime != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ starttime, endtime := "", ""
|
|
|
+ now := time.Now()
|
|
|
+ if publishtime == "lately-7" { //最近7天
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishtime == "lately-30" { //最近30天
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishtime == "thisyear" { //最近一年
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
|
+ endtime = fmt.Sprint(now.Unix())
|
|
|
+ } else if publishtime == "threeyear" { //最近三年
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year()-3, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
|
+ endtime = fmt.Sprint(now.Unix())
|
|
|
+ } else if publishtime == "fiveyear" { //最近五年
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year()-5, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
|
+ endtime = fmt.Sprint(now.Unix())
|
|
|
+ } else {
|
|
|
+ starttime = strings.Split(publishtime, "_")[0]
|
|
|
+ endtime = strings.Split(publishtime, "_")[1]
|
|
|
+ etTime := time.Now()
|
|
|
+ if endtime != "" {
|
|
|
+ et, _ := strconv.ParseInt(endtime, 0, 64)
|
|
|
+ etTime = time.Unix(et, 0)
|
|
|
+ }
|
|
|
+ endtime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ }
|
|
|
+ query += `{"range":{"publishtime":{`
|
|
|
+ if starttime != "" {
|
|
|
+ query += `"gte":` + starttime
|
|
|
+ }
|
|
|
+ if starttime != "" && endtime != "" {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ if endtime != "" {
|
|
|
+ query += `"lt":` + endtime
|
|
|
+ }
|
|
|
+ query += `}}}`
|
|
|
+ }
|
|
|
+ if subtype != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"subtype":[`
|
|
|
+ for k, v := range strings.Split(subtype, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ if winner != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"s_winner":[`
|
|
|
+ for k, v := range strings.Split(winner, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ if buyerclass != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"buyerclass":[`
|
|
|
+ for k, v := range strings.Split(buyerclass, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ return query
|
|
|
}
|
|
|
|
|
|
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}}`
|
|
|
- query_bools_must := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
|
|
|
- query_bool_must := `{"bool":{"must":[{"terms":{"s_subscopeclass":[%s]}}]}}`
|
|
|
- query_missing := `{"constant_score":{"filter":{"missing":{"field":"%s"}}}}`
|
|
|
- gte := `"gte": %s`
|
|
|
- lte := `"lte": %s`
|
|
|
- musts, must_not := []string{}, []string{}
|
|
|
- if mustquery != "" {
|
|
|
- musts = append(musts, mustquery)
|
|
|
- }
|
|
|
- if keyword != "" {
|
|
|
- keyword_multi_match := fmt.Sprintf(multi_match, "%s", findfields)
|
|
|
- shoulds := []string{}
|
|
|
- for _, v := range strings.Split(keyword, "+") {
|
|
|
- shoulds = append(shoulds, fmt.Sprintf(keyword_multi_match, elastic.ReplaceYH(v)))
|
|
|
- }
|
|
|
- musts = append(musts, fmt.Sprintf(elastic.NgramMust, strings.Join(shoulds, ",")))
|
|
|
- }
|
|
|
- if industry != "" {
|
|
|
- industrys := strings.Split(industry, ",")
|
|
|
- musts = append(musts, fmt.Sprintf(query_bool_must, `"`+strings.Join(industrys, `","`)+`"`))
|
|
|
- }
|
|
|
- if minprice != "" || maxprice != "" {
|
|
|
- sq := ``
|
|
|
- if minprice != "" {
|
|
|
- min, _ := strconv.ParseFloat(minprice, 64)
|
|
|
- minprice = fmt.Sprintf("%.0f", min*10000)
|
|
|
- if minprice == "0" {
|
|
|
- minprice = ""
|
|
|
- }
|
|
|
- }
|
|
|
- if maxprice != "" {
|
|
|
- max, _ := strconv.ParseFloat(maxprice, 64)
|
|
|
- maxprice = fmt.Sprintf("%.0f", max*10000)
|
|
|
- if maxprice == "0" {
|
|
|
- maxprice = ""
|
|
|
- }
|
|
|
- }
|
|
|
- if minprice != "" {
|
|
|
- sq += fmt.Sprintf(gte, minprice)
|
|
|
- }
|
|
|
- if minprice != "" && maxprice != "" {
|
|
|
- sq += `,`
|
|
|
- }
|
|
|
- if maxprice != "" {
|
|
|
- sq += fmt.Sprintf(lte, maxprice)
|
|
|
- }
|
|
|
- if minprice != "" || maxprice != "" {
|
|
|
- query_price := fmt.Sprintf(query_bool_should, fmt.Sprintf(query_bools_must, sq, sq))
|
|
|
- musts = append(musts, query_price)
|
|
|
- }
|
|
|
- }
|
|
|
- if hasBuyerTel != "" {
|
|
|
- if hasBuyerTel == "y" {
|
|
|
- must_not = append(must_not, fmt.Sprintf(query_missing, "buyertel"))
|
|
|
- } else {
|
|
|
- musts = append(musts, fmt.Sprintf(query_missing, "buyertel"))
|
|
|
- }
|
|
|
- }
|
|
|
- if hasWinnerTel != "" {
|
|
|
- if hasWinnerTel == "y" {
|
|
|
- must_not = append(must_not, fmt.Sprintf(query_missing, "winnertel"))
|
|
|
- } else {
|
|
|
- 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, ",")))
|
|
|
- }
|
|
|
- qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(must_not, ","))
|
|
|
- log.Println(qstr)
|
|
|
- return
|
|
|
+ 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}}`
|
|
|
+ query_bools_must := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
|
|
|
+ query_bool_must := `{"bool":{"must":[{"terms":{"s_subscopeclass":[%s]}}]}}`
|
|
|
+ query_missing := `{"constant_score":{"filter":{"missing":{"field":"%s"}}}}`
|
|
|
+ gte := `"gte": %s`
|
|
|
+ lte := `"lte": %s`
|
|
|
+ musts, must_not := []string{}, []string{}
|
|
|
+ if mustquery != "" {
|
|
|
+ musts = append(musts, mustquery)
|
|
|
+ }
|
|
|
+ if keyword != "" {
|
|
|
+ keyword_multi_match := fmt.Sprintf(multi_match, "%s", findfields)
|
|
|
+ shoulds := []string{}
|
|
|
+ for _, v := range strings.Split(keyword, "+") {
|
|
|
+ shoulds = append(shoulds, fmt.Sprintf(keyword_multi_match, elastic.ReplaceYH(v)))
|
|
|
+ }
|
|
|
+ musts = append(musts, fmt.Sprintf(elastic.NgramMust, strings.Join(shoulds, ",")))
|
|
|
+ }
|
|
|
+ if industry != "" {
|
|
|
+ industrys := strings.Split(industry, ",")
|
|
|
+ musts = append(musts, fmt.Sprintf(query_bool_must, `"`+strings.Join(industrys, `","`)+`"`))
|
|
|
+ }
|
|
|
+ if minprice != "" || maxprice != "" {
|
|
|
+ sq := ``
|
|
|
+ if minprice != "" {
|
|
|
+ min, _ := strconv.ParseFloat(minprice, 64)
|
|
|
+ minprice = fmt.Sprintf("%.0f", min*10000)
|
|
|
+ if minprice == "0" {
|
|
|
+ minprice = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if maxprice != "" {
|
|
|
+ max, _ := strconv.ParseFloat(maxprice, 64)
|
|
|
+ maxprice = fmt.Sprintf("%.0f", max*10000)
|
|
|
+ if maxprice == "0" {
|
|
|
+ maxprice = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if minprice != "" {
|
|
|
+ sq += fmt.Sprintf(gte, minprice)
|
|
|
+ }
|
|
|
+ if minprice != "" && maxprice != "" {
|
|
|
+ sq += `,`
|
|
|
+ }
|
|
|
+ if maxprice != "" {
|
|
|
+ sq += fmt.Sprintf(lte, maxprice)
|
|
|
+ }
|
|
|
+ if minprice != "" || maxprice != "" {
|
|
|
+ query_price := fmt.Sprintf(query_bool_should, fmt.Sprintf(query_bools_must, sq, sq))
|
|
|
+ musts = append(musts, query_price)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasBuyerTel != "" {
|
|
|
+ if hasBuyerTel == "y" {
|
|
|
+ must_not = append(must_not, fmt.Sprintf(query_missing, "buyertel"))
|
|
|
+ } else {
|
|
|
+ musts = append(musts, fmt.Sprintf(query_missing, "buyertel"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasWinnerTel != "" {
|
|
|
+ if hasWinnerTel == "y" {
|
|
|
+ must_not = append(must_not, fmt.Sprintf(query_missing, "winnertel"))
|
|
|
+ } else {
|
|
|
+ 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, ",")))
|
|
|
+ }
|
|
|
+ qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(must_not, ","))
|
|
|
+ log.Println(qstr)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
+ var start int
|
|
|
+ vipStatus := jy.GetVipState(public.Mysql, public.MQFW, userId)
|
|
|
+ isPayedUser := vipStatus.IsPayedUser()
|
|
|
+ queryItems := vipStatus.GetQueryItems(selectType, bidSearchOldUserLimit)
|
|
|
|
|
|
- if isPayedUser {
|
|
|
- if currentPage > SearchMaxPageNum_PAYED {
|
|
|
- currentPage = SearchMaxPageNum_PAYED
|
|
|
- }
|
|
|
- } else {
|
|
|
- if currentPage > SearchMaxPageNum_PC {
|
|
|
- currentPage = SearchMaxPageNum_PC
|
|
|
- }
|
|
|
- //时间自定义选择默认是vip 大会员 等权限
|
|
|
- if len(strings.Split(publishtime, "_")) == 2 {
|
|
|
- publishtime = ""
|
|
|
- }
|
|
|
- }
|
|
|
- start = (currentPage - 1) * SearchPageSize_PC
|
|
|
+ if publishtime == "" {
|
|
|
+ if isPayedUser {
|
|
|
+ publishtime = "fiveyear"
|
|
|
+ } else {
|
|
|
+ publishtime = "thisyear"
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return isPayedUser, publishtime, queryItems, currentPage, start
|
|
|
+ if isPayedUser {
|
|
|
+ if currentPage > SearchMaxPageNum_PAYED {
|
|
|
+ currentPage = SearchMaxPageNum_PAYED
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if currentPage > SearchMaxPageNum_PC {
|
|
|
+ currentPage = SearchMaxPageNum_PC
|
|
|
+ }
|
|
|
+ //时间自定义选择默认是vip 大会员 等权限
|
|
|
+ if len(strings.Split(publishtime, "_")) == 2 || publishtime == "threeyear" || publishtime == "fiveyear" {
|
|
|
+ publishtime = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ start = (currentPage - 1) * SearchPageSize_PC
|
|
|
+
|
|
|
+ return isPayedUser, publishtime, queryItems, currentPage, start
|
|
|
}
|
|
|
|
|
|
//所有的再次分词查询 只查标题
|
|
|
func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, secondFlag, area, 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
|
|
|
- for _, item := range queryItems {
|
|
|
- if item == "title" {
|
|
|
- secondSearch = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- if secondSearch {
|
|
|
- secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address)
|
|
|
- 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 && len(*secRel) > 0 {
|
|
|
- public.BidListConvert(industry, secRel)
|
|
|
- if platform == "app" || platform == "wx" {
|
|
|
- for _, v := range *secRel {
|
|
|
- v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if list != nil {
|
|
|
- secRel = public.MapArrSortMerge(*list, *secRel, "_id", "publishtime")
|
|
|
- }
|
|
|
- secondFlag = "T"
|
|
|
- pcAjaxFlag = "T"
|
|
|
- if secondKWS != "" {
|
|
|
- s_word += "+" + secondKWS
|
|
|
- }
|
|
|
- }
|
|
|
- return s_word, pcAjaxFlag, secondFlag, secondKWS, secRel
|
|
|
+ var pcAjaxFlag string
|
|
|
+ secondSearch := false
|
|
|
+ var secRel *[]map[string]interface{} = list
|
|
|
+ for _, item := range queryItems {
|
|
|
+ if item == "title" {
|
|
|
+ secondSearch = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if secondSearch {
|
|
|
+ secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address)
|
|
|
+ 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 && len(*secRel) > 0 {
|
|
|
+ public.BidListConvert(industry, secRel)
|
|
|
+ if platform == "app" || platform == "wx" {
|
|
|
+ for _, v := range *secRel {
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if list != nil {
|
|
|
+ secRel = public.MapArrSortMerge(*list, *secRel, "_id", "publishtime")
|
|
|
+ }
|
|
|
+ secondFlag = "T"
|
|
|
+ pcAjaxFlag = "T"
|
|
|
+ if secondKWS != "" {
|
|
|
+ s_word += "+" + secondKWS
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return s_word, pcAjaxFlag, secondFlag, secondKWS, secRel
|
|
|
}
|
|
|
|
|
|
func classify(stp, area, industry string, configData map[string]interface{}) (string, string, string) {
|
|
|
- var areas, _ = configData["area"].(map[string]interface{})
|
|
|
- var stypes, _ = configData["stype"].(map[string]interface{})
|
|
|
- var industrys, _ = configData["industry"].(map[string]interface{})
|
|
|
- var tpadd = ""
|
|
|
- var areaadd = ""
|
|
|
- var induadd = ""
|
|
|
- if area != "" && area != "A" {
|
|
|
- for k, v := range areas {
|
|
|
- if area == v.(map[string]interface{})["NAME"] {
|
|
|
- areaadd = k
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //
|
|
|
- if stp != "" {
|
|
|
- for k, v := range stypes {
|
|
|
- if stp == v.(map[string]interface{})["NAME"] {
|
|
|
- tpadd = k
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //
|
|
|
- if industry != "" {
|
|
|
- for k, v := range industrys {
|
|
|
- if strings.Contains(util.ObjToString(v.(map[string]interface{})["NAME"]), industry) {
|
|
|
- induadd = k
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return tpadd, areaadd, induadd
|
|
|
+ var areas, _ = configData["area"].(map[string]interface{})
|
|
|
+ var stypes, _ = configData["stype"].(map[string]interface{})
|
|
|
+ var industrys, _ = configData["industry"].(map[string]interface{})
|
|
|
+ var tpadd = ""
|
|
|
+ var areaadd = ""
|
|
|
+ var induadd = ""
|
|
|
+ if area != "" && area != "A" {
|
|
|
+ for k, v := range areas {
|
|
|
+ if area == v.(map[string]interface{})["NAME"] {
|
|
|
+ areaadd = k
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if stp != "" {
|
|
|
+ for k, v := range stypes {
|
|
|
+ if stp == v.(map[string]interface{})["NAME"] {
|
|
|
+ tpadd = k
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if industry != "" {
|
|
|
+ for k, v := range industrys {
|
|
|
+ if strings.Contains(util.ObjToString(v.(map[string]interface{})["NAME"]), industry) {
|
|
|
+ induadd = k
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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, 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
|
|
|
- hasNextPage bool
|
|
|
- )
|
|
|
- if list != nil && len(*list) > 0 {
|
|
|
- if stype != 3 && stype != 4 {
|
|
|
- for _, v := range *list {
|
|
|
- if v["_id"] != nil {
|
|
|
- v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
|
|
|
- }
|
|
|
- stp, ok := v["subtype"].(string)
|
|
|
- if ok && stp == "" {
|
|
|
- stp = v["toptype"].(string)
|
|
|
- }
|
|
|
- area, ok := v["area"].(string)
|
|
|
- indtry := util.ObjToString(v["industry"])
|
|
|
- v["stypeadd"], v["areaadd"], v["indadd"] = classify(stp, area, indtry, configData)
|
|
|
- //正文匹配检索关键词
|
|
|
- highlight, _ := v["highlight"].(map[string][]string)
|
|
|
- detail := ""
|
|
|
- for _, val := range highlight["detail"] {
|
|
|
- detail += public.ClearHtml.ReplaceAllString(val, "")
|
|
|
- }
|
|
|
- v["detail"] = detail
|
|
|
- v["href"] = util.EncodeArticleId2ByCheck(util.GetRandom(20))
|
|
|
- }
|
|
|
- }
|
|
|
- if secondFlag != "" {
|
|
|
- if len(*list) > SearchPageSize_PC {
|
|
|
- secondList = (*list)[SearchPageSize_PC:]
|
|
|
- if len(secondList) > SearchPageSize_PC {
|
|
|
- secondList = secondList[:SearchPageSize_PC]
|
|
|
- }
|
|
|
- *list = (*list)[:SearchPageSize_PC]
|
|
|
- totalPage = 2
|
|
|
- } else {
|
|
|
- totalPage = 1
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ var (
|
|
|
+ secondList []map[string]interface{}
|
|
|
+ totalPage int64
|
|
|
+ hasNextPage bool
|
|
|
+ )
|
|
|
+ if list != nil && len(*list) > 0 {
|
|
|
+ if stype != 3 && stype != 4 {
|
|
|
+ for _, v := range *list {
|
|
|
+ if v["_id"] != nil {
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
|
|
|
+ }
|
|
|
+ stp, ok := v["subtype"].(string)
|
|
|
+ if ok && stp == "" {
|
|
|
+ stp = v["toptype"].(string)
|
|
|
+ }
|
|
|
+ area, ok := v["area"].(string)
|
|
|
+ indtry := util.ObjToString(v["industry"])
|
|
|
+ v["stypeadd"], v["areaadd"], v["indadd"] = classify(stp, area, indtry, configData)
|
|
|
+ //正文匹配检索关键词
|
|
|
+ highlight, _ := v["highlight"].(map[string][]string)
|
|
|
+ detail := ""
|
|
|
+ for _, val := range highlight["detail"] {
|
|
|
+ detail += public.ClearHtml.ReplaceAllString(val, "")
|
|
|
+ }
|
|
|
+ v["detail"] = detail
|
|
|
+ v["href"] = util.EncodeArticleId2ByCheck(util.GetRandom(20))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if secondFlag != "" {
|
|
|
+ if len(*list) > SearchPageSize_PC {
|
|
|
+ secondList = (*list)[SearchPageSize_PC:]
|
|
|
+ if len(secondList) > SearchPageSize_PC {
|
|
|
+ secondList = secondList[:SearchPageSize_PC]
|
|
|
+ }
|
|
|
+ *list = (*list)[:SearchPageSize_PC]
|
|
|
+ totalPage = 2
|
|
|
+ } else {
|
|
|
+ totalPage = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- 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
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
func SearchData(platform string, 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 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, start, SearchPageSize_APP, queryItems, field, notkey)
|
|
|
- } else {
|
|
|
- count, totalPage, list = GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
|
|
|
- }
|
|
|
+ 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, 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, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
|
|
|
+ }
|
|
|
|
|
|
- if len([]rune(s_word)) > 3 && int(count) < SearchPageSize_PC && start == number {
|
|
|
- var paramList *[]map[string]interface{} = list
|
|
|
- s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
|
|
|
- }
|
|
|
+ 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, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
|
|
|
+ }
|
|
|
|
|
|
- listSize := 0
|
|
|
- if list != nil {
|
|
|
- listSize = len(*list)
|
|
|
- }
|
|
|
- public.SaveUserSearchLog(request, userId, -1, platform, "超级搜索", map[string]interface{}{
|
|
|
- "search_word": util.If(platform == "app" || platform == "wx", searchvalue, s_word),
|
|
|
- "search_area": area,
|
|
|
- "search_price": []string{minprice, maxprice},
|
|
|
- "search_publishtime": publishtime,
|
|
|
- "search_type": subtype,
|
|
|
- "search_industry": industry,
|
|
|
- "pagenum": currentPage,
|
|
|
- "pagesize": listSize,
|
|
|
- })
|
|
|
- return
|
|
|
+ listSize := 0
|
|
|
+ if list != nil {
|
|
|
+ listSize = len(*list)
|
|
|
+ }
|
|
|
+ public.SaveUserSearchLog(request, userId, -1, platform, "超级搜索", map[string]interface{}{
|
|
|
+ "search_word": util.If(platform == "app" || platform == "wx", searchvalue, s_word),
|
|
|
+ "search_area": area,
|
|
|
+ "search_price": []string{minprice, maxprice},
|
|
|
+ "search_publishtime": publishtime,
|
|
|
+ "search_type": subtype,
|
|
|
+ "search_industry": industry,
|
|
|
+ "pagenum": currentPage,
|
|
|
+ "pagesize": listSize,
|
|
|
+ })
|
|
|
+ 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
|
|
|
+ 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
|
|
|
}
|