zhangxinlei1996 3 سال پیش
والد
کامیت
8912afaad3
2فایلهای تغییر یافته به همراه6 افزوده شده و 18 حذف شده
  1. 1 16
      handler/push.go
  2. 5 2
      util/push.go

+ 1 - 16
handler/push.go

@@ -14,20 +14,5 @@ func (p *Push) Jywx_activity_message(msg *model.Message) {
 	if len(msg.E_body) == 0 {
 		return
 	}
-	util.StartPush(msg.E_body)
-	/*
-			phone := qu.ObjToString(mess["phone"])
-		product_type := qu.ObjToString(mess["product_type"])
-		order_code := qu.ObjToString(mess["order_code"])
-		buy_time := qu.ObjToString(mess["buy_time"])
-		end_time := qu.ObjToString(mess["end_time"])
-	*/
-	// util.StartPush("", map[string]interface{}{
-	// 	"phone":        "18624906090",
-	// 	"product_type": "超级订阅一个月",
-	// 	"order_code":   "1234567890",
-	// 	"buy_time":     "2021-10-19 22:22:22",
-	// 	"end_time":     "2021-11-19 23:59:59",
-	// })
-	// return
+	util.StartPush(msg.E_body, msg.E_userId)
 }

+ 5 - 2
util/push.go

@@ -12,10 +12,10 @@ import (
 
 var PushPool = make(chan bool, config.PushConfig.PushPoolSize)
 
-func StartPush(mess map[string]interface{}) {
+func StartPush(mess map[string]interface{}, userid string) {
 	//推送微信
 	if isPushOk := SendWeixin(mess); !isPushOk {
-		log.Println("推送失败:", mess)
+		log.Println("推送失败:", userid, mess)
 	}
 
 }
@@ -29,6 +29,9 @@ func SendWeixin(mess map[string]interface{}) bool {
 	if config.PushConfig.TestId != "" {
 		s_m_openid = config.PushConfig.TestId
 	}
+	if s_m_openid == "" {
+		return false
+	}
 	PushPool <- true
 	defer func() {
 		<-PushPool