Sfoglia il codice sorgente

Merge branch 'feature/v4.8.40_wky' of qmx/jy into feature/v4.8.40

wangkaiyue 2 anni fa
parent
commit
e341a72dc6

+ 70 - 34
src/jfw/front/tags.go

@@ -214,7 +214,7 @@ func (this *Tags) Index(types, name string) {
 	this.T["areaList"] = this.GetArea(areaHref)
 
 	//行业标签获取
-	this.T["industryList"] = this.GetIndustry(industryHref)
+	this.T["industryList"] = this.GetIndustry(industryHref, checkedProvince, checkedCity) //需要根据地区获取不同的标的物
 	//标的物标签获取
 
 	//字母表获取
@@ -391,7 +391,7 @@ func (this *Tags) GetkeysMap() []map[string][]map[string]interface{} {
 		for _, v := range *data {
 			name := qu.ObjToString(v["name"])
 			id := qu.Int64All(v["id"])
-			r := public.BaseMysql.SelectBySql(`select id,name from seo_words.seo_industry where class_1 =? limit 10`, name)
+			r := public.BaseMysql.SelectBySql(`select id,name from seo_words.seo_hot_purchasing where industry =? limit 10`, name)
 			if r != nil && len(*r) > 0 {
 				for _, vv := range *r {
 					name2 := qu.ObjToString(vv["name"])
@@ -410,41 +410,77 @@ func (this *Tags) GetkeysMap() []map[string][]map[string]interface{} {
 	return mar
 }
 
-func (this *Tags) GetIndustry(industryHref string) interface{} {
-	rediskey := fmt.Sprintf("pcindex_getIndustry_%s", industryHref)
-	if l := redis.Get("seoCache", rediskey); l != nil {
-		return l
-	} else {
-		data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a inner join  seo_words.seo_industry_class b on a.class_1=b.name and  a.class_2 !='药品'  order by a.class_1`)
-		industryArr := []string{}
-		industryMap := map[string][]map[string]interface{}{}
-		if len(*data) > 0 && data != nil {
-			for _, v := range *data {
-				class := qu.ObjToString(v["class_1"])
-				name := qu.ObjToString(v["name"])
-				id := qu.Int64All(v["id"])
-				industryId := qu.Int64All(v["class_id"])
-				if !IsInArr(industryArr, class) {
-					industryArr = append(industryArr, class)
-				}
-				industryMap[class] = append(industryMap[class], map[string]interface{}{
-					"name": name + qu.ObjToString(config.Seoconfig["seoKeywordSuffix"]),
-					// "url":  fmt.Sprintf("/tags/industry/%v_all_all_%v.html", industryId, id),
-					"url": fmt.Sprintf(industryHref, industryId, id),
-				})
+func (this *Tags) GetIndustry(industryHref, province, city string) interface{} {
+	//rediskey := fmt.Sprintf("pcindex_getIndustry_%s", industryHref)
+	//if l := redis.Get("seoCache", rediskey); l != nil {
+	//    return l
+	//} else {
+	//data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a inner join  seo_words.seo_industry_class b on a.class_1=b.name and  a.class_2 !='药品'  order by a.class_1`)
+	var filterSql string
+	if province != "" {
+
+	} else if city != "" {
+
+	}
+
+	data := public.BaseMysql.SelectBySql(fmt.Sprintf(`
+SELECT
+	fullData.id,
+	fullData.name,
+	fullData.industry as class_1,
+	fullData.total,
+	b.id AS class_id
+FROM
+	(
+	SELECT
+		industry,
+		name,
+		sum( frequ ) AS total,
+		id,
+		ROW_NUMBER() OVER ( PARTITION BY industry ORDER BY SUM( frequ ) DESC ) AS sort
+	FROM
+		seo_words.seo_hot_purchasing
+    %s
+	GROUP BY
+		industry,
+		name,
+		id
+	) AS fullData
+	INNER JOIN seo_words.seo_industry_class	b
+	on fullData.industry=b.name
+WHERE
+	sort <= %d
+ORDER BY
+ class_1 `, filterSql, 20))
+
+	industryArr := []string{}
+	industryMap := map[string][]map[string]interface{}{}
+	if len(*data) > 0 && data != nil {
+		for _, v := range *data {
+			class := qu.ObjToString(v["class_1"])
+			name := qu.ObjToString(v["name"])
+			id := qu.Int64All(v["id"])
+			industryId := qu.Int64All(v["class_id"])
+			if !IsInArr(industryArr, class) {
+				industryArr = append(industryArr, class)
 			}
-		}
-		m := []map[string][]map[string]interface{}{}
-		//
-		for _, v := range industryArr {
-			m = append(m, map[string][]map[string]interface{}{
-				v: industryMap[v],
+			industryMap[class] = append(industryMap[class], map[string]interface{}{
+				"name": name + qu.ObjToString(config.Seoconfig["seoKeywordSuffix"]),
+				// "url":  fmt.Sprintf("/tags/industry/%v_all_all_%v.html", industryId, id),
+				"url": fmt.Sprintf(industryHref, industryId, id),
 			})
 		}
-		redis.Put("seoCache", rediskey, m, cacheTime)
-		return m
 	}
-	return nil
+	m := []map[string][]map[string]interface{}{}
+	//
+	for _, v := range industryArr {
+		m = append(m, map[string][]map[string]interface{}{
+			v: industryMap[v],
+		})
+	}
+	//redis.Put("seoCache", rediskey, m, cacheTime)
+	return m
+	//}
 }
 
 // 判断字符串是否再数组str内
@@ -745,7 +781,7 @@ func (this *Tags) GetSeoKeyWords(id string) (string, string) {
 // 获取行业分类下的标签
 func (this *Tags) GetInsturyKeywords(idstr string) (name, class_1, class_2 string) {
 	id, _ := strconv.Atoi(idstr)
-	data := public.BaseMysql.SelectBySql(`select id,class_1,class_2,name from seo_words.seo_industry where id =?`, id)
+	data := public.BaseMysql.SelectBySql(`select id,industry as class_1,industry as class_2,name from seo_words.seo_hot_purchasing where id =?`, id)
 	if data != nil && len(*data) > 0 {
 		for _, v := range *data {
 			class_1 = qu.ObjToString(v["class_1"])

+ 1 - 1
src/web/templates/pc/tags/template/industry-tags.html

@@ -7,7 +7,7 @@
                 <div class="tags-label">{{$kk}}</div>
                 <div class="tags-card-list clearfix">
                     {{range $kkk,$vvv := $vv}}
-                    <a class="tags-card-item inline fl" href="{{$vvv.url}}">{{$vvv.name}}</a>
+                    <a class="tags-card-item inline fl" href="{{$vvv.url}}" target="_blank">{{$vvv.name}}</a>
                     {{end}}
                     <a class="tags-card-item inline fr more-button show-more-button" style="display: none" href="javascript:;">更多 ></a>
                     <a class="tags-card-item inline fr more-button hide-more-button" style="display: none" href="javascript:;">收起</a>