Sfoglia il codice sorgente

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

duxin 1 anno fa
parent
commit
a53e4038f6
1 ha cambiato i file con 106 aggiunte e 0 eliminazioni
  1. 106 0
      src/jfw/front/dataServiceArea.go

+ 106 - 0
src/jfw/front/dataServiceArea.go

@@ -4,6 +4,10 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/public"
+	"fmt"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gctx"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/config"
 )
 
@@ -12,6 +16,108 @@ func HomeBiddingTrends() config.IndustryTrend {
 	return config.IndustryTrendConfig
 }
 
+type (
+	KeyWordSiteRoot struct {
+		SiteCodeMap map[string]*KeyWordSiteNode //省份直辖市简称对照
+		SiteArr     []*KeyWordSiteNode
+	}
+
+	KeyWordSiteNode struct {
+		Code               string `json:"code" doc:"代码"`
+		Alias              string `json:"alias" doc:"名称"`
+		AreaKeyWord        string `json:"areaKeyword" doc:"省份关键词"`
+		CityKeyWord        string `json:"cityKeyword" doc:"城市关键词"`
+		CitySpecialKeyWord string `json:"citySpecialKeyword" doc:"直辖市关键词"`
+	}
+
+	KeyWordSiteShow struct {
+		Code string `json:"code" doc:"代码"`
+		Name string `json:"name" doc:"名称"`
+		//KeyWord string `json:"keyWord" doc:"对应关键词"`
+	}
+	argument struct {
+		Name string
+		Url  string
+	}
+)
+
+var (
+	siteCodeMap map[string]*KeyWordSiteNode
+	specialArea = map[string]bool{"北京": true, "上海": true, "天津": true, "重庆": true}
+)
+
+func init() {
+	siteCodeMap = make(map[string]*KeyWordSiteNode)
+	res, err := g.DB().Query(gctx.New(), `SELECT * FROM seo_siteKeywords_splicing order by site_code asc`)
+	if err == nil && len(res.List()) > 0 {
+		for _, m := range res.List() {
+			node := &KeyWordSiteNode{
+				Code:               fmt.Sprintf("S%s", gconv.String(m["site_code"])),
+				Alias:              gconv.String(m["alias"]),
+				AreaKeyWord:        gconv.String(m["area"]),
+				CityKeyWord:        gconv.String(m["city"]),
+				CitySpecialKeyWord: gconv.String(m["city_special"]),
+			}
+			siteCodeMap[node.Code] = node
+		}
+	}
+}
+
+// 政府招标
+func GovernmentTender() {
+	areaM := make(map[string]string)
+	//省份
+	areaMap, _ := config.Seoconfig["area"].(map[string]interface{})
+	if areaMap != nil && len(areaMap) > 0 {
+		for k, v := range areaMap {
+			area := v.(map[string]interface{})
+			name := common.ObjToString(area["NAME"])
+			if name != "全国" {
+				areaM[name] = k
+			}
+		}
+	}
+	var (
+		data       []argument
+		upperLimit int
+	)
+	siteCode := make(map[string]bool)
+	for acronym, name := range areaM {
+		upperLimit++
+		if upperLimit > 12 {
+			break
+		}
+		if len(siteCode) < len(siteCodeMap) {
+			for code, node := range siteCodeMap {
+				if !siteCode[code] {
+					tagName := common.If(specialArea[name], node.CitySpecialKeyWord, node.AreaKeyWord).(string)
+					data = append(data, argument{
+						fmt.Sprintf("%s%s", name, tagName),
+						fmt.Sprintf("/list/area/%s_%s", acronym, code),
+					})
+					siteCode[code] = true
+					break
+				}
+			}
+		} else {
+			for code, node := range siteCodeMap {
+				var tagName string
+				if specialArea[name] {
+					tagName = fmt.Sprintf("%s%s", name, node.CitySpecialKeyWord)
+				} else {
+					tagName = fmt.Sprintf("%s%s", name, node.AreaKeyWord)
+				}
+				data = append(data, argument{
+					tagName,
+					fmt.Sprintf("/list/area/%s_%s", acronym, code),
+				})
+				break
+			}
+		}
+
+	}
+}
+
 /*
 const (
 	PSearch_DecMust = `"bidstatus": ["中标","成交","合同","单一"]`