Beispiel #1
0
        public void UpdateLv2Info(UserAccount user, UpdateLv2InfoIM im)
        {
            var profile = new UserProfileAgent().GetUserProfile(user.Id);

            if (user.L1VerifyStatus != VerifyStatus.Certified)
            {
                throw new ApplicationException(Resources.VerificationLv1First);
            }
            if (profile.L2VerifyStatus == VerifyStatus.Certified || profile.L2VerifyStatus == VerifyStatus.UnderApproval)
            {
                throw new ApplicationException(MessageResources.AccountHasBeenVerification);
            }
            var sr = new UserProfileAgent().UpdateLv2Info(new Lv2Info
            {
                Address1       = im.Address1,
                Address2       = im.Address2,
                City           = im.City,
                Id             = user.Id,
                Postcode       = im.Postcode,
                ResidentImage  = im.ResidentImage,
                State          = im.State,
                L2VerifyStatus = VerifyStatus.UnderApproval,
                Country        = profile.Country.Value
            });

            if (sr)
            {
                new UserAccountDAC().UpdateL2VerfiyStatus(user.Id, (byte)VerifyStatus.UnderApproval);
            }
        }
Beispiel #2
0
        public void UpdateLv1Info(UserAccount user, UpdateLv1InfoIM im)
        {
            if (user.L1VerifyStatus == VerifyStatus.Certified || user.L1VerifyStatus == VerifyStatus.UnderApproval)
            {
                throw new ApplicationException(MessageResources.AccountHasBeenVerification);
            }
            var profileSDK = new UserProfileAgent();

            int count = profileSDK.GetCountByIdentityDocNo(user.Id, im.IdentityDocNo);

            if (count >= Framework.Component.Constant.IDENTITY_LIMIT)
            {
                throw new CommonException(ReasonCode.IDENTITYNO_USED_OVERLIMIT, MessageResources.IdentityUsedOverLimit);
            }

            var sr = profileSDK.UpdateLv1Info(new Lv1Info
            {
                BackIdentityImage  = im.BackIdentityImage,
                FirstName          = im.FirstName,
                FrontIdentityImage = im.FrontIdentityImage,
                HandHoldWithCard   = im.HandHoldWithCard,
                Id              = user.Id,
                IdentityDocNo   = im.IdentityDocNo,
                IdentityDocType = (byte)((im.IdentityDocType != IdentityDocType.IdentityCard && im.IdentityDocType != IdentityDocType.Passport) ? IdentityDocType.IdentityCard : im.IdentityDocType),
                LastName        = im.LastName,
                L1VerifyStatus  = VerifyStatus.UnderApproval
            });

            if (sr)
            {
                new UserAccountDAC().UpdateL1VerfiyStatus(user.Id, (byte)VerifyStatus.UnderApproval);
            }
        }
        public PreTransferOM PreTransfer(UserAccount account, PreTransferIM im)
        {
            var toAccount = new UserAccountDAC().GetByCountryIdAndCellphone(im.ToCountryId, im.ToCellphone);

            if (toAccount == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotExist);
            }
            if (account.Id == toAccount.Id)
            {
                throw new CommonException(ReasonCode.TRANSFER_TO_SELF, MessageResources.TransferToSelf);
            }
            var country        = new CountryComponent().GetById(im.ToCountryId);
            var profile        = new UserProfileAgent().GetUserProfile(toAccount.Id);
            var cryptoCurrency = new CryptocurrencyDAC().GetById(im.CoinId);
            var fromWallet     = new UserWalletComponent().GetUserWallet(account.Id, im.CoinId);

            return(new PreTransferOM
            {
                ToAvatar = toAccount.Photo ?? Guid.Empty,
                ToAccountName = country.PhoneCode + " " + toAccount.Cellphone,
                ToFullname = profile == null ? "" : ("* " + profile.LastName),
                IsTransferAbled = !toAccount.IsAllowTransfer.HasValue || toAccount.IsAllowTransfer.Value,
                IsProfileVerified = toAccount.L1VerifyStatus == VerifyStatus.Certified,
                CoinId = cryptoCurrency.Id,
                CoinCode = cryptoCurrency.Code,
                MinCount = ((decimal)Math.Pow(10, -cryptoCurrency.DecimalPlace)).ToString("G"),
                CoinDecimalPlace = cryptoCurrency.DecimalPlace.ToString(),
                CoinBalance = (fromWallet == null ? "0" : fromWallet.Balance.ToString(cryptoCurrency.DecimalPlace)),
                FiatCurrency = account.FiatCurrency,
                Price = (GetExchangeRate(account.CountryId, account.FiatCurrency, cryptoCurrency.Code)).ToString(),
                ChargeFee = "0"
            });
        }
