getsubsomeinfologic.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. "strconv"
  9. "time"
  10. "jyBXSubscribe/rpc/internal/svc"
  11. "jyBXSubscribe/rpc/type/bxsubscribe"
  12. "github.com/zeromicro/go-zero/core/logx"
  13. )
  14. type GetSubSomeInfoLogic struct {
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. logx.Logger
  18. }
  19. func NewGetSubSomeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubSomeInfoLogic {
  20. return &GetSubSomeInfoLogic{
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. Logger: logx.WithContext(ctx),
  24. }
  25. }
  26. // 获取订阅推送相关信息
  27. func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SomeInfoReq) (*bxsubscribe.SomeInfoResp, error) {
  28. resp := &bxsubscribe.SomeInfoResp{
  29. Data: &bxsubscribe.SomeInfo{
  30. HasKey: false,
  31. IsInTSguide: false,
  32. IsExpire: 0,
  33. IsOnTail: 0,
  34. IsPassCount: false,
  35. OtherFlag: false,
  36. IsRead: false,
  37. Industry: nil,
  38. UserId: "",
  39. },
  40. }
  41. baseUserId, _ := strconv.ParseInt(in.NewUserId, 10, 64)
  42. //accountId, _ := strconv.ParseInt(in.AccountId, 10, 64)
  43. //positionType, _ := strconv.ParseInt(in.PositionType, 10, 64)
  44. //positionId, _ := strconv.ParseInt(in.PositionId, 10, 64)
  45. //entId, _ := strconv.ParseInt(in.EntId, 10, 64)
  46. //userInfo := IC.Compatible.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, baseUserId, accountId, entId, positionType, positionId)
  47. //logx.Info("userInfo:", userInfo)
  48. //P278 身份切换,切换企业 userId从代理header 获取的值是 职位id,所以改成用base_user_id 进行查user表信息
  49. user, _ := model.NewSubscribePush(in.UserType).UserInfo(baseUserId)
  50. //
  51. resp.Data.HasKey, resp.Data.Industry = model.GetKeySet(in.UserType, user, []string{})
  52. todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
  53. if user != nil {
  54. //超级订阅
  55. if common.IntAll((*user)["i_vip_status"]) == 1 || common.IntAll((*user)["i_vip_status"]) == 2 {
  56. var threeRemind = int64(3 * 24 * 60 * 60)
  57. var twoRemind = int64(2 * 24 * 60 * 60)
  58. var oneRemind = int64(1 * 24 * 60 * 60)
  59. if (*user)["isread"] != nil {
  60. resp.Data.IsRead = (*user)["isread"].(bool)
  61. }
  62. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 2000
  63. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  64. _endtime := (*user)["l_vip_endtime"]
  65. //是否到期
  66. if common.Int64All(_endtime)-time.Now().Unix() < threeRemind && common.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
  67. resp.Data.IsExpire = 3 //即将到期
  68. } else if common.Int64All(_endtime)-time.Now().Unix() < twoRemind && common.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
  69. resp.Data.IsExpire = 2 //即将到期
  70. } else if common.Int64All(_endtime)-time.Now().Unix() < oneRemind && common.Int64All(_endtime)-time.Now().Unix() >= 0 {
  71. resp.Data.IsExpire = 1 //即将到期
  72. }
  73. //判断首次用户是否推送的带有”其他“
  74. t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
  75. today_1 := t.Unix()
  76. today_2 := t.AddDate(0, 0, 1).Unix()
  77. //错误
  78. 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 {
  79. resp.Data.OtherFlag = true
  80. }
  81. } else {
  82. if (*user)["i_vip_status"] == nil {
  83. resp.Data.IsExpire = 0
  84. } else {
  85. resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
  86. }
  87. resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
  88. }
  89. //是否进入向导查询
  90. resp.Data.IsInTSguide = func() bool {
  91. //付费用户无免费订阅,不进入订阅向导页面
  92. if common.IntAll((*user)["i_member_status"]) > 0 || common.IntAll((*user)["i_vip_status"]) > 0 {
  93. return false
  94. }
  95. o_jy, _ := (*user)["o_jy"].(map[string]interface{})
  96. iTsGuide := common.IntAll((*user)["i_ts_guide"])
  97. if iTsGuide == 2 || (iTsGuide == 0 && len(o_jy) == 0) {
  98. return true
  99. }
  100. return false
  101. }()
  102. }
  103. return resp, nil
  104. }