getsubsomeinfologic.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/redis"
  5. "context"
  6. IC "jyBXSubscribe/rpc/init"
  7. "jyBXSubscribe/rpc/util"
  8. "time"
  9. "jyBXSubscribe/rpc/internal/svc"
  10. "jyBXSubscribe/rpc/type/bxsubscribe"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type GetSubSomeInfoLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewGetSubSomeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubSomeInfoLogic {
  19. return &GetSubSomeInfoLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 获取订阅推送相关信息
  26. func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
  27. resp := &bxsubscribe.SomeInfoResp{}
  28. user, _ := util.NewSubscribePush().UserInfo(in.UserId)
  29. resp.Data.HasKey, resp.Data.Industry = util.GetKeySet(in.UserType, user, []string{})
  30. todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
  31. if user != nil {
  32. //超级订阅
  33. if common.IntAll((*user)["i_vip_status"]) == 1 || common.IntAll((*user)["i_vip_status"]) == 2 {
  34. var threeRemind = int64(3 * 24 * 60 * 60)
  35. var twoRemind = int64(2 * 24 * 60 * 60)
  36. var oneRemind = int64(1 * 24 * 60 * 60)
  37. if (*user)["isread"] != nil {
  38. resp.Data.IsRead = (*user)["isread"].(bool)
  39. }
  40. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 2000
  41. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  42. _endtime := (*user)["l_vip_endtime"]
  43. //是否到期
  44. if common.Int64All(_endtime)-time.Now().Unix() < threeRemind && common.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
  45. resp.Data.IsExpire = 3 //即将到期
  46. } else if common.Int64All(_endtime)-time.Now().Unix() < twoRemind && common.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
  47. resp.Data.IsExpire = 2 //即将到期
  48. } else if common.Int64All(_endtime)-time.Now().Unix() < oneRemind && common.Int64All(_endtime)-time.Now().Unix() >= 0 {
  49. resp.Data.IsExpire = 1 //即将到期
  50. }
  51. //判断首次用户是否推送的带有”其他“
  52. t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
  53. today_1 := t.Unix()
  54. today_2 := t.AddDate(0, 0, 1).Unix()
  55. if IC.PushMysql.CountBySql("select count(1) as count from pushsubscribe where isvip =1 and userid =? and buyerclass=? and (date between ? and ? )", in.UserId, 93, today_1, today_2) > 0 {
  56. resp.Data.OtherFlag = true
  57. }
  58. } else {
  59. if (*user)["i_vip_status"] == nil {
  60. resp.Data.IsExpire = 0
  61. } else {
  62. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  63. }
  64. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
  65. }
  66. }
  67. return &bxsubscribe.SubscribeInfosResp{}, nil
  68. }