Bläddra i källkod

Merge branch 'dev/v4.8.83_rjj' of qmx/jy into feature/v4.8.83

renjiaojiao 1 år sedan
förälder
incheckning
3b9fa8caf1

+ 67 - 22
src/jfw/front/index.go

@@ -18,6 +18,7 @@ import (
 	"jy/src/jfw/site/jySchool"
 	"math/rand"
 	"regexp"
+	"strings"
 	"time"
 )
 
@@ -33,7 +34,7 @@ var (
 	BiddingTypeUrl = map[int]string{
 		1:  "/list/stype/ZBYG.html",
 		2:  "/list/stype/ZBJG.html",
-		3:  "/list/stype/CGYX.html",
+		5:  "/list/stype/CGYX.html",
 		6:  "/list/stype/XMFB.html",
 		13: "/list/rmxm/",
 		14: "/list/xxxm/",
@@ -184,23 +185,30 @@ func (nIndex *NewIndex) NewIndex() error {
 	//顶部菜单
 	nIndex.T["topMenu"] = g.Cfg("index").MustGet(context.Background(), "topMenu").Maps()
 	//招标公告
-	biddingList, _ := GetRecommendBidZone(5, 8)
+	biddingList, _ := GetRecommendBidZone(5, 16)
 	nIndex.T["newbids"] = map[string]interface{}{
 		"biddingList": biddingList,
 		"more":        fmt.Sprintf("%s", "/list/stype/ZBGG.html"),
 	}
 	//推荐标讯专区
-	rangeInfoType := []int{1, 2, 3}
+	rangeInfoType := []int{1, 2}
 	//招标动态
 	bidTrends := []map[string]interface{}{}
 	for _, v := range rangeInfoType { //1招标预告 2 中标成交 3采购意向 4 拟建项目
-		listData, types := GetRecommendBidZone(v, 5)
+		listData, types := GetRecommendBidZone(v, 10)
 		bidTrends = append(bidTrends, map[string]interface{}{
 			"listData": listData,
 			"types":    types,
 			"url":      fmt.Sprintf("%s", BiddingTypeUrl[v]),
 		})
 	}
+	//采购意向
+	procure, procureName := GetIndexProjectList(5, 5)
+	bidTrends = append(bidTrends, map[string]interface{}{
+		"listData": procure,
+		"types":    procureName,
+		"url":      fmt.Sprintf("%s", BiddingTypeUrl[5]),
+	})
 	//项目分包
 	projectPage, typesName := GetIndexProjectList(6, 5)
 	bidTrends = append(bidTrends, map[string]interface{}{
@@ -254,51 +262,86 @@ func GetRecommendBidZone(typ int, pageSize int) (list []map[string]interface{},
 	if typ == 0 {
 		typ = 1
 	}
-	rediskey := fmt.Sprintf("pcIndexRecommendBidZone_%d", typ)
 	sql := ""
 	switch typ {
 	case 1:
 		//招标预告
 		typs = "招标预告"
-		sql = fmt.Sprintf(" toptype = '%s' ", "预告")
+		sql = fmt.Sprintf(" AND toptype = '%s' ", "预告")
 	case 2:
 		//招标中标成交
 		typs = "中标成交"
-		sql = fmt.Sprintf(" subtype = '%s' or subtype = '%s' ", "中标", "成交")
-	case 3:
-		//采购意向
-		typs = "采购意向"
-		sql = fmt.Sprintf(" toptype = '%s' ", "采购意向")
+		sql = fmt.Sprintf(" AND subtype = '%s' or subtype = '%s' ", "中标", "成交")
+	/*case 3:
+	  //采购意向
+	  typs = "采购意向"
+	  sql = fmt.Sprintf(" AND toptype = '%s' ", "采购意向")*/
 	case 4:
 		//拟建
 		typs = "拟建项目"
-		sql = fmt.Sprintf(" toptype = '%s' ", "拟建")
+		sql = fmt.Sprintf(" AND toptype = '%s' ", "拟建")
 	case 5:
 		typs = "招标公告"
-		sql = fmt.Sprintf(" toptype = '%s' ", "招标")
+		sql = fmt.Sprintf(" AND toptype = '%s' ", "招标")
 	}
+	rediskey := fmt.Sprintf("pcIndexRecommendBidZone_%d", typ)
 	if l, ok := redis.Get(RedisNameNew, rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
 		list = common.ObjArrToMapArr(l)
 		return list, typs
-	} else {
-		bidRes, _ := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,title,publish_time FROM new_bidList WHERE %s ORDER BY publish_time DESC limit %d`, sql, pageSize))
-		if bidRes.IsEmpty() {
-			return nil, typs
+	}
+	queryRes, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT b.bid_id
+			FROM new_areaClass b
+			WHERE 1=1 %s
+			ORDER BY b.publish_time DESC
+			LIMIT 0,?`, sql), pageSize)
+	if err != nil || queryRes.IsEmpty() {
+		return nil, ""
+	}
+	finalArr := FillingBiddingBaseFields(gctx.New(), queryRes.List(), typs)
+	redis.Put(RedisNameNew, rediskey, finalArr, 24*3600)
+	return finalArr, typs
+}
+
+func FillingBiddingBaseFields(ctx context.Context, res []map[string]interface{}, typs string) []map[string]interface{} {
+	bidIdStrings := make([]string, 0, len(res))
+	for _, m := range res {
+		if bidId := gconv.String(m["bid_id"]); bidId != "" {
+			bidIdStrings = append(bidIdStrings, bidId)
 		}
-		var finalArr []map[string]interface{}
-		for _, m := range bidRes.List() {
+	}
+	bidRes, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM new_bidList WHERE bid_id IN ('%s')`, strings.Join(bidIdStrings, "','")))
+	if bidRes.IsEmpty() {
+		return nil
+	}
+	bidMap := map[string]map[string]interface{}{}
+	titleReduction := map[string]bool{}
+	for _, m := range bidRes.List() {
+		if bidIdStr := gconv.String(m["bid_id"]); bidIdStr != "" {
+			//重复标题加数字后缀
+			if titleReduction[gconv.String(m["title"])] {
+				continue
+			}
+			titleReduction[gconv.String(m["title"])] = true
 			m["_id"] = encrypt.EncodeArticleId2ByCheck(common.ObjToString(m["bid_id"]))
 			if typs == "招标公告" {
 				m["publish_time"] = time.Unix(common.Int64All(m["publish_time"]), 0).Format("01-02")
 			} else {
 				m["publish_time"] = time.Unix(common.Int64All(m["publish_time"]), 0).Format("2006-01-02")
 			}
-			finalArr = append(finalArr, m)
+			bidMap[bidIdStr] = m
+		}
+	}
 
+	var finalArr []map[string]interface{}
+	for i := 0; i < len(res); i++ {
+		if tBid := gconv.String(res[i]["bid_id"]); tBid != "" && bidMap[tBid] != nil && len(bidMap[tBid]) > 0 {
+			for k, v := range bidMap[tBid] {
+				res[i][k] = v
+			}
+			finalArr = append(finalArr, res[i])
 		}
-		redis.Put(RedisNameNew, rediskey, finalArr, 24*3600)
-		return finalArr, typs
 	}
+	return finalArr
 }
 
 // GetStrategyList 招投标攻略
@@ -321,6 +364,8 @@ func GetStrategyList() (strategyList []map[string]interface{}) {
 
 func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, types string) {
 	switch typ {
+	case 5:
+		types = "采购意向"
 	case 6:
 		types = "项目分包"
 	case 13:

+ 3 - 1
src/web/templates/pc/template/index/module-card-list-container.html

@@ -15,12 +15,14 @@
       </header>
       <main class="cms-card-content">
         <ul class="cms-card-list clearfix">
-          {{range $vv := $v.listData}}
+          {{range $kk,$vv := $v.listData}}
+          {{if lt $kk 5}}
           <li class="cms-card-list-item">
             <a class="cms-card-list-item-left cms-link ellipsis" target="_blank" title="{{$vv.title}}" href="/nologin/content/{{$vv._id}}.html">{{$vv.title}}</a>
             <span class="cms-card-list-item-right">{{$vv.publish_time}}</span>
           </li>
           {{end}}
+          {{end}}
         </ul>
       </main>
       <!-- <main class="cms-card-content cms-card-list empty">

+ 2 - 0
src/web/templates/pc/template/index/zb-aside-card.html

@@ -8,11 +8,13 @@
   <main class="cms-card-content border-ec">
     <ul class="cms-card-list clearfix">
       {{range $k,$v := .T.newbids.biddingList}}
+      {{if lt $k 8}}
       <li class="cms-card-list-item">
         <a class="cms-card-list-item-left cms-link ellipsis" target="_blank" title="{{$v.title}}" href="/nologin/content/{{$v._id}}.html">{{$v.title}}</a>
         <span class="cms-card-list-item-right">{{$v.publish_time}}</span>
       </li>
       {{end}}
+      {{end}}
     </ul>
   </main>
   <!-- <main class="cms-card-content cms-card-list empty">