wangchuanjin hace 3 meses
padre
commit
5195f24807

+ 1 - 0
pushsubscribe/push/config.json

@@ -81,6 +81,7 @@
 		"dayNum":7,
 		"dayNum":7,
 		"count":1000000,
 		"count":1000000,
 		"retain":100000,
 		"retain":100000,
+		"usableNum":8000,
 		"wx":{
 		"wx":{
 			"id":"ahEQafQBYZX8cVYXko-XaU1QkJ8MHiR-O9UNv_BRMzk",
 			"id":"ahEQafQBYZX8cVYXko-XaU1QkJ8MHiR-O9UNv_BRMzk",
 			"url":"/jy_mobile/tabbar/recommendedlist",
 			"url":"/jy_mobile/tabbar/recommendedlist",

+ 1 - 0
pushsubscribe/push/config/config.go

@@ -62,6 +62,7 @@ type config struct {
 		DayNum              int64 `json:"dayNum"`
 		DayNum              int64 `json:"dayNum"`
 		Count               int64 `json:"count"`
 		Count               int64 `json:"count"`
 		Retain              int64 `json:"retain"`
 		Retain              int64 `json:"retain"`
+		UsableNum           int64 `json:"usableNum"`
 		Wx                  struct {
 		Wx                  struct {
 			Id        string
 			Id        string
 			Url       string
 			Url       string

+ 11 - 10
pushsubscribe/push/job/nomsgtipjob.go

@@ -24,6 +24,8 @@ import (
 	. "bp.jydev.jianyu360.cn/BaseService/pushpkg/recommend"
 	. "bp.jydev.jianyu360.cn/BaseService/pushpkg/recommend"
 )
 )
 
 
+const tenDaySecond = 864000
+
 type NoMsgTipJob struct {
 type NoMsgTipJob struct {
 	selectPool chan bool
 	selectPool chan bool
 	savePool   chan bool
 	savePool   chan bool
@@ -100,6 +102,9 @@ func (n *NoMsgTipJob) Execute(taskType int) {
 	})
 	})
 	var noMsgTipLastId atomic.Value
 	var noMsgTipLastId atomic.Value
 	wxTplSurplus := WxNoMsgTmplUsableNum(Mgo_Log, Config.NoMsgTip.WxNodeNum, Config.NoMsgTip.DayNum, Config.NoMsgTip.Count, Config.NoMsgTip.Retain)
 	wxTplSurplus := WxNoMsgTmplUsableNum(Mgo_Log, Config.NoMsgTip.WxNodeNum, Config.NoMsgTip.DayNum, Config.NoMsgTip.Count, Config.NoMsgTip.Retain)
+	if wxTplSurplus > Config.NoMsgTip.UsableNum && Config.NoMsgTip.UsableNum > 0 {
+		wxTplSurplus = Config.NoMsgTip.UsableNum
+	}
 	if Config.NoMsgTip.IsRecommendNewest {
 	if Config.NoMsgTip.IsRecommendNewest {
 		VarRecommend.SetNewest(1)
 		VarRecommend.SetNewest(1)
 	}
 	}
@@ -112,7 +117,7 @@ func (n *NoMsgTipJob) Execute(taskType int) {
 	logger.Info("无消息提醒任务结束。。。", taskType)
 	logger.Info("无消息提醒任务结束。。。", taskType)
 }
 }
 
 
-//提醒
+// 提醒
 func (n *NoMsgTipJob) isTip(taskType int, user *UserInfo) bool {
 func (n *NoMsgTipJob) isTip(taskType int, user *UserInfo) bool {
 	if exists, err := redis.Exists(Pushcache_2_c, HasPushKey(user.Id)); err != nil {
 	if exists, err := redis.Exists(Pushcache_2_c, HasPushKey(user.Id)); err != nil {
 		logger.Error("无消息提醒任务", taskType, "redis判断今天是否推送过出错", err, user.Id)
 		logger.Error("无消息提醒任务", taskType, "redis判断今天是否推送过出错", err, user.Id)
@@ -129,16 +134,15 @@ func (n *NoMsgTipJob) isTip(taskType int, user *UserInfo) bool {
 	}
 	}
 	now := time.Now()
 	now := time.Now()
 	if prevTipUnix, err := redis.GetNewInt(Pushcache_2_c, PrevNoMsgTipKey(user.Id)); err != nil {
 	if prevTipUnix, err := redis.GetNewInt(Pushcache_2_c, PrevNoMsgTipKey(user.Id)); err != nil {
-		logger.Error("无消息提醒任务", taskType, "redis判断三天前是否提醒过出错", err)
+		logger.Error("无消息提醒任务", taskType, "redis判断十天内是否提醒过出错", err)
 		return false
 		return false
-	} else if now.Unix() < int64(prevTipUnix+ThreeDay) {
-		logger.Info("无消息提醒任务", taskType, "天内已经提醒过,过滤掉", user.Id)
+	} else if now.Unix() < int64(prevTipUnix+tenDaySecond) {
+		logger.Info("无消息提醒任务", taskType, "天内已经提醒过,过滤掉", user.Id)
 		return false
 		return false
 	}
 	}
 	return true
 	return true
 }
 }
 
 
-//
 func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
 func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
 	pushPool := make(chan bool, Config.PushPoolSize)
 	pushPool := make(chan bool, Config.PushPoolSize)
 	pushWait := &sync.WaitGroup{}
 	pushWait := &sync.WaitGroup{}
@@ -161,7 +165,6 @@ func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus i
 	pushWait.Wait()
 	pushWait.Wait()
 }
 }
 
 
-//
 func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
 func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
 	firstTitle, area, jcly, mailContent, infoCount, firstAutoId, firstId, isNewestBid := n.SubRecommend(user)
 	firstTitle, area, jcly, mailContent, infoCount, firstAutoId, firstId, isNewestBid := n.SubRecommend(user)
 	if infoCount == 0 {
 	if infoCount == 0 {
@@ -173,7 +176,7 @@ func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, no
 	}
 	}
 	now := time.Now()
 	now := time.Now()
 	redis.Put(Pushcache_2_c, NoMsgTipKey(user.Id), 1, OneDaySecond)
 	redis.Put(Pushcache_2_c, NoMsgTipKey(user.Id), 1, OneDaySecond)
-	redis.Put(Pushcache_2_c, PrevNoMsgTipKey(user.Id), time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix(), ThreeDay+OneDaySecond)
+	redis.Put(Pushcache_2_c, PrevNoMsgTipKey(user.Id), time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix(), tenDaySecond+OneDaySecond)
 	start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
 	start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
 	startEndMd := fmt.Sprintf("%d月%d日", start.Month(), start.Day())
 	startEndMd := fmt.Sprintf("%d月%d日", start.Month(), start.Day())
 	logger.Info("无消息提醒任务", taskType, "开始推送", user.Id, "rateMode", user.PushSet.SubSet.RateMode, "jpushid", user.Jpushid, "opushid", user.Opushid, "appponetype", user.AppPhoneType, "email", user.PushSet.Email)
 	logger.Info("无消息提醒任务", taskType, "开始推送", user.Id, "rateMode", user.PushSet.SubSet.RateMode, "jpushid", user.Jpushid, "opushid", user.Opushid, "appponetype", user.AppPhoneType, "email", user.PushSet.Email)
@@ -231,7 +234,7 @@ func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, no
 	}
 	}
 }
 }
 
 
