From 94acfe69e5d28fd607de6da1293a58e17133d4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=87=E9=98=B3=20=E9=82=B9?= Date: Mon, 11 Dec 2023 09:59:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E6=9D=BFid=E6=94=B9=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 24Hour/WechatMessagerClient.cs | 10 ++++++++-- 24Hour/appsettings.json | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/24Hour/WechatMessagerClient.cs b/24Hour/WechatMessagerClient.cs index 0294221..bc380f3 100644 --- a/24Hour/WechatMessagerClient.cs +++ b/24Hour/WechatMessagerClient.cs @@ -31,6 +31,8 @@ namespace _24Hour /// 小程序secretID /// private string secid = "e752e4fba67526eca21313a18c96a58f"; + private string TemplateIdSuccess { get; set; } = ""; + private string TemplateIdFail { get; set; } = ""; private readonly ILogger logger; public WechatMessagerClient(HttpClient _httpCliet, IConfiguration configuration, ILogger _logger) { @@ -44,6 +46,8 @@ namespace _24Hour appid = $"{configuration.GetSection("Wechat:appid").Value}"; secret = $"{configuration.GetSection("Wechat:secret").Value}"; secid = $"{configuration.GetSection("Wechat:secid").Value}"; + TemplateIdSuccess = $"{configuration.GetSection("Wechat:templateIdSuccess").Value}"; + TemplateIdFail = $"{configuration.GetSection("Wechat:templateIdFail").Value}"; } public async Task GetOpenId(string code) { @@ -112,7 +116,8 @@ namespace _24Hour msg = new { touser = useropenId, - template_id = "XgrMTq1gwDfMJI6vN0jsSEv3xGy7v3amh0JMWj4SnAY", + //兼容北关区模板id,那边的配置文件没有模板id的字段 + template_id = string.IsNullOrEmpty(TemplateIdSuccess) ? "XgrMTq1gwDfMJI6vN0jsSEv3xGy7v3amh0JMWj4SnAY" : TemplateIdSuccess, page = "pages/selfService/reception/reception", miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", lang = "zh_CN", @@ -185,7 +190,8 @@ namespace _24Hour msg = new { touser = useropenId, - template_id = "bfA-t5EN4pkQzAOS17SRPRKvmMteaJt0kw3YKIcovIQ", + //兼容北关区模板id,那边的配置文件没有模板id的字段 + template_id = string.IsNullOrEmpty(TemplateIdFail) ? "bfA-t5EN4pkQzAOS17SRPRKvmMteaJt0kw3YKIcovIQ" : TemplateIdFail, page = "pages/selfService/reception/reception", miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", lang = "zh_CN", diff --git a/24Hour/appsettings.json b/24Hour/appsettings.json index 4f7e7c7..2716add 100644 --- a/24Hour/appsettings.json +++ b/24Hour/appsettings.json @@ -49,7 +49,9 @@ "appid": "wx48108a0c98a3dab0", "secret": "e752e4fba67526eca21313a18c96a58f", "secid": "e752e4fba67526eca21313a18c96a58f", - "miniprogram_state": "trial" + "miniprogram_state": "trial", + "templateIdSuccess": "XgrMTq1gwDfMJI6vN0jsSEv3xGy7v3amh0JMWj4SnAY", + "templateIdFail": "bfA-t5EN4pkQzAOS17SRPRKvmMteaJt0kw3YKIcovIQ" }, "CaseTwenty": { "SysAddress": "http://127.0.0.1:5194",