Jelajahi Sumber

Merge branch 'feature/v1.2.7_wky' of moapp/MessageCenter into feature/v1.2.7

wangkaiyue 1 tahun lalu
induk
melakukan
9cdc6476a6
2 mengubah file dengan 8 tambahan dan 4 penghapusan
  1. 7 3
      rpc/internal/common/sendWxTmplMsg.go
  2. 1 1
      rpc/internal/config/config.go

+ 7 - 3
rpc/internal/common/sendWxTmplMsg.go

@@ -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
 	}
 

+ 1 - 1
rpc/internal/config/config.go

@@ -53,7 +53,7 @@ type WxTmplMsg struct {
 	CloseNotice string `json:"closeNotice"`
 	Limit       struct {
 		Total       int64 `json:"total"`
-		OneDayLimit int   `json:"oneDayLimit"`
+		OneDayLimit int64 `json:"oneDayLimit"`
 		DuringMine  int   `json:"duringMine"`
 		Alert       struct {
 			Nums   []int64  `json:"nums"`