diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs index e074d4da2..60dd53c08 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs @@ -18,6 +18,7 @@ using Learun.Application.TwoDevelopment.LR_Desktop; using Learun.Application.TwoDevelopment.Permission; using Learun.Application.WorkFlow; using Learun.Application.OA.Email.EmailSend; +using Quanjiang.DigitalScholl.SendSms; namespace Learun.Application.Web.Controllers { @@ -60,6 +61,7 @@ namespace Learun.Application.Web.Controllers private ICache redisCache = CacheFactory.CaChe(); private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL(); private EmailSendIBLL emailSendIBLL = new EmailSendBLL(); + private readonly ISms aliyunSms = new AliyunSms(); #region 视图功能 public ActionResult FirstChangePwd() @@ -764,18 +766,11 @@ namespace Learun.Application.Web.Controllers { return Fail("手机号格式不正确!"); } - //todo:待取消注释 - //string raRndNum = Learun.Util.CommonHelper.RndNum(6); - string raRndNum = "123456"; var listStr = new List(); - var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。"; - listStr.Add(str1); - //todo:待开发短信平台 - //var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); - //if (result.Result.code == "0") - if (true) + var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); + if (result.Result.code == "OK") { - redisCache.Write("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms); + redisCache.Write("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms); //日志 LogEntity logEntity = new LogEntity(); logEntity.F_CategoryId = 3; @@ -784,10 +779,10 @@ namespace Learun.Application.Web.Controllers logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 200; - logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message; - logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum; + logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum; logEntity.WriteLog(); - return Success("短信发送成功:");// + result.Result.message); + return Success("短信发送成功:" + result.Result.message); } else { @@ -798,10 +793,10 @@ namespace Learun.Application.Web.Controllers logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 400; - //logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; - //logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; - //logEntity.WriteLog(); - //return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); + logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; + logEntity.WriteLog(); + return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs index af11d4000..ea1291ab6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs @@ -1254,18 +1254,11 @@ namespace Learun.Application.Web.Controllers { return Fail("当前用户非首次登录,请使用账号密码进行登录!"); } - //todo:待取消注释 - //string raRndNum = Learun.Util.CommonHelper.RndNum(6); - string raRndNum = "123456"; var listStr = new List(); - var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。"; - listStr.Add(str1); - //todo:待开发短信平台 - //var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); - //if (result.Result.code == "0") - if (true) - { - redisCache.Write("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms); + var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); + if (result.Result.code == "OK") + { + redisCache.Write("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms); //日志 LogEntity logEntity = new LogEntity(); logEntity.F_CategoryId = 3; @@ -1274,10 +1267,10 @@ namespace Learun.Application.Web.Controllers logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 200; - logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message; - logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum; + logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum; logEntity.WriteLog(); - return Success("短信发送成功:");// + result.Result.message); + return Success("短信发送成功:" + result.Result.message); } else { @@ -1288,10 +1281,10 @@ namespace Learun.Application.Web.Controllers logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 400; - //logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; - //logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; - //logEntity.WriteLog(); - //return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); + logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; + logEntity.WriteLog(); + return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); } } /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs index 5d8a32c2f..210651a36 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs @@ -117,18 +117,11 @@ namespace Learun.Application.WebApi { return Fail("手机号格式不正确!"); } - //todo:待取消注释 - //string raRndNum = Learun.Util.CommonHelper.RndNum(6); - string raRndNum = "123456"; var listStr = new List(); - var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。"; - listStr.Add(str1); - //todo:待开发短信平台 - //var result = aliyunSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr); - //if (result.Result.code == "0") - if (true) - { - redisCache.Write("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms); + var result = aliyunSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr); + if (result.Result.code == "OK") + { + redisCache.Write("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms); //日志 LogEntity logEntity = new LogEntity(); logEntity.F_CategoryId = 3; @@ -137,10 +130,10 @@ namespace Learun.Application.WebApi logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 200; - logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message; - logEntity.F_Description = "短信发送:" + loginModel.username + " 验证码:" + raRndNum; + logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; + logEntity.F_Description = "短信发送:" + loginModel.username + " 验证码:" + result.Result.randomNum; logEntity.WriteLog(); - return Success("短信发送成功:");// + result.Result.message); + return Success("短信发送成功:" + result.Result.message); } else { @@ -151,10 +144,10 @@ namespace Learun.Application.WebApi logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 400; - //logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; - //logEntity.F_Description = "短信发送:" + loginModel.username; - //logEntity.WriteLog(); - //return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); + logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; + logEntity.F_Description = "短信发送:" + loginModel.username; + logEntity.WriteLog(); + return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs index f11bb6313..51e83bfec 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs @@ -112,18 +112,11 @@ namespace Learun.Application.WebApi { return Fail("当前用户非首次登录,请使用账号密码进行登录!"); } - //todo:待取消注释 - //string raRndNum = Learun.Util.CommonHelper.RndNum(6); - string raRndNum = "123456"; var listStr = new List(); - var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。"; - listStr.Add(str1); - //todo:待开发短信平台 - //var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); - //if (result.Result.code == "0") - if (true) + var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); + if (result.Result.code == "OK") { - redisCache.Write("sendcodeinapp_" + loginModel.codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms); + redisCache.Write("sendcodeinapp_" + loginModel.codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms); //日志 LogEntity logEntity = new LogEntity(); logEntity.F_CategoryId = 3; @@ -132,10 +125,10 @@ namespace Learun.Application.WebApi logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 200; - logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message; - logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum; + logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum; logEntity.WriteLog(); - return Success("短信发送成功:");// + result.Result.message); + return Success("短信发送成功:" + result.Result.message); } else { @@ -146,10 +139,10 @@ namespace Learun.Application.WebApi logEntity.F_OperateType = "sms"; logEntity.F_OperateAccount = "system"; logEntity.F_ExecuteResult = 400; - //logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; - //logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; - //logEntity.WriteLog(); - //return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); + logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; + logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; + logEntity.WriteLog(); + return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); } } /// diff --git a/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs b/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs index 16de654bb..83792d260 100644 --- a/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs +++ b/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs @@ -70,14 +70,11 @@ namespace Quanjiang.DigitalScholl.SendSms var randomNum = CommonHelper.RandNum(6); switch (st) { - case SmsType.Register: - result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); - break; case SmsType.LoginBind: - result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); + result = ("SMS_468910589", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); break; case SmsType.ForgetPassWord: - result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); + result = ("SMS_468910589", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); break; default: throw new ArgumentOutOfRangeException(nameof(st), st, null); diff --git a/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config b/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config index 1f74dc2ca..a7cdc7788 100644 --- a/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config +++ b/Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config @@ -7,7 +7,7 @@ - +