Exemple #1
0
        /// <summary>
        /// 登录信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public SysAdminUserModel GetUserForLogin(SysAdminUserModel user)
        {
            SysAdminUserModel result = null;
            string            sqltxt = @"SELECT  ID ,
        UserName ,
        UserPwd ,
        UserStatus ,
        UserEmail ,
        TruethName ,
        UserPhone ,
        Question ,
        Answer ,
        GID ,
        GName,
        LoginName,HeaderImg,WebSkin,LastLoginIP,LastLoginTime,IsAdmin
FROM    dbo.SysAdminUser
WHERE LoginName=@loginname ";

            SqlParameter[] paramter =
            {
                new SqlParameter("@loginname", user.LoginName)
            };
            DataTable dt = helper.Query(sqltxt, paramter).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                result               = new SysAdminUserModel();
                result.Answer        = dt.Rows[0]["Answer"].ToString();
                result.GID           = int.Parse(dt.Rows[0]["GID"].ToString());
                result.GName         = dt.Rows[0]["GName"].ToString();
                result.ID            = int.Parse(dt.Rows[0]["ID"].ToString());
                result.LoginName     = dt.Rows[0]["LoginName"].ToString();
                result.Question      = dt.Rows[0]["Question"].ToString();
                result.TruethName    = dt.Rows[0]["TruethName"].ToString();
                result.UserEmail     = dt.Rows[0]["UserEmail"].ToString();
                result.UserName      = dt.Rows[0]["UserName"].ToString();
                result.UserPhone     = dt.Rows[0]["UserPhone"].ToString();
                result.UserPwd       = dt.Rows[0]["UserPwd"].ToString();
                result.HeaderImg     = dt.Rows[0]["HeaderImg"].ToString();
                result.UserStatus    = int.Parse(dt.Rows[0]["UserStatus"].ToString());
                result.WebSkin       = string.IsNullOrWhiteSpace(dt.Rows[0]["WebSkin"].ToString()) ? "default" : dt.Rows[0]["WebSkin"].ToString();
                result.LastLoginIP   = string.IsNullOrWhiteSpace(dt.Rows[0]["LastLoginIP"].ToString()) ? "" : dt.Rows[0]["LastLoginIP"].ToString();
                result.LastLoginTime = string.IsNullOrWhiteSpace(dt.Rows[0]["LastLoginTime"].ToString()) ? DateTime.MinValue : DateTime.Parse(dt.Rows[0]["LastLoginTime"].ToString());
                result.IsAdmin       = dt.Rows[0]["IsAdmin"].ToString().ParseToInt(0);
                if (result.UserPwd != user.UserPwd)
                {
                    result.LoginResult = "0用户密码不正确";
                    return(result);
                }
                if (result.UserStatus == 0)
                {
                    result.LoginResult = "0用户已经被禁用";
                    return(result);
                }
                UpdateLoginMsg(user.LastLoginTime, user.LastLoginIP, result.ID);
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 2;
                    log.BehaviorType   = 1;
                    log.HOrderCode     = "";
                    log.MemberID       = result.ID;
                    log.MemberName     = result.UserName;
                    log.MemberPhone    = result.UserPhone;
                    log.ProcAmount     = 0;
                    log.Remark         = "管理员:" + result.UserName + "登陆";
                    int rowcount = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                result.LoginResult = "1";
            }
            else
            {
                result             = new SysAdminUserModel();
                result.LoginResult = "0无此用户";
                return(result);
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 分配激活码
        /// </summary>
        /// <param name="codes"></param>
        /// <param name="memberphone"></param>
        /// <returns></returns>
        public int AssignedCode(List <string> codes, string memberphone)
        {
            int result = 0;
            //得到激活码信息
            List <ActiveCodeModel> codelist = GetCodeMassage(codes);
            //得到被分配会员信息
            MemberInfoModel member = GetMember(memberphone);

            if (member.MStatus != 2)
            {
                return(0);
            }
            //开启事务,分配激活码
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //更改原表状态
                    result = UpdateStatus(codelist);
                    if (result < codelist.Count)
                    {
                        throw new Exception("更改激活码原表失败");
                    }
                    List <MemberActiveCodeModel> maclist = new List <MemberActiveCodeModel>();
                    foreach (var item in codelist)
                    {
                        MemberActiveCodeModel mac = new MemberActiveCodeModel();
                        mac.ActiveCode  = item.ActivationCode;
                        mac.MemberID    = member.ID;
                        mac.MemberName  = member.TruethName;
                        mac.MemberPhone = member.MobileNum;
                        mac.AMType      = item.AType;
                        maclist.Add(mac);
                    }
                    result = AddMemberActiveCode(maclist);
                    if (result < 1)
                    {
                        return(0);
                    }
                    ActiveCodeLogModel activemodel = new ActiveCodeLogModel();
                    activemodel.ActiveCode  = "";
                    activemodel.Addtime     = DateTime.Now;
                    activemodel.AID         = 0;
                    activemodel.MemberID    = member.ID;
                    activemodel.MemberName  = member.TruethName;
                    activemodel.MemberPhone = member.MobileNum;
                    activemodel.Remark      = "接收" + codelist.Count + "个" + (codelist[0].AType == 1 ? "激活币" : "排单币");
                    OperateLogDAL.AddActiveCodeLog(activemodel);
                    try
                    {
                        UserBehaviorLogModel log = new UserBehaviorLogModel();
                        log.AOrderCode     = "";
                        log.BehaviorSource = 2;
                        if (codelist[0].AType == 1)
                        {
                            log.BehaviorType = 8;
                        }
                        else
                        {
                            log.BehaviorType = 7;
                        }
                        log.HOrderCode  = "";
                        log.MemberID    = member.ID;
                        log.MemberName  = member.TruethName;
                        log.MemberPhone = member.MobileNum;
                        log.ProcAmount  = 0;
                        log.Remark      = "系统派发激活码/排单币" + codelist.Count + "个";
                        UserBehaviorLogDAL.AddUserBehaviorLog(log);
                    }
                    catch { }
                    scope.Complete();
                    result = 1;
                }
            }
            catch
            {
                return(0);
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 会员间赠送激活码
        /// </summary>
        /// <param name="soucememberID">原始会员ID</param>
        /// <param name="type">赠送激活码类型</param>
        /// <param name="acceptMemberPhone">接受会员电话</param>
        /// <param name="count">赠送数量</param>
        /// <returns>返回值(-1 接受会员不存在 -2 没有足够的激活币赠送 0 数据库操作失败 1 成功)</returns>
        public int GiveActiveCodeFromMember(int soucememberID, int type, string acceptMemberPhone, int count)
        {
            int result = 0;
            //读取接受会员信息
            MemberInfoModel member = GetMember(acceptMemberPhone);

            if (member == null)
            {
                return(-1);
            }
            if (member.MStatus != 2)
            {
                return(-1);
            }
            //开启事务
            using (TransactionScope scope = new TransactionScope())
            {
                //查询该会员名下可用类型的激活码数量
                List <MemberActiveCodeModel> aclist = GetMemberActiveCodeList(soucememberID, type);
                if (aclist.Count < count)
                {
                    return(-2);
                }
                //修改激活码的所有者信息
                string         sqltxt   = @"UPDATE TOP ( @count)
        MemberActiveCode
SET     MemberID = @memberid ,
        MemberPhone = @MemberPhone ,
        MemberName = @MemberName
WHERE   MemberID = @soucemid
        AND AMStatus = 1
        AND AMType = @AMType";
                SqlParameter[] paramter =
                {
                    new SqlParameter("@memberid",    member.ID),
                    new SqlParameter("@MemberPhone", member.MobileNum),
                    new SqlParameter("@MemberName",  member.TruethName),
                    new SqlParameter("@soucemid",    soucememberID),
                    new SqlParameter("@AMType",      type),
                    new SqlParameter("@count",       count)
                };
                int row = helper.ExecuteSql(sqltxt, paramter);
                if (row < 0)
                {
                    return(0);
                }
                int rowcount = row;
                //记录转出者名下日志
                MemberInfoModel    sourcemodel = GetMember(soucememberID);
                ActiveCodeLogModel souce       = new ActiveCodeLogModel();
                souce.MemberID    = soucememberID;
                souce.MemberName  = sourcemodel.TruethName;
                souce.MemberPhone = sourcemodel.MobileNum;
                souce.ActiveCode  = "";
                souce.AID         = 0;
                souce.Remark      = " 转出" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                row = OperateLogDAL.AddActiveCodeLog(souce);
                if (row < 0)
                {
                    return(0);
                }
                //记录转入者名下日志
                ActiveCodeLogModel accept = new ActiveCodeLogModel();
                accept.MemberID    = member.ID;
                accept.MemberName  = member.TruethName;
                accept.MemberPhone = member.MobileNum;
                accept.ActiveCode  = "";
                accept.AID         = 0;
                accept.Remark      = "接收" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                row = OperateLogDAL.AddActiveCodeLog(accept);
                if (row < 0)
                {
                    return(0);
                }
                //记录系统操作日志
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 1;
                    if (type == 1)
                    {
                        log.BehaviorType = 8;
                    }
                    else
                    {
                        log.BehaviorType = 7;
                    }
                    log.HOrderCode  = "";
                    log.MemberID    = member.ID;
                    log.MemberName  = member.TruethName;
                    log.MemberPhone = member.MobileNum;
                    log.ProcAmount  = 0;
                    log.Remark      = "会员:" + member.MobileNum + " 得到来自" + sourcemodel.MobileNum + "转来的" + rowcount.ToString() + "个" + (type == 1 ? "激活币" : "排单币");
                    UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                scope.Complete();
                result = 1;
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 前端会员登陆
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public MemberInfoModel GetMemberInfo(string phone, string pwd, out string logmsg)
        {
            MemberInfoModel model  = null;
            string          sqltxt = @"SELECT  ID ,
        TruethName ,
        Sex ,
        TelPhone ,
        MobileNum ,
        Email ,
        IdentificationID ,
        Province ,
        City ,
        Area ,
        [Address] ,
        WeixinNum ,
        AliPayName ,
        AliPayNum ,
        SecurityQuestion ,
        SecurityAnswer ,
        LogPwd ,
        MStatus ,
        AddTime
FROM    dbo.MemberInfo
WHERE MobileNum=@MobileNum";

            SqlParameter[] paramter = { new SqlParameter("@MobileNum", phone) };
            DataTable      dt       = helper.Query(sqltxt, paramter).Tables[0];

            if (dt.Rows.Count > 0)
            {
                string logpwd = dt.Rows[0]["LogPwd"].ToString();
                if (logpwd != pwd)
                {
                    logmsg = "登陆密码不正确";
                    return(null);
                }
                if (dt.Rows[0]["MStatus"].ToString() == "1")
                {
                    logmsg = "该账户未激活";
                    return(null);
                }
                if (dt.Rows[0]["MStatus"].ToString() == "3")
                {
                    logmsg = "该账户已被冻结";
                    return(null);
                }
                model = new MemberInfoModel();
                if (dt.Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(dt.Rows[0]["ID"].ToString());
                }
                if (dt.Rows[0]["Area"].ToString() != "")
                {
                    model.Area = dt.Rows[0]["Area"].ToString();
                }
                model.Address          = dt.Rows[0]["Address"].ToString();
                model.WeixinNum        = dt.Rows[0]["WeixinNum"].ToString();
                model.AliPayName       = dt.Rows[0]["AliPayName"].ToString();
                model.AliPayNum        = dt.Rows[0]["AliPayNum"].ToString();
                model.SecurityQuestion = dt.Rows[0]["SecurityQuestion"].ToString();
                model.SecurityAnswer   = dt.Rows[0]["SecurityAnswer"].ToString();
                model.LogPwd           = "password";
                if (dt.Rows[0]["MStatus"].ToString() != "")
                {
                    model.MStatus = int.Parse(dt.Rows[0]["MStatus"].ToString());
                }
                if (dt.Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(dt.Rows[0]["AddTime"].ToString());
                }
                model.TruethName = dt.Rows[0]["TruethName"].ToString();
                if (dt.Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = int.Parse(dt.Rows[0]["Sex"].ToString());
                }
                model.TelPhone         = dt.Rows[0]["TelPhone"].ToString();
                model.MobileNum        = dt.Rows[0]["MobileNum"].ToString();
                model.Email            = dt.Rows[0]["Email"].ToString();
                model.IdentificationID = dt.Rows[0]["IdentificationID"].ToString();
                if (dt.Rows[0]["Province"].ToString() != "")
                {
                    model.Province = dt.Rows[0]["Province"].ToString();
                }
                if (dt.Rows[0]["City"].ToString() != "")
                {
                    model.City = dt.Rows[0]["City"].ToString();
                }
                logmsg = "1";
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 1;
                    log.BehaviorType   = 1;
                    log.HOrderCode     = "";
                    log.MemberID       = model.ID;
                    log.MemberName     = model.TruethName;
                    log.MemberPhone    = model.MobileNum;
                    log.ProcAmount     = 0;
                    log.Remark         = "会员:" + model.MobileNum + "登陆";
                    int rowcount = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                return(model);
            }
            else
            {
                logmsg = "手机号不存在";
                return(null);
            }
        }