|
@@ -24,6 +24,8 @@ import (
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/pushpkg/recommend"
|
|
|
)
|
|
|
|
|
|
+const tenDaySecond = 864000
|
|
|
+
|
|
|
type NoMsgTipJob struct {
|
|
|
selectPool chan bool
|
|
|
savePool chan bool
|
|
@@ -100,6 +102,9 @@ func (n *NoMsgTipJob) Execute(taskType int) {
|
|
|
})
|
|
|
var noMsgTipLastId atomic.Value
|
|
|
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 {
|
|
|
VarRecommend.SetNewest(1)
|
|
|
}
|
|
@@ -112,7 +117,7 @@ func (n *NoMsgTipJob) Execute(taskType int) {
|
|
|
logger.Info("无消息提醒任务结束。。。", taskType)
|
|
|
}
|
|
|
|
|
|
-//提醒
|
|
|
+// 提醒
|
|
|
func (n *NoMsgTipJob) isTip(taskType int, user *UserInfo) bool {
|
|
|
if exists, err := redis.Exists(Pushcache_2_c, HasPushKey(user.Id)); err != nil {
|
|
|
logger.Error("无消息提醒任务", taskType, "redis判断今天是否推送过出错", err, user.Id)
|
|
@@ -129,16 +134,15 @@ func (n *NoMsgTipJob) isTip(taskType int, user *UserInfo) bool {
|
|
|
}
|
|
|
now := time.Now()
|
|
|
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
|
|
|
- } 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 true
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
|
|
|
pushPool := make(chan bool, Config.PushPoolSize)
|
|
|
pushWait := &sync.WaitGroup{}
|
|
@@ -161,7 +165,6 @@ func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus i
|
|
|
pushWait.Wait()
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, noMsgTipLastId atomic.Value) {
|
|
|
firstTitle, area, jcly, mailContent, infoCount, firstAutoId, firstId, isNewestBid := n.SubRecommend(user)
|
|
|
if infoCount == 0 {
|
|
@@ -173,7 +176,7 @@ func (n *NoMsgTipJob) toTip(taskType int, user *UserInfo, wxTplSurplus int64, no
|
|
|
}
|
|
|
now := time.Now()
|
|
|
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)
|
|
|
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)
|
|
@@ -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 {
|
|
|
tmplData := map[string]*qrpc.TmplItem{
|
|
|
"thing3": &qrpc.TmplItem{
|
|
@@ -263,7 +266,6 @@ func (n *NoMsgTipJob) sendWeixin(user *UserInfo, firstTitle, area, jcly string,
|
|
|
return ok
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func (n *NoMsgTipJob) SubRecommend(user *UserInfo) (string, string, string, string, int, int64, string, bool) {
|
|
|
n.selectPool <- true
|
|
|
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)
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func (n *NoMsgTipJob) saveLog(user *UserInfo, autoId int64, isNewestBid bool) {
|
|
|
n.savePool <- true
|
|
|
defer func() {
|