Browse Source

feat:seo 更新

wangshan 2 năm trước cách đây
mục cha
commit
e199de4773

+ 4 - 3
src/jfw/front/entsearch.go

@@ -19,8 +19,8 @@ import (
 
 
 type Entsearch struct {
 type Entsearch struct {
 	*xweb.Action
 	*xweb.Action
-	bidsearchforentindex  xweb.Mapper `xweb:"/jylab/bidsearchforent/index.html"`
-	pcSearchZbqyAjax      xweb.Mapper `xweb:"/jylab/pcSearchZbqyAjax"`
+	//bidsearchforentindex  xweb.Mapper `xweb:"/jylab/bidsearchforent/index.html"`-- 此功能已取消
+	//pcSearchZbqyAjax      xweb.Mapper `xweb:"/jylab/pcSearchZbqyAjax"`-- 此功能已取消
 	recList               xweb.Mapper `xweb:"/jylab/bidsearchforent/recList"`
 	recList               xweb.Mapper `xweb:"/jylab/bidsearchforent/recList"`
 	entSearchIndex        xweb.Mapper `xweb:"/jylab/entSearch/index.html"`
 	entSearchIndex        xweb.Mapper `xweb:"/jylab/entSearch/index.html"`
 	pushSearchIndex       xweb.Mapper `xweb:"/jylab/purSearch/index.html"`
 	pushSearchIndex       xweb.Mapper `xweb:"/jylab/purSearch/index.html"`
@@ -90,6 +90,7 @@ func (e *Entsearch) PurScopebusniessIndex() error {
 	return e.Render("/pc/purScopebusniess.html", &e.T)
 	return e.Render("/pc/purScopebusniess.html", &e.T)
 }
 }
 
 
+// 此功能已失效
 func (e *Entsearch) Bidsearchforentindex() error {
 func (e *Entsearch) Bidsearchforentindex() error {
 	defer util.Catch()
 	defer util.Catch()
 	var shareid = e.GetString("id")
 	var shareid = e.GetString("id")
@@ -192,7 +193,7 @@ func getSearchResult(searchvalue, area string, minprice, maxprice float64, curre
 	return count, totalPage, list
 	return count, totalPage, list
 }
 }
 
 
-// 异步请求方法
+// 异步请求方法   //此功能已失效
 func (e *Entsearch) PcSearchZbqyAjax() error {
 func (e *Entsearch) PcSearchZbqyAjax() error {
 	defer util.Catch()
 	defer util.Catch()
 	userid := util.ObjToString(e.GetSession("userId"))
 	userid := util.ObjToString(e.GetSession("userId"))

+ 10 - 3
src/jfw/front/front.go

@@ -451,10 +451,11 @@ func (f *Front) Extension(page string) error {
 // SEM推广
 // SEM推广
 func (f *Front) Topics() error {
 func (f *Front) Topics() error {
 	f.T["logid"] = config.Seoconfig["jySEMtgy"].(string)
 	f.T["logid"] = config.Seoconfig["jySEMtgy"].(string)
-	userId, _ := f.GetSession("userId").(string)
+	//userId, _ := f.GetSession("userId").(string)
 	f.DisableHttpCache()
 	f.DisableHttpCache()
 	//底部最新招标数据  3*6 条信息
 	//底部最新招标数据  3*6 条信息
-	news := PCS_list("", 18, userId) //Newbids("")[0].([]interface{})
+	//news := PCS_list("", 18, userId) //Newbids("")[0].([]interface{})
+	news := NewBidddingsForSEO("SEO", 3, 6)
 	listAll := [][]map[string]interface{}{}
 	listAll := [][]map[string]interface{}{}
 	i := 1
 	i := 1
 	list := []map[string]interface{}{}
 	list := []map[string]interface{}{}
@@ -464,12 +465,18 @@ func (f *Front) Topics() error {
 			if data["publishtime"] == nil && data["time"] != nil {
 			if data["publishtime"] == nil && data["time"] != nil {
 				continue
 				continue
 			}
 			}
+			if util.ObjToString(data["_id"]) == "" {
+				continue
+			}
+			t := time.Unix(util.Int64All(data["publishtime"]), 0)
+			data["timetemp"] = fmt.Sprint(util.Int64All(data["publishtime"]))
+			data["_id"] = encrypt.EncodeArticleId2ByCheck(util.ObjToString(data["_id"]))
 			if (now-util.Int64All(data["publishtime"]))/60 < 60 {
 			if (now-util.Int64All(data["publishtime"]))/60 < 60 {
 				data["printTime"] = fmt.Sprintf("%d分钟前", (now-util.Int64All(data["publishtime"]))/60)
 				data["printTime"] = fmt.Sprintf("%d分钟前", (now-util.Int64All(data["publishtime"]))/60)
 			} else if (now-util.Int64All(data["publishtime"]))/(60*60) < 24 {
 			} else if (now-util.Int64All(data["publishtime"]))/(60*60) < 24 {
 				data["printTime"] = fmt.Sprintf("%d小时前", (now-util.Int64All(data["publishtime"]))/(60*60))
 				data["printTime"] = fmt.Sprintf("%d小时前", (now-util.Int64All(data["publishtime"]))/(60*60))
 			} else {
 			} else {
-				data["printTime"] = data["time"]
+				data["printTime"] = util.TimeDiff(t)
 			}
 			}
 			data["index"] = i
 			data["index"] = i
 			i++
 			i++

+ 4 - 3
src/jfw/front/pcIndex.go

@@ -289,9 +289,10 @@ func GetInfoNum() (one map[string]interface{}) {
 // 标签查询
 // 标签查询
 func (f *PcIndex) SearchResult(at, name string) error {
 func (f *PcIndex) SearchResult(at, name string) error {
 	defer util.Catch()
 	defer util.Catch()
-	if at == "stype" && name == "NJ" {
-		return f.Redirect("/jylab/supsearch/proposedProject.html")
-	}
+	//NJ 已改成 NJXM  地址:/list/stype/NJXM.html
+	//if at == "stype" && name == "NJ" {
+	//	return f.Redirect("/jylab/supsearch/proposedProject.html")
+	//}
 	userId := util.ObjToString(f.GetSession("userId"))
 	userId := util.ObjToString(f.GetSession("userId"))
 	var no = 5
 	var no = 5
 	var area = ""
 	var area = ""

+ 103 - 65
src/jfw/front/supsearch.go

@@ -31,12 +31,12 @@ import (
 
 
 type Pcsearch struct {
 type Pcsearch struct {
 	*xweb.Action
 	*xweb.Action
-	pcSearchIndex   xweb.Mapper `xweb:"/jylab/(supsearch|medical|bi)/index.html"` //搜索首页
-	getNewBids      xweb.Mapper `xweb:"/jylab/supsearch/getNewBids"`              //最新招标信息
-	getstatus       xweb.Mapper `xweb:"/jylab/supsearch/getstatus"`               //实验室开启状态
-	proposedProject xweb.Mapper `xweb:"/jylab/supsearch/proposedProject.html"`    //拟建项目
-	qr              xweb.Mapper `xweb:"/jylab/supsearch/qr/(.*)"`                 //生成进入实验室的二维码
-	changePro       xweb.Mapper `xweb:"/jylab/changePro"`                         //修改提示信息状态
+	pcSearchIndex xweb.Mapper `xweb:"/jylab/(supsearch|medical|bi)/index.html"` //搜索首页
+	getNewBids    xweb.Mapper `xweb:"/jylab/supsearch/getNewBids"`              //最新招标信息
+	getstatus     xweb.Mapper `xweb:"/jylab/supsearch/getstatus"`               //实验室开启状态
+	//proposedProject xweb.Mapper `xweb:"/jylab/supsearch/proposedProject.html"`    //拟建项目-- 此功能已取消 影响es 检索功能
+	qr        xweb.Mapper `xweb:"/jylab/supsearch/qr/(.*)"` //生成进入实验室的二维码
+	changePro xweb.Mapper `xweb:"/jylab/changePro"`         //修改提示信息状态
 }
 }
 
 
 var industrylist map[string][]string
 var industrylist map[string][]string
@@ -134,6 +134,7 @@ func (p *Pcsearch) ChangePro() {
 	}
 	}
 }
 }
 
 
+// 此功能已失效
 func (p *Pcsearch) ProposedProject() error {
 func (p *Pcsearch) ProposedProject() error {
 	defer util.Catch()
 	defer util.Catch()
 	var shareid = p.GetString("id")
 	var shareid = p.GetString("id")
@@ -565,74 +566,111 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	return p.Render("/pc/supsearch.html", &p.T)
 	return p.Render("/pc/supsearch.html", &p.T)
 }
 }
 
 
-// Newbids  最新招标信息
+// Newbids  最新招标信息 --已失效
 func Newbids(p, userId string) []map[string]interface{} {
 func Newbids(p, userId string) []map[string]interface{} {
-	//fmt.Println("11111", redis.Get("newother", "index_list"))
-	nologin := ""
-	count := 500
-	pagenum := 10
-	limit := 50
-	if userId == "" {
-		nologin = "_nologin"
-		count = bidsearch.SearchMaxPageCount_NOLOGIN
-		pagenum = 20
-		limit = 250
-	}
-	indexOk, _ := redis.Exists("newother", "index_list"+p+nologin)
+	return nil
+	////fmt.Println("11111", redis.Get("newother", "index_list"))
+	//nologin := ""
+	//count := 500
+	//pagenum := 10
+	//limit := 50
+	//if userId == "" {
+	//    nologin = "_nologin"
+	//    count = bidsearch.SearchMaxPageCount_NOLOGIN
+	//    pagenum = 20
+	//    limit = 250
+	//}
+	//indexOk, _ := redis.Exists("newother", "index_list"+p+nologin)
+	//pages := []map[string]interface{}{}
+	//if indexOk {
+	//    pages = util.ObjArrToMapArr(redis.Get("newother", "index_list"+p+nologin).([]interface{}))
+	//}
+	//if len(pages) == 0 {
+	//    var list *[]map[string]interface{}
+	//    subtype := ""
+	//    bidField := ""
+	//    // 判断是不是医疗行业
+	//    if p == "medical" {
+	//        bidField = "0101"
+	//    } else {
+	//        if len(p) > 0 {
+	//            subtype = "拟建"
+	//        }
+	//        //未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
+	//        if subtype == "" {
+	//            subtype = "拟建,招标预告,招标公告,招标结果,招标信用信息"
+	//        }
+	//    }
+	//    //查询置顶信息
+	//    var ss []map[string]interface{}
+	//    ls := top500(subtype, bidField, userId)
+	//    if ls != nil && len(*ls) > 0 {
+	//        ss = append(ss, *ls...)
+	//    }
+	//    //pages = append(pages, ls)
+	//    if ls == nil || len(*ls) < count {
+	//        intns := make([]int, 0)
+	//        for i := 0; i < pagenum; i++ {
+	//            if len(intns) == 0 {
+	//                intns = append(intns, rand.Intn(1000))
+	//            } else {
+	//                for {
+	//                    v := rand.Intn(intns[(i-1)] + 1000)
+	//                    if v-intns[(i-1)] > limit {
+	//                        intns = append(intns, v)
+	//                        break
+	//                    }
+	//                }
+	//            }
+	//        }
+	//        for i := 0; i < pagenum; i++ {
+	//            _, list = getLastNewsData("", "", "", "", subtype, "", "", "", "", "", "", "", "Y", intns[i], true, false, "", bidField, limit)
+	//            if list != nil && len(*list) > 0 {
+	//                ss = append(ss, *list...)
+	//            }
+	//        }
+	//    }
+	//    data := duplicateRemoval(ss)
+	//    if len(data) > 0 {
+	//        pages = data
+	//        redis.Put("newother", "index_list"+p+nologin, pages, 60*60*24)
+	//        pages = util.ObjArrToMapArr(redis.Get("newother", "index_list"+p+nologin).([]interface{}))
+	//    }
+	//}
+	//return pages
+}
+
+// Newbids  最新招标信息
+func NewBidddingsForSEO(p string, pageNum, limit int) []map[string]interface{} {
+	indexOk, _ := redis.Exists("newother", "index_list_"+p)
 	pages := []map[string]interface{}{}
 	pages := []map[string]interface{}{}
 	if indexOk {
 	if indexOk {
-		pages = util.ObjArrToMapArr(redis.Get("newother", "index_list"+p+nologin).([]interface{}))
-	}
-	if len(pages) == 0 {
-		var list *[]map[string]interface{}
-		subtype := ""
-		bidField := ""
-		// 判断是不是医疗行业
-		if p == "medical" {
-			bidField = "0101"
-		} else {
-			if len(p) > 0 {
-				subtype = "拟建"
-			}
-			//未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
-			if subtype == "" {
-				subtype = "拟建,招标预告,招标公告,招标结果,招标信用信息"
-			}
-		}
-		//查询置顶信息
+		pages = util.ObjArrToMapArr(redis.Get("newother", "index_list_"+p).([]interface{}))
+	} else {
 		var ss []map[string]interface{}
 		var ss []map[string]interface{}
-		ls := top500(subtype, bidField, userId)
-		if ls != nil && len(*ls) > 0 {
-			ss = append(ss, *ls...)
-		}
-		//pages = append(pages, ls)
-		if ls == nil || len(*ls) < count {
-			intns := make([]int, 0)
-			for i := 0; i < pagenum; i++ {
-				if len(intns) == 0 {
-					intns = append(intns, rand.Intn(1000))
-				} else {
-					for {
-						v := rand.Intn(intns[(i-1)] + 1000)
-						if v-intns[(i-1)] > limit {
-							intns = append(intns, v)
-							break
-						}
+		intns := make([]int, 0)
+		for i := 0; i < pageNum; i++ {
+			if len(intns) == 0 {
+				intns = append(intns, rand.Intn(30))
+			} else {
+				for {
+					v := rand.Intn(intns[(i-1)] + 50)
+					if v-intns[(i-1)] > limit {
+						intns = append(intns, v)
+						break
 					}
 					}
 				}
 				}
 			}
 			}
-			for i := 0; i < pagenum; i++ {
-				_, list = getLastNewsData("", "", "", "", subtype, "", "", "", "", "", "", "", "Y", intns[i], true, false, "", bidField, limit)
-				if list != nil && len(*list) > 0 {
-					ss = append(ss, *list...)
-				}
+		}
+		for i := 0; i < pageNum; i++ {
+			list := elastic.GetPage(INDEX, TYPE, "", `{"publishtime":-1}`, bidField, intns[i], limit)
+			if list != nil && len(*list) > 0 {
+				ss = append(ss, *list...)
 			}
 			}
 		}
 		}
-		data := duplicateRemoval(ss)
-		if len(data) > 0 {
-			pages = data
-			redis.Put("newother", "index_list"+p+nologin, pages, 60*60*24)
-			pages = util.ObjArrToMapArr(redis.Get("newother", "index_list"+p+nologin).([]interface{}))
+		if len(ss) > 0 {
+			pages = ss
+			redis.Put("newother", "index_list_"+p, ss, 60*60*24)
 		}
 		}
 	}
 	}
 	return pages
 	return pages