wangshan 2 жил өмнө
parent
commit
5ad1fa54c0

+ 0 - 1
src/config.json

@@ -389,6 +389,5 @@
     "limitDay": 7,
     "limitCount": 3
   },
-  "defaultTotal": 180000000,
   "workDesktopUrl":"/page_workDesktop/work-bench/page?aside=0&link="
 }

+ 10 - 13
src/jfw/front/searchOptimize.go

@@ -633,16 +633,16 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
 
 // GetBidSearchListByCache   查询缓存数据
 //未登录用户默认搜索和关键词搜索改成500条和免费用户保持一致--需求调整P260来自产品经理杨蘭20220116
-func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interface{}, count int64) {
+func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interface{}, count, total int64) {
 	//缓存数据 最大量是5000条  100页数据
-	l, c := func(so *SearchOptimize) (list []*map[string]interface{}, count int64) {
-		//缓存数据: kws.SearchGroup-全部,招标信息,超前信息;kws.PageNum-当前页 免费用户 or 付费用户,BidField:领域化产品
-		redisDataKey := fmt.Sprintf(SearchCacheKey, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
-		log.Println("redisDataKey:", redisDataKey)
+	l, c, t := func(so *SearchOptimize) (list []*map[string]interface{}, count, total int64) {
 		//缓存数据总量 - 当前平台
 		redisCountKey := fmt.Sprintf(SearchCacheCount, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
+		total = int64(redis.GetInt(RedisNameNew, redisCountKey))
+		//缓存数据: kws.SearchGroup-全部,招标信息,超前信息;kws.PageNum-当前页 免费用户 or 付费用户,BidField:领域化产品
+		redisDataKey := fmt.Sprintf(SearchCacheKey, so.SearchGroup, util.If(so.IsPay, "v", "f").(string), util.If(so.BidField != "", so.BidField, "n").(string))
+		log.Println("-------redisDataKey:------", redisDataKey)
 		sCache, err := redis.GetNewBytes(RedisNameNew, redisDataKey)
-		count = int64(redis.GetInt(RedisNameNew, redisCountKey))
 		if err == nil {
 			if sCache != nil && len(*sCache) > 0 {
 				err = json.Unmarshal(*sCache, &list)
@@ -656,13 +656,9 @@ func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interfac
 		//查询缓存数据 参数初始化
 		so.DefaultSearchParamsAuto()
 		//缓存数据
-		count, _, list = so.GetBidSearchList(true)
-		limitCount := int64(bidsearch.SearchPageSize_PC * util.If(so.IsPay, bidsearch.SearchMaxPageNum_PAYED, bidsearch.SearchMaxPageNum_PC).(int))
-		if count > limitCount {
-			count = limitCount
-		}
+		count, total, list = so.GetBidSearchList(true)
 		if len(list) > 0 {
-			redis.Put(RedisNameNew, redisCountKey, count, 16*60*60)
+			redis.Put(RedisNameNew, redisCountKey, total, 16*60*60)
 			b, err := json.Marshal(list)
 			if err == nil {
 				if err = redis.PutBytes(RedisNameNew, redisDataKey, &b, 16*60*60); err != nil {
@@ -677,8 +673,9 @@ func (so *SearchOptimize) GetBidSearchListByCache() (list []*map[string]interfac
 		return
 	}(so)
 	if len(l) > 0 {
-		list = l[(so.PageNum-1)*so.PageSize : so.PageNum*so.PageSize]
+		total = t
 		count = c
+		list = l[(so.PageNum-1)*so.PageSize : so.PageNum*so.PageSize]
 	}
 	return
 }

+ 11 - 11
src/jfw/front/supsearch.go

@@ -256,6 +256,7 @@ func (p *Pcsearch) GetNewBids() error {
 				"list":      []map[string]interface{}{},
 				"count":     0,
 				"totalPage": 0,
+				"total":     0,
 			})
 			return nil
 		}
@@ -272,11 +273,10 @@ func (p *Pcsearch) GetNewBids() error {
 	//搜索条件处理
 	so.SearchParamsHandle()
 	var (
-		list  []*map[string]interface{}
-		count int64
-		total = util.Int64All(config.Sysconfig["defaultTotal"])
+		list         []*map[string]interface{}
+		count, total int64
 	)
-	list, count = so.GetBidSearchListByCache()
+	list, count, total = so.GetBidSearchListByCache()
 	if pageType == "" { //最新招标信息仅第一页条展示表格多字段
 		for k, v := range list {
 			if pagenum == 1 && k < 20 {
@@ -295,9 +295,10 @@ func (p *Pcsearch) GetNewBids() error {
 		}
 	}
 	p.ServeJson(map[string]interface{}{
-		"list":  list,
-		"count": count,
-		"total": total,
+		"list":      list,
+		"count":     count,
+		"total":     total,
+		"totalPage": (count + 1) / int64(pageSize),
 	})
 	return nil
 }
@@ -406,7 +407,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	}
 	var (
 		list                               []*map[string]interface{}
-		totalPage, count, total            int64
+		count, total                       int64
 		secondFlag                         = ""
 		isSearch                           = true
 		b_word, a_word, s_word, heightKeys = "", "", "", ""
@@ -441,8 +442,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 			}
 		} else {
 			p.DisableHttpCache()
-			list, count = so.GetBidSearchListByCache()
-			total = util.Int64All(config.Sysconfig["defaultTotal"])
+			list, count, total = so.GetBidSearchListByCache()
 		}
 	}
 	if noLoginBl {
@@ -490,7 +490,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	p.T["selectType"] = selectType
 	p.T["login"] = p.Session().Get("user")
 	p.T["count"] = count
-	p.T["totalPage"] = totalPage
+	p.T["totalPage"] = (count + 1) / int64(pageSize)
 	p.T["keywords"] = keywords      //搜索关键词
 	p.T["heightWords"] = heightKeys //主关键词和附加词合并后
 	p.T["industry"] = industry

+ 1 - 0
src/jfw/front/swordfish.go

@@ -179,6 +179,7 @@ func (m *Front) PcAjaxReq() {
 		"list":               list,
 		"count":              count,
 		"total":              total,
+		"totalPage":          (count + 1) / int64(pageSize),
 		"interceptOtherWord": a_word,                                                //截取后 用于提示的关键词
 		"interceptKeyWords":  b_word,                                                //超出限制长度 截取后的关键词
 		"interceptLimit":     util.IntAllDef(config.Sysconfig["keywordsLimit"], 35), //限制额度