Beispiel #4
0
        public UserProfile GetUserProfile(Guid accountGid)
        {
            var profileSDK = new UserProfileAgent();
            var data       = profileSDK.GetUserProfile(accountGid);

            return(data);
        }
        public bool FiiiPayLogin(string QRCode, UserAccount account)
        {
            if (!RedisHelper.KeyExists(0, QRCode))
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, R.无效二维码);
            }

            var profile     = new UserProfileAgent().GetUserProfile(account.Id);
            var country     = new CountryDAC().GetById(account.CountryId);
            var openAccount = new OpenAccountDAC().GetOpenAccount(FiiiType.FiiiPay, account.Id);

            if (openAccount == null)
            {
                openAccount = new OpenAccountComponent().Create((int)SystemPlatform.FiiiEX, FiiiType.FiiiPay, account.Id);
            }

            var om = new
            {
                OpenId         = openAccount.OpenId,
                AccountName    = country.PhoneCode + " " + account.Cellphone,
                UserType       = 0,//0FiiiPay 1FiiiPos
                CountryId      = country.Id,
                PosCode        = "",
                CountryName    = country.Name,
                CountryName_CN = country.Name_CN,
                FullName       = profile == null ? "" : (profile.FirstName + " " + profile.LastName),
                Cellphone      = GetMaskedCellphone(country.PhoneCode, account.Cellphone)
            };

            RedisHelper.StringSet(0, QRCode, JsonConvert.SerializeObject(om), TimeSpan.FromMinutes(5));

            return(true);
        }
Beispiel #6
0
        public TargetAccountDTO GetTargetAccount(int countryId, string cellphone)
        {
            CountryDAC     countryDac     = new CountryDAC();
            UserAccountDAC userAccountDac = new UserAccountDAC();
            Country        country        = countryDac.GetById(countryId);

            if (country == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist);
            }
            UserAccount userAccount = userAccountDac.GetByCountryIdAndCellphone(countryId, cellphone);

            if (userAccount == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist);
            }

            var profile = new UserProfileAgent().GetUserProfile(userAccount.Id);

            return(new TargetAccountDTO
            {
                Cellphone = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone),
                FullName = profile == null ? "" : ((string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName),
                Avatar = userAccount.Photo
            });
        }
Beispiel #7
0
        public List <UserAccountStatus> GetUserAccountStatusList(string cellphone, int country, int?status, ref GridPager pager)
        {
            var  profileSDK = new UserProfileAgent();
            int  totalCount = 0;
            bool isDesc     = (pager.OrderBy.ToLower() == "desc");
            var  data       = profileSDK.GetUserAccountStatusList(cellphone, country, status, pager.Size, pager.Page, out totalCount);

            pager.TotalPage = (int)Math.Ceiling((double)totalCount / (double)pager.Size);
            pager.Count     = totalCount;
            return(data);
        }
Beispiel #8
0
        public List <Entities.UserProfile> GetUserResidencePageList(string account, int countryId, int?status, ref GridPager pager)
        {
            var  profileSDK = new UserProfileAgent();
            int  totalCount = 0;
            bool isDesc     = (pager.OrderBy.ToLower() == "desc");
            var  data       = profileSDK.GetUserProfileListForL2(account, countryId, pager.SortColumn, isDesc, status, pager.Size, pager.Page, out totalCount);

            pager.TotalPage = (int)Math.Ceiling((double)totalCount / (double)pager.Size);
            pager.Count     = totalCount;
            return(data);
        }
        public ActionResult Detail(Guid id)
        {
            var pro     = new UserProfileBLL().GetUserProfile(id);
            var profile = ReflectionHelper.AutoCopy <Entities.UserProfile, UserProfileViewModel>(pro);

            profile.L1VerifyStatusName  = profile.L1VerifyStatus.HasValue ? ((VerifyStatus)profile.L1VerifyStatus.Value).ToString() : "";
            profile.IdentityDocTypeName = profile.IdentityDocType.HasValue ? ((IdentityDocType)profile.IdentityDocType.Value).ToString() : "";
            var profileSDK = new UserProfileAgent();
            int count      = profileSDK.GetCountByIdentityDocNo(profile.UserAccountId.Value, pro.IdentityDocNo);

            ViewBag.IdentityCount = count;
            return(View(profile));
        }
