|
|
|
@ -4,6 +4,7 @@ using Elight.Utility;
|
|
|
|
|
using Elight.Utility.Code; |
|
|
|
|
using Elight.Utility.Extensions; |
|
|
|
|
using java.lang.annotation; |
|
|
|
|
using java.util; |
|
|
|
|
using Microsoft.IdentityModel.Logging; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
@ -63,6 +64,7 @@ namespace _24Hour
|
|
|
|
|
GzhtemplateId = $"{configuration.GetSection("WechatGzh:templateId").Value}"; |
|
|
|
|
TemplateIdSuccess = $"{configuration.GetSection("Wechat:templateIdSuccess").Value}"; |
|
|
|
|
TemplateIdFail = $"{configuration.GetSection("Wechat:templateIdFail").Value}"; |
|
|
|
|
TemplateIdFail = $"{configuration.GetSection("Wechat:templateIdFail").Value}"; |
|
|
|
|
} |
|
|
|
|
//小程序获取openId |
|
|
|
|
public async Task<Result> GetOpenId(string code) |
|
|
|
@ -344,5 +346,164 @@ namespace _24Hour
|
|
|
|
|
return "失败"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 微信公众号消息提醒,推送检察官(律师注册后提醒检察官审核) |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<string> gzhwxtsshtx(string? useropenId, string? name, string? phone, string? company, DateTime? time) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var token = ""; |
|
|
|
|
|
|
|
|
|
// 获取缓存 |
|
|
|
|
token = cache.Get("gzhtoken")?.ToString(); |
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(token)) |
|
|
|
|
{ |
|
|
|
|
string geturl = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={Gzhappid}&secret={Gzhsecret}"; |
|
|
|
|
var re1 = HttpHelper.Get(geturl); |
|
|
|
|
if (re1.Jsonstr("errcode") == null) |
|
|
|
|
{ |
|
|
|
|
token = re1.Jsonstr("access_token"); |
|
|
|
|
|
|
|
|
|
// 移除缓存 |
|
|
|
|
cache.Remove("gzhtoken"); |
|
|
|
|
// 添加缓存 |
|
|
|
|
cache.Add("gzhtoken", token, new CacheItemPolicy { AbsoluteExpiration = DateTime.Now.AddMinutes(120) }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
string url = $"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";//发送地址 |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
object msg = null; |
|
|
|
|
string posturl = $"{url}{token}";//发送地址 |
|
|
|
|
var thing4 = name; |
|
|
|
|
var thing5 = company; |
|
|
|
|
if (!string.IsNullOrEmpty(name) && name.Length > 20) |
|
|
|
|
thing4 = name.Substring(0, 17) + "..."; |
|
|
|
|
if (!string.IsNullOrEmpty(company) && company.Length > 20) |
|
|
|
|
thing5 = company.Substring(0, 17) + "..."; |
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
template_id = $"{_configuration.GetSection("WechatGzh:templateId1").Value}", |
|
|
|
|
//miniprogram =new{ |
|
|
|
|
// appid= appid, |
|
|
|
|
// pagepath= "pages/selfService/reception/reception" |
|
|
|
|
//}, |
|
|
|
|
//miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
//lang = "zh_CN", |
|
|
|
|
//data = new |
|
|
|
|
//{ |
|
|
|
|
// thing3 = new { value = $"{thing5}"}, |
|
|
|
|
// thing1 = new { value = $"{thing4}" }, |
|
|
|
|
// phone_number5 = new { value = $"{phone}" }, |
|
|
|
|
// time4 = new { value = $"{time.Value.ToString("yyyy-MM-dd HH:mm")}" }, |
|
|
|
|
//}, |
|
|
|
|
data = new |
|
|
|
|
{ |
|
|
|
|
thing1 = new { value = $"{thing4}" }, |
|
|
|
|
thing2 = new { value = $"{thing5}" }, |
|
|
|
|
time3 = new { value = $"{time.Value.ToString("yyyy-MM-dd HH:mm")}" }, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
var re = HttpHelper.Post(posturl, msg); |
|
|
|
|
if (re.Jsonstr("errcode") == "0") |
|
|
|
|
return "成功"; |
|
|
|
|
return $"失败:{re}"; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
return $"{ex.Message}"; |
|
|
|
|
} |
|
|
|
|
return "成功"; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
return $"{ex.Message}"; |
|
|
|
|
} |
|
|
|
|
return "失败"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 微信公众号消息提醒,推送律师用户(检察官审核结果提醒) |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<string> gzhwxtsshtxjg(string useropenId, string name, string? phone, DateTime? time1, DateTime time2) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var token = ""; |
|
|
|
|
|
|
|
|
|
// 获取缓存 |
|
|
|
|
token = cache.Get("gzhtoken")?.ToString(); |
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(token)) |
|
|
|
|
{ |
|
|
|
|
string geturl = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={Gzhappid}&secret={Gzhsecret}"; |
|
|
|
|
var re1 = HttpHelper.Get(geturl); |
|
|
|
|
if (re1.Jsonstr("errcode") == null) |
|
|
|
|
{ |
|
|
|
|
token = re1.Jsonstr("access_token"); |
|
|
|
|
|
|
|
|
|
// 移除缓存 |
|
|
|
|
cache.Remove("gzhtoken"); |
|
|
|
|
// 添加缓存 |
|
|
|
|
cache.Add("gzhtoken", token, new CacheItemPolicy { AbsoluteExpiration = DateTime.Now.AddMinutes(120) }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
string url = $"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";//发送地址 |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
object msg = null; |
|
|
|
|
string posturl = $"{url}{token}";//发送地址 |
|
|
|
|
var thing4 = name; |
|
|
|
|
if (!string.IsNullOrEmpty(name) && name.Length > 20) |
|
|
|
|
thing4 = name.Substring(0, 17) + "..."; |
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
template_id = $"{_configuration.GetSection("WechatGzh:templateId2").Value}", |
|
|
|
|
//miniprogram =new{ |
|
|
|
|
// appid= appid, |
|
|
|
|
// pagepath= "pages/selfService/reception/reception" |
|
|
|
|
//}, |
|
|
|
|
//miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
//lang = "zh_CN", |
|
|
|
|
//data = new |
|
|
|
|
//{ |
|
|
|
|
// thing3 = new { value = $"{thing5}"}, |
|
|
|
|
// thing1 = new { value = $"{thing4}" }, |
|
|
|
|
// phone_number5 = new { value = $"{phone}" }, |
|
|
|
|
// time4 = new { value = $"{time.Value.ToString("yyyy-MM-dd HH:mm")}" }, |
|
|
|
|
//}, |
|
|
|
|
data = new |
|
|
|
|
{ |
|
|
|
|
thing3 = new { value = $"{name}" }, |
|
|
|
|
time4 = new { value = $"{time1.Value.ToString("yyyy-MM-dd HH:mm")}" }, |
|
|
|
|
time5 = new { value = $"{time2.ToString("yyyy-MM-dd HH:mm")}" }, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
var re = HttpHelper.Post(posturl, msg); |
|
|
|
|
if (re.Jsonstr("errcode") == "0") |
|
|
|
|
return "成功"; |
|
|
|
|
return $"失败:{re}"; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
return $"{ex.Message}"; |
|
|
|
|
} |
|
|
|
|
return "成功"; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
return $"{ex.Message}"; |
|
|
|
|
} |
|
|
|
|
return "失败"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|