瀏覽代碼

已读未读

wangshan 6 年之前
父節點
當前提交
edb2c66442
共有 3 個文件被更改,包括 20 次插入17 次删除
  1. 1 1
      src/jfw/front/pchelper.go
  2. 7 6
      src/jfw/front/swordfish.go
  3. 12 10
      src/jfw/modules/app/src/app/front/swordfish.go

+ 1 - 1
src/jfw/front/pchelper.go

@@ -328,7 +328,7 @@ func (l *PcHelper) PushView() error {
 		if lasttime == 1 {
 			lasttime = time.Now().Local().Unix()
 		}
-		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0)
+		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0, nil)
 		log.Println(logPrefix, "PushView-getHistorypush-size", len(*list))
 		if list != nil && len(*list) > 0 {
 			res["success"] = true

+ 7 - 6
src/jfw/front/swordfish.go

@@ -2635,7 +2635,7 @@ func (f *Front) HasPushHistory() {
 	} else {
 		haskey = true
 	}
-	thistime, list := getHistorypush(nowUnix, 0, myopenid, nil, 0)
+	thistime, list := getHistorypush(nowUnix, 0, myopenid, nil, 0, nil)
 	if haskey && (list == nil || len(*list) == 0) {
 		list = &[]map[string]interface{}{}
 		flag, data := makeHistoryDatas(util.BsonIdToSId((*user)["_id"]), myopenid, o_jy)
@@ -2714,7 +2714,7 @@ func (f *Front) HistorypushPaging() error {
 		if lasttime == 1 {
 			lasttime = time.Now().Local().Unix()
 		}
-		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0)
+		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0, nil)
 		if list != nil && len(*list) > 0 {
 			res["success"] = true
 			res["data"] = &list
@@ -2724,7 +2724,7 @@ func (f *Front) HistorypushPaging() error {
 	f.ServeJson(&res)
 	return nil
 }
-func getHistorypush(lasttime, infotime int64, openid string, res []map[string]interface{}, count int) (thistime int64, list *[]map[string]interface{}) {
+func getHistorypush(lasttime, infotime int64, openid string, res []map[string]interface{}, count int, vsidList []string) (thistime int64, list *[]map[string]interface{}) {
 	if lasttime < time.Now().Unix()-60*24*60*60 { //最多查询最近60天数据
 		return lasttime, &res
 	}
@@ -2746,8 +2746,9 @@ func getHistorypush(lasttime, infotime int64, openid string, res []map[string]in
 		//			"isopen": true,
 		//		})
 		//获取已浏览记录
-		visited := cassandra.Search("select vsid from jy_pushvisit where openid=? and pdate<? limit 100", openid, date)
-		vsidList := []string{}
+		dateend := date - 24*60*60
+		visited := cassandra.Search("select vsid from jy_pushvisit where openid=? and pdate<? and pdate>? limit 50", openid, date, dateend)
+		//		vsidList := []string{}
 		for _, v := range visited {
 			vsidList = append(vsidList, (v["vsid"]).(string))
 			//			log.Println("vsidList", vsidList)
@@ -2808,7 +2809,7 @@ func getHistorypush(lasttime, infotime int64, openid string, res []map[string]in
 			infotime = 24 * 60 * 60
 		}
 	}
-	return getHistorypush(thistime, infotime, openid, res, count)
+	return getHistorypush(thistime, infotime, openid, res, count, vsidList)
 }
 
 //电脑端招标订阅

+ 12 - 10
src/jfw/modules/app/src/app/front/swordfish.go

@@ -770,7 +770,7 @@ func (f *Front) HasPushHistory() {
 	} else {
 		haskey = true
 	}
-	thistime, list := getHistorypush(nowUnix, 0, myopenid, nil, 0)
+	thistime, list := getHistorypush(nowUnix, 0, myopenid, nil, 0, nil)
 	if haskey && (list == nil || len(*list) == 0) {
 		list = &[]map[string]interface{}{}
 		flag, data := makeHistoryDatas(util.BsonIdToSId((*user)["_id"]), myopenid, o_jy)
@@ -815,7 +815,7 @@ func (f *Front) HistorypushPaging() error {
 			isFirstPage = true
 			lasttime = time.Now().Local().Unix()
 		}
-		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0)
+		thistime, list := getHistorypush(lasttime, 0, myopenid, nil, 0, nil)
 		if list != nil && len(*list) > 0 {
 			if isFirstPage {
 				go updateUserApppushunread(myopenid)
@@ -828,7 +828,7 @@ func (f *Front) HistorypushPaging() error {
 	f.ServeJson(&res)
 	return nil
 }
-func getHistorypush(lasttime, infotime int64, openid string, res []map[string]interface{}, count int) (thistime int64, list *[]map[string]interface{}) {
+func getHistorypush(lasttime, infotime int64, openid string, res []map[string]interface{}, count int, vsidList []string) (thistime int64, list *[]map[string]interface{}) {
 	if lasttime < time.Now().Unix()-60*24*60*60 { //最多查询最近60天数据
 		return lasttime, &res
 	}
@@ -844,13 +844,15 @@ func getHistorypush(lasttime, infotime int64, openid string, res []map[string]in
 	//	log.Println("date", date)
 	if date > 0 {
 		//获取已浏览记录
-		visited := ca.Search("select vsid from jy_pushvisit where openid=? and pdate<? limit 100", openid, date)
-		vsidList := []string{}
-		for _, v := range visited {
-			vsidList = append(vsidList, (v["vsid"]).(string))
-			//			log.Println("vsidList", vsidList)
+		dateend := date - 24*60*60
+		visited := ca.Search("select vsid from jy_pushvisit where openid=? and pdate<? and pdate>? limit 50", openid, date, dateend)
+		//		vsidList := []string{}
+		if len(visited) > 0 {
+			for _, v := range visited {
+				vsidList = append(vsidList, (v["vsid"]).(string))
+				//			log.Println("vsidList", vsidList)
+			}
 		}
-
 		dateshort := util.FormatDateByInt64(&lasttime, util.Date_Short_Layout)
 		pinfo := ca.Search("select * from jy_push where id=? and openid=? and date<?", dateshort, openid, lasttime+infotime)
 		if len(pinfo) > 0 {
@@ -906,7 +908,7 @@ func getHistorypush(lasttime, infotime int64, openid string, res []map[string]in
 			infotime = 24 * 60 * 60
 		}
 	}
-	return getHistorypush(thistime, infotime, openid, res, count)
+	return getHistorypush(thistime, infotime, openid, res, count, vsidList)
 }
 
 func MFollow(userId, pname, pcode, title, openid string) (bool, string) {