Beispiel #10
0
        public SaveResult SaveResidenceVerify(int AdminId, string AdminName, UserProfile profile)
        {
            var oldProfile  = GetUserProfile(profile.UserAccountId.Value);
            var userAccount = FiiiPayDB.UserAccountDb.GetById(profile.UserAccountId);

            userAccount.L2VerifyStatus = profile.L2VerifyStatus.Value;
            if (oldProfile == null)
            {
                return(new SaveResult(false, "Data error"));
            }

            var profileSDK = new UserProfileAgent();
            var status     = profileSDK.UpdateL2Status(profile.UserAccountId.Value, profile.L2VerifyStatus.Value, profile.L2Remark);

            if (status)
            {
                FiiiPayDB.UserAccountDb.Update(userAccount);
                if ((profile.L2VerifyStatus == VerifyStatus.Certified || profile.L2VerifyStatus == VerifyStatus.Disapproval))
                {
                    var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords()
                    {
                        AccountId  = profile.UserAccountId.Value,
                        Username   = userAccount.Cellphone,
                        Body       = profile.L2Remark,
                        Type       = profile.L2VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.UserLv2Verified : VerifyRecordType.UserLv2Reject,
                        CreateTime = DateTime.UtcNow
                    });
                    if (profile.L2VerifyStatus == VerifyStatus.Certified)
                    {
                        RabbitMQSender.SendMessage("UserKYC_LV2_VERIFIED", recordId);
                    }
                    else if (profile.L2VerifyStatus == VerifyStatus.Disapproval)
                    {
                        RabbitMQSender.SendMessage("UserKYC_LV2_REJECT", recordId);
                    }
                }
            }
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = AdminId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(UserProfileBLL).FullName + ".SaveResidenceVerify";
            actionLog.Username   = AdminName;
            actionLog.LogContent = string.Format("verify user residence.accountId:{0},verifystatus:{1}", profile.UserAccountId, profile.L1VerifyStatus.ToString());
            new ActionLogBLL().Create(actionLog);

            return(new SaveResult(status));
        }
Beispiel #11
0
        public PreVerifyLv1OM PreVerifyLv1(UserAccount user)
        {
            var profile = new UserProfileAgent().GetUserProfile(user.Id);

            return(new PreVerifyLv1OM
            {
                BackIdentityImage = profile.BackIdentityImage,
                FrontIdentityImage = profile.FrontIdentityImage,
                Fullname = string.IsNullOrEmpty(profile.FirstName) ? "" : (profile.FirstName + " " + profile.LastName),
                HandHoldWithCard = profile.HandHoldWithCard,
                IdentityDocNo = profile.IdentityDocNo,
                IdentityDocType = (profile.IdentityDocType != IdentityDocType.IdentityCard && profile.IdentityDocType != IdentityDocType.Passport) ? IdentityDocType.IdentityCard : profile.IdentityDocType,
                FirstName = profile.FirstName,
                LastName = string.IsNullOrEmpty(profile.FirstName) ? "" : profile.LastName
            });
        }
Beispiel #12
0
        private List <MerchantVerifyStatusOM> GetMerchanstProfileInfo(List <MerchantAccount> list)
        {
            var groupIdDic = list.GroupBy(e => e.CountryId).ToDictionary(e => e.Key, e => e.Select(a => a.Id).ToList());

            var resultList = new List <MerchantVerifyStatusOM>();

            foreach (var kv in groupIdDic)
            {
                var result = new UserProfileAgent().GetVerifyStatusListByIds(kv.Key, kv.Value);
                if (result != null)
                {
                    resultList.AddRange(result);
                }
            }
            return(resultList);
        }
