getsubsomeinfologic.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/model"
  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.SomeInfoReq) (*bxsubscribe.SomeInfoResp, error) {
  27. resp := &bxsubscribe.SomeInfoResp{
  28. Data: &bxsubscribe.SomeInfo{},
  29. }
  30. user, _ := model.NewSubscribePush(in.UserType).UserInfo(in.UserId)
  31. resp.Data.HasKey, resp.Data.Industry = model.GetKeySet(in.UserType, user, []string{})
  32. todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
  33. if user != nil {
  34. //超级订阅
  35. if common.IntAll((*user)["i_vip_status"]) == 1 || common.IntAll((*user)["i_vip_status"]) == 2 {
  36. var threeRemind = int64(3 * 24 * 60 * 60)
  37. var twoRemind = int64(2 * 24 * 60 * 60)
  38. var oneRemind = int64(1 * 24 * 60 * 60)
  39. if (*user)["isread"] != nil {
  40. resp.Data.IsRead = (*user)["isread"].(bool)
  41. }
  42. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 2000
  43. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  44. _endtime := (*user)["l_vip_endtime"]
  45. //是否到期
  46. if common.Int64All(_endtime)-time.Now().Unix() < threeRemind && common.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
  47. resp.Data.IsExpire = 3 //即将到期
  48. } else if common.Int64All(_endtime)-time.Now().Unix() < twoRemind && common.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
  49. resp.Data.IsExpire = 2 //即将到期
  50. } else if common.Int64All(_endtime)-time.Now().Unix() < oneRemind && common.Int64All(_endtime)-time.Now().Unix() >= 0 {
  51. resp.Data.IsExpire = 1 //即将到期
  52. }
  53. //判断首次用户是否推送的带有”其他“
  54. t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
  55. today_1 := t.Unix()
  56. today_2 := t.AddDate(0, 0, 1).Unix()
  57. 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 {
  58. resp.Data.OtherFlag = true
  59. }
  60. } else {
  61. if (*user)["i_vip_status"] == nil {
  62. resp.Data.IsExpire = 0
  63. } else {
  64. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  65. }
  66. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
  67. }
  68. }
  69. return resp, nil
  70. }