getsublistlogic.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. IC "jyBXSubscribe/rpc/init"
  6. "jyBXSubscribe/rpc/internal/svc"
  7. "jyBXSubscribe/rpc/model"
  8. "jyBXSubscribe/rpc/type/bxsubscribe"
  9. )
  10. type GetSubListLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGetSubListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubListLogic {
  16. return &GetSubListLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 获取订阅推送列表
  23. func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
  24. //1、推送信息已读标识
  25. //超级订阅 i_apppushunread=0
  26. //大会员 i_member_apppushunread=0
  27. //商机管理 i_entniche_apppushunread=0
  28. if in.PageNum == 1 {
  29. go model.UpdateUserPushUnread(in.UserId, in.UserType)
  30. }
  31. spqp := &model.SubPushQueryParam{
  32. Mgo_bidding: IC.MgoBidding, //mongo
  33. Bidding: IC.DB.Mongo.Bidding.Collection, //招标信息 表
  34. Bidding_back: IC.DB.Mongo.Bidding.CollectionBack, //招标信息备份数据 表名
  35. UserId: in.UserId, //用户id
  36. PageNum: int(in.PageNum), //当前页码
  37. PageSize: int(in.PageSize), //每页多少条数据
  38. SelectTime: in.SelectTime, //时间跨度
  39. Area: in.Area, //省份
  40. City: in.City, //城市
  41. Buyerclass: in.BuyerClass, //采购单位类型
  42. Subtype: in.Subtype, //信息类型
  43. Subscopeclass: in.Industry, //行业
  44. Key: in.KeyWords, //关键词
  45. Price: in.Price, //价格区间
  46. FileExists: in.FileExists, //是否有附件
  47. EntId: in.EntId, //商机管理企业id
  48. EntUserId: in.EntUserId, //商机管理用户id
  49. DeptId: in.DeptId, //商机管理部门id
  50. NewUserId: in.NewUserId,
  51. BaseServiceMysql: IC.BaseServiceMysql,
  52. IsEnt: in.IsEnt,
  53. }
  54. /* if in.UserType == "mType" {
  55. spqp.BaseServiceMysql = IC.MemberPushMysql
  56. } else if in.UserType == "eType" {
  57. spqp.BaseServiceMysql = IC.EntnichePushMysql
  58. } else {
  59. spqp.BaseServiceMysql = IC.PushMysql
  60. }*/
  61. hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp)
  62. //hasNextPage, total, list = false, 0, []*bxsubscribe.SubscribeInfo{}
  63. /*
  64. *无推送记录生成推送记录
  65. *免费用户默认推送50条
  66. *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
  67. */
  68. if in.PageNum == 1 && spqp.IsEmpty() && len(list) == 0 && in.IsEnt == false {
  69. hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp)
  70. }
  71. //查询是否收藏
  72. model.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
  73. return &bxsubscribe.SubscribeInfosResp{
  74. Data: &bxsubscribe.SubscribeData{
  75. List: list,
  76. Count: total,
  77. HasNextPage: hasNextPage,
  78. },
  79. }, nil
  80. }