Browse Source

fix:修改推送获取数据逻辑

duxin 3 years ago
parent
commit
f82693f257
1 changed files with 20 additions and 20 deletions
  1. 20 20
      src/jfw/modules/common/src/qfw/util/jy/subscribepush.go

+ 20 - 20
src/jfw/modules/common/src/qfw/util/jy/subscribepush.go

@@ -505,28 +505,28 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mg.MongodbSim, bidding, bidding
 	infos := map[string]map[string]interface{}{}
 	//redis
 
-	//es_ids := ids
-	//for _, v := range ids {
-	//	info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
-	//	if info_i != nil {
-	//		info_m, _ := info_i.(map[string]interface{})
-	//		info_m["_id"] = v
-	//		infos[v] = info_m
-	//	} else {
-	//		es_ids = append(es_ids, v)
-	//	}
-	//}
-	//	log.Println(es_ids)
+	es_ids := ids
+	for _, v := range ids {
+		info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
+		if info_i != nil {
+			info_m, _ := info_i.(map[string]interface{})
+			info_m["_id"] = v
+			infos[v] = info_m
+		} else {
+			es_ids = append(es_ids, v)
+		}
+	}
+	log.Println(es_ids)
 	//elasticsearch
-	//if len(es_ids) > 0 {
-	list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(ids, `","`), len(ids)))
-	if list != nil {
-		for _, v := range *list {
-			_id := ObjToString(v["_id"])
-			infos[_id] = v
+	if len(es_ids) > 0 {
+		list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
+		if list != nil {
+			for _, v := range *list {
+				_id := ObjToString(v["_id"])
+				infos[_id] = v
+			}
 		}
 	}
-	//}
 	//mongodb bidding
 	mgo_ids := []primitive.ObjectID{}
 	for _, v := range ids {
@@ -576,7 +576,7 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mg.MongodbSim, bidding, bidding
 //保存最近7天的数据到历史记录
 func (s *subscribePush) MakeHistoryDatas(MQFW mg.MongodbSim, PushMysql *mysql.Mysql, userId string, PushView func(userid, allquery, field string, pageNum, pageSize int) (keys []interface{}, list *[]map[string]interface{})) (bool, []*SubPushList) {
 	log.Println("匹配最近7天数据", userId)
-	field := `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount"`
+	field := `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount","spidercode","site"`
 	allquery := `{"range":{"publishtime":{"gt":%s}}}`
 	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
 	//allquery = ``