|
@@ -38,7 +38,7 @@ func NewNewestBiddingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *New
|
|
func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, error) {
|
|
func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, error) {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
userType := ""
|
|
userType := ""
|
|
- r := func(in *bxbase.NewestBiddingReq) *bxbase.NewsetBiddingResp {
|
|
|
|
|
|
+ r, i := func(in *bxbase.NewestBiddingReq) (*bxbase.NewsetBiddingResp, int) {
|
|
var res = &bxbase.NewsetBiddingResp{
|
|
var res = &bxbase.NewsetBiddingResp{
|
|
Data: &bxbase.NewsetBidding{
|
|
Data: &bxbase.NewsetBidding{
|
|
List: []*bxbase.NewestList{},
|
|
List: []*bxbase.NewestList{},
|
|
@@ -58,6 +58,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
}
|
|
}
|
|
redisKey := "p1_indexMessage_new_" + rks
|
|
redisKey := "p1_indexMessage_new_" + rks
|
|
if in.UserId == "" {
|
|
if in.UserId == "" {
|
|
|
|
+ //未登录用户查询当天缓存
|
|
redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
redisKey = fmt.Sprintf("%s_%d_%d_%d", redisKey, time.Now().Year(), time.Now().Month(), time.Now().Day())
|
|
}
|
|
}
|
|
|
|
|
|
@@ -68,7 +69,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.ErrCode = -1
|
|
res.ErrCode = -1
|
|
res.ErrMsg = fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error())
|
|
res.ErrMsg = fmt.Sprintf("读取缓存 序列化异常,err:%s", err.Error())
|
|
}
|
|
}
|
|
- return res
|
|
|
|
|
|
+ return res, 1
|
|
}
|
|
}
|
|
//登录用户
|
|
//登录用户
|
|
if in.UserId != "" {
|
|
if in.UserId != "" {
|
|
@@ -79,7 +80,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
//查询出错
|
|
//查询出错
|
|
res.ErrCode = -1
|
|
res.ErrCode = -1
|
|
res.ErrMsg = fmt.Errorf("未查询到用户信息").Error()
|
|
res.ErrMsg = fmt.Errorf("未查询到用户信息").Error()
|
|
- return res
|
|
|
|
|
|
+ return res, -1
|
|
}
|
|
}
|
|
//var isPayUser bool = false
|
|
//var isPayUser bool = false
|
|
//付费用户如果没有数据 直接返回 需求来源:测试
|
|
//付费用户如果没有数据 直接返回 需求来源:测试
|
|
@@ -103,7 +104,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
res.Data.SubFlag = "m"
|
|
res.Data.SubFlag = "m"
|
|
}
|
|
}
|
|
- return res
|
|
|
|
|
|
+ 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 != "" {
|
|
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 != "" {
|
|
//商机管理
|
|
//商机管理
|
|
@@ -121,7 +122,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
res.Data.SubFlag = "e"
|
|
res.Data.SubFlag = "e"
|
|
}
|
|
}
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -141,7 +142,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
res.Data.SubFlag = "v"
|
|
res.Data.SubFlag = "v"
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}
|
|
}
|
|
|
|
|
|
//普通用户用户- 有关键词
|
|
//普通用户用户- 有关键词
|
|
@@ -155,7 +156,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
res.Data.SubFlag = "f"
|
|
res.Data.SubFlag = "f"
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}
|
|
}
|
|
//搜索历史-关键词
|
|
//搜索历史-关键词
|
|
hKeys := redis.GetStr("other", fmt.Sprintf("s_%s", in.UserId))
|
|
hKeys := redis.GetStr("other", fmt.Sprintf("s_%s", in.UserId))
|
|
@@ -169,7 +170,7 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.HasSubKeys = false
|
|
res.Data.HasSubKeys = false
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if in.IsSearch == 2 { //定位查询(默认全国)
|
|
if in.IsSearch == 2 { //定位查询(默认全国)
|
|
@@ -179,39 +180,41 @@ func (l *NewestBiddingLogic) NewestBidding(in *bxbase.NewestBiddingReq) (*bxbase
|
|
res.Data.HasSubKeys = false
|
|
res.Data.HasSubKeys = false
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.Count = int64(len(result))
|
|
res.Data.List = result
|
|
res.Data.List = result
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}
|
|
}
|
|
- return res
|
|
|
|
|
|
+ return res, 0
|
|
}(in)
|
|
}(in)
|
|
if r.Data.Count > 0 {
|
|
if r.Data.Count > 0 {
|
|
//排序
|
|
//排序
|
|
sort.Slice(r.Data.List, func(i, j int) bool {
|
|
sort.Slice(r.Data.List, func(i, j int) bool {
|
|
return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
|
|
return r.Data.List[i].PublishTime > r.Data.List[j].PublishTime
|
|
})
|
|
})
|
|
- //
|
|
|
|
- rks := ""
|
|
|
|
- if userType == "e" {
|
|
|
|
- rks = MC.If(in.UserId != "", MC.InterfaceToStr(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())
|
|
|
|
|
|
+ //-1:程序异常 0 不存在缓存数据 1 存在缓存数据 新数据 存入缓存
|
|
|
|
+ if i == 0 {
|
|
|
|
+ rks := ""
|
|
|
|
+ if userType == "e" {
|
|
|
|
+ rks = MC.If(in.UserId != "", MC.InterfaceToStr(in.EntUserId), in.City).(string)
|
|
|
|
+ } else {
|
|
|
|
+ rks = MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
}
|
|
}
|
|
- if err = redis.PutBytes("other", redisKey, &b, timeOut); err != nil {
|
|
|
|
|
|
+ //rks := MC.If(in.UserId != "", in.UserId, in.City).(string)
|
|
|
|
+ b, err := json.Marshal(r.Data)
|
|
|
|
+ if err != nil {
|
|
r.ErrCode = -1
|
|
r.ErrCode = -1
|
|
- r.ErrMsg = fmt.Sprintf("保存缓存 redis 异常,err:%s", err.Error())
|
|
|
|
|
|
+ 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)
|
|
model.MakeCollection(in.UserId, r.Data.List)
|