-//推送微信
+// 推送微信
 func (n *NoMsgTipJob) sendWeixin(user *UserInfo, firstTitle, area, jcly string, infoCount int, firstId string, isNewestBid bool) bool {
 func (n *NoMsgTipJob) sendWeixin(user *UserInfo, firstTitle, area, jcly string, infoCount int, firstId string, isNewestBid bool) bool {
 	tmplData := map[string]*qrpc.TmplItem{
 	tmplData := map[string]*qrpc.TmplItem{
 		"thing3": &qrpc.TmplItem{
 		"thing3": &qrpc.TmplItem{
@@ -263,7 +266,6 @@ func (n *NoMsgTipJob) sendWeixin(user *UserInfo, firstTitle, area, jcly string,
 	return ok
 	return ok
 }
 }
 
 
-//
 func (n *NoMsgTipJob) SubRecommend(user *UserInfo) (string, string, string, string, int, int64, string, bool) {
 func (n *NoMsgTipJob) SubRecommend(user *UserInfo) (string, string, string, string, int, int64, string, bool) {
 	n.selectPool <- true
 	n.selectPool <- true
 	defer func() {
 	defer func() {
@@ -272,7 +274,6 @@ func (n *NoMsgTipJob) SubRecommend(user *UserInfo) (string, string, string, stri
 	return VarRecommend.SubRecommend(Mysql_Push, Config.JianyuDomain, user.Id, Config.NoMsgTip.Mail.Content, user.PushSet.SubSet.MailPush, 10)
 	return VarRecommend.SubRecommend(Mysql_Push, Config.JianyuDomain, user.Id, Config.NoMsgTip.Mail.Content, user.PushSet.SubSet.MailPush, 10)
 }
 }
 
 
-//
 func (n *NoMsgTipJob) saveLog(user *UserInfo, autoId int64, isNewestBid bool) {
 func (n *NoMsgTipJob) saveLog(user *UserInfo, autoId int64, isNewestBid bool) {
 	n.savePool <- true
 	n.savePool <- true
 	defer func() {
 	defer func() {