|
@@ -446,11 +446,6 @@ func (p *Purchase) FindDataFromES() (int64, []map[string]interface{}, error) {
|
|
|
}
|
|
|
total, list = biddingSearch.GetAllByNgramWithCount(es.LoginTypePay)
|
|
|
fmt.Println(total, "-------------------", list)
|
|
|
- p.Total = total
|
|
|
- total = int64(util.SearchPageSize * util.SearchMaxPageNum)
|
|
|
- if p.Total > total {
|
|
|
- p.Total = total
|
|
|
- }
|
|
|
if total == 0 || list == nil {
|
|
|
return 0, nil, fmt.Errorf("暂无数据")
|
|
|
}
|
|
@@ -472,34 +467,46 @@ func (p *Purchase) GetPurchaseData() (list []*bxcore.PurchaseList, err error) {
|
|
|
//查缓存
|
|
|
cacheBytes, err := redis.GetBytes(redisCode, purchaseCacheKey)
|
|
|
start := int((p.PageNum - 1) * p.PageSize)
|
|
|
- pageSize := p.PageSize
|
|
|
if err == nil && len(*cacheBytes) > start {
|
|
|
end := int(p.PageNum * p.PageSize)
|
|
|
if end > len(*cacheBytes) {
|
|
|
end = len(*cacheBytes)
|
|
|
}
|
|
|
- err = json.Unmarshal((*cacheBytes)[start:end], res)
|
|
|
+ total = int64(len(*cacheBytes))
|
|
|
+ err = json.Unmarshal((*cacheBytes)[start:end], &res)
|
|
|
}
|
|
|
if len(res) == 0 {
|
|
|
p.PageNum = 1
|
|
|
+ pageSize := p.PageSize
|
|
|
+ start = int((p.PageNum - 1) * p.PageSize)
|
|
|
+ end := int(p.PageNum * p.PageSize)
|
|
|
p.PageSize = int64(util.SearchPageSize * util.SearchMaxPageNum)
|
|
|
total, res, err = p.FindDataFromES()
|
|
|
log.Println(total, "----------缓存数据:", len(res))
|
|
|
- if total > 0 && res != nil {
|
|
|
+ if total > 0 && len(res) > 0 {
|
|
|
var b []byte
|
|
|
b, err = json.Marshal(res)
|
|
|
log.Println(b, "----------------002---------------------", err)
|
|
|
if err == nil && len(b) > 0 {
|
|
|
err = redis.PutBytes(redisCode, purchaseCacheKey, &b, purchaseCacheExpire)
|
|
|
}
|
|
|
+ if end > len(res) {
|
|
|
+ end = len(res)
|
|
|
+ }
|
|
|
+ res = res[start:end]
|
|
|
}
|
|
|
+ p.PageSize = pageSize
|
|
|
}
|
|
|
- res = (res)[start:pageSize]
|
|
|
} else {
|
|
|
//实时查询
|
|
|
- _, res, err = p.FindDataFromES()
|
|
|
+ total, res, err = p.FindDataFromES()
|
|
|
}
|
|
|
if len(res) > 0 {
|
|
|
+ p.Total = total
|
|
|
+ total = int64(util.SearchPageSize * util.SearchMaxPageNum)
|
|
|
+ if p.Total > total {
|
|
|
+ p.Total = total
|
|
|
+ }
|
|
|
list = p.PurchaseListFormat(res)
|
|
|
}
|
|
|
return
|