예제 #1
0
        /// <summary>
        /// 职员登录
        /// </summary>
        public HttpResponseMessage EmployeeLogin(RequestModel request)
        {
            var result = WebHelper.GetResult <string>(request);

            if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功))
            {
                var model = employeeService.Login(StringHelper.Get(request.Obj["account"]), StringHelper.Get(request.Obj["password"]));
                if (!VerifyHelper.IsEmpty(model) && !VerifyHelper.IsEmpty(model.Id))
                {
                    WebHelper.SetEmployee(model);
                    result.Code     = EnumHelper.GetValue(EnumResultCode.跳转地址);
                    result.Redirect = UrlsHelper.GetRefUrl(defaultUrl: WebHelper.GetManageUrl());
                }
            }
            return(WebApiHelper.ToHttpResponseMessage(result));
        }
예제 #2
0
        /// <summary>
        /// 找回密码
        /// </summary>
        public HttpResponseMessage MemberForgetPwd(RequestModel request)
        {
            var result = WebHelper.GetResult <string>(request);

            if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功))
            {
                string receiver = "", mobile = JsonHelper.GetValue(request.Obj, "Mobile"),
                       email    = JsonHelper.GetValue(request.Obj, "Email"),
                       code     = JsonHelper.GetValue(request.Obj, "Code"),
                       pwd      = JsonHelper.GetValue(request.Obj, "Pwd"),
                       sendType = JsonHelper.GetValue(request.Obj, "SendType");
                Guid taskId     = GuidHelper.Get(JsonHelper.GetValue(request.Obj, "TaskId"));

                #region  入信息判断

                if (VerifyHelper.IsEmpty(sendType) ||
                    (sendType != KeyModel.Config.Template.KeyForgetPwdMobile && sendType != KeyModel.Config.Template.KeyForgetPwdEmail))
                {
                    throw new MessageException(EnumMessageCode.信息错误);
                }

                if ((VerifyHelper.IsEmpty(mobile) && VerifyHelper.IsEmpty(email)) || VerifyHelper.IsEmpty(taskId))
                {
                    throw new MessageException(EnumMessageCode.信息错误);
                }

                if (sendType == KeyModel.Config.Template.KeyForgetPwdMobile && VerifyHelper.IsEmpty(mobile))
                {
                    throw new MessageException(EnumMessageCode.请输入手机号码);
                }

                if (sendType == KeyModel.Config.Template.KeyForgetPwdEmail && VerifyHelper.IsEmpty(email))
                {
                    throw new MessageException(EnumMessageCode.请输入邮箱地址);
                }

                if (VerifyHelper.IsEmpty(pwd))
                {
                    throw new MessageException(EnumMessageCode.请输入密码);
                }

                if (VerifyHelper.IsEmpty(code))
                {
                    throw new MessageException(EnumMessageCode.请输入验证码);
                }

                #endregion

                receiver = sendType == KeyModel.Config.Template.KeyForgetPwdMobile ? mobile : email;

                //验证码效验
                bool isSuccess = notificationService.ConfirmVerifyCode(taskId, receiver, code, request.CurrentContext.VisitId);
                if (!isSuccess)
                {
                    throw new MessageException(EnumMessageCode.验证码错误);
                }

                //找回密码修改
                var entity = memberService.MemberForgetPwd(email, mobile, pwd, BrowserHelper.GetClientIP());
                if (VerifyHelper.IsEmpty(entity))
                {
                    throw new MessageException(EnumMessageCode.找回密码失败);
                }

                //返回
                if (!VerifyHelper.IsEmpty(entity) && !VerifyHelper.IsEmpty(entity.Id))
                {
                    notificationService.ExpireVerifyCode(taskId);
                    WebHelper.SetMember(entity);
                    result.Code     = EnumHelper.GetValue(EnumResultCode.跳转地址);
                    result.Redirect = UrlsHelper.GetRefUrl(defaultUrl: WebHelper.GetMemberUrl());
                }
            }
            return(WebApiHelper.ToHttpResponseMessage(result));
        }
예제 #3
0
        /// <summary>
        /// 会员注册
        /// </summary>
        public HttpResponseMessage MemberRegist(RequestModel request)
        {
            var result = WebHelper.GetResult <string>(request);

            if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功))
            {
                string receiver = "", mobile = JsonHelper.GetValue(request.Obj, "Mobile"),
                       email    = JsonHelper.GetValue(request.Obj, "Email"),
                       code     = JsonHelper.GetValue(request.Obj, "Code"),
                       pwd      = JsonHelper.GetValue(request.Obj, "Pwd"),
                       nameTag  = JsonHelper.GetValue(request.Obj, "NameTag"),
                       sendType = JsonHelper.GetValue(request.Obj, "SendType");
                Guid taskId     = GuidHelper.Get(JsonHelper.GetValue(request.Obj, "TaskId"));

                #region  入信息判断

                if (VerifyHelper.IsEmpty(sendType) ||
                    (sendType != KeyModel.Config.Template.KeyRegistMobile && sendType != KeyModel.Config.Template.KeyRegistEmail))
                {
                    throw new MessageException(EnumMessageCode.信息错误);
                }

                if ((VerifyHelper.IsEmpty(mobile) && VerifyHelper.IsEmpty(email)) || VerifyHelper.IsEmpty(taskId))
                {
                    throw new MessageException(EnumMessageCode.信息错误);
                }

                if (sendType == KeyModel.Config.Template.KeyRegistMobile && VerifyHelper.IsEmpty(mobile))
                {
                    throw new MessageException(EnumMessageCode.请输入手机号码);
                }

                if (sendType == KeyModel.Config.Template.KeyRegistEmail && VerifyHelper.IsEmpty(email))
                {
                    throw new MessageException(EnumMessageCode.请输入邮箱地址);
                }

                if (VerifyHelper.IsEmpty(pwd))
                {
                    throw new MessageException(EnumMessageCode.请输入密码);
                }

                if (VerifyHelper.IsEmpty(code))
                {
                    throw new MessageException(EnumMessageCode.请输入验证码);
                }

                #endregion

                receiver = sendType == KeyModel.Config.Template.KeyRegistMobile ? mobile : email;

                //验证码效验
                bool isSuccess = notificationService.ConfirmVerifyCode(taskId, receiver, code, request.CurrentContext.VisitId);
                if (!isSuccess)
                {
                    throw new MessageException(EnumMessageCode.验证码错误);
                }

                //注册
                var entity = memberService.Regist(receiver, email, mobile, pwd, nameTag, BrowserHelper.GetClientIP());
                if (VerifyHelper.IsEmpty(entity))
                {
                    throw new MessageException(EnumMessageCode.注册失败);
                }
                //首次注册,送100元, 添加充值记录信息
                rechargeRecordService.Insert(new RechargeRecordEntity
                {
                    AccountId  = entity.Id,
                    MoneyValue = 100,
                    Descript   = "注册赠送",
                    CreateId   = entity.Id,
                    CreateDt   = DateTime.Now,
                    LastId     = entity.Id,
                    LastDt     = DateTime.Now
                });
                //返回
                if (!VerifyHelper.IsEmpty(entity) && !VerifyHelper.IsEmpty(entity.Id))
                {
                    notificationService.ExpireVerifyCode(taskId);
                    WebHelper.SetMember(entity);
                    result.Code     = EnumHelper.GetValue(EnumResultCode.跳转地址);
                    result.Redirect = UrlsHelper.GetRefUrl(defaultUrl: WebHelper.GetMemberUrl());
                }
            }
            return(WebApiHelper.ToHttpResponseMessage(result));
        }