getsublistlogic.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. IC "jyBXSubscribe/rpc/init"
  7. "jyBXSubscribe/rpc/internal/svc"
  8. "jyBXSubscribe/rpc/model"
  9. "jyBXSubscribe/rpc/type/bxsubscribe"
  10. "time"
  11. )
  12. type GetSubListLogic struct {
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. logx.Logger
  16. }
  17. func NewGetSubListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubListLogic {
  18. return &GetSubListLogic{
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. Logger: logx.WithContext(ctx),
  22. }
  23. }
  24. // 获取订阅推送列表
  25. func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
  26. start := time.Now().Unix()
  27. //1、推送信息已读标识
  28. //超级订阅 i_apppushunread=0
  29. //大会员 i_member_apppushunread=0
  30. //商机管理 i_entniche_apppushunread=0
  31. if in.PageNum == 1 {
  32. go model.UpdateUserPushUnread(in.UserId, in.UserType)
  33. }
  34. spqp := &model.SubPushQueryParam{
  35. Mgo_bidding: IC.MgoBidding, //mongo
  36. Bidding: IC.DB.Mongo.Bidding.Collection, //招标信息 表
  37. Bidding_back: IC.DB.Mongo.Bidding.CollectionBack, //招标信息备份数据 表名
  38. UserId: in.UserId, //用户id
  39. PageNum: int(in.PageNum), //当前页码
  40. PageSize: int(in.PageSize), //每页多少条数据
  41. SelectTime: in.SelectTime, //时间跨度
  42. Area: in.Area, //省份
  43. City: in.City, //城市
  44. Buyerclass: in.BuyerClass, //采购单位类型
  45. Subtype: in.Subtype, //信息类型
  46. Subscopeclass: in.Industry, //行业
  47. Key: in.KeyWords, //关键词
  48. Price: in.Price, //价格区间
  49. FileExists: in.FileExists, //是否有附件
  50. EntId: in.EntId, //商机管理企业id
  51. EntUserId: in.EntUserId, //商机管理用户id
  52. DeptId: in.DeptId, //商机管理部门id
  53. NewUserId: in.NewUserId,
  54. BaseServiceMysql: IC.BaseServiceMysql,
  55. IsEnt: in.IsEnt,
  56. BuySubject: 0,
  57. UserType: in.UserType,
  58. }
  59. //主体处理(fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户)
  60. infoCount := IC.MainMysql.CountBySql("select count(id) from entniche_wait_empower where ent_id=? and end_time>NOW() and (product_type like '%VIP订阅%' or product_type like '%大会员%') ", in.EntId)
  61. if infoCount > 0 {
  62. in.UserType = model.EntnicheFlag
  63. //主体等于企业的
  64. spqp.BuySubject = 1
  65. }
  66. if in.UserType == model.EntnicheFlag {
  67. spqp.UserId = common.InterfaceToStr(spqp.EntUserId)
  68. }
  69. hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp)
  70. start1 := time.Now().Unix()
  71. logx.Info("1、查询数据用户", start1-start)
  72. /*
  73. *无推送记录生成推送记录
  74. *免费用户默认推送50条
  75. *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
  76. */
  77. if in.PageNum == 1 && spqp.IsEmpty() && len(list) == 0 && in.IsEnt == false {
  78. hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp)
  79. }
  80. start2 := time.Now().Unix()
  81. logx.Info("2、查询数据用户", start2-start1)
  82. //查询是否收藏
  83. model.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
  84. start3 := time.Now().Unix()
  85. logx.Info("3、查询数据用户", start3-start2)
  86. logx.Info("总共查询数据用户", start3-start)
  87. return &bxsubscribe.SubscribeInfosResp{
  88. Data: &bxsubscribe.SubscribeData{
  89. List: list,
  90. Count: total,
  91. HasNextPage: hasNextPage,
  92. },
  93. }, nil
  94. }