12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package logic
- import (
- "context"
- "github.com/zeromicro/go-zero/core/logx"
- IC "jyBXSubscribe/rpc/init"
- "jyBXSubscribe/rpc/internal/svc"
- "jyBXSubscribe/rpc/model"
- "jyBXSubscribe/rpc/type/bxsubscribe"
- "jyBXSubscribe/rpc/util"
- "strings"
- "time"
- )
- type ByPushHistoryLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewByPushHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ByPushHistoryLogic {
- return &ByPushHistoryLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 推送页面筛选导出
- func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.ByPushHistoryResp, error) {
- // todo: add your logic here and delete this line
- vipType := in.UserType
- spqp := &model.SubPushQueryParam{
- Mgo_bidding: IC.MgoBidding, //mongo
- Bidding: IC.DB.Mongo.Bidding.Collection, //招标信息 表
- Bidding_back: IC.DB.Mongo.Bidding.CollectionBack, //招标信息备份数据 表名
- UserId: in.UserId, //用户id
- PageNum: 1, //当前页码
- PageSize: 20000,
- Export: true,
- SelectTime: in.SelectTime, //时间跨度
- Area: in.Area, //省份
- City: in.City, //城市
- Buyerclass: in.BuyerClass, //采购单位类型
- Subtype: in.Subtype, //信息类型
- Subscopeclass: in.Industry, //行业
- Key: in.KeyWords, //关键词
- Price: in.Price, //价格区间
- FileExists: in.FileExists, //是否有附件
- }
- if selectIds := strings.TrimSpace(in.SelectIds); selectIds != "" {
- //encodeArr := strings.Split(selectIds, ",")
- //idArr := make([]string, 0, len(encodeArr))
- //for _, encodeId := range encodeArr {
- // if tmp := util.DecodeId(encodeId); tmp != "" {
- // idArr = append(idArr, tmp)
- // }
- //}
- spqp.SelectInfoIds = strings.Split(selectIds, ",")
- }
- _, _, list := model.NewSubscribePush(vipType).Datas(spqp)
- if list == nil || len(list) == 0 {
- return &bxsubscribe.ByPushHistoryResp{
- ErrorCode: 1,
- ErrorMsg: "未查询到数据",
- }, nil
- }
- ids := make([]string, 0, len(list))
- keyWords := make([]string, 0, len(list))
- for _, pushData := range list {
- if pushData.XId != "" {
- if xid := util.EncodeId(pushData.XId); len(xid) > 0 {
- ids = append(ids, xid)
- keyWords = append(keyWords, strings.Join(pushData.MatchKeys, ","))
- }
- }
- }
- saveData := map[string]interface{}{
- "s_userid": in.UserId,
- "comeinfrom": "pushHistory",
- "comeintime": time.Now().Unix(),
- "selectIds": ids,
- "pushKeyWords": keyWords,
- }
- _id := IC.Mgo.Save("export_search", saveData)
- if _id == "" {
- return &bxsubscribe.ByPushHistoryResp{
- ErrorCode: 1,
- ErrorMsg: "创建导出异常",
- }, nil
- }
- return &bxsubscribe.ByPushHistoryResp{
- Data: util.EncodeId(_id),
- }, nil
- }
|