public static string RejectEdit(string KeyID, string Remark) { Common.ResultMessage Msg = new Common.ResultMessage(); Hi.Model.YZT_FirstCamp fcmodel = new Hi.BLL.YZT_FirstCamp().GetModel(KeyID.ToInt(0)); if (fcmodel != null) { fcmodel.Remark = Remark; fcmodel.State = 1; fcmodel.ts = DateTime.Now; if (new Hi.BLL.YZT_FirstCamp().Update(fcmodel)) { Msg.result = true; Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(fcmodel.CreateUserID); string Phone = usersModel == null ? "" : usersModel.Phone; Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(fcmodel.CompID); string compName = comp == null ? "" : comp.CompName; GetPhoneCode pc = new GetPhoneCode(); pc.SendReject(Phone, compName, Remark); } } else { Msg.code = "未查找到数据"; } return(new JavaScriptSerializer().Serialize(Msg)); }
/// <summary> /// 发送短信:提示员工登录信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_SendOut(object sender, EventArgs e) { try { string Phone = lblPhone.InnerText; string name = lblUserName.InnerText; GetPhoneCode pc = new GetPhoneCode(); string pp = pc.SendUser(Phone, name, "123456"); if (pp == "Success") { JScript.AlertMsgOne(this, "发送成功!", JScript.IconOption.笑脸, 2500); } else { JScript.AlertMsgOne(this, "发送失败", JScript.IconOption.哭脸, 2500); } return; } catch (Exception ex) { JScript.AlertMsgOne(this, "发送失败!", JScript.IconOption.错误, 2500); return; } }
/// <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> /// <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 = "参数异常" }); } }
public static string Edit(string KeyID, string Remark, string DisAreaID, string CompID, string UserID) { Common.ResultMessage Msg = new Common.ResultMessage(); Hi.Model.YZT_FirstCamp fcmodel = new Hi.BLL.YZT_FirstCamp().GetModel(KeyID.ToInt(0)); List <Hi.Model.YZT_Annex> annlist = new Hi.BLL.YZT_Annex().GetList("", " fcID=" + KeyID + " and type=2 and fileAlias='2' ", ""); if (annlist != null && annlist.Count <= 0) { Msg.code = "请先上传授权书"; } else { if (fcmodel != null) { //判断是否是该厂商的代理商 List <Hi.Model.SYS_CompUser> compulist = new Hi.BLL.SYS_CompUser().GetList("", " UserID=" + fcmodel.CreateUserID + " and CompID=" + CompID + " and DisID=" + fcmodel.DisID + "", ""); Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(CompID.ToInt(0)); string compName = comp == null ? "" : comp.CompName; SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); fcmodel.AreaID = DisAreaID.ToInt(0); fcmodel.Remark = Remark; fcmodel.State = 2; fcmodel.ts = DateTime.Now; if (new Hi.BLL.YZT_FirstCamp().Update(fcmodel, Tran)) { if (compulist != null && compulist.Count <= 0) { Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(fcmodel.CreateUserID); string Phone = usersModel == null ? "" : usersModel.Phone; string UserName = usersModel == null ? "" : usersModel.UserName; Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser(); compuser.UserID = fcmodel.CreateUserID; compuser.CompID = CompID.ToInt(0); compuser.DisID = fcmodel.DisID; compuser.AreaID = DisAreaID.ToInt(0); compuser.RoleID = usersModel == null ? 0 : usersModel.RoleID; compuser.CType = 2; compuser.UType = 5; compuser.IsAudit = 2; compuser.IsEnabled = 1; compuser.ts = DateTime.Now; compuser.CreateUserID = UserID.ToInt(0); compuser.modifyuser = UserID.ToInt(0); compuser.CreateDate = DateTime.Now; if (new Hi.BLL.SYS_CompUser().Add(compuser, Tran) > 0) { Tran.Commit(); Msg.result = true; GetPhoneCode pc = new GetPhoneCode(); pc.SendConfirm(Phone, compName, UserName); } else { Tran.Rollback(); Msg.code = "用户信息添加失败"; } } else { Hi.Model.SYS_CompUser compuser = compulist[0]; compuser.IsAudit = 2; compuser.AreaID = DisAreaID.ToInt(0); compuser.ts = DateTime.Now; compuser.modifyuser = UserID.ToInt(0); if (new Hi.BLL.SYS_CompUser().Update(compuser, Tran)) { Tran.Commit(); Msg.result = true; Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(compulist[0].UserID); string Phone = usersModel == null ? "" : usersModel.Phone; string UserName = usersModel == null ? "" : usersModel.UserName; GetPhoneCode pc = new GetPhoneCode(); pc.SendConfirm(Phone, compName, UserName); } else { Tran.Rollback(); Msg.code = "用户信息添加失败"; } } } else { Tran.Rollback(); Msg.code = "通过失败"; } } else { Msg.code = "未查找到数据"; } } return(new JavaScriptSerializer().Serialize(Msg)); }
//public string GetPhoto() //{ // try // { // string code = CreateVerifyCode(); // Bitmap photo = CreateImageCode(code); // byte[] b_photo = null; // MemoryStream stream = new MemoryStream(); // using (photo) // { // photo.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); // } // photo.Dispose(); // using (stream) // { // b_photo = stream.GetBuffer(); // } // //stream.Dispose(); // stream.Close(); // string PhotoUrl = Convert.ToBase64String(b_photo, 0, b_photo.Length); // return PhotoUrl; // } // catch (Exception ex) // { // return ex.ToString(); // } //} //public void write() //{ // string PhotoUrl = GetPhoto(); // byte[] b = Convert.FromBase64String(PhotoUrl); // FileStream fs = new FileStream(@"F:/QQ文件/IMG_14.JPG",FileMode.Create,FileAccess.Write); // fs.Write(b,0,b.Length); // fs.Flush(); // fs.Close(); //} //核心企业提交入驻申请 #region public ResultCompEnter SendEnterRequest(string JSon, string version) { string PhoneNumb = string.Empty; string LoginName = string.Empty; string PassWord = string.Empty; string CompanyName = string.Empty; string Captcha = string.Empty; string SendId = string.Empty; string Type = string.Empty; int compid = 0; try { #region//JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["PhoneNumb"].ToString().Trim() != "" && JInfo["LoginName"].ToString().Trim() != "" && JInfo["Captcha"].ToString().Trim() != "" && JInfo["PassWord"].ToString().Trim() != "" && JInfo["CompanyName"].ToString().Trim() != "" && JInfo["SendId"].ToString().Trim() != "" && JInfo["Type"].ToString().Trim() != "") { PhoneNumb = Common.NoHTML(JInfo["PhoneNumb"].ToString()); LoginName = Common.NoHTML(JInfo["LoginName"].ToString()); if (LoginName != JInfo["LoginName"].ToString()) { return new ResultCompEnter() { Result = "F", Description = "用户名存在非法字符串" } } ; PassWord = JInfo["PassWord"].ToString(); CompanyName = Common.NoHTML(JInfo["CompanyName"].ToString()); Captcha = JInfo["Captcha"].ToString(); SendId = JInfo["SendId"].ToString(); Type = JInfo["Type"].ToString(); } else { return(new ResultCompEnter() { Result = "F", Description = "参数异常" }); } #endregion #region//验证验证码是否有效 Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(SendId)); if (code != null && code.dr == 0) { if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1) { return new ResultCompEnter() { Result = "F", Description = "验证码过期" } } ; if (code.PhoneCode != Captcha) { return new ResultCompEnter() { Result = "F", Description = "验证码错误" } } ; } else { return(new ResultCompEnter() { Result = "F", Description = "验证码不可用" }); } code.IsPast = 1; code.ts = DateTime.Now; code.modifyuser = 0; SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer); if (conn.State.ToString().ToLower() != "open") { conn.Open(); } SqlTransaction mytran = conn.BeginTransaction(); #endregion //如果验证码正确的话,修改验证码状态 try { if (new Hi.BLL.SYS_PhoneCode().Update(code, mytran))//验证码状态修改成功的话,开始进行注册流程 { if (Type == "distributor") { Boolean result = RegisterDistributor(CompanyName, PhoneNumb, PassWord, mytran); if (result) { return(new ResultCompEnter() { Result = "T", Description = "注册成功" }); } else { return(new ResultCompEnter() { Result = "F", Description = "注册用户失败" }); } } else { //首先在bd_company表中新增一条数据 Hi.Model.BD_Company comp = new Hi.Model.BD_Company(); comp.CompName = CompanyName; comp.LegalTel = PhoneNumb; comp.Phone = PhoneNumb; comp.AuditState = 0; comp.IsEnabled = 1; comp.FirstShow = 1; comp.Erptype = 0; comp.SortIndex = "001"; comp.HotShow = 1; comp.CreateDate = DateTime.Now; comp.CreateUserID = 0; comp.ts = DateTime.Now; comp.modifyuser = 0; compid = new Hi.BLL.BD_Company().Add(comp, mytran); //bd_company表中数据新增成功后,在sys_users表中新增一条数据 if (compid <= 0) { mytran.Rollback(); conn.Close(); return(new ResultCompEnter() { Result = "F", Description = "注册核心企业失败" }); } //在表sys_users表中新增一条数据 Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); user.UserName = LoginName; user.TrueName = ""; user.UserPwd = new GetPhoneCode().md5(PassWord); user.Phone = PhoneNumb; user.CreateDate = DateTime.Now; user.CreateUserID = 0; user.ts = DateTime.Now; user.modifyuser = 0; user.AuditState = 2; user.IsEnabled = 1; int userid = new Hi.BLL.SYS_Users().Add(user, mytran); if (userid <= 0) { mytran.Rollback(); conn.Close(); return(new ResultCompEnter() { Result = "F", Description = "注册用户失败" }); } //sys_users新增成功的话,在sys_compuser表中新增一条数据 Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser(); compuser.CompID = compid; compuser.DisID = 0; compuser.CreateDate = DateTime.Now; compuser.CreateUserID = 0; compuser.ts = DateTime.Now; compuser.modifyuser = 0; compuser.CType = 1; compuser.UType = 4; compuser.dr = 0; compuser.IsAudit = 0; compuser.IsEnabled = 1; compuser.UserID = userid; int compuserid = new Hi.BLL.SYS_CompUser().Add(compuser, mytran); if (compuserid <= 0) { mytran.Rollback(); conn.Close(); return(new ResultCompEnter() { Result = "F", Description = "用户与核心企业关联失败" }); } else { // 通知运营 string SendRegiPhone = System.Configuration.ConfigurationManager.AppSettings["SendTels"].ToString(); string[] Phones = SendRegiPhone.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string tel in Phones) { GetPhoneCode phoneCode = new GetPhoneCode(); phoneCode.GetUser( System.Configuration.ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), System.Configuration.ConfigurationManager.AppSettings["PhoneCodePwd"].ToString()); phoneCode.ReturnComp(tel, comp.CompName); } } } } else { mytran.Rollback(); conn.Close(); return(new ResultCompEnter() { Result = "F", Description = "验证码异常" }); } } catch { mytran.Rollback(); conn.Close(); } mytran.Commit(); conn.Close(); return(new ResultCompEnter() { Result = "T", Description = "注册成功", CompID = compid.ToString() }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "SendEnterRequest" + JSon); return(new ResultCompEnter() { Result = "F", Description = "参数异常" }); } }