Browse Source

Merge branch 'dev/v4.8.47_ws' of qmx/jy into feature/v4.8.47

wangshan 2 years ago
parent
commit
30377160d4

+ 61 - 48
src/jfw/modules/app/src/app/front/tags.go

@@ -67,14 +67,34 @@ func init() {
 	}
 	//随机数
 	jyutil.RandNum = jyutil.RandomNumberGenerator()
-	//地区
+	//地区-读取配置
 	if areaInfoByte, err := json.Marshal(config.Seoconfig["areaInfo"]); err == nil {
 		if err = json.Unmarshal(areaInfoByte, &jyutil.AreaInfo); err != nil {
+			log.Println("areaInfo unmarshal err:", err)
+		}
+	} else {
+		log.Println("获取地区信息异常:", err)
+	}
+	//省份-读取配置
+	if areaByte, err := json.Marshal(config.Seoconfig["area"]); err == nil {
+		if err = json.Unmarshal(areaByte, &jyutil.AreaMap); err != nil {
 			log.Println("area unmarshal err:", err)
 		}
 	} else {
 		log.Println("获取地区信息异常:", err)
 	}
+	//城市-读取配置
+	if cityByte, err := json.Marshal(config.Seoconfig["city"]); err == nil {
+		if err = json.Unmarshal(cityByte, &jyutil.CityMap); err != nil {
+			log.Println("city unmarshal err:", err)
+		}
+	} else {
+		log.Println("获取地区信息异常:", err)
+	}
+	//初始化地区信息
+	jyutil.GetAllArea()
+	//热门地区
+	jyutil.GetHotArea()
 }
 
 func (tg *Tags) TagsIndex(first, types, name string) error {
@@ -89,20 +109,13 @@ onceAgain:
 	tagsMobileKey := fmt.Sprintf("tags_mobile_key_%s_%s", types, name)
 	if res := redis.Get("seoCache", tagsMobileKey); res == nil || res == "" {
 		var (
-			areaList           []map[string][]*jyutil.SeoInfo //地区
-			infoTypeList       []map[string]interface{}       //信息类型
-			currentLocation    []*jyutil.SeoInfo
-			hasIndustryNav     bool // 有没有招标导航
-			prevPage, nextPage string
-			areaTopTip         string
-			areaToCode         = map[string]*jyutil.SeoInfo{}
-			cityToCode         = map[string]*jyutil.SeoInfo{}
-			areaToCity         = map[string][]*jyutil.SeoInfo{}
-			topMap             = map[string]*jyutil.SeoInfo{}
-			codes              = strings.Split(name, "_")
-			title              = "剑鱼标讯官网_招标信息查询_全国招标采购信息订阅推送_专业招标大数据平台"
-			suffix             = "_剑鱼标讯官网"
-			biddingInfo        = jyutil.BiddingInfo{
+			infoTypeList                        []map[string]interface{} //信息类型
+			currentLocation                     []*jyutil.SeoInfo
+			hasIndustryNav                      bool // 有没有招标导航
+			prevPage, nextPage, tdk, areaTopTip string
+			topInfoMap                          = map[string]*jyutil.SeoInfo{}
+			codes                               = strings.Split(name, "_")
+			biddingInfo                         = jyutil.BiddingInfo{
 				Total:    qu.IntAll(config.Seoconfig["seoTotal"]), //查询数据总量
 				PageSize: qu.IntAll(config.Seoconfig["seoSize"]),  //每页数据量
 				PageNum:  1,                                       //当前页码
@@ -110,29 +123,31 @@ onceAgain:
 			}
 			isInfoList bool // 是否是在列表页面
 		)
-		areaList, areaToCode, cityToCode, areaToCity = jyutil.GetAllArea()
-		infoTypeList, topMap = jyutil.GetInfoType()
+		if len(jyutil.AreaInfo) == 0 || jyutil.AreaMap == nil {
+			jyutil.GetAllArea()
+		}
+		//areaList, areaToCode, cityToCode, areaToCity = jyutil.GetAllArea()
+		infoTypeList, topInfoMap = jyutil.GetInfoType()
 		switch types {
-		case jyutil.Label["area"]: //地区
-			if len(codes) == 3 {
-				areaCode, cityCode := codes[0], codes[1]
-				if areaToCode[areaCode] != nil {
+		case jyutil.Label["area"], jyutil.Label["city"]: //地区
+			if len(codes) == 2 || len(codes) == 1 {
+				if jyutil.AreaCityToCode[codes[0]] != nil {
 					biddingInfo.IsEffective = true
-					currentLocation = append(currentLocation, areaToCode[areaCode])
-					biddingInfo.Area = areaToCode[areaCode].Name
+					currentLocation = append(currentLocation, jyutil.AreaCityToCode[codes[0]])
+					biddingInfo.Area = jyutil.AreaCityToCode[codes[0]].Name
+					tdk = biddingInfo.Area
 					areaTopTip = fmt.Sprintf("%s%s", biddingInfo.Area, "招标网")
-					title = fmt.Sprintf("%s%s", areaTopTip, suffix)
-					if cityCode != "0" && cityToCode[cityCode] != nil {
-						currentLocation = append(currentLocation, cityToCode[cityCode])
-						biddingInfo.City = cityToCode[cityCode].Name
-						areaTopTip = fmt.Sprintf("%s%s", biddingInfo.City, "招标网")
-						title = fmt.Sprintf("%s%s", areaTopTip, suffix)
-					} else if cityCode == "0" && !directRuleCity[biddingInfo.Area] {
-						tg.T["cityList"] = areaToCity[areaCode]
-					} else if cityCode == "0" && directRuleCity[biddingInfo.Area] {
-						// 直辖市不显示下面的管理城市
-					} else {
-						biddingInfo.IsEffective = false //没有对应城市 异常
+					if len(codes) == 2 {
+						if jyutil.AreaCityToCode[name] != nil {
+							currentLocation = append(currentLocation, jyutil.AreaCityToCode[name])
+							biddingInfo.City = jyutil.AreaCityToCode[name].Name
+							areaTopTip = fmt.Sprintf("%s%s", biddingInfo.City, "招标网")
+							tdk = biddingInfo.City
+						} else {
+							biddingInfo.IsEffective = false //没有对应城市 异常
+						}
+					} else if !directRuleCity[biddingInfo.Area] { //非直辖市
+						tg.T["cityList"] = jyutil.AreaToCity[codes[0]]
 					}
 					if len(currentLocation) > 0 {
 						for _, cv := range currentLocation {
@@ -142,6 +157,8 @@ onceAgain:
 					biddingInfo.Total = 8
 					biddingInfo.PageSize = 8
 					hasIndustryNav = true
+				} else {
+					biddingInfo.IsEffective = false //没有对应城市 异常
 				}
 			}
 		case jyutil.Label["infoType"]: //信息类型
@@ -149,19 +166,19 @@ onceAgain:
 				codes = strings.Split(infoTypeToCode[name], "_")
 			}
 			if len(codes) == 2 {
-				if topMap != nil && topMap[codes[0]] != nil {
+				if topInfoMap != nil && topInfoMap[codes[0]] != nil {
 					biddingInfo.IsEffective = true
-					biddingInfo.TopType = bidsearch.TopType[topMap[codes[0]].Name]
+					biddingInfo.TopType = bidsearch.TopType[topInfoMap[codes[0]].Name]
 					if biddingInfo.TopType == "" {
 						biddingInfo.TopType = "拟建" //正常不会走到此处
 					}
-					currentLocation = append(currentLocation, topMap[codes[0]])
-					title = fmt.Sprintf("%s%s", topMap[codes[0]].Name, suffix)
+					code, _ := strconv.ParseInt(codes[0], 10, 64)
+					tdk = jyutil.CodeToInfoType[code]
+					currentLocation = append(currentLocation, topInfoMap[codes[0]])
 					biddingInfo.PageFormat(codes[1])
 					prevPage = fmt.Sprintf("%s_%d", codes[0], biddingInfo.PageNum-1)
 					nextPage = fmt.Sprintf("%s_%d", codes[0], biddingInfo.PageNum+1)
 					if biddingInfo.PageNum == 2 {
-						code, _ := strconv.ParseInt(codes[0], 10, 64)
 						prevPage = jyutil.CodeToInfoType[code]
 					}
 					isInfoList = true
@@ -183,7 +200,7 @@ onceAgain:
 					biddingInfo.Industry = fmt.Sprintf("%s_%s", class1, class2)                 //行业
 					biddingInfo.Keys = indu2                                                    //关键词
 					biddingInfo.Total = qu.IntAll(config.Seoconfig["seoUnderlyingAssetsTotal"]) //标的物查询数据量100
-					title = fmt.Sprintf("%s招标采购%s", indu2, suffix)
+					tdk = indu2
 					biddingInfo.PageFormat(codes[4])
 					prevPage = fmt.Sprintf("%s_all_all_%s_%d", codes[0], codes[3], biddingInfo.PageNum-1)
 					nextPage = fmt.Sprintf("%s_all_all_%s_%d", codes[0], codes[3], biddingInfo.PageNum+1)
@@ -196,14 +213,12 @@ onceAgain:
 				biddingInfo.IsEffective = true
 				biddingInfo.IsSearch = false
 				tg.T["industryData"] = jyutil.GetIndustry("/jyapp/s/tags/industry/%d_all_all_%d.html") // 行业标的物全部
-				title = fmt.Sprintf("%s%s", "招标导航", suffix)
 			}
 		case jyutil.Label["buyer"]: //采购单位
 			biddingInfo.IsEffective = true
 			biddingInfo.PageFormat(name)
 			prevPage = fmt.Sprintf("%d", biddingInfo.PageNum-1)
 			nextPage = fmt.Sprintf("%d", biddingInfo.PageNum+1)
-			title = fmt.Sprintf("%s%s", "采购单位", suffix)
 			biddingInfo.IsBuyer = true
 			currentLocation = append(currentLocation, &jyutil.SeoInfo{
 				Name: "采购单位",
@@ -222,7 +237,6 @@ onceAgain:
 			})
 			biddingInfo.IsSearch = false
 			hasIndustryNav = true
-			title = fmt.Sprintf("%s%s", "中标企业", suffix)
 			isInfoList = true
 		case jyutil.Label["home"]: //首页
 			if name == types {
@@ -246,7 +260,7 @@ onceAgain:
 			currentLocation[len(currentLocation)-1].Url = ""
 		}
 		tg.T["infoTypeList"] = infoTypeList //tg.GetInfoType()
-		tg.T["areaList"] = areaList
+		tg.T["areaList"] = jyutil.AreaInfo
 		tg.T["currentLocation"] = currentLocation
 		//行业首页 不用广告位
 		if !(types == "industry" && name == "home") {
@@ -265,7 +279,7 @@ onceAgain:
 		tg.T["nextPage"] = qu.If(nextPage != "", fmt.Sprintf("/jyapp/s/tags/%s/%s.html", types, nextPage), "").(string)
 		tg.T["totalPage"] = (biddingInfo.Total-1)/biddingInfo.PageSize + 1
 		tg.T["pageNum"] = biddingInfo.PageNum
-		tg.T["hotArea"] = jyutil.GetHotArea()
+		tg.T["hotArea"] = jyutil.HotAreas
 		if biddingInfo.IsBuyer && !biddingInfo.IsWinner {
 			//tg.T["buyerList"] = &jyutil.InfoRes{
 			//	Name: "采购单位",
@@ -284,9 +298,8 @@ onceAgain:
 			tg.T["industryNav"] = jyutil.GetIndustryNav(jyutil.GetIndustry("/jyapp/s/tags/industry/%d_all_all_%d.html")) // 标的物小于等于5个字的
 		}
 		tg.T["areaTopTip"] = areaTopTip
-		tg.T["title"] = title
 		//todo 获取tdk
-		tg.T["tdk"] = jyutil.GetTdk(types, "")
+		tg.T["tdk"] = jyutil.GetTdk(types, tdk)
 		tg.T["HomeOrigin"] = "/jyapp/s/tags/home/home.html"
 		tg.T["Home"] = "/jyapp/jylab/mainSearch"
 		tg.T["isInfoList"] = isInfoList

+ 43 - 66
src/jfw/modules/app/src/app/jyutil/tags.go

@@ -24,8 +24,6 @@ import (
 var (
 	mobileHref          = "/jyapp/s/tags/%s/%s.html"
 	infoTypeRedisKey    = "mobile_seo_infoType_home"
-	areaRedisKey        = "mobile_seo_area_home"
-	hotAreaRedisKey     = "mobile_seo_hot_area"
 	biddingListKey      = "mobile_seo_list_%s_%s_%d"
 	biddingListTotalKey = "mobile_seo_list_total_%s_%s"
 	industryRedisKey    = "mobile_seo_industry"
@@ -36,6 +34,7 @@ var (
 	randCount           = 600
 	Label               = map[string]string{
 		"area":     "area",
+		"city":     "city",
 		"infoType": "stype",
 		"industry": "industry",
 		"buyer":    "buyer",
@@ -60,6 +59,12 @@ var (
 	defaultDescription = "剑鱼标讯是国内专业的招标大数据服务平台,专注于全国招标采购信息的搜索查询、订阅推送和数据定制化服务。提供涵盖拟在建项目、招标预告、招标公告、中标公告、政府采购、企业工商信息等多种信息类型,帮助企业全方位掌握市场动态变化。招投标大数据平台就用剑鱼标讯。"
 )
 
+type tkd struct {
+	NAME        string
+	TITLE       string
+	KEYWORDS    string
+	DESCRIPTION string
+}
 type ReqLimit struct {
 	DoPool   chan struct{}
 	WaitPool chan struct{}
@@ -120,24 +125,15 @@ func GetInfoType() (list []map[string]interface{}, topMap map[string]*SeoInfo) {
 }
 
 // GetHotArea 获取热门地区
-func GetHotArea() (list []map[string]interface{}) {
-	if l, ok := redis.Get("seoCache", hotAreaRedisKey).([]interface{}); ok && l != nil && len(l) > 0 {
-		list = qu.ObjArrToMapArr(l)
-	} else {
-		data := public.BaseMysql.SelectBySql(fmt.Sprintf(`select name,code,level,pcode from seo_words.seo_area WHERE name IN ('%s') order by code`, strings.ReplaceAll(HotArea, ",", "','")))
-		if data != nil && len(*data) > 0 {
-			for _, v := range *data {
-				list = append(list, map[string]interface{}{
-					"name": qu.ObjToString(v["name"]),
-					"url":  fmt.Sprintf(mobileHref, Label["area"], combine(3, qu.Int64All(v["code"]), 0, 1)),
-				})
-			}
-			if len(list) > 0 {
-				redis.Put("seoCache", hotAreaRedisKey, list, qu.IntAll(config.Seoconfig["cacheTime"])+RandNum.Intn(randCount))
-			}
+func GetHotArea() {
+	if HotArea != "" {
+		for _, v := range strings.Split(HotArea, ",") {
+			HotAreas = append(HotAreas, &SeoInfo{
+				Name: v,
+				Url:  AreaToUrl[v],
+			})
 		}
 	}
-	return list
 }
 
 func combine(num int, pid, id, pageNum int64) string {
@@ -158,51 +154,31 @@ type SeoInfo struct {
 }
 
 // GetAllArea 获取所有地区信息
-func GetAllArea() (areaList []map[string][]*SeoInfo, areaToCode map[string]*SeoInfo, cityToCode map[string]*SeoInfo, areaToCity map[string][]*SeoInfo) {
+func GetAllArea() {
 	areaLock.Lock()
 	defer areaLock.Unlock()
-	var (
-		data []map[string]interface{}
-	)
-	if l, ok := redis.Get("seoCache", areaRedisKey).([]interface{}); ok && l != nil && len(l) > 0 {
-		data = qu.ObjArrToMapArr(l)
-	} else {
-		data = *public.BaseMysql.SelectBySql(`select name,code,level,pcode from seo_words.seo_area order by code`)
-		if data != nil && len(data) > 0 {
-			if b := redis.Put("seoCache", areaRedisKey, data, qu.IntAll(config.Seoconfig["cacheTime"])+RandNum.Intn(randCount)); !b {
-				log.Println("缓存保存失败,key:", areaRedisKey)
+	///list/area/HB.html
+	if AreaMap != nil && CityMap != nil {
+		for ak, am := range AreaMap {
+			AreaCityToCode[ak] = &SeoInfo{
+				Name: am.NAME,
+				Url:  fmt.Sprintf(mobileHref, Label["area"], ak),
 			}
+			AreaToUrl[am.NAME] = fmt.Sprintf(mobileHref, Label["area"], ak)
 		}
-	}
-	if data != nil && len(data) > 0 {
-		areaMap := map[string]string{}
-		areaToCity = map[string][]*SeoInfo{}
-		areaToCode = map[string]*SeoInfo{}
-		cityToCode = map[string]*SeoInfo{}
-		for _, v := range data {
-			name := qu.ObjToString(v["name"]) //名称
-			code := qu.Int64All(v["code"])    //行政区号
-			level := qu.Int64All(v["level"])
-			pCode := qu.Int64All(v["pcode"])
-			switch level {
-			case 1:
-				areaToCode[fmt.Sprintf("%d", code)] = &SeoInfo{
-					Name: name,
-					Url:  fmt.Sprintf(mobileHref, Label["area"], combine(3, qu.Int64All(v["code"]), 0, 1)),
-				}
-				areaMap[qu.ObjToString(v["name"])] = fmt.Sprintf(mobileHref, Label["area"], combine(3, qu.Int64All(v["code"]), 0, 1))
-			case 2:
-				cityToCode[fmt.Sprintf("%d", code)] = &SeoInfo{
-					Name: name,
-					Url:  fmt.Sprintf(mobileHref, Label["area"], combine(3, pCode, code, 1)),
-				}
-				areaToCity[fmt.Sprintf("%d", pCode)] = append(areaToCity[fmt.Sprintf("%d", pCode)], &SeoInfo{
-					Name: name,
-					Url:  fmt.Sprintf(mobileHref, Label["area"], combine(3, pCode, code, 1)),
+		for ck, cm := range CityMap {
+			AreaCityToCode[ck] = &SeoInfo{
+				Name: cm.NAME,
+				Url:  fmt.Sprintf(mobileHref, Label["area"], ck),
+			}
+			if strings.Contains(ck, "_") {
+				AreaToCity[strings.Split(ck, "_")[0]] = append(AreaToCity[strings.Split(ck, "_")[0]], &SeoInfo{
+					Name: cm.NAME,
+					Url:  fmt.Sprintf(mobileHref, Label["area"], ck),
 				})
 			}
 		}
-		if areaMap != nil {
+		if AreaToUrl != nil {
 		L:
 			for _, av := range AreaInfo {
 				for _, avv := range av {
@@ -210,12 +186,11 @@ func GetAllArea() (areaList []map[string][]*SeoInfo, areaToCode map[string]*SeoI
 						if an.Url != "" {
 							break L
 						}
-						an.Url = areaMap[an.Name]
+						an.Url = AreaToUrl[an.Name]
 					}
 				}
 			}
 		}
-		areaList = AreaInfo
 	}
 	return
 }
@@ -331,6 +306,12 @@ var (
 			Nickname: "拟建",
 		},
 	}
+	AreaMap        = map[string]tkd{}
+	CityMap        = map[string]tkd{}
+	AreaCityToCode = map[string]*SeoInfo{}
+	AreaToCity     = map[string][]*SeoInfo{}
+	AreaToUrl      = map[string]string{}
+	HotAreas       []*SeoInfo
 )
 
 func (b *BiddingInfo) PageFormat(page string) {
@@ -837,12 +818,12 @@ type TdkStruct struct {
 func GetTdk(types, name string) (tdk TdkStruct) {
 	title, keywords, description := defaultTitle, defaultKeywords, defaultDescription
 	switch types {
-	case "area": // 省份页面
+	case Label["area"], Label["city"]: // 省份页面
 		title = fmt.Sprintf("%s免费招标信息_%s采购服务平台_%s中标公告-剑鱼标讯", name, name, name)
-		keywords = fmt.Sprintf("%s免费招标信息,%s招标公告,%s中标公告,%s招标采购,%s招标网", name, name, name, name)
+		keywords = fmt.Sprintf("%s免费招标信息,%s招标公告,%s中标公告,%s招标采购,%s招标网", name, name, name, name, name)
 		description = fmt.Sprintf("剑鱼标讯%s专栏,提供%s免费招标信息、%s招标公告、%s中标公告和%s招标采购等内容,以及%s招标信息搜索查询、订阅推送和数据定制化服务,每天实时更新%s的招标信息,随时随地免费查看。", name, name, name, name, name, name, name)
 
-	case "stype": // 信息类型页面
+	case Label["infoType"]: // 信息类型页面
 		stypemp, _ := config.Seoconfig["stype"].(map[string]interface{})
 		if stypemp != nil {
 			stypemp1 := stypemp[name].(map[string]interface{})
@@ -853,7 +834,7 @@ func GetTdk(types, name string) (tdk TdkStruct) {
 				description = stypemp1["DESCRIPTION"].(string)
 			}
 		}
-	case "industry": // 行业首页
+	case Label["industry"]: // 行业首页
 		if name == "" {
 			title = fmt.Sprintf("%s招标采购行业大全-剑鱼标讯", "")
 			keywords = fmt.Sprintf("%s招标采购分类,%s招标行业分类,%s招标采购行业,%s招标采购信息", "", "", "", "")
@@ -865,10 +846,6 @@ func GetTdk(types, name string) (tdk TdkStruct) {
 		title = fmt.Sprintf("%s免费招标信息_%s采购服务平台-剑鱼标讯", area_name, name)
 		keywords = fmt.Sprintf("%s免费招标信息,%s招标公告,%s中标公告,%s招标采购,%s招标网", area_name, area_name, area_name, area_name, area_name)
 		description = fmt.Sprintf("剑鱼标讯%s专栏,是%s招标采购的免费信息平台,免费提供%s招标采购信息、招标公告,中标结果等所有%s相关的招投标信息,寻找优质免费%s招标信息网站,就用剑鱼标讯!", area_name, area_name, area_name, area_name, area_name)
-	case "city": // 城市页面
-		title = fmt.Sprintf("%s免费招标信息_%s采购服务平台_%s中标公告-剑鱼标讯", name, name, name)
-		keywords = fmt.Sprintf("%s免费招标信息,%s招标公告,%s中标公告,%s招标采购,%s招标网", name, name, name, name, name)
-		description = fmt.Sprintf("剑鱼标讯%s专栏,提供%s免费招标信息、%s招标公告、%s中标公告和%s招标采购等内容,以及%s招标信息搜索查询、订阅推送和数据定制化服务,每天实时更新%s的招标信息,随时随地免费查看。", name, name, name, name, name, name, name)
 	}
 	tdk = TdkStruct{
 		Title:       title,

+ 0 - 6
src/jfw/modules/app/src/seo.json

@@ -155,12 +155,6 @@
     }
   },
   "area": {
-    "QG": {
-      "NAME": "全国",
-      "TITLE": "全国",
-      "KEYWORDS": "全国",
-      "DESCRIPTION": "全国"
-    },
     "AH": {
       "NAME": "安徽",
       "TITLE": "安徽",

+ 1 - 1
src/jfw/modules/app/src/web/templates/tags/template/tag-area-nav.html

@@ -4,7 +4,7 @@
     <ul class="tag-area-nav-list">
       {{range $val:=.T.hotArea}}
       <li class="tag-area-nav-item">
-        <a href="{{$val.url}}" title="{{$val.name}}招标网">{{$val.name}}</a>
+        <a href="{{$val.Url}}" title="{{$val.Name}}招标网">{{$val.Name}}</a>
       </li>
       {{end}}
       <li class="tag-area-nav-item highlight-text action-show-more">更多 &gt;</li>

+ 1 - 0
src/jfw/modules/app/src/web/templates/tags/template/tag-meta.html

@@ -4,6 +4,7 @@
 <meta name="keywords" content="{{.T.tdk.Keywords}}">
 <meta name="description" content="{{.T.tdk.Description}}">
 <meta name="author" content="剑鱼标讯">
+<meta name="applicable-device" content="mobile" />
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
 <meta name="browsermode" content="application">