getsublistlogic.go 3.6 KB

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