bypushhistorylogic.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/encrypt"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. IC "jyBXSubscribe/rpc/init"
  7. "jyBXSubscribe/rpc/internal/svc"
  8. "jyBXSubscribe/rpc/model"
  9. "jyBXSubscribe/rpc/type/bxsubscribe"
  10. "jyBXSubscribe/rpc/util"
  11. "strings"
  12. "time"
  13. )
  14. type ByPushHistoryLogic struct {
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. logx.Logger
  18. }
  19. func NewByPushHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ByPushHistoryLogic {
  20. return &ByPushHistoryLogic{
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. Logger: logx.WithContext(ctx),
  24. }
  25. }
  26. // 推送页面筛选导出
  27. func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.ByPushHistoryResp, error) {
  28. // todo: add your logic here and delete this line
  29. vipType := in.UserType
  30. spqp := &model.SubPushQueryParam{
  31. Mgo_bidding: IC.MgoBidding, //mongo
  32. Bidding: IC.DB.Mongo.Bidding.Collection, //招标信息 表
  33. Bidding_back: IC.DB.Mongo.Bidding.CollectionBack, //招标信息备份数据 表名
  34. UserId: in.UserId, //用户id
  35. PageNum: 1, //当前页码
  36. PageSize: 20000, //每页多少条数据
  37. SelectTime: in.SelectTime, //时间跨度
  38. Area: in.Area, //省份
  39. City: in.City, //城市
  40. Export: true,
  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 selectIds := strings.TrimSpace(in.SelectIds); selectIds != "" {
  55. //encodeArr := strings.Split(selectIds, ",")
  56. //idArr := make([]string, 0, len(encodeArr))
  57. //for _, encodeId := range encodeArr {
  58. // if tmp := util.DecodeId(encodeId); tmp != "" {
  59. // idArr = append(idArr, tmp)
  60. // }
  61. //}
  62. spqp.SelectInfoIds = strings.Split(selectIds, ",")
  63. }
  64. _, _, list := model.NewSubscribePush(vipType).Datas(spqp)
  65. if list == nil || len(list) == 0 {
  66. return &bxsubscribe.ByPushHistoryResp{
  67. ErrorCode: 1,
  68. ErrorMsg: "未查询到数据",
  69. }, nil
  70. }
  71. ids := make([]string, 0, len(list))
  72. keyWords := make([]string, 0, len(list))
  73. for _, pushData := range list {
  74. if pushData.XId != "" {
  75. if xid := util.DecodeId(pushData.XId); len(xid) > 0 {
  76. ids = append(ids, xid)
  77. keyWords = append(keyWords, strings.Join(pushData.MatchKeys, ","))
  78. }
  79. }
  80. }
  81. saveData := map[string]interface{}{
  82. "s_userid": in.UserId,
  83. "comeinfrom": "pushHistory",
  84. "comeintime": time.Now().Unix(),
  85. "selectIds": ids,
  86. "pushKeyWords": keyWords,
  87. }
  88. _id := IC.Mgo.Save("export_search", saveData)
  89. if _id == "" {
  90. return &bxsubscribe.ByPushHistoryResp{
  91. ErrorCode: 1,
  92. ErrorMsg: "创建导出异常",
  93. }, nil
  94. }
  95. return &bxsubscribe.ByPushHistoryResp{
  96. Data: encrypt.SE.Encode2Hex(_id),
  97. }, nil
  98. }