Example #1
0
    /// <summary>
    /// 验证手机验证码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void checkphonecode()
    {
        string username   = Request["username3"].ToString();
        string userphone  = Request["userphone3"].ToString();
        string phonecodes = Request["phonecode3"].ToString();
        List <Hi.Model.SYS_PhoneCode> ListPhonecode = new Hi.BLL.SYS_PhoneCode().GetList("top 1 *", " DATEDIFF(minute,CreateDate,GETDATE()) between 0 and 30 and ispast=0 and module='修改登录密码' and username='******' and Phone='" + userphone + "' and PhoneCode='" + phonecodes + "' and dr=0 ", "");

        if (ListPhonecode.Count > 0)
        {
            //成功
            ListPhonecode[0].Type = 999;
            if (new Hi.BLL.SYS_PhoneCode().Update(ListPhonecode[0]))
            {
                Response.Write("{\"type\":true,\"str\":\"验证成功\"}");
                Response.End();
            }
            else
            {
                Response.Write("{\"type\":false,\"str\":\"验证异常请重试\"}");
                Response.End();
            }
        }
        else
        {
            Response.Write("{\"type\":false,\"str\":\"验证码错误或已失效!\"}");
            Response.End();
            return;
        }
    }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     user = new Hi.BLL.SYS_Users().GetModel(this.UserID);
     dis  = new Hi.BLL.BD_Distributor().GetModel(this.DisID);
     if (Request["code"] != null)
     {
         Hi.Model.SYS_PhoneCode phonecode = new Hi.BLL.SYS_PhoneCode().GetModel("支付密码找回", user.Phone, Common.DesDecrypt(Request.QueryString["code"], Common.EncryptKey));
         if (phonecode == null)
         {
             Response.Redirect("PayPWDEdit.aspx", true);
         }
     }
     else
     {
         Response.Redirect("PayPWDEdit.aspx", true);
     }
 }
Example #3
0
 protected void A_Affirm()
 {
     Hi.Model.SYS_PhoneCode phonecode = new Hi.BLL.SYS_PhoneCode().GetModel("支付密码找回", user.Phone, Request["code"].ToString());
     if (phonecode != null)
     {
         string str = "\"str\":\"" + Common.DesEncrypt(Request["code"].ToString(), Common.EncryptKey) + "\",\"type\":true";
         str = "{" + str + "}";
         Response.Write(str);
         Response.End();
     }
     else
     {
         string str = "\"str\":\"-验证码错误\",\"type\":false";
         str = "{" + str + "}";
         Response.Write(str);
         Response.End();
     }
 }
Example #4
0
 protected void A_Save(object sender, EventArgs e)
 {
     if (dis.Paypwd == Util.md5(Password.Value))
     {
         JScript.AlertMsgOne(this, "新密码不能与原密码相同!", JScript.IconOption.错误);
         return;
     }
     dis.Paypwd     = Util.md5(Password.Value);
     dis.ts         = DateTime.Now;
     dis.modifyuser = user.ID;
     if (new Hi.BLL.BD_Distributor().Update(dis))
     {
         if (user.IsFirst == 0 || user.IsFirst == 1)
         {
             if (user.IsFirst == 0)
             {
                 user.IsFirst = 2;
             }
             else
             {
                 user.IsFirst = 3;
             }
             user.modifyuser = user.ID;
             user.ts         = DateTime.Now;
             new Hi.BLL.SYS_Users().Update(user);
         }
         Hi.Model.SYS_PhoneCode phonecode = new Hi.BLL.SYS_PhoneCode().GetModel("支付密码找回", user.Phone, Common.DesDecrypt(Request.QueryString["code"], Common.EncryptKey));
         phonecode.IsPast     = 1;
         phonecode.ts         = DateTime.Now;
         phonecode.modifyuser = user.ID;
         if (new Hi.BLL.SYS_PhoneCode().Update(phonecode))
         {
             spanpwd1.Attributes.Add("style", "display:none");
             spanpwd2.Attributes.Add("style", "display:none");
             JScript.AlertMethod(this, "您的支付密码已经修改成功!", JScript.IconOption.笑脸, "function (){ location.href ='UserIndex.aspx'; }");
             return;
         }
     }
 }