Beispiel #13
0
        public PreVerifyLv2OM PreVerifyLv2(UserAccount user, bool isZH)
        {
            var profile = new UserProfileAgent().GetUserProfile(user.Id);
            var country = new CountryComponent().GetById(profile.Country.Value);

            return(new PreVerifyLv2OM
            {
                Address1 = profile.Address1,
                Address2 = profile.Address2,
                City = profile.City,
                CountryName = isZH ? country.Name_CN : country.Name,
                Postcode = profile.Postcode,
                State = profile.State,
                ResidentImage = profile.ResidentImage
            });
        }
Beispiel #14
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)
            });
        }
        public ActionResult Verify(Guid id)
        {
            var account = FiiiPayDB.UserAccountDb.GetById(id);

            ViewBag.AccountName = account.PhoneCode + " " + account.Cellphone;

            var pro     = new UserProfileBLL().GetUserProfile(id);
            var profile = ReflectionHelper.AutoCopy <Entities.UserProfile, UserProfileViewModel>(pro);

            profile.IdentityDocTypeName = profile.IdentityDocType.HasValue ? ((IdentityDocType)profile.IdentityDocType.Value).ToString() : "";
            ViewBag.VerifyStatusList    = GetVerifyStatusList();

            var profileSDK = new UserProfileAgent();
            int count      = profileSDK.GetCountByIdentityDocNo(profile.UserAccountId.Value, pro.IdentityDocNo);

            ViewBag.IdentityCount = count;

            return(View(profile));
        }
        public OrderDetailDTO OrderDetail(long accountId, Guid orderId)
        {
            InvestorOrder order = new InvestorOrderDAC().GetById(accountId, orderId);

            if (order == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.订单不存在);
            }

            UserAccount userAccount = new UserAccountDAC().GetById(order.UserAccountId);

            if (userAccount == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在);
            }
            Country country = new CountryDAC().GetById(userAccount.CountryId);

            if (country == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在);
            }


            var profile = new UserProfileAgent().GetUserProfile(userAccount.Id);

            Cryptocurrency crypto = new CryptocurrencyDAC().GetById(order.CryptoId);

            return(new OrderDetailDTO
            {
                OrderId = order.Id,
                OrderNo = order.OrderNo,
                TransactionType = order.TransactionType,
                Status = order.Status,
                CryptoCode = crypto.Code,
                Amount = order.CryptoAmount.ToString(crypto.DecimalPlace),
                UserAccount = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone),
                Username = profile == null ? "" : ((string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName),
                Timestamp = order.Timestamp.ToUnixTime()
            });
        }
        public void UpdateCellphone(UserAccount user, string cellphone)
        {
            SecurityVerify.Verify <UpdateCellphoneVerify>(new CustomVerifier("UpdateCellphone"), SystemPlatform.FiiiPay, user.Id.ToString(), (model) =>
            {
                return(model.PinVerified && model.NewCellphoneVerified);
            });

            if (new UserAccountDAC().GetByCountryIdAndCellphone(user.CountryId, cellphone) != null)
            {
                throw new ApplicationException(MessageResources.MobilePhoneHasReg);
            }

            user.Cellphone = cellphone;
            var sr = new UserProfileAgent().UpdatePhoneNumber(user.Id, cellphone);

            if (sr)
            {
                UserAccountDAC accountDAC = new UserAccountDAC();
                sr = accountDAC.UpdatePhoneNumber(user.Id, cellphone);
            }
            new UserAccountComponent().Logout(user);
        }
        public void VerifyResetPinCombine(Guid accountId, string idNumber, string smsCode, string googleCode)
        {
            UserAccount user = new UserAccountDAC().GetById(accountId);
            List <CombinedVerifyOption> options = new List <CombinedVerifyOption>
            {
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.Cellphone, Code = smsCode
                },
                new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.GooogleAuthenticator, Code = googleCode
                }
            };
            UserSecrets userSecrets = new UserSecrets
            {
                ValidationFlag      = user.ValidationFlag,
                GoogleAuthSecretKey = user.AuthSecretKey
            };
            UserProfile profile = new UserProfileAgent().GetUserProfile(user.Id);

            if (profile != null && profile.L1VerifyStatus == VerifyStatus.Certified)
            {
                options.Add(new CombinedVerifyOption {
                    AuthType = (byte)ValidationFlag.IDNumber, Code = idNumber
                });
                userSecrets.IdentityNo = profile.IdentityDocNo;
            }

            SecurityVerify.CombinedVerify(SystemPlatform.FiiiPay, user.Id.ToString(), userSecrets, options);

            var model = new ResetPinVerify()
            {
                CombinedVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("ResetPin"), SystemPlatform.FiiiPay, user.Id.ToString(), model);
        }
        public TransferDetailOM Detail(Guid accountId, long transferId)
        {
            var    transfer      = new UserTransferDAC().GetTransfer(transferId);
            Guid   showAccountId = Guid.Empty;
            string transferType  = "";

            if (accountId == transfer.FromUserAccountId)
            {
                transferType  = Resources.TransferOut;
                showAccountId = transfer.ToUserAccountId;
            }
            else if (accountId == transfer.ToUserAccountId)
            {
                transferType  = Resources.TransferInto;
                showAccountId = transfer.FromUserAccountId;
            }

            UserProfile profile        = new UserProfileAgent().GetUserProfile(showAccountId);
            var         account        = new UserAccountDAC().GetById(showAccountId);
            var         country        = new CountryComponent().GetById(profile.Country.Value);
            var         cryptoCurrency = new CryptocurrencyDAC().GetById(transfer.CoinId);

            return(new TransferDetailOM
            {
                Status = (TransactionStatus)transfer.Status,
                StatusStr = Resources.OrderCompleted,
                TradeType = Resources.Transfer,
                TransferType = transferType,
                CoinCode = transfer.CoinCode,
                Amount = transfer.Amount.ToString(cryptoCurrency.DecimalPlace),
                AccountName = country.PhoneCode + " *******" + account.Cellphone.Substring(Math.Max(0, account.Cellphone.Length - 4)),
                Fullname = profile == null ? "" : ((string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName),
                Timestamp = transfer.Timestamp.ToUnixTime().ToString(),
                OrderNo = transfer.OrderNo
            });
        }
Beispiel #20
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);
        }
