Kaynağa Gözat

feat:推荐区域

wangchuanjin 1 yıl önce
ebeveyn
işleme
2ea90e3c94
2 değiştirilmiş dosya ile 13 ekleme ve 5 silme
  1. 3 0
      p/public.go
  2. 10 5
      recommend/recommend.go

+ 3 - 0
p/public.go

@@ -384,6 +384,9 @@ func NewBiddingInfo(info map[string]interface{}, keys []string) *BiddingInfo {
 	bi.Title, _ = info["title"].(string)
 	bi.ClearTitle = TitleClearRe.ReplaceAllString(strings.Replace(bi.Title, "\n", "", -1), "$1")
 	bi.Area, _ = info["area"].(string)
+	if bi.Area == "A" {
+		bi.Area = "全国"
+	}
 	bi.AreaTitle = fmt.Sprintf("[%s]%s", bi.Area, bi.ClearTitle)
 	bi.Publishtime = util.Int64All(info["publishtime"])
 	bi.PublishtimeYMD = FormatDateByInt64(&bi.Publishtime, Date_Short_Layout)

+ 10 - 5
recommend/recommend.go

@@ -19,14 +19,14 @@ var VarRecommend = &Recommend{}
 type Recommend struct {
 }
 
-func (r *Recommend) SubRecommend(clickhouse *Mysql, domain, userId, content string, mailPush int) (string, string, int) {
+func (r *Recommend) SubRecommend(clickhouse *Mysql, domain, userId, content string, mailPush int) (string, string, string, int) {
 	datas := clickhouse.SelectBySql(`select bitmapToArray(infoids) as infoids from jianyu.sub_recommend_list where userid=? order by update_time desc limit 1`, userId)
 	if datas == nil || len(*datas) == 0 {
-		return "", "", 0
+		return "", "", "", 0
 	}
 	infoids, _ := (*datas)[0]["infoids"].([]uint64)
 	if len(infoids) == 0 {
-		return "", "", 0
+		return "", "", "", 0
 	}
 	ids := []string{}
 	for _, v := range infoids {
@@ -34,16 +34,21 @@ func (r *Recommend) SubRecommend(clickhouse *Mysql, domain, userId, content stri
 	}
 	list := elastic.Get(Es_Bidding, Es_Bidding, fmt.Sprintf(query, strings.Join(ids, ",")))
 	if list == nil || len(*list) == 0 {
-		return "", "", 0
+		return "", "", "", 0
 	}
 	mailContent := ""
 	firstTitle := ""
+	firstArea := ""
 	infosLength := 0
 	for _, v := range *list {
 		infosLength++
 		info := NewBiddingInfo(v, []string{})
 		if infosLength == 1 {
 			firstTitle = info.ClearTitle
+			firstArea = info.Area
+			if firstArea == "" {
+				firstArea = "全国"
+			}
 		}
 		if mailPush == 1 { //关于邮件的处理
 			url := fmt.Sprintf("%s/article/mailprivate/%s.html", domain, encrypt.CommonEncodeArticle("mailprivate", info.Id))
@@ -66,5 +71,5 @@ func (r *Recommend) SubRecommend(clickhouse *Mysql, domain, userId, content stri
 			mailContent += fmt.Sprintf(content, infosLength, url, info.HighlightTitle, areaClassName, info.Area, typeClassName, info.Infotype, industryClassName, info.Buyerclass, acountClassName, info.Acount, info.PublishtimeDiff)
 		}
 	}
-	return firstTitle, mailContent, infosLength
+	return firstTitle, firstArea, mailContent, infosLength
 }