Exemplo n.º 1
0
        public IHttpActionResult Login([FromBody] JObject json)
        {
            LoginForPost model = JsonConvert.DeserializeObject <LoginForPost>(json.ToString());
            BodyInOut    ack   = api.Login(model.phone, model.user_pwd, model.open_id);

            return(Json <BodyInOut>(ack));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="user_id">用户ID</param>
        /// <param name="pwd">原密码</param>
        /// <param name="new_pwd">新密码</param>
        /// <returns></returns>
        public BodyInOut UpdatePwd(string user_id, string pwd, string new_pwd)
        {
            BodyInOut ack = new BodyInOut();

            try
            {
                UserMst model = GetBaseModel(user_id);
                if (model.user_pwd.Equals(BruceClass.Sha256(pwd)))
                {
                    if (dal.UpdatePwd(user_id, BruceClass.Sha256(new_pwd)))
                    {
                        ack.return_flag = ApiConst.RETURN_SUCCESS;
                        ack.return_msg  = "";
                    }
                    else
                    {
                        ack.return_flag = ApiConst.RETURN_FAIL;
                        ack.return_msg  = ErrConst.ErrCode_0007;
                    }
                }
                else
                {
                    ack.return_flag = ApiConst.RETURN_FAIL;
                    ack.return_msg  = ErrConst.ErrCode_0017;
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ex.ToString();
            }
            return(ack);
        }
Exemplo n.º 3
0
        public IHttpActionResult Register([FromBody] JObject json)
        {
            UserMst   model = JsonConvert.DeserializeObject <UserMst>(json.ToString());
            BodyInOut ack   = api.AddModel(model);

            return(Json <BodyInOut>(ack));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据会员ID——查询会员信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BodyInOut GetModel(string id)
        {
            BodyInOut ack = new BodyInOut();

            try
            {
                var model = GetBaseModel(id);
                if (model != null)
                {
                    ack.data        = model;
                    ack.return_flag = ApiConst.RETURN_SUCCESS;
                    ack.return_msg  = "";
                }
                else
                {
                    ack.return_flag = ApiConst.RETURN_FAIL;
                    ack.return_msg  = ErrConst.ErrCode_0003;
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }
            return(ack);
        }
Exemplo n.º 5
0
        public IHttpActionResult GetArea([FromBody] JObject json)
        {
            AreaForWeb model = JsonConvert.DeserializeObject <AreaForWeb>(json.ToString());
            BodyInOut  ack   = api.GetCodeByArea(model.area_id, true);

            return(Json <BodyInOut>(ack));
        }
Exemplo n.º 6
0
        public IHttpActionResult GetMenuListByUser([FromBody] JObject json)
        {
            GetRoleMenuForPost model = JsonConvert.DeserializeObject <GetRoleMenuForPost>(json.ToString());
            BodyInOut          ack   = api.GetMenuListByUser(model.user_id, model.role_id);

            return(Json <BodyInOut>(ack));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Web登录
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="pwd">密码</param>
        /// <param name="model"></param>
        /// <returns></returns>
        public BodyInOut WebLogin(string phone, string user_pwd)
        {
            BodyInOut       ack             = new BodyInOut();
            UserLoginForWeb model           = new UserLoginForWeb();
            string          sha256_user_pwd = BruceClass.Sha256(user_pwd);

            try
            {
                DataTable dt = dal.GetModel(phone);
                if (dt.Rows.Count > 0)
                {
                    string userPwd = BruceClass.DBNULLStr(dt.Rows[0]["UserPwd"]);
                    if (userPwd.Equals(sha256_user_pwd))
                    {
                        //用户角色
                        model.user_role  = BruceClass.DBNULLStr(dt.Rows[0]["UserRole"]);
                        model.user_id    = BruceClass.DBNULLStr(dt.Rows[0]["UserID"]);
                        model.nick_name  = BruceClass.DBNULLStr(dt.Rows[0]["NickName"]);
                        model.store_id   = BruceClass.DBNULLStr(dt.Rows[0]["StoreID"]);
                        model.store_name = BruceClass.DBNULLStr(dt.Rows[0]["StoreName"]);
                        model.store_logo = BruceClass.DBNULLStr(dt.Rows[0]["Logo"]);
                        model.active_flg = BruceClass.DBNULLStr(dt.Rows[0]["ActiveFlg"]);
                        ack.data         = model;

                        ack.return_flag = ApiConst.RETURN_SUCCESS;
                        ack.return_msg  = "";
                    }
                    else
                    {
                        ack.return_flag = ApiConst.RETURN_FAIL;
                        ack.return_msg  = ErrConst.ErrCode_0005;
                    }
                }
                else
                {
                    ack.return_flag = ApiConst.RETURN_FAIL;
                    ack.return_msg  = ErrConst.ErrCode_0003;
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }
            return(ack);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public BodyInOut AddModel(UserMst user)
        {
            BodyInOut ack   = new BodyInOut();
            UserLogin model = new UserLogin();

            if (Exists(user.phone))
            {
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0001;
            }
            else
            {
                user.user_id = seqNoDal.GetSeqNo(MemoConst.USER_KEY);     //采番
                if (string.IsNullOrEmpty(user.user_pwd))
                {
                    user.user_pwd = "111111";                             //默认密码为111111
                }
                user.user_pwd = BruceClass.Sha256(user.user_pwd);         //加密
                //user.user_type = MemoConst.USER_TYPE_DEFAULT;             //默认用户类型
                user.active_flg   = MemoConst.ACTIVEFLG_1;                //默认用户是否有效
                user.total_points = MemoConst.POINTS;                     //默认注册积分
                if (dal.Regist(user))
                {
                    model.user_id       = user.user_id;
                    model.nick_name     = user.nick_name;
                    model.phone         = user.phone;
                    model.photo         = user.photo;
                    model.sex           = user.sex;
                    model.mail_addr     = user.mail_addr;
                    model.active_flg    = user.active_flg;
                    model.total_points  = user.total_points;
                    model.register_time = user.register_time.ToString("yyyy-MM-dd hh:mm:ss");
                    model.open_id       = user.open_id;

                    ack.data        = model;
                    ack.return_flag = ApiConst.RETURN_SUCCESS;
                    ack.return_msg  = "";
                }
                else
                {
                    ack.return_flag = ApiConst.RETURN_FAIL;
                    ack.return_msg  = ErrConst.ErrCode_0002;
                }
            }
            return(ack);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取省市区选项值
        /// </summary>
        /// <param name="parent_id">父级区域ID</param>
        /// <returns></returns>
        public BodyInOut GetAreaByParentID(string parent_id)
        {
            BodyInOut ack = new BodyInOut();

            try
            {
                ack.data        = areaDal.GetAreaByParentID(parent_id);
                ack.return_flag = ApiConst.RETURN_SUCCESS;
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }
            return(ack);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取省市区选项值
        /// </summary>
        /// <param name="parent_id">父级区域ID</param>
        /// <param name="isDefault">默认选择</param>
        /// <returns></returns>
        public BodyInOut GetCodeByArea(string parent_id, bool isDefault)
        {
            BodyInOut ack = new BodyInOut();

            ack.function_id = ApiConst.FUNCTION_API_102;
            try
            {
                ack.data        = areaDal.GetCodeByArea(parent_id, isDefault);
                ack.return_flag = ApiConst.RETURN_SUCCESS;
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }
            return(ack);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取当前用户的菜单信息
        /// </summary>
        /// <param name="user_id">用户ID</param>
        /// <param name="role_id">用户角色ID</param>
        /// <returns></returns>
        public BodyInOut GetMenuListByUser(string user_id, string role_id)
        {
            BodyInOut ack = new BodyInOut();

            ack.function_id = ApiConst.FUNCTION_API_1002;

            try
            {
                ack.data = dal.GetMenuListByUser(user_id, role_id);

                ack.return_flag = ApiConst.RETURN_SUCCESS;
                ack.return_msg  = "";
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }

            return(ack);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="pwd">密码</param>
        /// <param name="model"></param>
        /// <returns></returns>
        public BodyInOut Login(string phone, string user_pwd, string open_id)
        {
            BodyInOut ack = new BodyInOut();

            ack.function_id = ApiConst.FUNCTION_API_1001;
            string sha256_user_pwd = BruceClass.Sha256(user_pwd);

            try
            {
                DataTable dt = dal.GetModel(phone);
                if (dt.Rows.Count > 0)
                {
                    string userPwd = BruceClass.DBNULLStr(dt.Rows[0]["UserPwd"]);
                    if (userPwd.Equals(sha256_user_pwd))
                    {
                        UserLogin model = new UserLogin();
                        model.user_id        = BruceClass.DBNULLStr(dt.Rows[0]["UserID"]);
                        model.nick_name      = BruceClass.DBNULLStr(dt.Rows[0]["NickName"]);
                        model.phone          = BruceClass.DBNULLStr(dt.Rows[0]["Phone"]);
                        model.photo          = BruceClass.DBNULLStr(dt.Rows[0]["Photo"]);
                        model.sex            = BruceClass.DBNULLStr(dt.Rows[0]["Sex"]);
                        model.mail_addr      = BruceClass.DBNULLStr(dt.Rows[0]["MailAddr"]);
                        model.active_flg     = BruceClass.DBNULLStr(dt.Rows[0]["ActiveFlg"]);
                        model.total_points   = BruceClass.DBNULLDouble(dt.Rows[0]["TotalPoints"]);
                        model.total_consume  = BruceClass.DBNULLDouble(dt.Rows[0]["TotalConsume"]);
                        model.total_recharge = BruceClass.DBNULLDouble(dt.Rows[0]["TotalRecharge"]);
                        model.user_role      = BruceClass.DBNULLStr(dt.Rows[0]["UserRole"]);
                        model.register_time  = BruceClass.DBNULLStr(dt.Rows[0]["RegisterTime"]);

                        if (string.IsNullOrEmpty(open_id))
                        {
                            model.open_id = BruceClass.DBNULLStr(dt.Rows[0]["OpenID"]);
                        }
                        else
                        {
                            model.open_id = open_id;
                        }

                        ack.data = model;

                        ack.return_flag = ApiConst.RETURN_SUCCESS;
                        ack.return_msg  = "";
                    }
                    else
                    {
                        ack.return_flag = ApiConst.RETURN_FAIL;
                        ack.return_msg  = ErrConst.ErrCode_0005;
                    }
                }
                else
                {
                    ack.return_flag = ApiConst.RETURN_FAIL;
                    ack.return_msg  = ErrConst.ErrCode_0003;
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog(ex.ToString());
                ack.return_flag = ApiConst.RETURN_FAIL;
                ack.return_msg  = ErrConst.ErrCode_0004;
            }
            return(ack);
        }