Beispiel #21
0
        public SaveResult SaveProfileVerify(int AdminId, string AdminName, UserProfile profile)
        {
            var oldProfile  = GetUserProfile(profile.UserAccountId.Value);
            var userAccount = FiiiPayDB.UserAccountDb.GetById(profile.UserAccountId);

            userAccount.L1VerifyStatus = profile.L1VerifyStatus.Value;
            if (oldProfile == null)
            {
                return(new SaveResult(false, "Data error"));
            }

            var profileSDK = new UserProfileAgent();
            int count      = profileSDK.GetCountByIdentityDocNo(profile.UserAccountId.Value, oldProfile.IdentityDocNo);

            if (profile.L1VerifyStatus == VerifyStatus.Certified && count > 6)
            {
                return(new SaveResult(false, "This identty document has been used for 7 accounts, cannot be verified "));
            }
            long profitId   = 0; //被邀请人奖励ID
            long exProfitId = 0; //邀请人额外奖励ID

            bool result = profileSDK.UpdateL1Status(profile.UserAccountId.Value, profile.L1VerifyStatus.Value, profile.L1Remark);

            if (result)
            {
                FiiiPayDB.UserAccountDb.Update(userAccount);
            }
            else
            {
                profileSDK.UpdateL1Status(profile.UserAccountId.Value, oldProfile.L1VerifyStatus.Value, oldProfile.L1Remark);
            }

            if (result && profile.L1VerifyStatus == VerifyStatus.Certified)
            {
                var invite = FiiiPayDB.DB.Queryable <InviteRecords>().Where(t => t.AccountId == profile.UserAccountId.Value).First();
                if (invite != null)
                {
                    var inviteProfit = FiiiPayDB.DB.Queryable <ProfitDetails>().Where(t => t.AccountId == invite.InviterAccountId && t.InvitationId == invite.Id && t.Type == ProfitType.InvitePiiiPay).First();
                    var rewardProfit = FiiiPayDB.DB.Queryable <ProfitDetails>().Where(t => t.AccountId == invite.InviterAccountId && t.Status == InviteStatusType.IssuedFrozen && t.Type == ProfitType.Reward).OrderBy(t => t.Timestamp).First();

                    profitId = inviteProfit.Id;
                    var uwComponent = new UserWalletBLL();
                    var uwsDAC      = new UserWalletStatementDAC();
                    var uwDAC       = new UserWalletDAC();
                    var pfDAC       = new ProfitDetailDAC();
                    var utDAC       = new UserTransactionDAC();

                    int invitedCount = pfDAC.GetInvitedAndActiveCount(invite.InviterAccountId);

                    var cryptoId     = new CryptocurrencyDAC().GetByCode("FIII").Id;
                    var inviteWallet = uwComponent.GetUserWallet(invite.InviterAccountId, cryptoId);
                    if (inviteWallet == null)
                    {
                        inviteWallet = uwComponent.GenerateWallet(invite.InviterAccountId, cryptoId);
                    }

                    var inviteMoney = inviteProfit.CryptoAmount;

                    var adoResult = FiiiPayDB.DB.Ado.UseTran(() =>
                    {
                        try
                        {
                            //解冻奖励
                            uwDAC.Unfreeze(inviteWallet.Id, inviteMoney);
                            //插入奖励流水
                            uwsDAC.Insert(new UserWalletStatement
                            {
                                WalletId  = inviteWallet.Id,
                                Action    = UserWalletStatementAction.Invite,
                                Amount    = inviteMoney,
                                Balance   = inviteWallet.Balance + inviteMoney,
                                Timestamp = DateTime.UtcNow
                            });
                            //修改奖励状态为已激活
                            pfDAC.UpdateStatus(inviteProfit.Id, InviteStatusType.IssuedActive);
                            utDAC.UpdateStatus(UserTransactionType.Profit, inviteProfit.Id.ToString(), invite.InviterAccountId, (byte)InviteStatusType.IssuedActive);

                            // 每当满50人时则可以奖励 采用了插入操作 所以只要满足为49个就可以了
                            if ((invitedCount + 1) % 50 == 0)
                            {
                                exProfitId      = rewardProfit.Id;
                                var rewardMoney = rewardProfit.CryptoAmount;
                                //解冻满50人的额外奖励
                                uwDAC.Unfreeze(inviteWallet.Id, rewardMoney);
                                //插入满50人的额外奖励流水
                                uwsDAC.Insert(new UserWalletStatement
                                {
                                    WalletId  = inviteWallet.Id,
                                    Action    = UserWalletStatementAction.Reward,
                                    Amount    = rewardMoney,
                                    Balance   = inviteWallet.Balance + rewardMoney,
                                    Timestamp = DateTime.UtcNow
                                });
                                //修改奖励状态为已激活
                                pfDAC.UpdateStatus(rewardProfit.Id, InviteStatusType.IssuedActive);
                                utDAC.UpdateStatus(UserTransactionType.Profit, rewardProfit.Id.ToString(), invite.InviterAccountId, (byte)InviteStatusType.IssuedActive);
                            }
                        }
                        catch (Exception e)
                        {
                            log.Info(profile.UserAccountId + "    --------- " + e.ToString());
                        }
                    });
                    result = adoResult.Data;
                }
            }

            if (result && (profile.L1VerifyStatus == VerifyStatus.Certified || profile.L1VerifyStatus == VerifyStatus.Disapproval))
            {
                var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords()
                {
                    AccountId  = profile.UserAccountId.Value,
                    Username   = userAccount.Cellphone,
                    Body       = profile.L1Remark,
                    Type       = profile.L1VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.UserLv1Verified : VerifyRecordType.UserLv1Reject,
                    CreateTime = DateTime.UtcNow
                });
                if (profile.L1VerifyStatus == VerifyStatus.Certified)
                {
                    RabbitMQSender.SendMessage("UserKYC_LV1_VERIFIED", recordId);
                }
                else if (profile.L1VerifyStatus == VerifyStatus.Disapproval)
                {
                    RabbitMQSender.SendMessage("UserKYC_LV1_REJECT", recordId);
                }
            }

            if (result && profitId > 0)
            {
                RabbitMQSender.SendMessage("UserInviteSuccessed", profitId);
            }
            if (result && exProfitId > 0)
            {
                RabbitMQSender.SendMessage("UserInviteSuccessed", profitId);
            }
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = AdminId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(UserProfileBLL).FullName + ".SaveProfileVerify";
            actionLog.Username   = AdminName;
            actionLog.LogContent = string.Format("verify user profile.accountId:{0},verifystatus:{1}", profile.UserAccountId, profile.L1VerifyStatus.ToString());
            new ActionLogBLL().Create(actionLog);

            return(new SaveResult(result));
        }