From a4e4986fb4612a49337fc7ade2417eefdf3889b8 Mon Sep 17 00:00:00 2001 From: zhaojs <349234519@qq.com> Date: 星期五, 20 十月 2023 14:12:52 +0800 Subject: [PATCH] no message --- api/.vs/FxProject/v16/.suo | 0 api/CommonUtil/CommonUtil.xml | 19 ++++++ api/ScheduledTasks/Handle/SmsWarningHandle.cs | 50 ++++++++++++++++ api/ScheduledTasks/Scheduler.cs | 9 -- api/CommonUtil/Web/WebUtil.cs | 22 +++++++ api/ScheduledTasks/appsettings.json | 16 ++--- api/CommonUtil/Web/SendQwGroup.cs | 31 ++++++++++ 7 files changed, 130 insertions(+), 17 deletions(-) diff --git a/api/.vs/FxProject/v16/.suo b/api/.vs/FxProject/v16/.suo index 6a70bc4..fb50286 100644 --- a/api/.vs/FxProject/v16/.suo +++ b/api/.vs/FxProject/v16/.suo Binary files differ diff --git a/api/CommonUtil/CommonUtil.xml b/api/CommonUtil/CommonUtil.xml index bc619e6..ec1a91e 100644 --- a/api/CommonUtil/CommonUtil.xml +++ b/api/CommonUtil/CommonUtil.xml @@ -15373,6 +15373,16 @@ </summary> <param name="output"></param> </member> + <member name="T:CommonUtil.Web.SendQwGroup"> + <summary> + 鍙戦�佷紒寰満鍣ㄤ汉 + </summary> + </member> + <member name="M:CommonUtil.Web.SendQwGroup.SendMessage(System.String)"> + <summary> + + </summary> + </member> <member name="T:CommonUtil.Web.ServiceUtil"> <summary> @@ -15513,6 +15523,15 @@ <param name="textParams">Text parameters.</param> <param name="headerParams">Header parameters.</param> </member> + <member name="M:CommonUtil.Web.WebUtil.DoPostWithJson(System.String,System.String,System.Collections.Generic.IDictionary{System.String,System.String})"> + <summary> + post json璇锋眰 + </summary> + <param name="url"></param> + <param name="body"></param> + <param name="headerParams"></param> + <returns></returns> + </member> <member name="M:CommonUtil.Web.WebUtil.GetWebRequest(System.String,System.String,System.Collections.Generic.IDictionary{System.String,System.String})"> <summary> 鐢熸垚HttpWebRequest diff --git a/api/CommonUtil/Web/SendQwGroup.cs b/api/CommonUtil/Web/SendQwGroup.cs new file mode 100644 index 0000000..588ef4e --- /dev/null +++ b/api/CommonUtil/Web/SendQwGroup.cs @@ -0,0 +1,31 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace CommonUtil.Web +{ + /// <summary> + /// 鍙戦�佷紒寰満鍣ㄤ汉 + /// </summary> + public class SendQwGroup + { + /// <summary> + /// + /// </summary> + public static void SendMessage(string message) + { + try + { + string body = "{\"msgtype\": \"markdown\",\"markdown\":{\"content\":\"" + message + "\"}}"; + string res = new WebUtil().DoPostWithJson("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1e5a8b47-b108-40a6-9a29-d629863bd066", body, null); + + body = "{\"msgtype\": \"text\",\"text\":{\"content\":\"鎮ㄦ湁鏂扮殑娑堟伅闇�瑕佸鐞哱",\"mentioned_mobile_list\":[\"13382447768\",\"15862977578\",\"17315773080\"]}}"; + res = new WebUtil().DoPostWithJson("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1e5a8b47-b108-40a6-9a29-d629863bd066", body, null); + } + catch + { + + } + } + } +} diff --git a/api/CommonUtil/Web/WebUtil.cs b/api/CommonUtil/Web/WebUtil.cs index 5469101..19f35b9 100644 --- a/api/CommonUtil/Web/WebUtil.cs +++ b/api/CommonUtil/Web/WebUtil.cs @@ -212,6 +212,28 @@ } /// <summary> + /// post json璇锋眰 + /// </summary> + /// <param name="url"></param> + /// <param name="body"></param> + /// <param name="headerParams"></param> + /// <returns></returns> + public string DoPostWithJson(string url, string body, IDictionary<string, string> headerParams) + { + HttpWebRequest req = GetWebRequest(url, "POST", headerParams); + req.ContentType = "application/json;charset=utf-8"; + + byte[] postData = Encoding.UTF8.GetBytes(body); + Stream reqStream = req.GetRequestStream(); + reqStream.Write(postData, 0, postData.Length); + reqStream.Close(); + + HttpWebResponse rsp = (HttpWebResponse)req.GetResponse(); + Encoding encoding = GetResponseEncoding(rsp); + return GetResponseAsString(rsp, encoding); + } + + /// <summary> /// 鐢熸垚HttpWebRequest /// </summary> /// <param name="url"></param> diff --git a/api/ScheduledTasks/Handle/SmsWarningHandle.cs b/api/ScheduledTasks/Handle/SmsWarningHandle.cs new file mode 100644 index 0000000..a993ade --- /dev/null +++ b/api/ScheduledTasks/Handle/SmsWarningHandle.cs @@ -0,0 +1,50 @@ +锘縰sing CommonUtil; +using CommonUtil.Web; +using Operater.DAL; +using Quartz; +using System; +using System.Collections.Generic; +using System.Data; +using System.Text; +using System.Threading.Tasks; + +namespace ScheduledTasks.Handle +{ + public class SmsWarningHandle : IJob + { + public async Task Execute(IJobExecutionContext context) + { + await Synchronize(context); + } + public static async Task Synchronize(IJobExecutionContext context) + { + try + { + //鏌ヨ瓒呰繃3鍒嗛挓鏈鏍哥殑 + string searchSql = $"select count(1) as count from sms_send where sendstatus=0 and isshowsend=0 and TIMESTAMPDIFF(MINUTE, now(),createtime)>3"; + DataTable shDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql); + int shCount = int.Parse(shDt.Rows[0]["count"].ToString()); + if (shCount > 0) + {//鍙戦璀� + string warStr = "鎮ㄦ湁寰呭鏍哥殑浠诲姟\n>绫诲瀷锛氬緟瀹℃牳\n>鏁伴噺:" + shCount + "\n>鏌ョ湅:[鐐瑰嚮澶勭悊](https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7a9a40880081340d&redirect_uri=https%3A%2F%2Fsms.ushopvip.com%2Fpages%2Fad_page%2Ftrans&response_type=code&scope=snsapi_base&state=gzh#wechat_redirect)"; + SendQwGroup.SendMessage(warStr); + + } + //鏌ヨ闀挎椂闂存湭鍙戦�佹垚鍔� + searchSql = $"select count(1) as count from sms_send where isshowsend=0 and wantsendtime>now() and sendstatus=0 and TIMESTAMPDIFF(MINUTE, now(),wantsendtime)>5"; + DataTable wfDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql); + int wfCount = int.Parse(wfDt.Rows[0]["count"].ToString()); + if (wfCount > 0) + {//鍙戦璀� + string warStr = "闀挎椂闂存湭鍙戦�佸畬鎴愪换鍔n>绫诲瀷锛氫换鍔″紓甯竆n>鏁伴噺:" + wfCount; + SendQwGroup.SendMessage(warStr); + } + } + catch (Exception e) + { + LogUtil.Info(e.ToString(), "鐭俊棰勮error"); + Console.WriteLine($"鐭俊棰勮error", e.ToString()); + } + } + } +} diff --git a/api/ScheduledTasks/Scheduler.cs b/api/ScheduledTasks/Scheduler.cs index 32caa4a..c457bd6 100644 --- a/api/ScheduledTasks/Scheduler.cs +++ b/api/ScheduledTasks/Scheduler.cs @@ -41,14 +41,7 @@ scheduler = await factory.GetScheduler(); //寮�濮嬭皟搴﹀櫒 await scheduler.Start(); - - - //鏈夎禐鍜�1688token鏇存柊 - string tokenupdate = ConfigUtil.GetValue<string>("job_tokenupdate"); - await CreateJob<TokenUpdateHandle>("token鏇存柊", "token鏇存柊", tokenupdate); - await CreateJob<DataStatisticsHandle>("鏁版嵁缁熻", "鏁版嵁缁熻", ConfigUtil.GetValue<string>("job_datastatic")); - //await CreateJob<YzTradeVerifyHandle>("鏈夎禐璁㈠崟鏍¢獙", "鏈夎禐璁㈠崟鏍¢獙", ConfigUtil.GetValue<string>("job_yztradeverify")); - await CreateJob<WxMiniTokenHandle>("閿�寰俊灏忕▼搴弔oken鏇存柊", "閿�寰俊灏忕▼搴弔oken鏇存柊", ConfigUtil.GetValue<string>("job_fxwxtoken")); + await CreateJob<SmsWarningHandle>("鐭俊绯荤粺棰勮", "鐭俊绯荤粺棰勮", ConfigUtil.GetValue<string>("job_smswarning")); } diff --git a/api/ScheduledTasks/appsettings.json b/api/ScheduledTasks/appsettings.json index 95a5eaf..00afa5a 100644 --- a/api/ScheduledTasks/appsettings.json +++ b/api/ScheduledTasks/appsettings.json @@ -7,20 +7,18 @@ } }, "AllowedHosts": "*", - //有赞和1688 token更新 每天凌晨1点 - "job_tokenupdate": "0 0 1 * * ?", - //数据统计 每天凌晨3点 - "job_datastatic": "0 0 3 * * ?", - //有赞订单校验 - "job_yztradeverify": "0 0 2 * * ?", - //分销微信小程序token更新 每隔10分钟触发一次 - "job_fxwxtoken": "0 0/10 * * * ?", - + //短信系统预警 每隔5分钟触发一次 + "job_smswarning": "0 0/5 * * * ?", "DbConnection": [ { //正式 "Key": "Main", "ConnectionString": "server=123.60.83.120;port=3306;uid=fxuser;pwd=opRer16#2e2rdq;database=fx_main;Allow Zero Datetime=True;Charset=utf8;" + }, + { + //正式 + "Key": "Sms", + "ConnectionString": "server=123.60.83.120;port=3306;uid=fxuser;pwd=opRer16#2e2rdq;database=sms_sender;Allow Zero Datetime=True;Charset=utf8;" } ] } -- Gitblit v1.9.3