コード例 #1
0
        public JsonResult RegisterUser(WeUser.Dto.WeUserInputDto inputDto)
        {
            Common.JsonResultStatus jsonResult = new Common.JsonResultStatus();
            jsonResult.Code = 400;
            jsonResult.Msg  = "注册失败";
            if (inputDto != null)
            {
                inputDto.RegDate = DateTime.Now;
                //WeUser.Dto.WeUserOutputDto outputDto = this.weUserAppService.GetWeUserByUserId(Common.UserHelper.Instance.getUserId());
                inputDto.Id     = Common.UserHelper.Instance.getUserId();
                inputDto.IsInit = 0;

                if (this.weUserAppService.IsHasRecommendCode(inputDto.Recommend_Code))
                {
                    inputDto.Invit_Code = RandomNum(0);
                    this.weUserAppService.UpdateUser(inputDto);
                    if (inputDto != null)
                    {
                        jsonResult.Code   = 200;
                        jsonResult.Msg    = "注册成功";
                        jsonResult.Result = inputDto;
                        return(Json(jsonResult));
                    }
                }
                else
                {
                    jsonResult.Code   = 201;
                    jsonResult.Msg    = "推荐码不存在!!!";
                    jsonResult.Result = inputDto;
                    return(Json(jsonResult));
                }
            }
            return(Json(jsonResult));
        }
コード例 #2
0
        public JsonResult LoginValidate(Models.WeiXinInfo userInfo)
        {
            var user = this.weUserAppService.GetWeUser(userInfo.OpenId);

            Common.JsonResultStatus rstJson = new Common.JsonResultStatus();
            rstJson.Code = 200;
            // var user = this.weUserAppService.GetWeUser("oCbECv1pwMNyAodYQtRJVvJf_Zsg");
            if (user == null)
            {
                WeUser.Dto.WeUserInputDto input = new WeUser.Dto.WeUserInputDto();
                input.HeadImgUrl = userInfo.HeadImgUrl;
                input.NickName   = userInfo.NickName;
                input.OpenId     = userInfo.OpenId;
                input.IsInit     = 1;
                weUserAppService.CreateWeUser(input);
                rstJson.Msg = "用户第一次初始化成功,即将跳转";
                // string regUrl = string.Format("/RegisterWeChat/Index?openId={0}&HeadImgUrl={1}&NickName={2}&retUrl=", userInfo.OpenId, userInfo.HeadImgUrl, userInfo.NickName, userInfo.RetUrl);
                // rstJson.RedirectUrl = regUrl;
                rstJson.RedirectUrl = userInfo.RetUrl;
                return(Json(rstJson));
            }
            else
            {
                UserPoints.Dto.UserPointsInputDto points = new UserPoints.Dto.UserPointsInputDto();
                points.Ip     = HttpContext.Request.UserHostAddress;
                points.Score  = int.Parse(Common.CommonConst.PointsScore);
                points.UserId = user.Id;
                this.userPointAppService.AddPointsScore(points);

                string encrtpt = Common.DESEncryptEx.Encrypt(string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, userInfo.AccessToken, userInfo.OpenId));
                Logger.Debug("当前用户Cookie" + encrtpt);
                //        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                //1,
                //user.NickName,
                //DateTime.Now,
                //DateTime.Now.Add(FormsAuthentication.Timeout), true, string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, accessToken, opentid)

                //);

                //DateTime.Now.Add(FormsAuthentication.Timeout), true, string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, accessToken, openId)
                //HttpCookie cookie = new HttpCookie(
                //    Common.CommonConst.AuthSaveKey,
                //    FormsAuthentication.Encrypt(ticket));
                HttpCookie cookie = new HttpCookie(
                    Common.CommonConst.AuthSaveKey,
                    encrtpt);
                Response.Cookies.Add(cookie);
                rstJson.Msg         = "用户验证成功,即将跳转";
                rstJson.RedirectUrl = userInfo.RetUrl;
                return(Json(rstJson));
            }


            //return Json(retUrl);
        }
コード例 #3
0
        public JsonResult AlterUser(WeUser.Dto.WeUserInputDto inputDto)
        {
            Common.JsonResultStatus jsonResult = new Common.JsonResultStatus();
            jsonResult.Code = 400;
            jsonResult.Msg  = "编辑失败";
            if (inputDto != null)
            {
                inputDto.RegDate = DateTime.Now;
                //WeUser.Dto.WeUserOutputDto outputDto = this.weUserAppService.GetWeUserByUserId(Common.UserHelper.Instance.getUserId());
                inputDto.Id     = Common.UserHelper.Instance.getUserId();
                inputDto.IsInit = 0;

                this.weUserAppService.UpdateUser(inputDto);
                if (inputDto != null)
                {
                    jsonResult.Code   = 200;
                    jsonResult.Msg    = "编辑成功";
                    jsonResult.Result = inputDto;
                    return(Json(jsonResult));
                }
            }
            return(Json(jsonResult));
        }