/// <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 (SellerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg) != null) { errMsg = string.Format("手机号:{0}已经被注册过,请使用其它手机号注册!", mobilePhone); return(false); } if (!string.IsNullOrEmpty(errMsg)) { //访问出错 return(false); } //2.检查该手机今日接收短信业务条数 var count = SmsLogBll.GetSmsCount(mobilePhone, ESmsLogType.SellerRegister); if (count >= Laplace.LiteCOS.Global.ApplicationParms.SmsMaxCount) { errMsg = string.Format("手机号:{0}今日接收验证码过多,请明天再试!", mobilePhone); return(false); } //3.生成手机验证码 var code = SmsLogBll.CreateSmsVerificationCode(); //code = "123456"; string smsContent; //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.SellerRegister }; 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); }