Beispiel #1
0
        //public CreateQrCodeResult CreateQrCode()
        //{
        //    var set = SetWeChatService.GetById(1);
        //    var access_token = AccessTokenContainer.GetToken(set.appID);
        //    return Senparc.Weixin.MP.AdvancedAPIs.QrCodeApi.Create(access_token, 0, 001);

        //}

        public ResultMessage Save()
        {
            try
            {
                //if (string.IsNullOrWhiteSpace(openID))
                //    return new ResultMessage() { Code = -1, Msg = "请重新进入页面!" };
                //var account = AccountService.GetByopenID(openID);
                //if (account != null)
                //    return new ResultMessage() { Code = -1, Msg = "你已注册!" };
                var user = MembershipService.GetByMobile(Mobile);
                if (user != null)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "手机号码已注册,请更换!"
                           }
                }
                ;
                if (string.IsNullOrWhiteSpace(Password))
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "请输入密码!"
                           }
                }
                ;
                if (Password != PasswordConfirm)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "两次输入密码不一致!"
                           }
                }
                ;
                var     site       = SiteService.Query(new SiteRequest()).FirstOrDefault();
                int     salerId    = 0;
                Account saleAccont = null;
                if (!string.IsNullOrWhiteSpace(orangeKey))
                {
                    saleAccont = AccountService.GetByorangeKey(orangeKey);

                    if (saleAccont == null)
                    {
                        return new ResultMessage()
                               {
                                   Code = -2, Msg = "推荐码不存在!"
                               }
                    }
                    ;
                    salerId = saleAccont.accountId;
                }
                TransactionHelper.BeginTransaction();
                AccountUser modelUser = new AccountUser();
                modelUser.Address     = Address;
                modelUser.DisplayName = Name;
                modelUser.Email       = Email;
                modelUser.Gender      = Sex;
                modelUser.Mobile      = Mobile;
                modelUser.Name        = Mobile;
                modelUser.SetPassword(Password);
                modelUser.State = UserStates.Normal;
                MembershipService.CreateUser(modelUser);
                Account modelAccount = new Account();
                //var QrCodeResult = CreateQrCode();
                //modelAccount.ticket = QrCodeResult.ticket;
                modelAccount.activatePoint = 0;
                //modelAccount.notActivatePoint = 0;
                modelAccount.orangeKey = modelUser.UserId.ToString().PadLeft(modelUser.UserId.ToString().Length + 2, '0');
                //modelAccount.payPoint = 0;
                modelAccount.openID = openID;
                //modelAccount.presentExp = site.givePoint;
                modelAccount.salerId    = salerId;
                modelAccount.state      = AccountStates.Normal;
                modelAccount.submitTime = DateTime.Now;
                modelAccount.userId     = modelUser.UserId;
                modelAccount.grade      = AccountGrade.not;
                AccountService.Insert(modelAccount);
                if (salerId > 0)
                {
                    RecommendLog recommendlog = new RecommendLog();
                    recommendlog.remark     = string.Format("推荐了{0}", Mobile);
                    recommendlog.salerId    = saleAccont.userId;
                    recommendlog.submitTime = DateTime.Now;
                    recommendlog.userId     = modelUser.UserId;
                    recommendlog.userName   = Mobile;
                    RecommendLogService.Insert(recommendlog);
                }
                TransactionHelper.Commit();
                return(new ResultMessage()
                {
                    Code = 0
                });
            }
            catch (Exception ex)
            {
                Log4netService.Insert(ex);
                return(new ResultMessage()
                {
                    Code = -1, Msg = "系统错误!"
                });
            }
        }