Browse Source

发送模版消息增加开关

xyxie 1 year ago
parent
commit
66fd7cbc52
4 changed files with 13 additions and 5 deletions
  1. 1 1
      go.mod
  2. 2 2
      go.sum
  3. 4 2
      services/report.go
  4. 6 0
      utils/config.go

+ 1 - 1
go.mod

@@ -11,7 +11,7 @@ require (
 	github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c
 	github.com/kgiannakakis/mp3duration v0.0.0-20191013070830-d834f8d5ed53
 	github.com/olivere/elastic/v7 v7.0.32
-	github.com/rdlucklib/rdluck_tools v1.0.2
+	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/shopspring/decimal v1.3.1
 	github.com/yidane/formula v0.0.0-20210902154546-0782e1736717
 	golang.org/x/net v0.7.0

+ 2 - 2
go.sum

@@ -334,8 +334,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
 github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
 github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
-github.com/rdlucklib/rdluck_tools v1.0.2 h1:Xf1khfttpAh4D1jtMVE5OxLXhFUaDnvG74vZH7FSZQY=
-github.com/rdlucklib/rdluck_tools v1.0.2/go.mod h1:9Onw9o4w19C8KE5lxb8GyxgRBbZweRVkQSc79v38EaA=
+github.com/rdlucklib/rdluck_tools v1.0.3 h1:iOtK2QPlPQ6CL6c1htCk5VnFCHzyG6DCfJtunrMswK0=
+github.com/rdlucklib/rdluck_tools v1.0.3/go.mod h1:9Onw9o4w19C8KE5lxb8GyxgRBbZweRVkQSc79v38EaA=
 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

+ 4 - 2
services/report.go

@@ -188,8 +188,10 @@ func PublishReport(cont context.Context) (err error) {
 			_ = UpdateReportEs(item.Id, 2)
 
 			// 判断是否未发送模版消息,并且配置了立即推送模版消息的报告需要推送
-			if item.MsgIsSend == 0 && item.PreMsgSend == 1 {
-				_ = ReportSendTemplateMsg(item.Id)
+			if utils.SendWxTemplateEnable == "on" {
+				if item.MsgIsSend == 0 && item.PreMsgSend == 1 {
+					_ = ReportSendTemplateMsg(item.Id)
+				}
 			}
 		}()
 

+ 6 - 0
utils/config.go

@@ -41,6 +41,7 @@ var (
 	RemindTemplateId            string
 	AppointmentRemindTemplateId string //活动预约通知模板id
 	YbCommonTemplateId          string //研报小程序消息模板ID
+	SendWxTemplateEnable        string //是否开启模版消息
 
 	WxYbAppId string //微信研报小程序
 
@@ -191,4 +192,9 @@ func init() {
 		AccessKeyId = config["access_key_id"]
 		AccessKeySecret = config["access_key_secret"]
 	}
+
+	// 微信模版消息
+	{
+		SendWxTemplateEnable = config["send_wx_template_enable"]
+	}
 }