/// <summary> /// 请求修改密码 /// </summary> /// <param name="mobilePhone"></param> /// <param name="password"></param> /// <param name="code"></param> /// <param name="errMsg"></param> /// <returns></returns> public static bool RequestChangePassword(string mobilePhone, string password, string code, out string errMsg) { errMsg = String.Empty; try { if (string.IsNullOrEmpty(password)) { errMsg = "密码不能为空!"; return(false); } //1.校验注册码是否合法 if (!SmsLogBll.CheckSmsVerificationCode(mobilePhone, code, ESmsLogType.BuyerChangePassword, out errMsg)) { return(false); } var buyer = BuyerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg); if (buyer == null) { errMsg = string.Format("手机号:{0}不存在!", mobilePhone); return(false); } buyer.Password = password; buyer.LDate = DateTime.Now; buyer.LMan = buyer.BuyerId; return(Dal.Update(buyer, Global.ApplicationParms.ConnectionString)); } catch (Exception ex) { errMsg = "执行异常:" + ex.Message; Logger.LogError4Exception(ex, "AppLogger"); } return(false); }
/// <summary> /// 手机注册:申请验证码 /// </summary> /// <param name="mobilePhone">接收验证码的手机号,同时也是注册号</param> /// <param name="errMsg">请求失败时的错误提示</param> /// <returns></returns> public static bool RequestRegisterVerificationCode(string mobilePhone, out string errMsg) { errMsg = String.Empty; try { //1.检查手机是否已经注册 if (BuyerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg) != null) { errMsg = string.Format("手机号:{0}已经被注册过,请使用其它手机号注册!", mobilePhone); return(false); } //2.检查该手机今日接收短信业务条数 var count = SmsLogBll.GetSmsCount(mobilePhone, ESmsLogType.BuyerRegister); if (count >= Laplace.LiteCOS.Global.ApplicationParms.SmsMaxCount) { errMsg = string.Format("手机号:{0}今日接收验证码过多,请明天再试!", mobilePhone); return(false); } //3.生成手机验证码 var code = SmsLogBll.CreateSmsVerificationCode(); //code = "123456"; string smsContent = string.Empty; //4.发送短信,调用短信接口 //#if !DEBUG if (!SmsLogBll.SendSms4RegisterVerificationCode(mobilePhone, code, out smsContent, out errMsg)) { errMsg = string.Format("发送验证码短信失败,请稍后重试!\r\n错误描述:{0}", errMsg); return(false); } //#endif //5.保存日志 var log = new SmsLog() { MobilePhone = mobilePhone, SmsTime = DateTime.Now, SmsContent = smsContent, UserId = 0, Config = code, //注册码 LogType = ESmsLogType.BuyerRegister }; SmsLogBll.Insert(log); } catch (Exception ex) { errMsg = string.Format("异常:{0}", ex.Message); Logger.LogError4Exception(ex, "AppLogger"); } return(true); }
/// <summary> /// 修改密码:申请验证码 /// </summary> /// <param name="mobilePhone">接收验证码的手机号,同时也是注册号</param> /// <param name="errMsg">请求失败时的错误提示</param> /// <returns></returns> public static bool RequestChangePasswordVerificationCode(string mobilePhone, out string errMsg) { errMsg = String.Empty; try { //1.检查手机是否已经注册 var customer = BuyerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg); if (customer == null) { errMsg = string.Format("手机号:{0}不存在!", mobilePhone); return(false); } //2.检查该手机今日接收短信业务条数 var count = SmsLogBll.GetSmsCount(mobilePhone, ESmsLogType.BuyerGetPassword); if (count >= Laplace.LiteCOS.Global.ApplicationParms.SmsMaxCount) { errMsg = string.Format("手机号:{0}今日接收验证码过多,请明天再试!", mobilePhone); return(false); } //3.生成手机验证码 var code = SmsLogBll.CreateSmsVerificationCode(); //4.发送短信 string smsContent = string.Empty; //调用短信接口 if (!SmsLogBll.SendSms4ModifyPassword(mobilePhone, code, out smsContent, out errMsg)) { errMsg = string.Format("发送密码通知短信失败,请稍后重试!\r\n错误描述:{0}", errMsg); return(false); } //5.保存日志 var log = new SmsLog() { MobilePhone = mobilePhone, SmsTime = DateTime.Now, SmsContent = smsContent, UserId = 0, Config = code, //注册码 LogType = ESmsLogType.BuyerChangePassword }; return(SmsLogBll.Insert(log)); } catch (Exception ex) { errMsg = string.Format("异常:{0}", ex.Message); Logger.LogError4Exception(ex, "AppLogger"); } return(false); }