getsubsomeinfologic.go 4.2 KB

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