getsublistlogic.go 4.1 KB

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