diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs index 9b1465025..df1ad608d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs @@ -12,6 +12,7 @@ using System.Net; using Learun.Cache.Base; using Learun.Cache.Factory; using Nancy.Responses; +using Quanjiang.DigitalScholl.SendSms; namespace Learun.Application.WebApi { @@ -27,6 +28,7 @@ namespace Learun.Application.WebApi private SunshineEducationIBLL sunshineEducationIBLL = new SunshineEducationBLL(); private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); private ICache redisCache = CacheFactory.CaChe(); + private readonly ISms yixintongSms = new YixintongSms(); /// /// 阳光教育 @@ -56,11 +58,58 @@ namespace Learun.Application.WebApi public Response CheckVerifyCode(dynamic _) { MobileVerify mobileVerify = this.GetReqData(); - var code = redisCache.Read("sunshineimgvcode" + mobileVerify.pagecode); + var code = redisCache.Read("sunshineimgvcode_" + mobileVerify.pagecode); + LogEntity logEntity = null; if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode) { //发送短信 - + try + { + //学生增加短信发送验证 + string raRndNum = Learun.Util.CommonHelper.RndNum(6); + var listStr = new List(); + var str1 = $"您本次提交的验证码是" + raRndNum + "。"; + listStr.Add(str1); + var result = yixintongSms.SendSmsToSingle(mobileVerify.mobile, SmsType.LoginBind, listStr); + if (result.Result.code == "0") + { + redisCache.Write("sunshinesmscode_"+mobileVerify.pagecode +"_"+ mobileVerify.mobile, raRndNum, new TimeSpan(0, 5, 0)); + //日志 + logEntity = new LogEntity(); + logEntity.F_CategoryId = 3; + logEntity.F_OperateTypeId = "sms"; + logEntity.F_OperateType = "sms"; + logEntity.F_OperateAccount = "system"; + logEntity.F_ExecuteResult = 200; + logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; + logEntity.F_Description = "短信发送:" + mobileVerify.mobile; + logEntity.WriteLog(); + } + else + { + logEntity = new LogEntity(); + logEntity.F_CategoryId = 4; + logEntity.F_OperateTypeId = "sms"; + logEntity.F_OperateType = "sms"; + logEntity.F_OperateAccount = "system"; + logEntity.F_ExecuteResult = 400; + logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; + logEntity.F_Description = "短信发送:" + mobileVerify.mobile; + logEntity.WriteLog(); + } + } + catch (Exception e) + { + logEntity = new LogEntity(); + logEntity.F_CategoryId = 4; + logEntity.F_OperateTypeId = "sms"; + logEntity.F_OperateType = "sms"; + logEntity.F_OperateAccount = "system"; + logEntity.F_ExecuteResult = 400; + logEntity.F_ExecuteResultJson = "短信发送失败:" + e.Message; + logEntity.F_Description = "短信发送:" + mobileVerify.mobile; + logEntity.WriteLog(); + } return Success("短信验证码已成功发送。"); } else @@ -86,7 +135,7 @@ namespace Learun.Application.WebApi try { (byte[] buffer,string code) = new VerifyCode().GetVerifyCodeForMobileApi(); - redisCache.Write("sunshineimgvcode" + pagecode, code, new TimeSpan(0, 5, 0)); + redisCache.Write("sunshineimgvcode_" + pagecode, code, new TimeSpan(0, 5, 0)); ms = new MemoryStream(buffer); return ms; } @@ -194,13 +243,23 @@ namespace Learun.Application.WebApi return Fail("评论失败,受理单号不正确"); } entity.Contents = data.Contents; + sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); + return Success("提交成功!"); } else { entity.Contents = WebHelper.HtmlEncode(entity.Contents); + var code = redisCache.Read("sunshinesmscode_" +entity.pagecode+"_" + entity.mobile); + if (entity.smscode== code) + { + sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); + return Success("提交成功!"); + } + else + { + return Fail("验证失败,验证码错误或已失效。"); + } } - sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); - return Success("保存成功!"); } /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SunshineEducation/SunshineEducationEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SunshineEducation/SunshineEducationEntity.cs index b08cde749..338154871 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SunshineEducation/SunshineEducationEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/SunshineEducation/SunshineEducationEntity.cs @@ -155,6 +155,12 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration [NotMapped] public string AcceptanceUnitName { get; set; } + [NotMapped] + public string mobile { get; set; } + [NotMapped] + public string smscode { get; set; } + [NotMapped] + public string pagecode { get; set; } #endregion #region 扩展操作