Example #5
0
 protected void Btn_Update(object sender, EventArgs e)
 {
     Hi.Model.BD_Distributor dis       = new Hi.BLL.BD_Distributor().GetModel(DisID);
     Hi.Model.SYS_PhoneCode  phonecode = new Hi.BLL.SYS_PhoneCode().GetModel("修改绑定手机", txtphone.Value, txtcode.Value);
     //if (Util.md5(txtpaypwd.Value) == dis.Paypwd)
     //{
     if (phonecode != null)
     {
         user.Phone      = txtphone.Value;
         user.ts         = DateTime.Now;
         user.modifyuser = user.ID;
         if (new Hi.BLL.SYS_Users().Update(user))
         {
             phonecode.IsPast     = 1;
             phonecode.ts         = DateTime.Now;
             phonecode.modifyuser = user.ID;
             if (new Hi.BLL.SYS_PhoneCode().Update(phonecode))
             {
                 JScript.AlertMethod(this, "您的绑定手机已经修改成功!", JScript.IconOption.正确, "function (){ location.href = 'UserIndex.aspx'; }");
                 return;
             }
         }
     }
     else
     {
         spancode.Attributes.CssStyle.Value = "display:inline-block;color:Red;";
         spancode.InnerText = "-验证码错误";
         return;
     }
     //}
     //else
     //{
     //    spancode.Attributes.CssStyle.Value = "display:inline-block;color:Red;";
     //    spancode.InnerText = "-支付密码错误";
     //    return;
     //}
 }
Example #6
0
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="JSon"></param>
    /// <param name="version"></param>
    /// <returns></returns>
    public ResultLoginCaptcha GetLoginCaptcha(string JSon, string version)
    {
        string phonenumb = string.Empty;
        string password  = string.Empty;
        string SendID    = string.Empty;
        string Captcha   = string.Empty;
        List <Hi.Model.SYS_Users> userList = new List <Hi.Model.SYS_Users>();

        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["Pwd"].ToString().Trim() != "" &&
                JInfo["SendId"].ToString().Trim() != "" && JInfo["Captcha"].ToString().Trim() != "")
            {
                phonenumb = JInfo["PhoneNumb"].ToString();
                password  = JInfo["Pwd"].ToString();
                SendID    = JInfo["SendId"].ToString();
                Captcha   = JInfo["Captcha"].ToString();
            }
            else
            {
                return(new ResultLoginCaptcha()
                {
                    Result = "F", Description = "参数异常"
                });
            }
            #endregion
            #region
            //判断登录账号是否存在
            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.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 ResultLoginCaptcha()
                           {
                               Result = "F", Description = "账号不存在"
                           }
                }
                ;
            }
            Hi.Model.SYS_Users user = userList[0];
            //验证验证码是否正确
            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 ResultLoginCaptcha()
                           {
                               Result = "F", Description = "验证码过期"
                           }
                }
                ;
                if (code.UserID.ToString() != user.ID.ToString())
                {
                    return new ResultLoginCaptcha()
                           {
                               Result = "F", Description = "非本人操作"
                           }
                }
                ;
                if (code.PhoneCode != Captcha)
                {
                    return new ResultLoginCaptcha()
                           {
                               Result = "F", Description = "验证码错误"
                           }
                }
                ;
            }
            else
            {
                return(new ResultLoginCaptcha()
                {
                    Result = "F", Description = "验证码不可用"
                });
            }
            if (user.UserPwd == new GetPhoneCode().md5(password))
            {
                return(new ResultLoginCaptcha()
                {
                    Result = "F", Description = "新密码不能与老密码相同"
                });
            }
            code.IsPast     = 1;
            code.ts         = DateTime.Now;
            code.modifyuser = user.ID;
            //更新sys_phonecode中此验证码的状态为已使用
            if (new Hi.BLL.SYS_PhoneCode().Update(code))
            {
                user.UserPwd    = new GetPhoneCode().md5(password);
                user.ts         = DateTime.Now;
                user.modifyuser = user.ID;
                //更新登录密码
                if (new Hi.BLL.SYS_Users().Update(user))
                {
                    return(new ResultLoginCaptcha()
                    {
                        Result = "T", Description = "修改成功"
                    });
                }
                else
                {
                    return(new ResultLoginCaptcha()
                    {
                        Result = "F", Description = "修改失败"
                    });
                }
            }
            else
            {
                return(new ResultLoginCaptcha()
                {
                    Result = "F", Description = "验证码异常"
                });
            }

            #endregion
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetLoginCaptcha:" + JSon);
            return(new ResultLoginCaptcha()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Example #7
0
    /// <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 = "参数异常"
            });
        }
    }
