Просмотр исходного кода

Merge branch 'release_dev_wcj' into release

lianbingjie 6 лет назад
Родитель
Сommit
d4002a680d

+ 3 - 1
src/config.json

@@ -290,5 +290,7 @@
     },
     "getpicurl": "https://res.jianyu360.com/",
     "sealSendTime": 14400,
-    "appPushServiceRpc": "127.0.0.1:5566"
+    "appPushServiceRpc": "127.0.0.1:5566",
+	"pushTimeout": 300,
+	"ninePushTimeout": 172800
 }

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

@@ -343,8 +343,8 @@ func (l *PcHelper) PushView() error {
 	res := map[string]interface{}{}
 	res["success"] = false
 	if userid != "" && lasttime > 0 {
-		_, openId := public.GetOldOpenid(userid)
-		thisindex, list := public.GetHistorypush(0, userid, openId)
+		user, openId := public.GetOldOpenid(userid)
+		thisindex, list := public.GetHistorypush(0, user, userid, openId)
 		log.Println(logPrefix, "PushView-getHistorypush-size", len(*list))
 		if list != nil && len(*list) > 0 {
 			res["success"] = true

+ 5 - 5
src/jfw/front/swordfish.go

@@ -2495,8 +2495,8 @@ func (f *Front) HasPushHistory() {
 	} else {
 		haskey = true
 	}
-	thistime, list := public.GetHistorypush(0, userid, openId)
-	if haskey && (list == nil || len(*list) == 0) {
+	thistime, list := public.GetHistorypush(0, user, userid, openId)
+	/*if haskey && (list == nil || len(*list) == 0) {
 		list = &[]map[string]interface{}{}
 		flag, data := makeHistoryDatas(util.BsonIdToSId((*user)["_id"]), openId, o_jy)
 		if flag && data != nil {
@@ -2507,7 +2507,7 @@ func (f *Front) HasPushHistory() {
 				*list = append(*list, tmp)
 			}
 		}
-	}
+	}*/
 	//
 	var success bool
 	if list != nil && len(*list) > 0 {
@@ -2565,8 +2565,8 @@ func (f *Front) HistorypushPaging() error {
 	res := map[string]interface{}{}
 	res["success"] = false
 	if userid != "" && lasttime > 0 {
-		_, openId := public.GetOldOpenid(userid)
-		thisindex, list := public.GetHistorypush(lasttime, userid, openId)
+		user, openId := public.GetOldOpenid(userid)
+		thisindex, list := public.GetHistorypush(lasttime, user, userid, openId)
 		if list != nil && len(*list) > 0 {
 			res["success"] = true
 			res["data"] = &list

+ 5 - 5
src/jfw/modules/app/src/app/front/swordfish.go

@@ -736,8 +736,8 @@ func (f *Front) HasPushHistory() {
 	} else {
 		haskey = true
 	}
-	thistime, list := public.GetHistorypush(0, userid, openId)
-	if haskey && (list == nil || len(*list) == 0) {
+	thistime, list := public.GetHistorypush(0, user, userid, openId)
+	/*if haskey && (list == nil || len(*list) == 0) {
 		list = &[]map[string]interface{}{}
 		flag, data := makeHistoryDatas(userid, openId, o_jy)
 		if flag && data != nil {
@@ -748,7 +748,7 @@ func (f *Front) HasPushHistory() {
 				*list = append(*list, tmp)
 			}
 		}
-	}
+	}*/
 	//
 	var success bool
 	if list != nil && len(*list) > 0 {
@@ -779,8 +779,8 @@ func (f *Front) HistorypushPaging() error {
 		if lasttime == -1 {
 			isFirstPage = true
 		}
-		_, openId := public.GetOldOpenid(userId)
-		thistime, list := public.GetHistorypush(lasttime, userId, openId)
+		user, openId := public.GetOldOpenid(userId)
+		thistime, list := public.GetHistorypush(lasttime, user, userId, openId)
 		if list != nil && len(*list) > 0 {
 			if isFirstPage {
 				go updateUserApppushunread(userId)

+ 3 - 1
src/jfw/modules/app/src/config.json

@@ -97,5 +97,7 @@
     "appPushServiceRpc": "127.0.0.1:5566",
     "appPower": {
         "grayflag": true
-    }
+    },
+	"pushTimeout": 300,
+	"ninePushTimeout": 172800
 }

+ 19 - 9
src/jfw/public/public.go

@@ -191,19 +191,25 @@ func (s sortList) Swap(i, j int) {
 	s[i], s[j] = s[j], s[i]
 }
 
-func GetHistorypush(lastindex int, userId, openId string) (int, *[]map[string]interface{}) {
+func GetHistorypush(lastindex int, user *map[string]interface{}, userId, openId string) (int, *[]map[string]interface{}) {
+	rateMode := 1
+	var o_jy map[string]interface{}
+	if user != nil {
+		o_jy, _ = (*user)["o_jy"].(map[string]interface{})
+		rateMode = util.IntAllDef(o_jy["i_ratemode"], 1)
+	}
 	flag := true
 	if lastindex == -1 {
 		flag = false
 		lastindex = 0
 	}
-	pinfo := GetHistorypushDatas(flag, userId, openId)
+	pinfo := GetHistorypushDatas(flag, rateMode, userId, openId)
 	list := []map[string]interface{}{}
 	if len(pinfo) > 0 {
 		count := 0
 		for ; lastindex < len(pinfo); lastindex++ {
-			info := pinfo[lastindex]
-			tmp, _ := info.(map[string]interface{})
+			info, _ := pinfo[lastindex].(map[string]interface{})
+			tmp := ChangeMapKeyForCass(info)
 			if ats, ok := tmp["o_pushinfo"].(map[string]interface{}); ok {
 				thistime := util.Int64All(tmp["l_date"])
 				//获取已浏览记录
@@ -225,13 +231,13 @@ func GetHistorypush(lastindex int, userId, openId string) (int, *[]map[string]in
 	}
 	return lastindex + 1, &list
 }
-func GetHistorypushDatas(flag bool, userId, openId string) []interface{} {
+func GetHistorypushDatas(flag bool, rateMode int, userId, openId string) []interface{} {
 	list := []interface{}{}
 	if flag {
-		cacheDatas := redis.Get("pushcache", "jypush_"+userId)
+		cacheDatas := redis.Get("pushcache", "pushsubscribe_"+userId)
 		if cacheDatas != nil {
 			log.Println("GetHistorypushDatas from redis", userId)
-			list = cacheDatas.([]interface{})
+			list, _ = cacheDatas.([]interface{})
 			return list
 		}
 	}
@@ -251,9 +257,13 @@ func GetHistorypushDatas(flag bool, userId, openId string) []interface{} {
 		sort.Sort(sl)
 	}
 	for _, v := range sl {
-		list = append(list, ChangeMapKeyForCass(v))
+		list = append(list, v)
+	}
+	timeout := util.IntAllDef(config.Sysconfig["pushTimeout"], 300)
+	if rateMode == 2 {
+		timeout = util.IntAllDef(config.Sysconfig["ninePushTimeout"], 48*60*60)
 	}
-	redis.Put("pushcache", "jypush_"+userId, list, util.IntAllDef(config.Sysconfig["pushTimeout"], 300))
+	redis.Put("pushcache", "pushsubscribe_"+userId, list, timeout)
 	return list
 }