|
@@ -10,7 +10,9 @@ import (
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
"io/ioutil"
|
|
|
IC "jyBXCore/rpc/init"
|
|
|
+ "jyBXCore/rpc/internal/config"
|
|
|
"jyBXCore/rpc/type/bxcore"
|
|
|
+ "log"
|
|
|
"math/big"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
@@ -655,3 +657,35 @@ func DelRepeatSearchData(resOne, resTwo []*bxcore.SearchList) []*bxcore.SearchLi
|
|
|
//})
|
|
|
return resOne
|
|
|
}
|
|
|
+
|
|
|
+//付费用户搜索优化
|
|
|
+func IsOptimize(cc config.Config, in *bxcore.SearchReq) bool {
|
|
|
+ if cc.PaySearchLimit.Switch && in.UserType != "fType" {
|
|
|
+ //首页----字数(<7)
|
|
|
+ if in.PageNum <= cc.PaySearchLimit.PageNum && len([]rune(in.KeyWords)) < cc.PaySearchLimit.WordSize {
|
|
|
+ //时间超过一年----
|
|
|
+ if pTime := GetPublishTime(cc.PaySearchLimit.Time, in.PublishTime); pTime != "" {
|
|
|
+ in.PublishTime = pTime
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+func GetPublishTime(tt int, publishTime string) string {
|
|
|
+ //发布时间
|
|
|
+ if publishTime != "" && len(strings.Split(publishTime, "-")) > 1 {
|
|
|
+ now := time.Now()
|
|
|
+ startTime, _ := strconv.ParseInt(strings.Split(publishTime, "-")[0], 10, 64)
|
|
|
+ endTime, _ := strconv.ParseInt(strings.Split(publishTime, "-")[1], 10, 64)
|
|
|
+ pTime := time.Date(now.Year()-tt, now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
|
|
|
+ log.Println(pTime, "---", endTime)
|
|
|
+ //超过一年
|
|
|
+ if endTime > startTime && pTime > startTime {
|
|
|
+ return fmt.Sprint(pTime) + "-" + fmt.Sprint(endTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return publishTime
|
|
|
+}
|