12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package logic
- import (
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "context"
- IC "jyBXSubscribe/rpc/init"
- "jyBXSubscribe/rpc/util"
- "time"
- "jyBXSubscribe/rpc/internal/svc"
- "jyBXSubscribe/rpc/type/bxsubscribe"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetSubSomeInfoLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetSubSomeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubSomeInfoLogic {
- return &GetSubSomeInfoLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 获取订阅推送相关信息
- func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SomeInfoReq) (*bxsubscribe.SomeInfoResp, error) {
- resp := &bxsubscribe.SomeInfoResp{
- Data: &bxsubscribe.SomeInfo{},
- }
- user, _ := util.NewSubscribePush(in.UserType).UserInfo(in.UserId)
- resp.Data.HasKey, resp.Data.Industry = util.GetKeySet(in.UserType, user, []string{})
- todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
- if user != nil {
- //超级订阅
- if common.IntAll((*user)["i_vip_status"]) == 1 || common.IntAll((*user)["i_vip_status"]) == 2 {
- var threeRemind = int64(3 * 24 * 60 * 60)
- var twoRemind = int64(2 * 24 * 60 * 60)
- var oneRemind = int64(1 * 24 * 60 * 60)
- if (*user)["isread"] != nil {
- resp.Data.IsRead = (*user)["isread"].(bool)
- }
- resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 2000
- resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
- _endtime := (*user)["l_vip_endtime"]
- //是否到期
- if common.Int64All(_endtime)-time.Now().Unix() < threeRemind && common.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
- resp.Data.IsExpire = 3 //即将到期
- } else if common.Int64All(_endtime)-time.Now().Unix() < twoRemind && common.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
- resp.Data.IsExpire = 2 //即将到期
- } else if common.Int64All(_endtime)-time.Now().Unix() < oneRemind && common.Int64All(_endtime)-time.Now().Unix() >= 0 {
- resp.Data.IsExpire = 1 //即将到期
- }
- //判断首次用户是否推送的带有”其他“
- t, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
- today_1 := t.Unix()
- today_2 := t.AddDate(0, 0, 1).Unix()
- 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 {
- resp.Data.OtherFlag = true
- }
- } else {
- if (*user)["i_vip_status"] == nil {
- resp.Data.IsExpire = 0
- } else {
- resp.Data.IsOnTail = common.Int64All((*user)["i_vip_status"])
- }
- resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
- }
- }
- return resp, nil
- }
|