|
@@ -25,7 +25,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-//
|
|
|
const (
|
|
|
pageSize = 100
|
|
|
AllSubPushCacheSize = 250
|
|
@@ -76,7 +75,7 @@ type PushCa struct {
|
|
|
FileExists bool
|
|
|
}
|
|
|
|
|
|
-//查询参数
|
|
|
+// 查询参数
|
|
|
type SubPushQueryParam struct {
|
|
|
Mgo_bidding mongodb.MongodbSim //
|
|
|
Bidding string //
|
|
@@ -100,6 +99,7 @@ type SubPushQueryParam struct {
|
|
|
BaseServiceMysql *mysql.Mysql
|
|
|
NewUserId int64
|
|
|
IsEnt bool
|
|
|
+ SelectInfoIds []string
|
|
|
}
|
|
|
|
|
|
func (spqp *SubPushQueryParam) IsEmpty() bool {
|
|
@@ -118,7 +118,7 @@ func NewSubscribePush(module ...string) *subscribePush {
|
|
|
return &subscribePush{m}
|
|
|
}
|
|
|
|
|
|
-//从pushcache_2_a中取
|
|
|
+// 从pushcache_2_a中取
|
|
|
func (s *subscribePush) GetTodayCache(userId string) (*SubPush, error) {
|
|
|
pc_a, err := redis.GetNewBytes("pushcache_2_b", s.todayKey(userId))
|
|
|
if err != nil {
|
|
@@ -134,12 +134,12 @@ func (s *subscribePush) GetTodayCache(userId string) (*SubPush, error) {
|
|
|
return p, nil
|
|
|
}
|
|
|
|
|
|
-//往pushcache_2_a中放
|
|
|
+// 往pushcache_2_a中放
|
|
|
func (s *subscribePush) PutTodayCache(userId string, pc_a *SubPush) {
|
|
|
redis.Put("pushcache_2_b", s.todayKey(userId), pc_a, oneDay)
|
|
|
}
|
|
|
|
|
|
-//获取redis key
|
|
|
+// 获取redis key
|
|
|
func (s *subscribePush) todayKey(userId string) string {
|
|
|
return fmt.Sprintf("%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
|
|
|
}
|
|
@@ -147,7 +147,7 @@ func (s *subscribePush) allKey(userId string) string {
|
|
|
return fmt.Sprintf("all_%s_%s", aboutDbMsg[s.ModuleFlag].RedisKeyFlag, userId)
|
|
|
}
|
|
|
|
|
|
-//历史推送记录中单条信息格式化
|
|
|
+// 历史推送记录中单条信息格式化
|
|
|
func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}) *bxsubscribe.SubscribeInfo {
|
|
|
area := common.ObjToString((*info)["area"])
|
|
|
if area == "A" {
|
|
@@ -259,7 +259,7 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
|
|
|
result = subPush.Datas[start:end]
|
|
|
}
|
|
|
total = int64(length)
|
|
|
- } else if spqp.IsEmpty() && (spqp.PageNum-1)*spqp.PageSize < 250 { //全部,没有过滤条件 之前缓存5页*50条=250
|
|
|
+ } else if spqp.IsEmpty() && (spqp.PageNum-1)*spqp.PageSize < 250 && len(spqp.SelectInfoIds) == 0 { //全部,没有过滤条件 之前缓存5页*50条=250
|
|
|
logx.Info("a2:", s.allKey(spqp.UserId))
|
|
|
allCache := &SubPush{}
|
|
|
var err error
|
|
@@ -303,160 +303,171 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, endtime int64, size int, isLimit bool) (result []*bxsubscribe.SubscribeInfo, count int64) {
|
|
|
querys := []string{}
|
|
|
- if spqp.IsEnt {
|
|
|
- querys = []string{fmt.Sprintf("a.entid='%s'", spqp.EntId)}
|
|
|
+ var (
|
|
|
+ searchSql, findSql string
|
|
|
+ )
|
|
|
+ if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
|
|
|
+ searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
|
|
|
+ fmt.Println("searchSql", searchSql)
|
|
|
+ //查询总数
|
|
|
+ count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
|
|
|
+ findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
} else {
|
|
|
- querys = []string{fmt.Sprintf("a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))}
|
|
|
+ if spqp.IsEnt {
|
|
|
+ querys = []string{fmt.Sprintf("a.entid='%s'", spqp.EntId)}
|
|
|
+ } else {
|
|
|
+ querys = []string{fmt.Sprintf("a.userid='%s'", common.If(s.ModuleFlag == "eType", spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))}
|
|
|
|
|
|
- }
|
|
|
- codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
|
|
|
- if codeMap.Data == nil || err != nil {
|
|
|
- logx.Error("代码表获取失败")
|
|
|
- return result, count
|
|
|
- }
|
|
|
- //时间
|
|
|
- if starttime > 0 && endtime > 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("a.date>=%d and date<=%d", starttime, endtime))
|
|
|
- } else if starttime > 0 && endtime == 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("a.date>=%d", starttime))
|
|
|
- } else if starttime == 0 && endtime > 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("a.date<=%d", endtime))
|
|
|
- }
|
|
|
- if spqp.Area != "" || spqp.City != "" {
|
|
|
- var sqlAreaCity = ""
|
|
|
- //城市
|
|
|
- city := []string{}
|
|
|
- for _, v := range strings.Split(spqp.City, ",") {
|
|
|
- if codeMap.Data.City[v] != "" {
|
|
|
- city = append(city, fmt.Sprint(codeMap.Data.City[v]))
|
|
|
- } else {
|
|
|
- city = append(city, "-1")
|
|
|
- }
|
|
|
}
|
|
|
- if len(city) == 1 {
|
|
|
- city = append(city, "9999")
|
|
|
- }
|
|
|
- if len(city) > 0 {
|
|
|
- sqlAreaCity = fmt.Sprintf("b.city_code in (%s)", strings.Join(city, ","))
|
|
|
- }
|
|
|
- //区域
|
|
|
- var sqlArea = ""
|
|
|
- area := []string{}
|
|
|
- for _, v := range strings.Split(spqp.Area, ",") {
|
|
|
- if codeMap.Data.Area[v] != "" {
|
|
|
- area = append(area, fmt.Sprint(codeMap.Data.Area[v]))
|
|
|
- } else {
|
|
|
- area = append(area, "-1")
|
|
|
+ codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
|
|
|
+ if codeMap.Data == nil || err != nil {
|
|
|
+ logx.Error("代码表获取失败")
|
|
|
+ return result, count
|
|
|
+ }
|
|
|
+ //时间
|
|
|
+ logx.Info("starttime,endtime", starttime, endtime)
|
|
|
+ if starttime > 0 && endtime > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf("a.date>=%d and date<=%d", starttime, endtime))
|
|
|
+ } else if starttime > 0 && endtime == 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf("a.date>=%d", starttime))
|
|
|
+ } else if starttime == 0 && endtime > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf("a.date<=%d", endtime))
|
|
|
+ }
|
|
|
+ if spqp.Area != "" || spqp.City != "" {
|
|
|
+ var sqlAreaCity = ""
|
|
|
+ //城市
|
|
|
+ city := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.City, ",") {
|
|
|
+ if codeMap.Data.City[v] != "" {
|
|
|
+ city = append(city, fmt.Sprint(codeMap.Data.City[v]))
|
|
|
+ } else {
|
|
|
+ city = append(city, "-1")
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if len(area) == 1 {
|
|
|
- area = append(area, "9999")
|
|
|
- }
|
|
|
- if len(area) > 0 {
|
|
|
- sqlArea = fmt.Sprintf("b.area_code in (%s)", strings.Join(area, ","))
|
|
|
- }
|
|
|
- if sqlAreaCity != "" && sqlArea != "" {
|
|
|
- sqlAreaCity = "( " + sqlAreaCity + " or " + sqlArea + " )"
|
|
|
- } else if sqlAreaCity == "" && sqlArea != "" {
|
|
|
- sqlAreaCity = sqlArea
|
|
|
- }
|
|
|
- if sqlAreaCity != "" {
|
|
|
- querys = append(querys, sqlAreaCity)
|
|
|
- }
|
|
|
- }
|
|
|
- //采购单位行业
|
|
|
- if spqp.Buyerclass != "" {
|
|
|
- buyerclass := []string{}
|
|
|
- for _, v := range strings.Split(spqp.Buyerclass, ",") {
|
|
|
- if codeMap.Data.Buyerclass[v] != "" {
|
|
|
- buyerclass = append(buyerclass, fmt.Sprint(codeMap.Data.Buyerclass[v]))
|
|
|
+ if len(city) == 1 {
|
|
|
+ city = append(city, "9999")
|
|
|
+ }
|
|
|
+ if len(city) > 0 {
|
|
|
+ sqlAreaCity = fmt.Sprintf("b.city_code in (%s)", strings.Join(city, ","))
|
|
|
+ }
|
|
|
+ //区域
|
|
|
+ var sqlArea = ""
|
|
|
+ area := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.Area, ",") {
|
|
|
+ if codeMap.Data.Area[v] != "" {
|
|
|
+ area = append(area, fmt.Sprint(codeMap.Data.Area[v]))
|
|
|
+ } else {
|
|
|
+ area = append(area, "-1")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(area) == 1 {
|
|
|
+ area = append(area, "9999")
|
|
|
+ }
|
|
|
+ if len(area) > 0 {
|
|
|
+ sqlArea = fmt.Sprintf("b.area_code in (%s)", strings.Join(area, ","))
|
|
|
+ }
|
|
|
+ if sqlAreaCity != "" && sqlArea != "" {
|
|
|
+ sqlAreaCity = "( " + sqlAreaCity + " or " + sqlArea + " )"
|
|
|
+ } else if sqlAreaCity == "" && sqlArea != "" {
|
|
|
+ sqlAreaCity = sqlArea
|
|
|
+ }
|
|
|
+ if sqlAreaCity != "" {
|
|
|
+ querys = append(querys, sqlAreaCity)
|
|
|
}
|
|
|
}
|
|
|
- if len(buyerclass) == 1 {
|
|
|
- buyerclass = append(buyerclass, "9999")
|
|
|
- }
|
|
|
- if len(buyerclass) > 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("b.buyerclass_code in (%s)", strings.Join(buyerclass, ",")))
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- //信息类型
|
|
|
- if spqp.Subtype != "" {
|
|
|
- subtype := []string{}
|
|
|
- for _, v := range strings.Split(spqp.Subtype, ",") {
|
|
|
- if codeMap.Data.Subtype[v] != "" {
|
|
|
- subtype = append(subtype, fmt.Sprint(codeMap.Data.Subtype[v]))
|
|
|
+ //采购单位行业
|
|
|
+ if spqp.Buyerclass != "" {
|
|
|
+ buyerclass := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.Buyerclass, ",") {
|
|
|
+ if codeMap.Data.Buyerclass[v] != "" {
|
|
|
+ buyerclass = append(buyerclass, fmt.Sprint(codeMap.Data.Buyerclass[v]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(buyerclass) == 1 {
|
|
|
+ buyerclass = append(buyerclass, "9999")
|
|
|
+ }
|
|
|
+ if len(buyerclass) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf("b.buyerclass_code in (%s)", strings.Join(buyerclass, ",")))
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if len(subtype) == 1 {
|
|
|
- subtype = append(subtype, "9999")
|
|
|
- }
|
|
|
- if len(subtype) > 0 {
|
|
|
- querys = append(querys, fmt.Sprintf("b.subtype_code in (%s)", strings.Join(subtype, ",")))
|
|
|
- }
|
|
|
+ //信息类型
|
|
|
+ if spqp.Subtype != "" {
|
|
|
+ subtype := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.Subtype, ",") {
|
|
|
+ if codeMap.Data.Subtype[v] != "" {
|
|
|
+ subtype = append(subtype, fmt.Sprint(codeMap.Data.Subtype[v]))
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- //信息行业
|
|
|
- if spqp.Subscopeclass != "" {
|
|
|
- find_in_set := []string{}
|
|
|
- for _, v := range strings.Split(spqp.Subscopeclass, ",") {
|
|
|
- if codeMap.Data.Subscopeclass[v] != "" {
|
|
|
- find_in_set = append(find_in_set, codeMap.Data.Subscopeclass[v])
|
|
|
+ }
|
|
|
+ if len(subtype) == 1 {
|
|
|
+ subtype = append(subtype, "9999")
|
|
|
+ }
|
|
|
+ if len(subtype) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf("b.subtype_code in (%s)", strings.Join(subtype, ",")))
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if len(find_in_set) == 1 {
|
|
|
- querys = append(querys, find_in_set[0])
|
|
|
- } else if len(find_in_set) > 1 {
|
|
|
- querys = append(querys, fmt.Sprintf(" t.labelvalues in (%s)", strings.Join(find_in_set, ",")))
|
|
|
- }
|
|
|
- }
|
|
|
- //关键词
|
|
|
- if spqp.Key != "" {
|
|
|
- find_in_set := []string{}
|
|
|
- for _, v := range strings.Split(spqp.Key, ",") {
|
|
|
- find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchkeys,'+',','),' ',','))", v))
|
|
|
+ //信息行业
|
|
|
+ if spqp.Subscopeclass != "" {
|
|
|
+ find_in_set := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.Subscopeclass, ",") {
|
|
|
+ if codeMap.Data.Subscopeclass[v] != "" {
|
|
|
+ find_in_set = append(find_in_set, codeMap.Data.Subscopeclass[v])
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if len(find_in_set) == 1 {
|
|
|
+ querys = append(querys, find_in_set[0])
|
|
|
+ } else if len(find_in_set) > 1 {
|
|
|
+ querys = append(querys, fmt.Sprintf(" t.labelvalues in (%s)", strings.Join(find_in_set, ",")))
|
|
|
+ }
|
|
|
}
|
|
|
- if len(find_in_set) == 1 {
|
|
|
- querys = append(querys, find_in_set[0])
|
|
|
- } else if len(find_in_set) > 1 {
|
|
|
- querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
|
|
|
+ //关键词
|
|
|
+ if spqp.Key != "" {
|
|
|
+ find_in_set := []string{}
|
|
|
+ for _, v := range strings.Split(spqp.Key, ",") {
|
|
|
+ find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchkeys,'+',','),' ',','))", v))
|
|
|
+ }
|
|
|
+ if len(find_in_set) == 1 {
|
|
|
+ querys = append(querys, find_in_set[0])
|
|
|
+ } else if len(find_in_set) > 1 {
|
|
|
+ querys = append(querys, fmt.Sprintf("(%s)", strings.Join(find_in_set, " or ")))
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //价格- 预算和中标金额
|
|
|
- if spqp.Price != "" && strings.Contains(spqp.Price, "-") {
|
|
|
- minPriceStr, maxPriceStr := strings.Split(spqp.Price, "-")[0], strings.Split(spqp.Price, "-")[1]
|
|
|
- minPrice := common.Int64All(common.Float64All(minPriceStr) * 10000) //换成元
|
|
|
- maxPrice := common.Int64All(common.Float64All(maxPriceStr) * 10000) //换成元
|
|
|
- if minPriceStr != "" && maxPriceStr != "" {
|
|
|
- querys = append(querys, fmt.Sprintf("((b.bidamount>=%d and b.bidamount<=%d) or (b.budget>=%d and b.budget<=%d and b.bidamount is null))", minPrice, maxPrice, minPrice, maxPrice))
|
|
|
- } else if minPriceStr != "" {
|
|
|
- querys = append(querys, fmt.Sprintf("(b.bidamount>=%d or (b.budget>=%d and b.bidamount is null))", minPrice, minPrice))
|
|
|
- } else if maxPriceStr != "" {
|
|
|
- querys = append(querys, fmt.Sprintf("(b.bidamount<=%d or (b.budget<=%d and b.bidamount is null))", maxPrice, maxPrice))
|
|
|
+ //价格- 预算和中标金额
|
|
|
+ if spqp.Price != "" && strings.Contains(spqp.Price, "-") {
|
|
|
+ minPriceStr, maxPriceStr := strings.Split(spqp.Price, "-")[0], strings.Split(spqp.Price, "-")[1]
|
|
|
+ minPrice := common.Int64All(common.Float64All(minPriceStr) * 10000) //换成元
|
|
|
+ maxPrice := common.Int64All(common.Float64All(maxPriceStr) * 10000) //换成元
|
|
|
+ if minPriceStr != "" && maxPriceStr != "" {
|
|
|
+ querys = append(querys, fmt.Sprintf("((b.bidamount>=%d and b.bidamount<=%d) or (b.budget>=%d and b.budget<=%d and b.bidamount is null))", minPrice, maxPrice, minPrice, maxPrice))
|
|
|
+ } else if minPriceStr != "" {
|
|
|
+ querys = append(querys, fmt.Sprintf("(b.bidamount>=%d or (b.budget>=%d and b.bidamount is null))", minPrice, minPrice))
|
|
|
+ } else if maxPriceStr != "" {
|
|
|
+ querys = append(querys, fmt.Sprintf("(b.bidamount<=%d or (b.budget<=%d and b.bidamount is null))", maxPrice, maxPrice))
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //附件
|
|
|
- if spqp.FileExists != "" {
|
|
|
- if spqp.FileExists == "1" {
|
|
|
- querys = append(querys, fmt.Sprintf("b.isvalidfile =1 "))
|
|
|
- } else if spqp.FileExists == "-1" {
|
|
|
- querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
|
|
|
+ //附件
|
|
|
+ if spqp.FileExists != "" {
|
|
|
+ if spqp.FileExists == "1" {
|
|
|
+ querys = append(querys, fmt.Sprintf("b.isvalidfile =1 "))
|
|
|
+ } else if spqp.FileExists == "-1" {
|
|
|
+ querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
|
|
|
+ }
|
|
|
}
|
|
|
+ searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid LEFT JOIN %s t on t.infoid = b.infoid and t.labelcode=2 where %s"+
|
|
|
+ " order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, BidTags, strings.Join(querys, " and "))
|
|
|
+ fmt.Println("searchSql", searchSql)
|
|
|
+ //查询总数
|
|
|
+ count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
|
|
|
+ logx.Info("count:", count, "---", s.ModuleFlag)
|
|
|
+ findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
}
|
|
|
- searchSql := fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid LEFT JOIN %s t on t.infoid = b.infoid and t.labelcode=2 where %s"+
|
|
|
- " order by a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, BidTags, strings.Join(querys, " and "))
|
|
|
- fmt.Println("searchSql", searchSql)
|
|
|
- //查询总数
|
|
|
- count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
|
|
|
- logx.Info("count:", count, "---", s.ModuleFlag)
|
|
|
- findSql := "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
|
|
|
- findSql += ",isvip"
|
|
|
+ findSql += ",a.isvip"
|
|
|
}
|
|
|
findSql += searchSql
|
|
|
if isLimit {
|
|
@@ -466,14 +477,27 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
list := spqp.BaseServiceMysql.SelectBySql(findSql)
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
pushCas := s.GetJyPushs(*list)
|
|
|
- result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
|
|
|
+ if !spqp.Export {
|
|
|
+ result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
|
|
|
+ } else {
|
|
|
+ result = s.GetOnlyExportInfo(pushCas)
|
|
|
+ }
|
|
|
} else {
|
|
|
result = []*bxsubscribe.SubscribeInfo{}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据id取内容
|
|
|
+// GetOnlyInfoId 获取信息id
|
|
|
+func (s *subscribePush) GetOnlyExportInfo(pushCas []*PushCa) []*bxsubscribe.SubscribeInfo {
|
|
|
+ array := make([]*bxsubscribe.SubscribeInfo, len(pushCas))
|
|
|
+ for k, v := range pushCas {
|
|
|
+ array[k] = &bxsubscribe.SubscribeInfo{XId: encrypt.EncodeArticleId2ByCheck(v.InfoId), MatchKeys: v.Keys}
|
|
|
+ }
|
|
|
+ return array
|
|
|
+}
|
|
|
+
|
|
|
+// 根据id取内容
|
|
|
func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bidding_back string, pushCas []*PushCa) []*bxsubscribe.SubscribeInfo {
|
|
|
array := make([]*bxsubscribe.SubscribeInfo, len(pushCas))
|
|
|
if len(pushCas) == 0 {
|
|
@@ -558,7 +582,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
|
|
|
return array
|
|
|
}
|
|
|
|
|
|
-//获取历史推送
|
|
|
+// 获取历史推送
|
|
|
func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
|
|
|
pushCas = []*PushCa{}
|
|
|
for _, v := range datas {
|
|
@@ -580,7 +604,7 @@ func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*P
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//查看全部列表缓存
|
|
|
+// 查看全部列表缓存
|
|
|
func (s *subscribePush) PutAllCache(userId string, datas *SubPush) {
|
|
|
log.Println(s.allKey(userId), datas, oneDay)
|
|
|
redis.Put("pushcache_2_a", s.allKey(userId), datas, oneDay)
|
|
@@ -605,7 +629,7 @@ func (s *subscribePush) GetCache(code, key string) (*SubPush, error) {
|
|
|
return p, nil
|
|
|
}
|
|
|
|
|
|
-//是否收藏
|
|
|
+// 是否收藏
|
|
|
func (s *subscribePush) MakeCollection(userId string, list []*bxsubscribe.SubscribeInfo) {
|
|
|
if list == nil || len(list) == 0 {
|
|
|
return
|
|
@@ -635,7 +659,7 @@ func (s *subscribePush) MakeCollection(userId string, list []*bxsubscribe.Subscr
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//仅移动端首页使用,历史推送7天信息
|
|
|
+// 仅移动端首页使用,历史推送7天信息
|
|
|
func (s *subscribePush) sevenDayKey(userId string) string {
|
|
|
return fmt.Sprintf("7day_subpush_%s", userId)
|
|
|
}
|
|
@@ -644,7 +668,7 @@ func (s *subscribePush) PutSevenDayCache(userId string, datas []*bxsubscribe.Sub
|
|
|
redis.Put("pushcache_2_a", s.sevenDayKey(userId), SubPush{Datas: datas}, 7*24*60*60)
|
|
|
}
|
|
|
|
|
|
-//从pushcache_2_a中取
|
|
|
+// 从pushcache_2_a中取
|
|
|
func (s *subscribePush) GetSevenDayCache(userId string) ([]*bxsubscribe.SubscribeInfo, error) {
|
|
|
allPush, _ := s.GetCache("pushcache_2_a", s.sevenDayKey(userId))
|
|
|
if allPush != nil && allPush.Datas != nil && len(allPush.Datas) > 0 {
|
|
@@ -653,7 +677,7 @@ func (s *subscribePush) GetSevenDayCache(userId string) ([]*bxsubscribe.Subscrib
|
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
-//历史推送记录中单条信息格式化
|
|
|
+// 历史推送记录中单条信息格式化
|
|
|
func InfoFormats(info map[string]interface{}, tmp map[string]interface{}) map[string]interface{} {
|
|
|
area := common.ObjToString(info["area"])
|
|
|
if area == "A" {
|
|
@@ -686,7 +710,7 @@ func InfoFormats(info map[string]interface{}, tmp map[string]interface{}) map[st
|
|
|
return info
|
|
|
}
|
|
|
|
|
|
-//UpdateUserPushUnread 更新app未读标识为已读
|
|
|
+// UpdateUserPushUnread 更新app未读标识为已读
|
|
|
func UpdateUserPushUnread(userid string, vt string) {
|
|
|
if vt == MemberFlag {
|
|
|
IC.Mgo.UpdateById("user", userid, map[string]interface{}{"$set": map[string]interface{}{"i_member_apppushunread": 0}})
|
|
@@ -699,7 +723,7 @@ func UpdateUserPushUnread(userid string, vt string) {
|
|
|
|
|
|
//
|
|
|
|
|
|
-//获取用户信息
|
|
|
+// 获取用户信息
|
|
|
func (s *subscribePush) UserInfo(userId string) (*map[string]interface{}, int64) {
|
|
|
user, ok := IC.Mgo.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1,"i_member_status":1,"o_member_jy":1}`)
|
|
|
if !ok || user == nil {
|
|
@@ -708,7 +732,7 @@ func (s *subscribePush) UserInfo(userId string) (*map[string]interface{}, int64)
|
|
|
return user, common.Int64All((*user)["l_firstpushtime"])
|
|
|
}
|
|
|
|
|
|
-//是否有订阅词
|
|
|
+// 是否有订阅词
|
|
|
func GetKeySet(t string, u *map[string]interface{}, data []string) (bool, []string) {
|
|
|
var industry_ = []string{}
|
|
|
if u != nil {
|
|
@@ -756,8 +780,8 @@ const (
|
|
|
findfields = `"title"`
|
|
|
)
|
|
|
|
|
|
-//首次访问推送页面 默认生成推送数据
|
|
|
-//默认匹配es 7天内数据
|
|
|
+// 首次访问推送页面 默认生成推送数据
|
|
|
+// 默认匹配es 7天内数据
|
|
|
func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
|
|
|
if spqp.UserId == "" {
|
|
|
return false, 0, nil
|
|
@@ -794,7 +818,7 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam) (hasNextPage bool,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//保存推送表
|
|
|
+// 保存推送表
|
|
|
func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]interface{}, keyword []ViewKeyWord, ccount int) (resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
t2 := time.Now()
|
|
|
now := time.Now().Unix()
|
|
@@ -858,7 +882,7 @@ func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取匹配得关键词
|
|
|
+// 获取匹配得关键词
|
|
|
func getKeys(title string, keywords []ViewKeyWord) (str []string) {
|
|
|
if len(keywords) > 0 {
|
|
|
L:
|
|
@@ -880,7 +904,7 @@ func getKeys(title string, keywords []ViewKeyWord) (str []string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取查询语句
|
|
|
+// 获取查询语句
|
|
|
func (s *subscribePush) getDefaultDatasSQL(bsp *ViewCondition) (str string) {
|
|
|
query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
|
|
|
query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
|
|
@@ -1016,7 +1040,7 @@ type ViewCondition struct {
|
|
|
Size int //数量
|
|
|
}
|
|
|
|
|
|
-//获取用户信息
|
|
|
+// 获取用户信息
|
|
|
func (s *subscribePush) getUserInfo(spqp *SubPushQueryParam) (vc *ViewCondition) {
|
|
|
var isPayBool = false
|
|
|
var tmpInfo = struct {
|
|
@@ -1105,7 +1129,7 @@ func (s *subscribePush) getUserInfo(spqp *SubPushQueryParam) (vc *ViewCondition)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//关键词 附加词 排除词
|
|
|
+// 关键词 附加词 排除词
|
|
|
func getKeyWordArrFromDbResult(a_items []interface{}, item string, index int) (arr []ViewKeyWord) {
|
|
|
if a_items == nil {
|
|
|
return
|
|
@@ -1180,7 +1204,7 @@ func getKeyWordArrFromDbResultByFree(a_items []interface{}, item string, index i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//地区格式化
|
|
|
+// 地区格式化
|
|
|
func getStringArrFromDbResult(area map[string]interface{}, i int) (arr []string) {
|
|
|
if area == nil {
|
|
|
return
|
|
@@ -1202,7 +1226,7 @@ func getStringArrFromDbResult(area map[string]interface{}, i int) (arr []string)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//IsInTsGuide 是否进入向导
|
|
|
+// IsInTsGuide 是否进入向导
|
|
|
func (s *subscribePush) IsInTsGuide(userid string) bool {
|
|
|
if userid == "" {
|
|
|
return false
|