|
@@ -75,7 +75,7 @@ func GetWxTmplConfig(msgType int64) (*WxTmplConfig, error) {
|
|
|
|
|
|
func (stm *WxTmplPush) SendMsg(link, title, detail, date, row4 string) error {
|
|
|
if stm.Config.TmplId == "" || (stm.MgoId != "" && stm.OpenId != "" && stm.Position != "") || link == "" {
|
|
|
- return fmt.Errorf("缺少参数")
|
|
|
+ return fmt.Errorf("缺少参数 stm.Config.TmplId:%v stm.MgoId:%v stm.OpenId:%v stm.Position:%v link:%v ", stm.Config.TmplId, stm.MgoId, stm.OpenId, stm.Position, link)
|
|
|
}
|
|
|
// 校验推送是否开启
|
|
|
if err := stm.getUserOpenIdAndWxPushState(); err != nil {
|
|
@@ -157,13 +157,17 @@ func (stm *WxTmplPush) IncrCount() (error, func()) {
|
|
|
_ = redis.SetExpire(CacheDb, allCache, 60*60*24)
|
|
|
}
|
|
|
if total > config.ConfigJson.WxTmplConfig.Limit.Total {
|
|
|
+ redis.Decrby(CacheDb, allCache, 1)
|
|
|
return fmt.Errorf("已达发送总量上限"), nil
|
|
|
}
|
|
|
|
|
|
- if uTotal := redis.Incr(CacheDb, uCache); uTotal == 1 {
|
|
|
+ uTotal := redis.Incr(CacheDb, uCache)
|
|
|
+ if uTotal == 1 {
|
|
|
_ = redis.SetExpire(CacheDb, uCache, 60*60*24)
|
|
|
} //当日用户发送数量
|
|
|
- if uTotal := redis.GetInt(CacheDb, uCache); uTotal > config.ConfigJson.WxTmplConfig.Limit.OneDayLimit {
|
|
|
+ if uTotal > config.ConfigJson.WxTmplConfig.Limit.OneDayLimit {
|
|
|
+ redis.Decrby(CacheDb, allCache, 1)
|
|
|
+ redis.Decrby(CacheDb, uCache, 1)
|
|
|
return fmt.Errorf("已达单该用户发送总量上限"), nil
|
|
|
}
|
|
|
|