zhangxinlei1996 4 years ago
parent
commit
96244feabb
2 changed files with 63 additions and 0 deletions
  1. 61 0
      src/jfw/front/pcIndex.go
  2. 2 0
      src/jfw/front/swordfish.go

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

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"jfw/config"
 	"log"
+	"strconv"
 	"strings"
 
 	"encoding/json"
@@ -26,12 +27,17 @@ type PcIndex struct {
 	newSordfishC xweb.Mapper `xweb:"/pcindex.html"`            //剑鱼标讯pc首页-统计
 	searchResult xweb.Mapper `xweb:"/list/(\\w+)/(\\w+).html"` //剑鱼标讯分类 地区结果列表
 	labelUrl     xweb.Mapper `xweb:"/index/labelUrl"`          //首页链接跳转地址
+	tesa         xweb.Mapper `xweb:"/index/tesa"`
 }
 
 func init() {
 	xweb.AddAction(&PcIndex{})
 }
 
+func (a *PcIndex) Tesa() {
+	GetNewArticle(4)
+}
+
 //剑鱼标讯pc首页
 func (m *PcIndex) NewSordfish() error {
 	ispc, _ := m.GetInteger("ispc")
@@ -68,6 +74,8 @@ func (m *PcIndex) NewSordfish() error {
 		for _, v := range []int{1, 2, 3} {
 			m.T[fmt.Sprintf("labUrl_%d", v)] = GetLabUrl(v) //1地域 2信息类型 3热门招标
 		}
+		//信息条数(上线以来..)
+		m.T["infoNum"] = GetInfoNum()
 		content, _ := m.Render4Cache("/pc/index.html", &m.T)
 		//redis.Put("other", "jypcindex", string(content), 60*60*2)
 		return m.SetBody(content)
@@ -149,6 +157,13 @@ func GetNewArticle(typ int) (list []map[string]interface{}) {
 				v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
 				delete(v, "toptype")
 				delete(v, "s_subscopeclass")
+				tmpdate := v["publishtime"]
+				v["publishtime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
+				if v["budget"] != nil {
+					v["budget"] = ConversionMoeny(v["budget"])
+				} else if v["bidamount"] != nil {
+					v["budget"] = ConversionMoeny(v["bidamount"])
+				}
 			}
 			list = *lists
 			redis.Put("other", rediskey, list, 2*60*60)
@@ -196,6 +211,33 @@ func GetLabUrl(typ int) interface{} {
 	return nil
 }
 
+//招标搜索数量
+func GetInfoNum() (one map[string]interface{}) {
+	defer util.Catch()
+	redis_obj := redis.Get("other", "pcsw_index")
+	if redis_obj != nil {
+		one = redis_obj.(map[string]interface{})
+		log.Println("newpage from the cache...")
+	} else {
+		rs, err := mongodb.Find("swordfish_index", nil, `{"_id":-1}`, nil, false, 0, 1)
+		if err {
+			one = (*rs)[0]
+			one["i_site"] = util.IntAll(one["i_entsite"]) + util.IntAll(one["i_govsite"])
+			avg := util.IntAll(one["i_bidmonth"])/21 + util.IntAll(one["i_bidmonth"])%21
+			one["i_avg"] = avg
+			one["i_my"] = util.IntAll(one["i_entsite"]) * 35 / 100
+			one["i_hy"] = util.IntAll(one["i_entsite"]) * 15 / 100
+			one["i_zb"] = util.IntAll(one["i_entsite"]) - util.IntAll(one["i_my"]) - util.IntAll(one["i_hy"])
+			one["i_push"] = NumberFormat(util.IntAll(one["i_push"]))
+			one["i_bidmonth"] = NumberFormat(util.IntAll(one["i_bidmonth"]))
+			one["i_site"] = NumberFormat(util.IntAll(one["i_site"]))
+			one["i_bidtoday"] = NumberFormat(util.IntAll(one["i_bidtoday"]))
+			redis.Put("other", "pcsw_index", one, 60*60*2)
+		}
+	}
+	return one
+}
+
 //标签查询
 func (f *PcIndex) SearchResult(at, name string) error {
 	defer util.Catch()
@@ -516,3 +558,22 @@ func getstype(stype string) string {
 	}
 	return stype
 }
+
+//
+func NumberFormat(i int) string {
+	str := strconv.Itoa(i)
+	length := len(str)
+	if length < 4 {
+		return str
+	}
+	arr := strings.Split(str, ".") //用小数点符号分割字符串,为数组接收
+	length1 := len(arr[0])
+	if length1 < 4 {
+		return str
+	}
+	count := (length1 - 1) / 3
+	for i := 0; i < count; i++ {
+		arr[0] = arr[0][:length1-(i+1)*3] + "," + arr[0][length1-(i+1)*3:]
+	}
+	return strings.Join(arr, ".") //将一系列字符串连接为一个字符串,之间用sep来分隔。
+}

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

@@ -2091,6 +2091,8 @@ func SearhWebContentblog(querymap map[string]string) (*[]map[string]interface{},
 			res[i]["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
 			tmpdate1, _ := res[i]["releasetime"]
 			res[i]["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1.(float64)), 0))
+			reltime := time.Unix(util.Int64All(tmpdate1.(float64)), 0)
+			res[i]["time"] = reltime.Format(util.Date_Short_Layout) //首页展示
 			res[i]["s_pic"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic"].(string)
 			res[i]["s_pic1"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic1"].(string)
 			res[i]["_id"] = se.EncodeString(res[i]["_id"].(string))