1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package recommend
- import (
- "fmt"
- "strings"
- "app.yhyue.com/moapp/jybase/encrypt"
- elastic "app.yhyue.com/moapp/jybase/es"
- . "app.yhyue.com/moapp/jybase/mysql"
- . "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
- )
- const (
- query = `{"query":{"bool":{"must":[{"terms":{"autoid":[%s]}}]}},"_source":["_id","title","area","publishtime","buyerclass","s_subscopeclass","bidamount","budget","subtype","toptype"],"sort":[{"publishtime":"desc"}],"from":0,"size":100}`
- )
- var VarRecommend = &Recommend{}
- type Recommend struct {
- }
- func (r *Recommend) SubRecommend(clickhouse *Mysql, domain, userId, content string, mailPush int) (string, string, string, int) {
- datas := clickhouse.SelectBySql(`select bitmapToArray(infoids) as infoids,area from jianyu.sub_recommend_list where userid=? order by update_time desc limit 1`, userId)
- if datas == nil || len(*datas) == 0 {
- return "", "", "", 0
- }
- area, _ := (*datas)[0]["area"].(string)
- if area == "" {
- area = "全国"
- }
- infoids, _ := (*datas)[0]["infoids"].([]uint64)
- if len(infoids) == 0 {
- return "", "", "", 0
- }
- ids := []string{}
- for _, v := range infoids {
- ids = append(ids, fmt.Sprint(v))
- }
- list := elastic.Get(Es_Bidding, Es_Bidding, fmt.Sprintf(query, strings.Join(ids, ",")))
- if list == nil || len(*list) == 0 {
- return "", "", "", 0
- }
- mailContent := ""
- firstTitle := ""
- infosLength := 0
- for _, v := range *list {
- infosLength++
- info := NewBiddingInfo(v, []string{})
- if infosLength == 1 {
- firstTitle = info.ClearTitle
- }
- if mailPush == 1 { //关于邮件的处理
- url := fmt.Sprintf("%s/article/mailprivate/%s.html", domain, encrypt.CommonEncodeArticle("mailprivate", info.Id))
- acountClassName := "none_a"
- if info.Acount != "" {
- acountClassName = "acount"
- }
- industryClassName := ""
- if info.Buyerclass != "" {
- industryClassName = "buyerclass"
- }
- areaClassName := ""
- if info.Area != "" {
- areaClassName = "area"
- }
- typeClassName := ""
- if info.Infotype != "" {
- typeClassName = "type"
- }
- 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
- }
|