Ver código fonte

feat:老用户

wangshan 3 anos atrás
pai
commit
03cc7124d6

+ 17 - 10
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -94,19 +94,26 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		if res.IsLimit == 1 {
 			count, list := util.GetBidSearchData(in)
 			//二次搜索- 一次搜索结果少于一页数据;关键词长度大于三;第一,二页请求;搜索范围包括title;四个条件
-			if len([]rune(in.KeyWords)) > 3 && int(count) < util.SearchPageSize && in.PageNum == 1 && strings.Contains(in.SelectType, "title") {
+			if len([]rune(in.KeyWords)) > 3 && int(count) < util.SearchPageSize && in.PageNum < 3 && strings.Contains(in.SelectType, "title") {
 				if in.KeyWords = util.HttpEs(in.KeyWords, "ik_smart", IC.DB.Es.Addr); in.KeyWords != "" {
 					in.SelectType = "title"
-					_count, _list := util.GetBidSearchData(in)
-					if count < _count {
-						count = _count
-						list = _list
-					}
-					//最多两页数据
-					if count > util.SearchPageSize*2 {
-						count = util.SearchPageSize * 2
-					}
+					//最多查两页数据
+					in.PageSize = 2 * in.PageSize
+					_, secondList := util.GetBidSearchData(in)
 					res.KeyWords = in.KeyWords
+					//数据合并 去重 排序
+					list = util.DelRepeatSearchData(list, secondList)
+					count = int64(len(list))
+					switch {
+					case count > util.SearchPageSize:
+						count = MC.If(count > util.SearchPageSize*2, util.SearchPageSize*2, count).(int64)
+						list = list[:util.SearchPageSize]
+						if in.SplitKeywords != "" {
+							list = list[util.SearchPageSize:count]
+						}
+					case count <= util.SearchPageSize:
+						list = list[:count]
+					}
 				}
 			}
 			limitCount := MC.If(in.UserType != "fType", int64(util.SearchPageSize*util.SearchMaxPageNum_PAYED), int64(util.SearchPageSize*util.SearchMaxPageNum)).(int64)

+ 20 - 0
jyBXCore/rpc/util/search.go

@@ -16,6 +16,7 @@ import (
 	"net/http"
 	"net/url"
 	"regexp"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -606,3 +607,22 @@ func SearchCahcheData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchL
 	}
 	return
 }
+
+//合并map数据,去重,排序
+func DelRepeatSearchData(resOne, resTwo []*bxcore.SearchList) []*bxcore.SearchList {
+	if len(resOne) > 0 && len(resTwo) > 0 {
+		for _, v := range resOne {
+			for n, m := range resTwo {
+				if v.Id == m.Id {
+					resTwo = append(resTwo[0:n], resTwo[n+1:]...)
+					break
+				}
+			}
+		}
+		resOne = append(resOne, resTwo...)
+	}
+	sort.Slice(resOne, func(i, j int) bool {
+		return resOne[i].PublishTime > resOne[j].PublishTime
+	})
+	return resOne
+}

+ 3 - 4
jyBXCore/rpc/util/userInfo.go

@@ -79,12 +79,11 @@ func (vs *VipState) GetQueryItems(selectType string, limitOldTime int64) (items
 		}
 		return
 	}
+	//老用户 使用付费功能
 	isOldUser := vs.registerData != 0 && vs.registerData < limitOldTime
 	for _, t := range strings.Split(selectType, ",") {
-		if t == "winner" {
-			if isOldUser {
-				items = append(items, "mwinner")
-			}
+		if t == "winner" && isOldUser {
+			items = append(items, "mwinner")
 		} else if t == "title" {
 			items = append(items, "title")
 		} else if t == "content" {