getsublistlogic.go 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. BuySubject: 0,
  56. }
  57. //主体处理(fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户)
  58. if in.UserType == "vType" || in.UserType == "mType" {
  59. infoCount := IC.MainMysql.CountBySql("select count(id) from entniche_wait_empower where ent_id=? and end_time>NOW() and product_type like '%超级订阅%' or product_type like '大会员' ", in.EntId)
  60. if infoCount > 0 {
  61. in.UserType = "eType"
  62. //主体等于企业的
  63. spqp.BuySubject = 1
  64. }
  65. }
  66. hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp)
  67. start1 := time.Now().Unix()
  68. logx.Info("1、查询数据用户", start1-start)
  69. /*
  70. *无推送记录生成推送记录
  71. *免费用户默认推送50条
  72. *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
  73. */
  74. if in.PageNum == 1 && spqp.IsEmpty() && len(list) == 0 && in.IsEnt == false {
  75. hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp)
  76. }
  77. start2 := time.Now().Unix()
  78. logx.Info("2、查询数据用户", start2-start1)
  79. //查询是否收藏
  80. model.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
  81. start3 := time.Now().Unix()
  82. logx.Info("3、查询数据用户", start3-start2)
  83. logx.Info("总共查询数据用户", start3-start)
  84. return &bxsubscribe.SubscribeInfosResp{
  85. Data: &bxsubscribe.SubscribeData{
  86. List: list,
  87. Count: total,
  88. HasNextPage: hasNextPage,
  89. },
  90. }, nil
  91. }