|
@@ -3,6 +3,7 @@ package model
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
IC "jyBXSubscribe/rpc/init"
|
|
|
ms "jyBXSubscribe/rpc/model/service"
|
|
|
"jyBXSubscribe/rpc/type/bxsubscribe"
|
|
@@ -114,7 +115,7 @@ type SubPushQueryParam struct {
|
|
|
Item string
|
|
|
SelectKeys []string //关键词
|
|
|
District string
|
|
|
- SubPushInactive string // 订阅活跃标记
|
|
|
+ SubPushInactive int // 订阅活跃标记
|
|
|
}
|
|
|
|
|
|
// 关键词参数
|
|
@@ -1069,7 +1070,7 @@ const (
|
|
|
|
|
|
// 首次访问推送页面 默认生成推送数据
|
|
|
// 默认匹配es 7天内数据
|
|
|
-func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
|
|
|
+func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition, userType string) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
|
|
|
if spqp.UserId == "" {
|
|
|
return false, 0, nil
|
|
|
}
|
|
@@ -1084,10 +1085,14 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
var mlist []map[string]interface{}
|
|
|
esM := listHistory(spqp)
|
|
|
- for _, m := range *list {
|
|
|
- if !esM[common.ObjToString(m["_id"])] {
|
|
|
- mlist = append(mlist, m)
|
|
|
+ if len(esM) > 0 {
|
|
|
+ for _, m := range *list {
|
|
|
+ if !esM[common.ObjToString(m["_id"])] {
|
|
|
+ mlist = append(mlist, m)
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ mlist = *list
|
|
|
}
|
|
|
logx.Info(time.Since(t1), "mlist count:", len(mlist))
|
|
|
total = int64(len(mlist))
|
|
@@ -1098,6 +1103,9 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if spqp.SubPushInactive == -1 && spqp.PositionType == 0 && (userType == "vType" || userType == "fType") {
|
|
|
+ IC.Mgo.UpdateById("user", spqp.UserId, bson.M{"$set": bson.M{"subpush_inactive": -2}})
|
|
|
+ }
|
|
|
logx.Info("请求耗时:", time.Since(t1))
|
|
|
return
|
|
|
}
|
|
@@ -1105,7 +1113,7 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
// 历史订阅消息
|
|
|
func listHistory(spqp *SubPushQueryParam) map[string]bool {
|
|
|
m := make(map[string]bool)
|
|
|
- sql := "SELECT infoid FROM push.pushentniche where userid = ? order by date desc, id desc limit 1000;"
|
|
|
+ sql := "SELECT infoid FROM push.pushsubscribe where userid = ? order by date desc, id desc limit 1000;"
|
|
|
info := spqp.BaseServiceMysql.SelectBySql(sql, spqp.NewUserId)
|
|
|
for _, m1 := range *info {
|
|
|
m[common.ObjToString(m1["infoid"])] = true
|
|
@@ -1382,7 +1390,7 @@ func (s *subscribePush) GetUserInfo(spqp *SubPushQueryParam) (vc *ViewCondition)
|
|
|
switch s.ModuleFlag {
|
|
|
case MemberFlag:
|
|
|
userMap, ok := IC.Mgo.FindById("user", spqp.UserId, `{"o_member_jy":1,"i_member_status":1,"subpush_inactive":1}`)
|
|
|
- spqp.SubPushInactive = common.ObjToString((*userMap)["subpush_inactive"])
|
|
|
+ spqp.SubPushInactive = common.IntAll((*userMap)["subpush_inactive"])
|
|
|
if !ok || userMap == nil || len(*userMap) == 0 {
|
|
|
return &ViewCondition{}
|
|
|
}
|
|
@@ -1398,7 +1406,7 @@ func (s *subscribePush) GetUserInfo(spqp *SubPushQueryParam) (vc *ViewCondition)
|
|
|
}
|
|
|
case SubVipFlag:
|
|
|
userMap, ok := IC.Mgo.FindById("user", spqp.UserId, `{"o_vipjy":1,"i_vip_status":1,"subpush_inactive":1}`)
|
|
|
- spqp.SubPushInactive = common.ObjToString((*userMap)["subpush_inactive"])
|
|
|
+ spqp.SubPushInactive = common.IntAll((*userMap)["subpush_inactive"])
|
|
|
if !ok || userMap == nil || len(*userMap) == 0 {
|
|
|
return &ViewCondition{}
|
|
|
}
|