Browse Source

Merge branch 'dev/v4.8.29_ws' of http://192.168.3.207:8080/qmx/jy into dev/v4.8.29_ws

fuwencai 2 years ago
parent
commit
8ab01e39b5

+ 28 - 0
src/jfw/front/classificationTag.go

@@ -3,6 +3,7 @@ package front
 import (
 	qu "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
 	"app.yhyue.com/moapp/jypkg/public"
@@ -265,3 +266,30 @@ func GetIndustry(industryHref string) []map[string]interface{} {
 	}
 	return m
 }
+
+type BuyerList struct {
+	Name string `json:"name"`
+	Id   string `json:"id"`
+}
+
+// 热门采购单位
+func HotBuyerList() []*BuyerList {
+	// 使用当前时间作为随机数生成器的种子
+	randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
+	// 获取一个范围在 [0, 100) 的随机整数
+	start := randGen.Intn(100)
+	buyerQuery := fmt.Sprintf(`{"query": {"bool": {"must": [{"exists": {"field": "name"}}]}},"from": %d,"size": %d}`, start, 200)
+	log.Println("buyerQuery:", buyerQuery)
+	data := elastic.Get("buyer", "buyer", buyerQuery)
+	if len(*data) > 0 {
+		var buyerList []*BuyerList
+		for _, b := range *data {
+			buyerList = append(buyerList, &BuyerList{
+				Name: qu.ObjToString(b["name"]),
+				Id:   encrypt.EncodeArticleId2ByCheck(qu.ObjToString(b["_id"])),
+			})
+		}
+		return buyerList
+	}
+	return nil
+}

+ 11 - 1
src/jfw/front/entsearch.go

@@ -1,6 +1,7 @@
 package front
 
 import (
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"fmt"
 	"jy/src/jfw/config"
 	"strconv"
@@ -47,6 +48,15 @@ func (e *Entsearch) PushSearchIndex() error {
 	if len(shareid) == 0 {
 		shareid = "10"
 	}
+	if userId, _ := e.GetSession("userId").(string); userId != "" {
+		userInfo := jy.GetVipState(e.Session(), *config.Middleground, userId)
+		e.T["isVip"] = userInfo.VipState > 0
+		e.T["isMember"] = userInfo.BigMember > 0
+		e.T["isEntniche"] = userInfo.EntMember > 0
+		e.T["isEntnicheNew"] = userInfo.IsNewEnt
+		e.T["isEntService"] = userInfo.EntService
+	}
+	e.T["login"] = e.Session().Get("user")
 	e.T["shareid"] = se.EncodeString(shareid)
 	e.T["searchvalue"] = e.GetString("searchvalue")
 	e.T["logid"] = config.Seoconfig["jyzbqyss"].(string)
@@ -170,7 +180,7 @@ func getSearchResult(searchvalue, area string, minprice, maxprice float64, curre
 	return count, totalPage, list
 }
 
-//异步请求方法
+// 异步请求方法
 func (e *Entsearch) PcSearchZbqyAjax() error {
 	defer util.Catch()
 	userid := util.ObjToString(e.GetSession("userId"))

+ 2 - 0
src/jfw/front/pcIndex.go

@@ -107,6 +107,8 @@ func (m *PcIndex) NewSordfish(flag string) error {
 			m.T["recommend"] = ContentRecommendation()
 			//推荐标讯专区
 			m.T["recommendBeacon"] = RecommendationBeacon()
+			//热门采购单位
+			m.T["hotBuyers"] = HotBuyerList()
 			m.T["hasLogin"] = m.GetSession("userId") != ""
 			return m.Render("/pc/index.html", &m.T)
 		}

+ 5 - 1
src/web/templates/pc/index.html

@@ -240,7 +240,11 @@
                 {{end}}
               </ul>
             </div>
-            <div class="hot-buyer-content line-show"></div>
+            <div class="hot-buyer-content simple-show">
+                {{range $k,$v := .T.hotBuyers}}
+                  <a class="tab-link tab-label" href="/swordfish/page_big_pc/unit_portrayal/{{$v.Name}}" target="_blank">{{$v.Name}}</a>
+                {{end}}
+            </div>
           </div>
         </div>
       </div>