getsubsomeinfologic.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. //
  32. resp.Data.HasKey, resp.Data.Industry = model.GetKeySet(in.UserType, user, []string{})
  33. todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
  34. if user != nil {
  35. //超级订阅
  36. if common.IntAll((*user)["i_vip_status"]) == 1 || common.IntAll((*user)["i_vip_status"]) == 2 {
  37. var threeRemind = int64(3 * 24 * 60 * 60)
  38. var twoRemind = int64(2 * 24 * 60 * 60)
  39. var oneRemind = int64(1 * 24 * 60 * 60)
  40. if (*user)["isread"] != nil {
  41. resp.Data.IsRead = (*user)["isread"].(bool)
  42. }
  43. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 2000
  44. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  45. _endtime := (*user)["l_vip_endtime"]
  46. //是否到期
  47. if common.Int64All(_endtime)-time.Now().Unix() < threeRemind && common.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
  48. resp.Data.IsExpire = 3 //即将到期
  49. } else if common.Int64All(_endtime)-time.Now().Unix() < twoRemind && common.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
  50. resp.Data.IsExpire = 2 //即将到期
  51. } else if common.Int64All(_endtime)-time.Now().Unix() < oneRemind && common.Int64All(_endtime)-time.Now().Unix() >= 0 {
  52. resp.Data.IsExpire = 1 //即将到期
  53. }
  54. //判断首次用户是否推送的带有”其他“
  55. t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
  56. today_1 := t.Unix()
  57. today_2 := t.AddDate(0, 0, 1).Unix()
  58. //错误
  59. if IC.BaseServiceMysql.CountBySql("select count(1) as count from pushsubscribe a left join global_common_data.dws_f_bid_baseinfo b on a.infoid=b.infoid where a.isvip =1 and a.userid =? and b.buyerclass_code=? and (a.date between ? and ? )", common.InterfaceToStr(in.NewUserId), 93, today_1, today_2) > 0 {
  60. resp.Data.OtherFlag = true
  61. }
  62. } else {
  63. if (*user)["i_vip_status"] == nil {
  64. resp.Data.IsExpire = 0
  65. } else {
  66. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  67. }
  68. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
  69. }
  70. }
  71. //是否进入想到查询
  72. resp.Data.IsInTSguide = model.NewSubscribePush().IsInTsGuide(in.UserId)
  73. return resp, nil
  74. }