|
@@ -12,7 +12,10 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
const (
|
|
const (
|
|
- fields = `"_id","title","area","publishtime","buyerclass","s_subscopeclass","bidamount","budget","subtype","toptype"`
|
|
|
|
|
|
+ fields = `"_id","title","area","publishtime","buyerclass","s_subscopeclass","bidamount","budget","subtype","toptype"`
|
|
|
|
+ searchTmpl = `您搜索的“%s”有新的机会`
|
|
|
|
+ visitTmpl = `您浏览过的“%s”项目有同类项目`
|
|
|
|
+ subsetTmpl = `您订阅的“%s”有新的机会`
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -28,7 +31,7 @@ type Recommend struct {
|
|
func (r *Recommend) SetNewest(size int) {
|
|
func (r *Recommend) SetNewest(size int) {
|
|
r.newest = elastic.Get(Es_Bidding, Es_Bidding, fmt.Sprintf(newestQuery, size))
|
|
r.newest = elastic.Get(Es_Bidding, Es_Bidding, fmt.Sprintf(newestQuery, size))
|
|
}
|
|
}
|
|
-func (r *Recommend) SubRecommend(tidb *Mysql, domain, userId, content string, mailPush, limit int) (string, string, string, int) {
|
|
|
|
|
|
+func (r *Recommend) SubRecommend(tidb *Mysql, domain, userId, content string, mailPush, limit int) (string, string, string, string, int) {
|
|
list, area := r.getList(tidb, userId, limit)
|
|
list, area := r.getList(tidb, userId, limit)
|
|
if area == "" {
|
|
if area == "" {
|
|
area = "全国"
|
|
area = "全国"
|
|
@@ -37,12 +40,24 @@ func (r *Recommend) SubRecommend(tidb *Mysql, domain, userId, content string, ma
|
|
list = r.newest
|
|
list = r.newest
|
|
}
|
|
}
|
|
if list == nil || len(*list) == 0 {
|
|
if list == nil || len(*list) == 0 {
|
|
- return "", "", "", 0
|
|
|
|
|
|
+ return "", "", "", "", 0
|
|
}
|
|
}
|
|
mailContent := ""
|
|
mailContent := ""
|
|
firstTitle := ""
|
|
firstTitle := ""
|
|
infosLength := 0
|
|
infosLength := 0
|
|
- for _, v := range *list {
|
|
|
|
|
|
+ jcly := ""
|
|
|
|
+ for k, v := range *list {
|
|
|
|
+ if k == 0 {
|
|
|
|
+ key := ObjToString(v["key"])
|
|
|
|
+ projectname := ObjToString(v["projectname"])
|
|
|
|
+ if typ := Int64All(v["type"]); typ == 1 {
|
|
|
|
+ jcly = fmt.Sprintf(searchTmpl, ShortenTxt(20, fmt.Sprintf(searchTmpl, ""), key))
|
|
|
|
+ } else if typ == 2 {
|
|
|
|
+ jcly = fmt.Sprintf(visitTmpl, ShortenTxt(20, fmt.Sprintf(visitTmpl, ""), projectname))
|
|
|
|
+ } else if typ == 3 {
|
|
|
|
+ jcly = fmt.Sprintf(subsetTmpl, ShortenTxt(20, fmt.Sprintf(subsetTmpl, ""), key))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
infosLength++
|
|
infosLength++
|
|
info := NewBiddingInfo(v, []string{})
|
|
info := NewBiddingInfo(v, []string{})
|
|
if infosLength == 1 {
|
|
if infosLength == 1 {
|
|
@@ -69,12 +84,12 @@ func (r *Recommend) SubRecommend(tidb *Mysql, domain, userId, content string, ma
|
|
mailContent += fmt.Sprintf(content, infosLength, url, info.HighlightTitle, areaClassName, info.Area, typeClassName, info.Infotype, industryClassName, info.Buyerclass, acountClassName, info.Acount, info.PublishtimeDiff)
|
|
mailContent += fmt.Sprintf(content, infosLength, url, info.HighlightTitle, areaClassName, info.Area, typeClassName, info.Infotype, industryClassName, info.Buyerclass, acountClassName, info.Acount, info.PublishtimeDiff)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return firstTitle, area, mailContent, infosLength
|
|
|
|
|
|
+ return firstTitle, area, jcly, mailContent, infosLength
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
func (r *Recommend) getList(tidb *Mysql, userId string, limit int) (*[]map[string]interface{}, string) {
|
|
func (r *Recommend) getList(tidb *Mysql, userId string, limit int) (*[]map[string]interface{}, string) {
|
|
- datas := tidb.SelectBySql(`select autoid,area,type from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, limit)
|
|
|
|
|
|
+ datas := tidb.SelectBySql(`select type,autoid,area,projectname,key from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, limit)
|
|
if datas == nil || len(*datas) == 0 {
|
|
if datas == nil || len(*datas) == 0 {
|
|
return nil, ""
|
|
return nil, ""
|
|
}
|
|
}
|