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",