|
@@ -1,6 +1,7 @@
|
|
|
package entity
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
"encoding/json"
|
|
|
"entniche_new/src/config"
|
|
|
"fmt"
|
|
@@ -269,7 +270,7 @@ func GetWinnerNewProjectCount(entId string) int64 {
|
|
|
}
|
|
|
|
|
|
// GetBuyerListSearch 采购单位中标动态查询
|
|
|
-func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]interface{}, total int64, err error) {
|
|
|
+func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]interface{}, total, updateTime int64, err error) {
|
|
|
if pwp.Screen.Ent == "" {
|
|
|
err = fmt.Errorf("企业名称异常")
|
|
|
return
|
|
@@ -280,11 +281,13 @@ func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]inter
|
|
|
if pwp.Screen.HasPower {
|
|
|
pwp.PageNum = qutil.If(pwp.PageNum == 0, 1, pwp.PageNum).(int) //默认第一页
|
|
|
pwp.PageSize = qutil.If(pwp.PageSize == 0, 10, pwp.PageSize).(int) //默认每页10条
|
|
|
- } else { //免费用户可以查看三条
|
|
|
- pwp.PageNum = 1
|
|
|
- pwp.PageSize = 5
|
|
|
+ //} else { //免费用户可以查看三条
|
|
|
+ // pwp.PageNum = 1
|
|
|
+ // pwp.PageSize = 5
|
|
|
+ }
|
|
|
+ if !pwp.Screen.HasPower {
|
|
|
+ return pwp.FreePortraitNews(mustQueryArr, false)
|
|
|
}
|
|
|
-
|
|
|
//仅第一页查询总量(非数据导出)
|
|
|
if pwp.PageNum == 1 || pwp.IsExport {
|
|
|
total = elastic.Count(biddingIndex, biddingIndex, fmt.Sprintf(NewMustSearch, strings.Join(mustQueryArr, ","), ""))
|
|
@@ -315,12 +318,51 @@ func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]inter
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func (pwp *PortraitProjectScreen) FreePortraitNews(mustQueryArr []string, isWinner bool) (data *[]map[string]interface{}, total int64, updateTime int64, err error) {
|
|
|
+ redisKey := fmt.Sprintf("free_portrait_list_%s", pwp.Screen.Ent)
|
|
|
+ redisData := make(map[string]interface{})
|
|
|
+ var dataArr []map[string]interface{}
|
|
|
+ if rBytes, err := redis.GetBytes("other", redisKey); err == nil && len(*rBytes) != 0 {
|
|
|
+ _ = json.Unmarshal(*rBytes, &redisData)
|
|
|
+ rData, _ := redisData["data"].([]interface{})
|
|
|
+ dataArr = qutil.ObjArrToMapArr(rData)
|
|
|
+ total = qutil.Int64All(redisData["total"])
|
|
|
+ updateTime = qutil.Int64All(redisData["updateTime"])
|
|
|
+ } else {
|
|
|
+ var fields string
|
|
|
+ updateTime = time.Now().Unix()
|
|
|
+ if isWinner {
|
|
|
+ fields = `"_id","projectname","bidamount","budget","title","publishtime","subtype","toptype","area","bidopentime","buyer"`
|
|
|
+ } else {
|
|
|
+ fields = `"bidstatus","_id","title","subtype","projectname","publishtime","area","bidamount","budget","bidopentime","s_winner","entidlist"`
|
|
|
+ }
|
|
|
+ mustQueryArrStr := strings.Join(mustQueryArr, ",")
|
|
|
+ total = elastic.Count(biddingIndex, biddingIndex, fmt.Sprintf(NewMustSearch, mustQueryArrStr, ""))
|
|
|
+ if total > 0 {
|
|
|
+ listQuery := fmt.Sprintf(NewMustSearch, mustQueryArrStr, fmt.Sprintf(`,"_source":[%s],"sort":{%s},"from":0,"size":%d`, fields, `"publishtime":"desc","id":"desc"`, config.Config.PortraitCount))
|
|
|
+ list := elastic.Get(biddingIndex, biddingIndex, listQuery)
|
|
|
+ if list != nil && len(*list) > 0 {
|
|
|
+ dataArr = *list
|
|
|
+ }
|
|
|
+ }
|
|
|
+ go func() {
|
|
|
+ redis.Put("other", redisKey, map[string]interface{}{
|
|
|
+ "data": dataArr,
|
|
|
+ "total": total,
|
|
|
+ "updateTime": updateTime,
|
|
|
+ }, 24*3600*config.Config.PortraitDynamicTime)
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ data = &dataArr
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GetBuyerList 获取采购单位采购信息数据
|
|
|
// 会员展示1-4页表格数据,免费用户前三条
|
|
|
-func (pwp *PortraitProjectScreen) GetBuyerList() (list []map[string]interface{}, total int64, err error) {
|
|
|
+func (pwp *PortraitProjectScreen) GetBuyerList() (list []map[string]interface{}, total, updateTime int64, err error) {
|
|
|
var newData *[]map[string]interface{}
|
|
|
//查询
|
|
|
- newData, total, err = pwp.GetBuyerListSearch()
|
|
|
+ newData, total, updateTime, err = pwp.GetBuyerListSearch()
|
|
|
if newData == nil || len(*newData) == 0 {
|
|
|
return
|
|
|
}
|
|
@@ -406,7 +448,7 @@ func (pwp *PortraitProjectScreen) CommonPare(isWinner bool) (mustQueryArr []stri
|
|
|
func (pwp *PortraitProjectScreen) GetBuyerListIds() (ids []string, err error) {
|
|
|
var newData *[]map[string]interface{}
|
|
|
//查询
|
|
|
- newData, _, err = pwp.GetBuyerListSearch()
|
|
|
+ newData, _, _, err = pwp.GetBuyerListSearch()
|
|
|
if newData == nil || len(*newData) == 0 {
|
|
|
err = fmt.Errorf("未查询到相关数据")
|
|
|
return
|