/// <summary> /// 发送找回密码短信 /// </summary> public ActionResult SendMSGMobile() { //发送找回密码短信 string moibleCode = Randoms.CreateRandomValue(6); try { string mobile = WebHelper.GetFormString("mobile"); if (string.IsNullOrEmpty(mobile)) { return(AjaxResult("nouser", "请输入正确的手机号")); } var smsmodel = NewUser.GetSMSCodeList(1, 1, " where account='" + mobile + "'").FirstOrDefault(); if (smsmodel != null) { moibleCode = smsmodel.Code; string body = "【PC蛋蛋】您正在注册,验证码" + moibleCode + ",若非本人操作,请勿泄露。"; bool smsres = SMSes.SendSY(mobile, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(AjaxResult("error", "发送失败")); } return(AjaxResult("success", "发送成功")); } else { string body = "【PC蛋蛋】您正在注册,验证码" + moibleCode + ",若非本人操作,请勿泄露。"; MD_SMSCode smscode = new MD_SMSCode { Account = mobile, Code = moibleCode, Expiretime = DateTime.Now.AddMinutes(10) }; bool sms = NewUser.AddSMSCode(smscode); if (sms) { //发送短信 bool smsres = SMSes.SendSY(mobile, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(AjaxResult("error", "发送失败")); } return(AjaxResult("success", "发送成功")); } else { return(AjaxResult("error", "发送失败")); } } } catch (Exception ex) { return(AjaxResult("error", "发送失败")); } }
/// <summary> /// 更新验证码 /// </summary> /// <param name="msg"></param> /// <returns></returns> public static bool UpdateSMSCode(MD_SMSCode code) { string result = OWZX.Data.NewUser.UpdateSMSCode(code); if (result.EndsWith("成功")) { return(true); } return(false); }
/// <summary> /// 发送短信验证码 /// </summary> /// <returns></returns> public ActionResult SendSMS() { try { NameValueCollection parmas = WorkContext.postparms; if (parmas.Keys.Count != 4) { return(APIResult("error", "缺少请求参数")); } string account = parmas["account"].Trim().ToLower(); //手机 string code = parmas["code"]; //验证码 string type = parmas["type"]; string body = "【PC蛋蛋】您正在" + type + ",验证码" + code + ",若非本人操作,请勿泄露。"; MD_SMSCode smscode = new MD_SMSCode { Account = account, Code = code, Expiretime = DateTime.Now.AddMinutes(10) }; bool sms = NewUser.AddSMSCode(smscode); if (sms) { //发送短信 bool smsres = SMSes.SendSY(account, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(APIResult("error", "发送失败")); } return(APIResult("success", "发送成功")); } else { return(APIResult("error", "发送失败")); } } catch (Exception ex) { return(APIResult("error", "发送失败")); } }
/// <summary> /// 添加验证码记录 /// </summary> /// <param name="msg"></param> /// <returns></returns> public string AddSMSCode(MD_SMSCode code) { DbParameter[] parms = { GenerateInParam("@account", SqlDbType.VarChar, 15, code.Account), GenerateInParam("@code", SqlDbType.VarChar, 10, code.Code), GenerateInParam("@expiretime", SqlDbType.DateTime, 25, code.Expiretime) }; string commandText = string.Format(@" begin try if exists(select 1 from owzx_usersmscode where account=@account) begin update a set a.code=@code,a.expiretime=@expiretime from owzx_usersmscode a where account=@account end else begin INSERT INTO owzx_usersmscode([account] ,[code] ,[expiretime]) VALUES (@account,@code,@expiretime) end select '添加成功' state end try begin catch select ERROR_MESSAGE() state end catch "); return(RDBSHelper.ExecuteScalar(CommandType.Text, commandText, parms).ToString()); }
/// <summary> /// 更新验证码 /// </summary> /// <param name="msg"></param> /// <returns></returns> public static string UpdateSMSCode(MD_SMSCode code) { return(OWZX.Core.BSPData.RDBS.UpdateSMSCode(code)); }
/// <summary> /// 添加验证码记录 /// </summary> /// <param name="msg"></param> /// <returns></returns> public static string AddSMSCode(MD_SMSCode code) { return(OWZX.Core.BSPData.RDBS.AddSMSCode(code)); }
/// <summary> /// 更新验证码 /// </summary> /// <param name="msg"></param> /// <returns></returns> public string UpdateSMSCode(MD_SMSCode code) { return(""); }