|
|
|
@ -21,31 +21,34 @@ namespace _24Hour
|
|
|
|
|
private readonly HttpClient httpCliet; |
|
|
|
|
// 实例化MemoryCache对象 |
|
|
|
|
MemoryCache cache = MemoryCache.Default; |
|
|
|
|
private readonly IConfiguration _configuration; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 小程序AppID |
|
|
|
|
/// </summary> |
|
|
|
|
private string appid = "wx48108a0c98a3dab0"; |
|
|
|
|
private string appid; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 小程序AppID |
|
|
|
|
/// </summary> |
|
|
|
|
private string secret = "wx48108a0c98a3dab0"; |
|
|
|
|
private string secret; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 微信公众号AppID |
|
|
|
|
/// </summary> |
|
|
|
|
private string Gzhappid = "wx48108a0c98a3dab0"; |
|
|
|
|
private string Gzhappid; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 微信公众号密码 |
|
|
|
|
/// </summary> |
|
|
|
|
private string Gzhsecret = "wx48108a0c98a3dab0"; |
|
|
|
|
private string Gzhsecret; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 微信公众号模板Id |
|
|
|
|
/// </summary> |
|
|
|
|
private string GzhtemplateId = "wx48108a0c98a3dab0"; |
|
|
|
|
private string GzhtemplateId; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 小程序secretID |
|
|
|
|
/// </summary> |
|
|
|
|
private string secid = "e752e4fba67526eca21313a18c96a58f"; |
|
|
|
|
private string secid; |
|
|
|
|
|
|
|
|
|
private string miniprogram_state; |
|
|
|
|
private string GzhTemplateId1; |
|
|
|
|
private string GzhTemplateId2; |
|
|
|
|
private string TemplateIdSuccess { get; set; } = ""; |
|
|
|
|
private string TemplateIdFail { get; set; } = ""; |
|
|
|
|
private readonly ILogger<WechatMessagerClient> logger; |
|
|
|
@ -56,7 +59,7 @@ namespace _24Hour
|
|
|
|
|
httpCliet.DefaultRequestHeaders.Add("Accept", "application/json"); |
|
|
|
|
httpCliet.DefaultRequestHeaders.Add("User-Agent", "HttpClientFactory-Sample"); |
|
|
|
|
httpCliet.DefaultRequestHeaders.ConnectionClose = true; |
|
|
|
|
_configuration = configuration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appid =AES.Decrypt( $"{configuration.GetSection("Wechat:appid").Value}"); |
|
|
|
|
secret = AES.Decrypt($"{configuration.GetSection("Wechat:secret").Value}"); |
|
|
|
@ -66,6 +69,9 @@ namespace _24Hour
|
|
|
|
|
GzhtemplateId = AES.Decrypt($"{configuration.GetSection("WechatGzh:templateId").Value}"); |
|
|
|
|
TemplateIdSuccess = AES.Decrypt($"{configuration.GetSection("Wechat:templateIdSuccess").Value}"); |
|
|
|
|
TemplateIdFail = AES.Decrypt($"{configuration.GetSection("Wechat:templateIdFail").Value}"); |
|
|
|
|
GzhTemplateId1 = AES.Decrypt($"{configuration.GetSection("WechatGzh:templateId1").Value}"); |
|
|
|
|
GzhTemplateId2 = AES.Decrypt($"{configuration.GetSection("WechatGzh:templateId2").Value}"); |
|
|
|
|
miniprogram_state = $"{configuration.GetSection("Wechat:miniprogram_state").Value}"; |
|
|
|
|
} |
|
|
|
|
//小程序获取openId |
|
|
|
|
public async Task<Result> GetOpenId(string code) |
|
|
|
@ -166,9 +172,9 @@ namespace _24Hour
|
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
//兼容北关区模板id,那边的配置文件没有模板id的字段 |
|
|
|
|
template_id = string.IsNullOrEmpty(TemplateIdSuccess) ? "XgrMTq1gwDfMJI6vN0jsSEv3xGy7v3amh0JMWj4SnAY" : TemplateIdSuccess, |
|
|
|
|
template_id = TemplateIdSuccess, |
|
|
|
|
page = "pages/selfService/reception/reception", |
|
|
|
|
miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
miniprogram_state = miniprogram_state, |
|
|
|
|
lang = "zh_CN", |
|
|
|
|
data = new |
|
|
|
|
{ |
|
|
|
@ -239,10 +245,9 @@ namespace _24Hour
|
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
//兼容北关区模板id,那边的配置文件没有模板id的字段 |
|
|
|
|
template_id = string.IsNullOrEmpty(TemplateIdFail) ? "bfA-t5EN4pkQzAOS17SRPRKvmMteaJt0kw3YKIcovIQ" : TemplateIdFail, |
|
|
|
|
template_id = TemplateIdFail, |
|
|
|
|
page = "pages/selfService/reception/reception", |
|
|
|
|
miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
miniprogram_state = miniprogram_state, |
|
|
|
|
lang = "zh_CN", |
|
|
|
|
data = new |
|
|
|
|
{ |
|
|
|
@ -389,7 +394,7 @@ namespace _24Hour
|
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
template_id = $"{_configuration.GetSection("WechatGzh:templateId1").Value}", |
|
|
|
|
template_id = GzhTemplateId1, |
|
|
|
|
//miniprogram =new{ |
|
|
|
|
// appid= appid, |
|
|
|
|
// pagepath= "pages/selfService/reception/reception" |
|
|
|
@ -467,7 +472,7 @@ namespace _24Hour
|
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
template_id = $"{_configuration.GetSection("WechatGzh:templateId2").Value}", |
|
|
|
|
template_id = GzhTemplateId2, |
|
|
|
|
//miniprogram =new{ |
|
|
|
|
// appid= appid, |
|
|
|
|
// pagepath= "pages/selfService/reception/reception" |
|
|
|
|