|
@@ -18,8 +18,12 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
- putil.LimitMaxOneMinutePush(&DoPush.minutePushPool, SysConfig.MinutePushSize)
|
|
|
|
- putil.LimitMaxOneMinutePush(&DoPush.fastigiumMinutePushPool, SysConfig.FastigiumMinutePushSize)
|
|
|
|
|
|
+ if SysConfig.MinutePushSize > 0 {
|
|
|
|
+ putil.LimitMaxOneMinutePush(&DoPush.minutePushPool, SysConfig.MinutePushSize)
|
|
|
|
+ }
|
|
|
|
+ if SysConfig.FastigiumMinutePushSize > 0 {
|
|
|
|
+ putil.LimitMaxOneMinutePush(&DoPush.fastigiumMinutePushPool, SysConfig.FastigiumMinutePushSize)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
type doPush struct {
|
|
type doPush struct {
|
|
@@ -28,22 +32,17 @@ type doPush struct {
|
|
}
|
|
}
|
|
|
|
|
|
func (d *doPush) Execute(taskType int, wxPush, appPush, mailPush int, u *UserInfo, list, tempList SortList) (isSaveSuccess bool, wxStatus, appStatus, mailStatus int) {
|
|
func (d *doPush) Execute(taskType int, wxPush, appPush, mailPush int, u *UserInfo, list, tempList SortList) (isSaveSuccess bool, wxStatus, appStatus, mailStatus int) {
|
|
- isSaveSuccess = true
|
|
|
|
- //开通订阅推送或邮箱推送的用户,由实时推送修改成九点推送,app推送用list字段,微信和邮箱推送用templist字段
|
|
|
|
if wxPush == 1 || appPush == 1 || mailPush == 1 || u.PchelperPush == 1 {
|
|
if wxPush == 1 || appPush == 1 || mailPush == 1 || u.PchelperPush == 1 {
|
|
if list != nil && tempList != nil {
|
|
if list != nil && tempList != nil {
|
|
isSaveSuccess, _, appStatus, _ = d.Do(taskType, true, 0, appPush, 0, u, &list)
|
|
isSaveSuccess, _, appStatus, _ = d.Do(taskType, true, 0, appPush, 0, u, &list)
|
|
- if !isSaveSuccess {
|
|
|
|
- return
|
|
|
|
|
|
+ if isSaveSuccess {
|
|
|
|
+ _, wxStatus, _, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
|
|
}
|
|
}
|
|
- _, wxStatus, _, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
|
|
|
|
} else if list != nil {
|
|
} else if list != nil {
|
|
isSaveSuccess, wxStatus, appStatus, mailStatus = d.Do(taskType, true, wxPush, appPush, mailPush, u, &list)
|
|
isSaveSuccess, wxStatus, appStatus, mailStatus = d.Do(taskType, true, wxPush, appPush, mailPush, u, &list)
|
|
- if !isSaveSuccess {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
} else if tempList != nil {
|
|
} else if tempList != nil {
|
|
_, wxStatus, appStatus, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
|
|
_, wxStatus, appStatus, mailStatus = d.Do(taskType, false, wxPush, 0, mailPush, u, &tempList)
|
|
|
|
+ isSaveSuccess = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return isSaveSuccess, wxStatus, appStatus, mailStatus
|
|
return isSaveSuccess, wxStatus, appStatus, mailStatus
|
|
@@ -161,16 +160,26 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
|
|
logger.Info("推送任务", taskType, "没有要推送的数据!", k.Id)
|
|
logger.Info("推送任务", taskType, "没有要推送的数据!", k.Id)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ //限制一分钟最大的推送数量
|
|
|
|
+ if d.fastigiumMinutePushPool != nil {
|
|
|
|
+ if hour := time.Now().Hour(); hour >= FastigiumStart && hour <= FastigiumEnd {
|
|
|
|
+ <-d.fastigiumMinutePushPool //高峰期
|
|
|
|
+ }
|
|
|
|
+ } else if d.minutePushPool != nil {
|
|
|
|
+ <-d.minutePushPool //正常期
|
|
|
|
+ }
|
|
if taskType != 0 && isSave {
|
|
if taskType != 0 && isSave {
|
|
//推送记录id
|
|
//推送记录id
|
|
pushId := putil.SaveSendInfo(k, pushIds, infos)
|
|
pushId := putil.SaveSendInfo(k, pushIds, infos)
|
|
if pushId == "" {
|
|
if pushId == "" {
|
|
logger.Info("推送任务", taskType, "保存到cassandra出错", k.Id)
|
|
logger.Info("推送任务", taskType, "保存到cassandra出错", k.Id)
|
|
return
|
|
return
|
|
- } else {
|
|
|
|
- logger.Info("推送任务", taskType, "成功保存到cassandra", pushId, k.Id)
|
|
|
|
}
|
|
}
|
|
|
|
+ logger.Info("推送任务", taskType, "成功保存到cassandra", pushId, k.Id)
|
|
isSaveSuccess = true
|
|
isSaveSuccess = true
|
|
|
|
+ }
|
|
|
|
+ logger.Info("推送任务", taskType, "开始进行终端推送", k.Id)
|
|
|
|
+ if isSaveSuccess {
|
|
//pc端助手推送
|
|
//pc端助手推送
|
|
if k.S_m_openid != "" {
|
|
if k.S_m_openid != "" {
|
|
logger.Info("推送任务", taskType, "开始助手推送", k.Id, "s_m_openid", k.S_m_openid)
|
|
logger.Info("推送任务", taskType, "开始助手推送", k.Id, "s_m_openid", k.S_m_openid)
|
|
@@ -183,20 +192,6 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
|
|
logger.Info("推送任务", taskType, "助手推送结束", isPushOk, k.Id, "phone", k.Phone)
|
|
logger.Info("推送任务", taskType, "助手推送结束", isPushOk, k.Id, "phone", k.Phone)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- logger.Info("推送任务", taskType, "开始进行终端推送", k.Id)
|
|
|
|
- //限制一分钟最大的推送数量
|
|
|
|
- hour := time.Now().Hour()
|
|
|
|
- fastigiumStart, fastigiumEnd := 0, 0
|
|
|
|
- fastigiumTimes := strings.Split(SysConfig.FastigiumTime, "-")
|
|
|
|
- if len(fastigiumTimes) == 2 {
|
|
|
|
- fastigiumStart = util.IntAll(fastigiumTimes[0])
|
|
|
|
- fastigiumEnd = util.IntAll(fastigiumTimes[1])
|
|
|
|
- }
|
|
|
|
- if hour >= fastigiumStart && hour <= fastigiumEnd {
|
|
|
|
- <-d.fastigiumMinutePushPool //高峰期
|
|
|
|
- } else {
|
|
|
|
- <-d.minutePushPool //正常期
|
|
|
|
- }
|
|
|
|
if wxPush == 1 {
|
|
if wxPush == 1 {
|
|
logger.Info("推送任务", taskType, "开始微信推送", k.ApplyStatus, k.Id)
|
|
logger.Info("推送任务", taskType, "开始微信推送", k.ApplyStatus, k.Id)
|
|
isPushOk := true
|
|
isPushOk := true
|
|
@@ -226,11 +221,7 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
|
|
}
|
|
}
|
|
wxtitle := fmt.Sprintf(SysConfig.WxTitle, wxTitleKeys)
|
|
wxtitle := fmt.Sprintf(SysConfig.WxTitle, wxTitleKeys)
|
|
TitleLen := len([]rune(wxtitle))
|
|
TitleLen := len([]rune(wxtitle))
|
|
- GroupLen := len([]rune(k.ModifyDate))
|
|
|
|
- reLen := 200 - TitleLen - GroupLen - WxContentLen - len([]rune(Tip1))
|
|
|
|
- //if infoType == 2 {
|
|
|
|
- // reLen = reLen - 4
|
|
|
|
- //}
|
|
|
|
|
|
+ reLen := 200 - TitleLen - 10 - WxGroupLen - len([]rune(Tip1))
|
|
WXTitle := ""
|
|
WXTitle := ""
|
|
bshow := false
|
|
bshow := false
|
|
for n := 1; n < len(TitleArray)+1; n++ {
|
|
for n := 1; n < len(TitleArray)+1; n++ {
|