Exemplo n.º 1
0
        public InfoOM Info(UserAccount user, bool isZH)
        {
            var agent = new UserProfileAgent();

            var profile = agent.GetUserProfile(user.Id);
            var country = new CountryComponent().GetById(user.CountryId);

            if (profile == null)
            {
                var userProfile = new UserProfile
                {
                    Country        = user.CountryId,
                    LastName       = "F" + RandomAlphaNumericGenerator.GenerateCode(8),
                    UserAccountId  = user.Id,
                    Cellphone      = user.Cellphone,
                    L1VerifyStatus = VerifyStatus.Uncertified,
                    L2VerifyStatus = VerifyStatus.Uncertified
                };
                var hasCreate = agent.AddProfile(userProfile);
                if (hasCreate)
                {
                    profile = userProfile;
                    _log.Info("Create profile info success. user id = " + user.Id);
                }
                else
                {
                    _log.Error("Create profile info error. user id = " + user.Id);
                }

                _log.Error("get profile info error, user id = " + user.Id);
            }

            return(new InfoOM
            {
                Avatar = user.Photo,
                Birthday = profile.DateOfBirth?.ToUnixTime().ToString(),
                Cellphone = new UserAccountComponent().GetMaskedCellphone(country.PhoneCode, user.Cellphone),
                CountryName = isZH ? country.Name_CN : country.Name,
                Email = new UserAccountComponent().GetMaskedEmail(user.Email),
                FullName = (string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName,
                Gender = profile.Gender,
                VerifiedStatus = GetVerifiedStatus(user)
            });
        }
Exemplo n.º 2
0
        private bool Register(int countryId, string cellphone, string password, string inviterCode)
        {
            var country   = new CountryComponent().GetById(countryId);
            var accountId = Guid.NewGuid();

            var userAccount = new UserAccount
            {
                Id                = accountId,
                PhoneCode         = country.PhoneCode,
                Cellphone         = cellphone,
                CountryId         = countryId,
                IsAllowExpense    = true,
                Email             = null,
                IsAllowWithdrawal = true,
                IsVerifiedEmail   = false,
                IsAllowTransfer   = true,
                Password          = PasswordHasher.HashPassword(password),
                Photo             = null,
                Pin               = null,
                RegistrationDate  = DateTime.UtcNow,
                SecretKey         = accountId.ToString().ToUpper(),
                Status            = 1,
                FiatCurrency      = country.FiatCurrency,
                InvitationCode    = GenerateInvitationCode(),
                InviterCode       = inviterCode,
                Nickname          = GenerateNickname(),
                ValidationFlag    = (byte)ValidationFlag.Cellphone
            };

            var userProfile = new UserProfile
            {
                Country        = countryId,
                LastName       = "F" + RandomAlphaNumericGenerator.GenerateCode(8),
                UserAccountId  = userAccount.Id,
                Cellphone      = cellphone,
                L1VerifyStatus = VerifyStatus.Uncertified,
                L2VerifyStatus = VerifyStatus.Uncertified
            };

            var accountDAC    = new UserAccountDAC();
            var agent         = new UserProfileAgent();
            var profileResult = agent.AddProfile(userProfile);

            if (profileResult)
            {
                try
                {
                    accountDAC.Insert(userAccount);
                }
                catch
                {
                    agent.RemoveProfile(userProfile);
                    throw;
                }

                //if (!string.IsNullOrEmpty(inviterCode))
                //{
                //    try
                //    {
                //        new InviteComponent().InsertRecord(new DTO.Invite.InviteRecordIM
                //        {
                //            InvitationCode = inviterCode,
                //            BeInvitedAccountId = userAccount.Id,
                //            Type = SystemPlatform.FiiiPay
                //        });
                //    }
                //    catch (Exception ex)
                //    {
                //        agent.RemoveProfile(userProfile);
                //        accountDAC.RemoveById(userAccount.Id);
                //        Error($"InviteComponent.InsertRecord faild:BeInvitedAccountId={userAccount.Id},InvitationCode={inviterCode},Type={SystemPlatform.FiiiPay.ToString()}", ex);
                //        throw ex;
                //    }
                //}
                return(true);
            }

            throw new CommonException(ReasonCode.GENERAL_ERROR, MessageResources.NetworkError);
        }