getsublistlogic.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. }
  51. if in.UserType == "mType" {
  52. spqp.PushMysql = IC.MemberPushMysql
  53. } else if in.UserType == "eType" {
  54. spqp.PushMysql = IC.EntnichePushMysql
  55. } else {
  56. spqp.PushMysql = IC.PushMysql
  57. }
  58. hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp)
  59. /*
  60. *无推送记录生成推送记录
  61. *免费用户默认推送50条
  62. *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
  63. */
  64. if in.PageNum == 1 && spqp.IsEmpty() && len(list) == 0 {
  65. hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp)
  66. }
  67. //查询是否收藏
  68. model.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
  69. return &bxsubscribe.SubscribeInfosResp{
  70. Data: &bxsubscribe.SubscribeData{
  71. List: list,
  72. Count: total,
  73. HasNextPage: hasNextPage,
  74. },
  75. }, nil
  76. }