/// <summary> /// 获取修改登录密码,核心企业入驻的短信验证码 /// </summary> /// <param name="JSon"></param> /// <param name="version"></param> /// <returns></returns> public ResultCaptcha GetCaptcha(string JSon, string version) { string phonenumb = string.Empty; string Type = string.Empty; int typeint = 0; string typename = string.Empty; string phonenum = string.Empty; List <Hi.Model.SYS_Users> userList = null; Hi.BLL.SYS_Users bll_user = new Hi.BLL.SYS_Users(); try { #region//JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["PhoneNumb"].ToString().Trim() != "" && JInfo["Type"].ToString().Trim() != "") { phonenumb = JInfo["PhoneNumb"].ToString(); Type = JInfo["Type"].ToString(); } else { return(new ResultCaptcha() { Result = "T", Description = "参数异常" }); } #endregion //double loginnum = 0; //if (double.TryParse(phonenumb, out loginnum))//如果输入的登录名是整数,则先判断是否是手机号登录,不是手机号登录的话,再判断是否是账号名登录 //{ // userList = bll_user.GetList("", // "Phone = " + phonenumb + " and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", ""); //} //if (userList == null || userList.Count <= 0)//不是手机号登录的话,再判断是不是账号名登录 //{ // userList = bll_user.GetList("", // "UserName = '******' and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", ""); // //如果两种情况都没找到,就是账号不存在 // if (userList == null || userList.Count <= 0) // return new ResultCaptcha() { Result = "F", Description = "账号不存在" }; //} Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); switch (Type) { case "1": double loginnum = 0; if (double.TryParse(phonenumb, out loginnum)) //如果输入的登录名是整数,则先判断是否是手机号登录,不是手机号登录的话,再判断是否是账号名登录 { userList = bll_user.GetList("", "Phone = " + phonenumb + " and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", ""); } if (userList == null || userList.Count <= 0) //不是手机号登录的话,再判断是不是账号名登录 { userList = bll_user.GetList("", "UserName = '******' and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", ""); //如果两种情况都没找到,就是账号不存在 if (userList == null || userList.Count <= 0) { return new ResultCaptcha() { Result = "F", Description = "账号不存在" } } ; } user = userList[0]; typeint = -5; typename = "修改登录密码"; phonenum = user.Phone; break; case "2": //首先验证这手机号是否已经注册 List <Hi.Model.SYS_Users> list_users = bll_user.GetList("", "Phone = " + phonenumb + " and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", ""); //如果已经注册,就不发送验证码,并提示 if (list_users != null && list_users.Count > 0) { return new ResultCaptcha() { Result = "F", Description = "该手机号码已注册过账号,请使用未注册的手机号码注册" } } ; typeint = -10; typename = "核心企业注册"; phonenum = phonenumb; break; default: return(new ResultCaptcha() { Result = "F", Description = "操作类型不存在" }); } //获取六位随机数 string PhoneCode = new Common().CreateRandomCode(6); GetPhoneCode getphonecode = new GetPhoneCode(); getphonecode.GetUser( System.Configuration.ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), System.Configuration.ConfigurationManager.AppSettings["PhoneCodePwd"].ToString()); //手机发送验证码 string rstr = getphonecode.ReturnSTR(phonenum, PhoneCode); //信息发送成功的话需要在sys_phonecode表中插入一条数据 if (rstr == "Success") { Hi.Model.SYS_PhoneCode phonecode = new Hi.Model.SYS_PhoneCode(); phonecode.Type = typeint; phonecode.Module = typename; phonecode.Phone = phonenum; phonecode.PhoneCode = PhoneCode; phonecode.IsPast = 0; phonecode.UserID = user.ID; phonecode.UserName = ""; phonecode.CreateDate = DateTime.Now; phonecode.ts = DateTime.Now; phonecode.modifyuser = user.ID; int i = new Hi.BLL.SYS_PhoneCode().Add(phonecode); if (i > 0)//新增成功的话拼接返回参数 { ResultCaptcha resultcaptcha = new ResultCaptcha(); resultcaptcha.Result = "T"; resultcaptcha.Description = "返回成功"; resultcaptcha.SendId = i.ToString(); resultcaptcha.Captcha = PhoneCode; resultcaptcha.PhoneNumb = phonenum; return(resultcaptcha); } else { return(new ResultCaptcha() { Result = "F", Description = "验证码异常" }); } } else { return(new ResultCaptcha() { Result = "F", Description = "发送失败 " + rstr }); } } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetCaptcha:" + JSon); return(new ResultCaptcha() { Result = "F", Description = "参数异常" }); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.SYS_PhoneCode model) { return(dal.Update(model)); }
/// <summary> /// 发送验证码 /// </summary> /// <param name="JSon"></param> /// <returns></returns> public PhoneCode GetPhoneCode(string JSon) { try { string disID = string.Empty; string userID = string.Empty; string type = string.Empty; string compID = string.Empty; int typeInt = 0; string Phone = string.Empty; string PhoneCode = new Common().CreateRandomCode(6); Hi.Model.SYS_Users user = null; Hi.Model.SYS_Users userMaster = null; #region 赋值、验证 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["Type"].ToString() != "" && JInfo["ResellerID"].ToString() != "" && JInfo["CompanyID"].ToString() != "") { userID = JInfo["UserID"].ToString(); type = JInfo["Type"].ToString(); disID = JInfo["ResellerID"].ToString(); compID = JInfo["CompanyID"].ToString(); } else { return(new PhoneCode() { Result = "F", Description = "参数不正确" }); } if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(compID), int.Parse(disID == "" ? "0" : disID))) { return new PhoneCode() { Result = "F", Description = "登录信息异常" } } ; if (disID != "") { userMaster = new Hi.BLL.SYS_Users().GetList("", " Type = 5 and compID='" + compID + "' and disID = '" + disID + "' and dr = 0 and IsEnabled = 1", "")[0]; if (userMaster == null) { return new PhoneCode() { Result = "F", Description = "经销商管理员异常" } } ; } switch (type.Trim()) { case "10": typeInt = 10; type = "App企业钱包密码修改"; Phone = userMaster.Phone; break; case "11": typeInt = 11; type = "App修改地址"; Phone = userMaster.Phone; break; case "12": typeInt = -1; type = "App手机号码登录"; Phone = user.Phone; break; } #endregion GetPhoneCode getphonecode = new GetPhoneCode(); getphonecode.GetUser( System.Configuration.ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), System.Configuration.ConfigurationManager.AppSettings["PhoneCodePwd"].ToString()); string rstr = getphonecode.ReturnSTR(Phone, PhoneCode); if (rstr == "Success") { Hi.Model.SYS_PhoneCode phonecode = new Hi.Model.SYS_PhoneCode(); phonecode.Type = typeInt; phonecode.Module = type; phonecode.Phone = Phone; phonecode.PhoneCode = PhoneCode; phonecode.IsPast = 0; phonecode.UserID = int.Parse(userID); phonecode.UserName = user.UserName; phonecode.CreateDate = DateTime.Now; phonecode.ts = DateTime.Now; phonecode.modifyuser = int.Parse(userID); int i = new Hi.BLL.SYS_PhoneCode().Add(phonecode); if (i > 0) { return(new PhoneCode() { Result = "T", Description = "发送成功", ChangePasswordID = i.ToString() }); } else { return(new PhoneCode() { Result = "F", Description = "验证码异常" }); } } else { return(new PhoneCode() { Result = "F", Description = "发送失败" }); } } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetPhoneCode:" + JSon); return(new PhoneCode() { Result = "F", Description = "参数异常" }); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.SYS_PhoneCode model) { return(dal.Add(model)); }