|
@@ -8,8 +8,6 @@ import (
|
|
|
"jyBXBase/rpc/model"
|
|
|
"log"
|
|
|
"sort"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
|
|
|
MC "app.yhyue.com/moapp/jybase/common"
|
|
@@ -39,195 +37,318 @@ func NewNewestBiddingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *New
|
|
|
func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, error) {
|
|
|
t := time.Now()
|
|
|
userType := ""
|
|
|
- r, i := func(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, int) {
|
|
|
+ // status : 0 -不存缓存 1-存到未登录用户 2-存到用户自己的key 3-存到登录用户最新标讯
|
|
|
+ r, status := func(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, int) {
|
|
|
var res = &bxbase.NewsetBiddingResp{
|
|
|
Data: &bxbase.NewsetBidding{
|
|
|
List: []*bxbase.NewestList{},
|
|
|
},
|
|
|
}
|
|
|
- entUserId, _ := strconv.ParseInt(in.EntUserId, 10, 64)
|
|
|
- //主体处理(fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户)
|
|
|
- if in.PositionType == 1 {
|
|
|
- //主体等于企业的
|
|
|
- userType = "e"
|
|
|
- }
|
|
|
- rks := ""
|
|
|
- if userType == "e" {
|
|
|
- rks = MC.If(in.UserId != "", in.EntUserId, in.City).(string)
|
|
|
- } else {
|
|
|
- rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
- }
|
|
|
- redisKey := "p1_indexMessage_new_" + rks
|
|
|
+ // 1. 未登录用户 查未登录缓存 返回 没有缓存 查最新标讯存未登录返回
|
|
|
+ // 2. 登录用户 查count count=1 查用户缓存 缓存没数据查用户推送
|
|
|
+ // count =0 查最新标讯缓存 缓存没数据查最新标讯存登录缓存 显示引导用户设置关键词
|
|
|
if in.UserId == "" {
|
|
|
- //未登录用户查询当天缓存
|
|
|
- redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
- }
|
|
|
- redisByte, err := redis.GetBytes("other", redisKey)
|
|
|
- if err == nil && redisByte != nil && len(*redisByte) > 0 {
|
|
|
- err = json.Unmarshal(*redisByte, res.Data)
|
|
|
- if err != nil {
|
|
|
- logx.Info(fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error()))
|
|
|
- }
|
|
|
- if len(res.Data.List) > 0 {
|
|
|
- return res, 1
|
|
|
- }
|
|
|
- }
|
|
|
- var subtype string
|
|
|
- //登录用户
|
|
|
- if in.UserId != "" {
|
|
|
- //优先级 由测试确认 大会员 》 商机管理 》 VIP 》 普通用户 》 搜索历史
|
|
|
- //获取订阅信息
|
|
|
- userMap := IC.Compatible.Select(in.UserId, `{"o_jy":1,"o_vipjy":1,"i_vip_status":1,"o_member_jy":1,"i_member_status":1,"s_m_phone":1,"s_phone":1}`)
|
|
|
- if userMap == nil || len(*userMap) == 0 {
|
|
|
- //查询出错
|
|
|
- res.ErrCode = -1
|
|
|
- res.ErrMsg = fmt.Errorf("未查询到用户信息").Error()
|
|
|
- return res, -1
|
|
|
- }
|
|
|
- //var isPayUser bool = false
|
|
|
- //付费用户如果没有数据 直接返回 需求来源:测试
|
|
|
- //vip用户
|
|
|
- vipStatus := MC.IntAll((*userMap)["i_vip_status"])
|
|
|
- //大会员用户
|
|
|
- bigStatus := MC.Int64All((*userMap)["i_member_status"])
|
|
|
- if bigStatus > 0 {
|
|
|
- o_msgset := MC.ObjToMap((*userMap)["o_member_jy"])
|
|
|
- big_items, ok := (*o_msgset)["a_items"].([]interface{})
|
|
|
- //大会员推送历史
|
|
|
- result := []*bxbase.NewestList{}
|
|
|
- if userType == "e" {
|
|
|
- result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
- } else {
|
|
|
- result = model.GetNewestInfo(rks, "m", in.NewUserId).GetPushHistory()
|
|
|
- }
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- if res.Data.Count > 0 {
|
|
|
- res.Data.HasSubKeys = ok && len(big_items) > 0
|
|
|
- res.Data.List = result
|
|
|
- res.Data.SubFlag = "m"
|
|
|
- }
|
|
|
- return res, 0
|
|
|
- }
|
|
|
- if phone := MC.If((*userMap)["s_phone"] != nil, MC.ObjToString((*userMap)["s_phone"]), MC.ObjToString((*userMap)["s_m_phone"])).(string); phone != "" && in.EntUserId != "" && in.EntId != "" {
|
|
|
- //商机管理
|
|
|
- entNicheInfos := IC.MainMysql.SelectBySql(`SELECT i.power_source,u.power FROM entniche_user u LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone=? and i.status=1 AND i.id = ?`, phone, in.EntId)
|
|
|
- if entNicheInfos != nil && len(*entNicheInfos) > 0 {
|
|
|
- entNicheInfo := (*entNicheInfos)[0]
|
|
|
- //排除商机管理服务
|
|
|
- if MC.IntAll(entNicheInfo["power_source"]) != 1 {
|
|
|
- // 已分发权限
|
|
|
- if MC.IntAll(entNicheInfo["power"]) > 0 {
|
|
|
- //商机管理推送历史
|
|
|
- result := model.GetNewestInfo(in.EntUserId, "e", entUserId).GetPushHistory()
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- if res.Data.Count > 0 {
|
|
|
- res.Data.List = result
|
|
|
- res.Data.SubFlag = "e"
|
|
|
- }
|
|
|
- return res, 0
|
|
|
- }
|
|
|
- }
|
|
|
+ redisKey := "p1_indexMessage_new_noLogin_%d_%d_%d"
|
|
|
+ redisKey = fmt.Sprintf(redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
+ redisByte, err := redis.GetBytes("other", redisKey)
|
|
|
+ if err == nil && redisByte != nil && len(*redisByte) > 0 {
|
|
|
+ err = json.Unmarshal(*redisByte, res.Data)
|
|
|
+ if err != nil {
|
|
|
+ logx.Info(fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error()))
|
|
|
}
|
|
|
}
|
|
|
- if vipStatus > 0 {
|
|
|
- o_msgset := MC.ObjToMap((*userMap)["o_vipjy"])
|
|
|
- vip_items, ok := (*o_msgset)["a_items"].([]interface{})
|
|
|
- //vip查询推送历史
|
|
|
- result := []*bxbase.NewestList{}
|
|
|
- if userType == "e" {
|
|
|
- result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
- } else {
|
|
|
- result = model.GetNewestInfo(rks, "v", in.NewUserId).GetPushHistory()
|
|
|
- }
|
|
|
- res.Data.IsVip = true
|
|
|
- res.Data.HasSubKeys = ok && len(vip_items) > 0
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- res.Data.List = result
|
|
|
- res.Data.SubFlag = "v"
|
|
|
+ if len(res.Data.List) > 0 { // 缓存有数据直接返回
|
|
|
return res, 0
|
|
|
}
|
|
|
+ // todo 没数据查最新数据返回
|
|
|
+ //未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
|
|
|
+ //subtype = `"预告","公告","结果","其它"`
|
|
|
+ //
|
|
|
+ return res, 1
|
|
|
+ }
|
|
|
|
|
|
- //普通用户用户- 有关键词
|
|
|
- o_msgset := MC.ObjToMap((*userMap)["o_jy"])
|
|
|
- items, ok := (*o_msgset)["a_key"].([]interface{})
|
|
|
- if ok && len(items) > 0 {
|
|
|
- //普通用户查询推送历史
|
|
|
- result := []*bxbase.NewestList{}
|
|
|
- if userType == "e" {
|
|
|
- result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
- } else {
|
|
|
- result = model.GetNewestInfo(rks, "f", in.NewUserId).GetPushHistory()
|
|
|
- }
|
|
|
- res.Data.IsVip = false
|
|
|
- res.Data.HasSubKeys = ok && len(items) > 0
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- res.Data.List = result
|
|
|
- res.Data.SubFlag = "f"
|
|
|
- return res, 0
|
|
|
+ // 登录根据用户身份构造 roleNewestInfo 用于后边查询数据
|
|
|
+ var roleNewestInfo *model.NewestInfo
|
|
|
+ flag := ""
|
|
|
+ powerCheck := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.MgoUserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
|
|
|
+ if powerCheck.Member.Status > 0 {
|
|
|
+ // 大会员
|
|
|
+ flag = "m"
|
|
|
+ if in.PositionType == int64(1) {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.EntUserId), "e", in.EntUserId)
|
|
|
+ } else {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.NewUserId), "m", in.NewUserId)
|
|
|
}
|
|
|
- //搜索历史-关键词
|
|
|
- hKeys := redis.GetStr("other", fmt.Sprintf("s_%s", in.UserId))
|
|
|
- if hKeys != "" && len(strings.Split(hKeys, ",")) > 0 {
|
|
|
- //历史搜索
|
|
|
- res.Data.History = strings.Split(hKeys, ",")
|
|
|
- //根据订阅词获取查询语句
|
|
|
- query := model.NewestQuery("", hKeys, subtype)
|
|
|
- result := model.NewestES(query)
|
|
|
- res.Data.IsVip = false
|
|
|
- res.Data.HasSubKeys = false
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- res.Data.List = result
|
|
|
- return res, 0
|
|
|
+ } else if powerCheck.Entniche.Status > 0 && powerCheck.Entniche.PowerSource != 1 && powerCheck.Entniche.IsEntPower == 1 {
|
|
|
+ // 商机管理
|
|
|
+ flag = "e"
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.EntUserId), "e", in.EntUserId)
|
|
|
+ } else if powerCheck.Vip.Status > 0 {
|
|
|
+ // 超级订阅
|
|
|
+ flag = "v"
|
|
|
+ if in.PositionType == int64(1) {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.EntUserId), "e", in.EntUserId)
|
|
|
+ } else {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.NewUserId), "v", in.NewUserId)
|
|
|
}
|
|
|
} else {
|
|
|
- //未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
|
|
|
- subtype = `"预告","公告","结果","其它"`
|
|
|
+ // 普通用户
|
|
|
+ flag = "f"
|
|
|
+ if in.PositionType == int64(1) {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.EntUserId), "e", in.EntUserId)
|
|
|
+ } else {
|
|
|
+ roleNewestInfo = model.GetNewestInfo(MC.InterfaceToStr(in.NewUserId), "f", in.NewUserId)
|
|
|
+ }
|
|
|
}
|
|
|
- if in.IsSearch == 2 { //定位查询(默认全国)
|
|
|
- query := model.NewestQuery(rks, "", subtype)
|
|
|
- result := model.NewestES(query)
|
|
|
- res.Data.IsVip = false
|
|
|
- res.Data.HasSubKeys = false
|
|
|
- res.Data.Count = int64(len(result))
|
|
|
- res.Data.List = result
|
|
|
+ res.Data.SubFlag = flag
|
|
|
+ existData := roleNewestInfo.GetPushHistoryCount()
|
|
|
+ if existData > 0 { // 存在推送 查推送缓存 缓存没有数据则查 推送数据
|
|
|
+ res.Data.ShowTip = 1 // 不显示
|
|
|
+ // todo 查缓存
|
|
|
+ return res, 0
|
|
|
+ // 查推送
|
|
|
+ return res, 2
|
|
|
+ } else { // 等0则说明推送里面没有数据 所以去查最新标讯信息缓存 返回 缓存没有则查最新标讯信息 存到缓存里面
|
|
|
+ res.Data.ShowTip = 2 // 不显示
|
|
|
+ // 查缓存
|
|
|
return res, 0
|
|
|
+ // todo 查最新标讯
|
|
|
+ // 显示引导设置
|
|
|
+ return res, 3
|
|
|
}
|
|
|
+
|
|
|
return res, 0
|
|
|
}(in)
|
|
|
- if r.Data.Count > 0 {
|
|
|
- //排序
|
|
|
- sort.Slice(r.Data.List, func(i, j int) bool {
|
|
|
- return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
|
|
|
- })
|
|
|
- //-1:程序异常 0 不存在缓存数据 1 存在缓存数据 新数据 存入缓存
|
|
|
- if i == 0 {
|
|
|
- rks := ""
|
|
|
- if userType == "e" {
|
|
|
- rks = MC.If(in.UserId != "", in.EntUserId, in.City).(string)
|
|
|
- } else {
|
|
|
- rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
- }
|
|
|
- //rks := MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
- b, err := json.Marshal(r.Data)
|
|
|
- if err != nil {
|
|
|
- r.ErrCode = -1
|
|
|
- r.ErrMsg = fmt.Sprintf("保存缓存 序列化异常,err:%s", err.Error())
|
|
|
- } else {
|
|
|
- redisKey := "p1_indexMessage_new_" + rks
|
|
|
- timeOut := 2 * 60 * 60
|
|
|
- if in.UserId == "" {
|
|
|
- //未登录用户缓存一天
|
|
|
- timeOut = 24 * 60 * 60
|
|
|
- redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
- }
|
|
|
- if err = redis.PutBytes("other", redisKey, &b, timeOut); err != nil {
|
|
|
- r.ErrCode = -1
|
|
|
- r.ErrMsg = fmt.Sprintf("保存缓存 redis 异常,err:%s", err.Error())
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //if r.Data.Count > 0 {
|
|
|
+ // //排序
|
|
|
+ // sort.Slice(r.Data.List, func(i, j int) bool {
|
|
|
+ // return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
|
|
|
+ // })
|
|
|
+ // //-1:程序异常 0 不存在缓存数据 1 存在缓存数据 新数据 存入缓存
|
|
|
+ // if i == 0 {
|
|
|
+ // rks := ""
|
|
|
+ // if userType == "e" {
|
|
|
+ // rks = MC.If(in.UserId != "", in.EntUserId, in.City).(string)
|
|
|
+ // } else {
|
|
|
+ // rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
+ // }
|
|
|
+ // //rks := MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
+ // b, err := json.Marshal(r.Data)
|
|
|
+ // if err != nil {
|
|
|
+ // r.ErrCode = -1
|
|
|
+ // r.ErrMsg = fmt.Sprintf("保存缓存 序列化异常,err:%s", err.Error())
|
|
|
+ // } else {
|
|
|
+ // redisKey := "p1_indexMessage_new_" + rks
|
|
|
+ // timeOut := 2 * 60 * 60
|
|
|
+ // if in.UserId == "" {
|
|
|
+ // //未登录用户缓存一天
|
|
|
+ // timeOut = 24 * 60 * 60
|
|
|
+ // redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
+ // }
|
|
|
+ // if err = redis.PutBytes("other", redisKey, &b, timeOut); err != nil {
|
|
|
+ // r.ErrCode = -1
|
|
|
+ // r.ErrMsg = fmt.Sprintf("保存缓存 redis 异常,err:%s", err.Error())
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
model.MakeCollection(in.UserId, r.Data.List)
|
|
|
log.Println("接口耗时:", time.Since(t).Seconds())
|
|
|
return r, nil
|
|
|
}
|
|
|
+
|
|
|
+//func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, error) {
|
|
|
+// t := time.Now()
|
|
|
+// userType := ""
|
|
|
+// r, i := func(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, int) {
|
|
|
+// var res = &bxbase.NewsetBiddingResp{
|
|
|
+// Data: &bxbase.NewsetBidding{
|
|
|
+// List: []*bxbase.NewestList{},
|
|
|
+// },
|
|
|
+// }
|
|
|
+// entUserId, _ := strconv.ParseInt(in.EntUserId, 10, 64)
|
|
|
+// //主体处理(fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户)
|
|
|
+// if in.PositionType == 1 {
|
|
|
+// //主体等于企业的
|
|
|
+// userType = "e"
|
|
|
+// }
|
|
|
+// rks := ""
|
|
|
+// if userType == "e" {
|
|
|
+// rks = MC.If(in.UserId != "", in.EntUserId, in.City).(string)
|
|
|
+// } else {
|
|
|
+// rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
+// }
|
|
|
+// redisKey := "p1_indexMessage_new_" + rks
|
|
|
+// if in.UserId == "" {
|
|
|
+// //未登录用户查询当天缓存
|
|
|
+// redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
+// }
|
|
|
+// redisByte, err := redis.GetBytes("other", redisKey)
|
|
|
+// if err == nil && redisByte != nil && len(*redisByte) > 0 {
|
|
|
+// err = json.Unmarshal(*redisByte, res.Data)
|
|
|
+// if err != nil {
|
|
|
+// logx.Info(fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error()))
|
|
|
+// }
|
|
|
+// if len(res.Data.List) > 0 {
|
|
|
+// return res, 1
|
|
|
+// }
|
|
|
+// }
|
|
|
+// var subtype string
|
|
|
+// //登录用户
|
|
|
+// if in.UserId != "" {
|
|
|
+// //优先级 由测试确认 大会员 》 商机管理 》 VIP 》 普通用户 》 搜索历史
|
|
|
+// //获取订阅信息
|
|
|
+// userMap := IC.Compatible.Select(in.UserId, `{"o_jy":1,"o_vipjy":1,"i_vip_status":1,"o_member_jy":1,"i_member_status":1,"s_m_phone":1,"s_phone":1}`)
|
|
|
+// if userMap == nil || len(*userMap) == 0 {
|
|
|
+// //查询出错
|
|
|
+// res.ErrCode = -1
|
|
|
+// res.ErrMsg = fmt.Errorf("未查询到用户信息").Error()
|
|
|
+// return res, -1
|
|
|
+// }
|
|
|
+// //var isPayUser bool = false
|
|
|
+// //付费用户如果没有数据 直接返回 需求来源:测试
|
|
|
+// //vip用户
|
|
|
+// vipStatus := MC.IntAll((*userMap)["i_vip_status"])
|
|
|
+// //大会员用户
|
|
|
+// bigStatus := MC.Int64All((*userMap)["i_member_status"])
|
|
|
+// if bigStatus > 0 {
|
|
|
+// o_msgset := MC.ObjToMap((*userMap)["o_member_jy"])
|
|
|
+// big_items, ok := (*o_msgset)["a_items"].([]interface{})
|
|
|
+// //大会员推送历史
|
|
|
+// result := []*bxbase.NewestList{}
|
|
|
+// if userType == "e" {
|
|
|
+// result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
+// } else {
|
|
|
+// result = model.GetNewestInfo(rks, "m", in.NewUserId).GetPushHistory()
|
|
|
+// }
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// if res.Data.Count > 0 {
|
|
|
+// res.Data.HasSubKeys = ok && len(big_items) > 0
|
|
|
+// res.Data.List = result
|
|
|
+// res.Data.SubFlag = "m"
|
|
|
+// }
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+// if phone := MC.If((*userMap)["s_phone"] != nil, MC.ObjToString((*userMap)["s_phone"]), MC.ObjToString((*userMap)["s_m_phone"])).(string); phone != "" && in.EntUserId != "" && in.EntId != "" {
|
|
|
+// //商机管理
|
|
|
+// entNicheInfos := IC.MainMysql.SelectBySql(`SELECT i.power_source,u.power FROM entniche_user u LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone=? and i.status=1 AND i.id = ?`, phone, in.EntId)
|
|
|
+// if entNicheInfos != nil && len(*entNicheInfos) > 0 {
|
|
|
+// entNicheInfo := (*entNicheInfos)[0]
|
|
|
+// //排除商机管理服务
|
|
|
+// if MC.IntAll(entNicheInfo["power_source"]) != 1 {
|
|
|
+// // 已分发权限
|
|
|
+// if MC.IntAll(entNicheInfo["power"]) > 0 {
|
|
|
+// //商机管理推送历史
|
|
|
+// result := model.GetNewestInfo(in.EntUserId, "e", entUserId).GetPushHistory()
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// if res.Data.Count > 0 {
|
|
|
+// res.Data.List = result
|
|
|
+// res.Data.SubFlag = "e"
|
|
|
+// }
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if vipStatus > 0 {
|
|
|
+// o_msgset := MC.ObjToMap((*userMap)["o_vipjy"])
|
|
|
+// vip_items, ok := (*o_msgset)["a_items"].([]interface{})
|
|
|
+// //vip查询推送历史
|
|
|
+// result := []*bxbase.NewestList{}
|
|
|
+// if userType == "e" {
|
|
|
+// result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
+// } else {
|
|
|
+// result = model.GetNewestInfo(rks, "v", in.NewUserId).GetPushHistory()
|
|
|
+// }
|
|
|
+// res.Data.IsVip = true
|
|
|
+// res.Data.HasSubKeys = ok && len(vip_items) > 0
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// res.Data.List = result
|
|
|
+// res.Data.SubFlag = "v"
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+//
|
|
|
+// //普通用户用户- 有关键词
|
|
|
+// o_msgset := MC.ObjToMap((*userMap)["o_jy"])
|
|
|
+// items, ok := (*o_msgset)["a_key"].([]interface{})
|
|
|
+// if ok && len(items) > 0 {
|
|
|
+// //普通用户查询推送历史
|
|
|
+// result := []*bxbase.NewestList{}
|
|
|
+// if userType == "e" {
|
|
|
+// result = model.GetNewestInfo(rks, "e", entUserId).GetPushHistory()
|
|
|
+// } else {
|
|
|
+// result = model.GetNewestInfo(rks, "f", in.NewUserId).GetPushHistory()
|
|
|
+// }
|
|
|
+// res.Data.IsVip = false
|
|
|
+// res.Data.HasSubKeys = ok && len(items) > 0
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// res.Data.List = result
|
|
|
+// res.Data.SubFlag = "f"
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+// //搜索历史-关键词
|
|
|
+// hKeys := redis.GetStr("other", fmt.Sprintf("s_%s", in.UserId))
|
|
|
+// if hKeys != "" && len(strings.Split(hKeys, ",")) > 0 {
|
|
|
+// //历史搜索
|
|
|
+// res.Data.History = strings.Split(hKeys, ",")
|
|
|
+// //根据订阅词获取查询语句
|
|
|
+// query := model.NewestQuery("", hKeys, subtype)
|
|
|
+// result := model.NewestES(query)
|
|
|
+// res.Data.IsVip = false
|
|
|
+// res.Data.HasSubKeys = false
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// res.Data.List = result
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// //未登录用户访问全部信息类型 需要过滤掉 拟建和采购意向
|
|
|
+// subtype = `"预告","公告","结果","其它"`
|
|
|
+// }
|
|
|
+// if in.IsSearch == 2 { //定位查询(默认全国)
|
|
|
+// query := model.NewestQuery(rks, "", subtype)
|
|
|
+// result := model.NewestES(query)
|
|
|
+// res.Data.IsVip = false
|
|
|
+// res.Data.HasSubKeys = false
|
|
|
+// res.Data.Count = int64(len(result))
|
|
|
+// res.Data.List = result
|
|
|
+// return res, 0
|
|
|
+// }
|
|
|
+// return res, 0
|
|
|
+// }(in)
|
|
|
+// if r.Data.Count > 0 {
|
|
|
+// //排序
|
|
|
+// sort.Slice(r.Data.List, func(i, j int) bool {
|
|
|
+// return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
|
|
|
+// })
|
|
|
+// //-1:程序异常 0 不存在缓存数据 1 存在缓存数据 新数据 存入缓存
|
|
|
+// if i == 0 {
|
|
|
+// rks := ""
|
|
|
+// if userType == "e" {
|
|
|
+// rks = MC.If(in.UserId != "", in.EntUserId, in.City).(string)
|
|
|
+// } else {
|
|
|
+// rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
+// }
|
|
|
+// //rks := MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
+// b, err := json.Marshal(r.Data)
|
|
|
+// if err != nil {
|
|
|
+// r.ErrCode = -1
|
|
|
+// r.ErrMsg = fmt.Sprintf("保存缓存 序列化异常,err:%s", err.Error())
|
|
|
+// } else {
|
|
|
+// redisKey := "p1_indexMessage_new_" + rks
|
|
|
+// timeOut := 2 * 60 * 60
|
|
|
+// if in.UserId == "" {
|
|
|
+// //未登录用户缓存一天
|
|
|
+// timeOut = 24 * 60 * 60
|
|
|
+// redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
|
+// }
|
|
|
+// if err = redis.PutBytes("other", redisKey, &b, timeOut); err != nil {
|
|
|
+// r.ErrCode = -1
|
|
|
+// r.ErrMsg = fmt.Sprintf("保存缓存 redis 异常,err:%s", err.Error())
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// model.MakeCollection(in.UserId, r.Data.List)
|
|
|
+// log.Println("接口耗时:", time.Since(t).Seconds())
|
|
|
+// return r, nil
|
|
|
+//}
|