Example #8
0
    /// <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 = "参数异常"
            });
        }
    }
Example #9
0
    /// <summary>
    /// 根据验证码,修改密码
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public PhoneCode ChangePwdByCode(string JSon)
    {
        try
        {
            string UserID           = string.Empty;
            string disID            = string.Empty;
            string Type             = string.Empty;
            string Password         = string.Empty;
            string MessageCode      = string.Empty;
            string ChangePasswordID = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" &&
                JInfo["Type"].ToString() != "" && JInfo["Password"].ToString() != "" &&
                JInfo["MessageCode"].ToString() != "" && JInfo["ChangePasswordID"].ToString() != "")
            {
                UserID           = JInfo["UserID"].ToString();
                Type             = JInfo["Type"].ToString();
                disID            = JInfo["ResellerID"].ToString();
                Password         = JInfo["Password"].ToString();
                MessageCode      = JInfo["MessageCode"].ToString();
                ChangePasswordID = JInfo["ChangePasswordID"].ToString();
            }
            else
            {
                return(new PhoneCode()
                {
                    Result = "F", Description = "参数不正确"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new PhoneCode()
                       {
                           Result = "F", Description = "登录信息异常"
                       }
            }
            ;

            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(int.Parse(disID));
            if (dis == null)
            {
                return new PhoneCode()
                       {
                           Result = "F", Description = "经销商异常"
                       }
            }
            ;

            Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(ChangePasswordID));
            if (code != null)
            {
                if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1)
                {
                    return new PhoneCode()
                           {
                               Result = "F", Description = "验证码过期"
                           }
                }
                ;

                if (code.UserID.ToString() != UserID)
                {
                    return new PhoneCode()
                           {
                               Result = "F", Description = "非本人操作"
                           }
                }
                ;
                if (code.PhoneCode != MessageCode)
                {
                    return new PhoneCode()
                           {
                               Result = "F", Description = "验证码错误"
                           }
                }
                ;
            }
            else
            {
                return(new PhoneCode()
                {
                    Result = "F", Description = "验证码异常"
                });
            }
            dis.Paypwd     = new GetPhoneCode().md5(Password);
            dis.ts         = DateTime.Now;
            dis.modifyuser = user.ID;
            if (new Hi.BLL.BD_Distributor().Update(dis))
            {
                code.IsPast     = 1;
                code.ts         = DateTime.Now;
                code.modifyuser = user.ID;
                if (new Hi.BLL.SYS_PhoneCode().Update(code))
                {
                    return(new PhoneCode()
                    {
                        Result = "T", Description = "修改成功"
                    });
                }
                else
                {
                    return(new PhoneCode()
                    {
                        Result = "F", Description = "验证失败"
                    });
                }
            }
            return(new PhoneCode()
            {
                Result = "F", Description = "修改失败"
            });;
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "ChangePwdByCode:" + JSon);
            return(new PhoneCode()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Example #10
0
    //public ResultAddLogin AddLoginLog(string JSon)
    //{
    //    string UserID = string.Empty;
    //    string CompUserID = string.Empty;
    //    #region//JSon取值
    //    try
    //    {
    //    JsonData JInfo = JsonMapper.ToObject(JSon);
    //    if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompUserID"].ToString().Trim() == "")
    //    {
    //        return new ResultAddLogin() { Result = "F", Description = "参数异常" };
    //    }
    //    else
    //    {
    //        UserID = JInfo["UserID"].ToString();
    //        CompUserID = JInfo["CompUserID"].ToString();
    //    }
    //    #endregion
    //    Hi.Model.SYS_Users use = new Hi.BLL.SYS_Users().GetModel(Int32.Parse(UserID));
    //         Hi.Model.SYS_CompUser compuser = new Hi.BLL.SYS_CompUser().GetModel(Int32.Parse(CompUserID));
    //    if (use == null || compuser == null)
    //    {
    //        return new ResultAddLogin() { Result = "F", Description = "参数异常" };
    //    }
    //    if (use.dr == 1 || use.IsEnabled != 1 || use.AuditState != 2)
    //    {
    //        Common.EditLog("安全日志", use.UserName, "用户" + use.UserName + "登录管理系统失败用户状态异常。", "系统安全模块", "", 0, 0, compuser.UType);
    //        return new ResultAddLogin() { Result="F",Description = "参数异常"};
    //    }
    //    if (compuser.dr == 1 || compuser.IsEnabled != 1 || compuser.IsAudit == 0)
    //    {
    //        Common.EditLog("安全日志", use.UserName, "用户" + use.UserName + "登录管理系统失败核心企业管理员状态异常。", "系统安全模块", "", 0, 0, compuser.UType);
    //        return new ResultAddLogin() { Result = "F", Description = "参数异常" };
    //    }
    //    Common.EditLog("安全日志", use.UserName, "用户" + use.UserName + "登录管理系统成功。", "系统安全模块", "", 0, 1, compuser.UType);
    //    return new ResultAddLogin() { Result = "T", Description = "登录成功" };
    //    }
    //    catch(Exception ex)
    //    {
    //        Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddLoginLog:" + JSon);
    //        return new ResultAddLogin() {Result = "F", Description = "参数异常"};
    //    }

    //}

    public ResultLogin LoginByPhone(string JSon)
    {
        try
        {
            #region JSon取值

            string phone = string.Empty;
            string code  = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["LoginPhone"].ToString() != "" && JInfo["CheckCode"].ToString() != "")
            {
                phone = JInfo["LoginPhone"].ToString();
                code  = JInfo["CheckCode"].ToString();
            }
            else
            {
                return(new ResultLogin()
                {
                    Result = "F", Description = "参数为空异常"
                });
            }

            #endregion

            List <Hi.Model.SYS_Users> userList = new Hi.BLL.SYS_Users().GetList("",
                                                                                " Phone='" + phone.Trim() + "' and AuditState =2 and dr=0 ", "");
            if (userList == null || userList.Count == 0)
            {
                return new ResultLogin()
                       {
                           Result = "F", Description = "该手机未绑定用户"
                       }
            }
            ;

            List <User> UserList = new List <User>();
            foreach (var user in userList)
            {
                Hi.Model.SYS_PhoneCode userphone = new Hi.BLL.SYS_PhoneCode().GetModel("手机登录", phone, code);

                if (userphone == null)
                {
                    return(new ResultLogin()
                    {
                        Result = "F", Description = "手机验证码错误"
                    });
                }

                List <Hi.Model.SYS_CompUser> compUserList = new Hi.BLL.SYS_CompUser().GetList("",
                                                                                              "UserID='" + user.ID + "' and IsNull(dr,0)=0 ", "");
                if (compUserList != null && compUserList.Count > 0)
                {
                    foreach (var compUser in compUserList)
                    {
                        User resultUser = new User();

                        resultUser.UserID = compUser.UserID;
                        resultUser.CompID = compUser.CompID;

                        resultUser.TrueName  = user.TrueName;
                        resultUser.Sex       = user.Sex;
                        resultUser.Phone     = user.Phone;
                        resultUser.IsEnabled = user.IsEnabled;//列表无判断,前台要使用此状态

                        Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(compUser.CompID);
                        if (comp == null)
                        {
                            return new ResultLogin()
                                   {
                                       Result = "F", Description = "核心企业异常"
                                   }
                        }
                        ;
                        resultUser.Erptype  = comp.Erptype;
                        resultUser.CompName = comp.CompName;

                        resultUser.UType = compUser.UType;
                        resultUser.CType = compUser.CType; // 1:核心企业  2:经销商
                        if (compUser.CType == 2)
                        {
                            resultUser.DisID = compUser.DisID;

                            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(compUser.DisID);
                            if (dis == null)
                            {
                                return new ResultLogin()
                                       {
                                           Result = "F", Description = "经销商异常"
                                       }
                            }
                            ;

                            resultUser.DisName = dis.DisName;
                        }

                        UserList.Add(resultUser);
                    }
                }
            }
            return(new ResultLogin()
            {
                Result = "T",
                Description = "登录成功",
                UserList = UserList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "LoginByPhone:" + JSon);
            return(new ResultLogin()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Example #11
0
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void UpdatPwd()
    {
        string pwd1      = Common.NoHTML(Request["pwd1"].ToString());
        string pwd2      = Common.NoHTML(Request["pwd2"].ToString());
        string userid    = Request["userid"].ToString();
        string username  = Request["username1"].ToString();
        string userphone = Request["userphone"];
        string Phonecode = Request["Phonecode"];
        List <Hi.Model.SYS_PhoneCode> ListPhonecode = new Hi.BLL.SYS_PhoneCode().GetList("top 1 * ", " DATEDIFF(minute,CreateDate,GETDATE()) between 0 and 60 and ispast=0 and Type='999' and module='修改登录密码' and username='******' and Phone='" + userphone + "' and PhoneCode='" + Phonecode + "' and dr=0 ", "");

        if (ListPhonecode.Count == 0)
        {
            Response.Write("{\"type\":false,\"str\":\"手机验证码校验异常,请重试!\",\"code\":\"error\"}");
            Response.End();
            return;
        }
        if (pwd1 != pwd2 || string.IsNullOrEmpty(pwd2) || string.IsNullOrEmpty(pwd1))
        {
            Response.Write("{\"type\":false,\"str\":\"密码不一致!\"}");
            Response.End();
            return;
        }
        else if (pwd1 == "123456" || pwd2 == "123456")
        {
            Response.Write("{\"type\":false,\"str\":\"不能使用系统默认密码作为新密码!\"}");
            Response.End();
            return;
        }
        else
        {
            List <Hi.Model.SYS_Users> ListUser = new Hi.BLL.SYS_Users().GetListUser("", "Username", username, "");
            if (ListUser.Count == 0)
            {
                Response.Write("{\"type\":false,\"str\":\"用户不存在!\"}");
                Response.End();
                return;
            }
            else
            {
                string newpwd = Util.md5(pwd2);
                if (ListUser[0].UserPwd == newpwd.Trim())
                {
                    Response.Write("{\"type\":false,\"str\":\"新密码不可与原密码一致!\"}");
                    Response.End();
                    return;
                }
                if (new Hi.BLL.SYS_Users().UpdatePassWord(newpwd, ListUser[0].ID.ToString()))
                {
                    ListPhonecode[0].IsPast     = 1;
                    ListPhonecode[0].ts         = DateTime.Now;
                    ListPhonecode[0].modifyuser = userid.ToInt(0);
                    new Hi.BLL.SYS_PhoneCode().Update(ListPhonecode[0]);
                    //修改成功,保存日志
                    Response.Write("{\"type\":true,\"str\":\"\"}");
                    Response.End();
                    return;
                }
                else
                {
                    Response.Write("{\"type\":false,\"str\":\"密码修改失败\"}");
                    Response.End();
                    return;
                }
            }
        }
    }
Example #12
0
    public ResultAddrAdd ResellerAddrAdd(string JSon)
    {
        try
        {
            #region JSon取值

            string userID      = string.Empty;
            string disID       = string.Empty;
            string phoneCodeID = string.Empty;
            string MessageCode = string.Empty;
            string Principal   = string.Empty;
            string Phone       = string.Empty;
            string Province    = string.Empty;
            string City        = string.Empty;
            string Area        = string.Empty;
            string Address     = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" &&
                JInfo["ChangePasswordID"].ToString() != "" && JInfo["MessageCode"].ToString() != "" &&
                JInfo["Phone"].ToString() != "" && JInfo["Principal"].ToString() != "" &&
                JInfo["Province"].ToString() != "" && JInfo["City"].ToString() != "" &&
                JInfo["Area"].ToString() != "" && JInfo["Address"].ToString() != "")
            {
                userID      = JInfo["UserID"].ToString();
                disID       = JInfo["ResellerID"].ToString();
                phoneCodeID = JInfo["ChangePasswordID"].ToString();
                MessageCode = JInfo["MessageCode"].ToString();
                Phone       = JInfo["Phone"].ToString();
                Principal   = JInfo["Principal"].ToString();
                Province    = JInfo["Province"].ToString();
                City        = JInfo["City"].ToString();
                Area        = JInfo["Area"].ToString();
                Address     = JInfo["Address"].ToString();
            }
            else
            {
                return(new ResultAddrAdd()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new ResultAddrAdd()
                       {
                           Result = "F", Description = "登录信息异常"
                       }
            }
            ;

            #endregion

            Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(phoneCodeID));
            if (code != null)
            {
                if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1)
                {
                    return new ResultAddrAdd()
                           {
                               Result = "F", Description = "验证码过期"
                           }
                }
                ;

                if (code.UserID.ToString() != userID)
                {
                    return new ResultAddrAdd()
                           {
                               Result = "F", Description = "非本人操作"
                           }
                }
                ;
                if (code.PhoneCode != MessageCode)
                {
                    return new ResultAddrAdd()
                           {
                               Result = "F", Description = "验证码错误"
                           }
                }
                ;
            }
            else
            {
                return(new ResultAddrAdd()
                {
                    Result = "F", Description = "验证码异常"
                });
            }

            List <Hi.Model.BD_DisAddr> addrList = new Hi.BLL.BD_DisAddr().GetList("", "disid='" + disID + "' and ", "");
            if (addrList != null)
            {
                if (addrList.Count >= 10)
                {
                    return new ResultAddrAdd()
                           {
                               Result = "F", Description = "一个经销商收货地址最多为10个"
                           }
                }
                ;
                if (addrList.Select(p => p.Address).Contains(Province + City + Area + Address))
                {
                    return new ResultAddrAdd()
                           {
                               Result = "F", Description = "经销商收货地址已经存在"
                           }
                }
                ;
            }

            Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr()
            {
                IsDefault    = 0,
                Principal    = Principal,
                Phone        = Phone,
                Province     = Province,
                City         = City,
                Area         = Area,
                Address      = Province + City + Area + Address,
                CreateDate   = DateTime.Now,
                CreateUserID = Convert.ToInt32(userID),
                modifyuser   = Convert.ToInt32(userID),
                dr           = 0
            };

            int count = new Hi.BLL.BD_DisAddr().Add(addr);
            if (count > 0)
            {
                return new ResultAddrAdd()
                       {
                           Result = "T", Description = "新增成功", AddrID = count
                       }
            }
            ;
            else
            {
                return(new ResultAddrAdd()
                {
                    Result = "F", Description = "新增失败"
                });
            }
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "ResellerAddrAdd :" + JSon);
            return(new ResultAddrAdd {
                Result = "F", Description = "异常"
            });
        }
    }
Example #13
0
    //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 = "参数异常"
            });
        }
    }