public SimpleUserInfoOM GetSimpleUserInfoOM(UserAccount user) { //var profile = new UserProfileAgent().GetUserProfile(user.Id); var country = new CountryComponent().GetById(user.CountryId); var fiatId = new CurrenciesDAC().GetByCode(user.FiatCurrency).ID; if (IsNullOrWhiteSpace(user.Nickname)) { user.Nickname = GenerateNickname(); } return(new SimpleUserInfoOM { Avatar = user.Photo, Cellphone = GetMaskedCellphone(country.PhoneCode, user.Cellphone), //不再读取profile表 FullName = user.Nickname,//profile == null ? "" : ((IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName), Nickname = user.Nickname, UserId = user.Id.ToString(), IsBaseProfileComplated = true,// profile != null, IsLV1Verified = user.L1VerifyStatus == VerifyStatus.Certified, HasSetPin = !IsNullOrEmpty(user.Pin), SecretKey = user.SecretKey, InvitationCode = user.InvitationCode, FiatId = fiatId, FiatCode = user.FiatCurrency }); }
public void SettingFiatCurrency(Guid accountId, string fiatCurrency) { var list = new CurrenciesDAC().GetAll(); if (list.All(e => e.Code != fiatCurrency)) { throw new CommonException(ReasonCode.GENERAL_ERROR, "Fiat currency error."); } var dac = new MerchantAccountDAC(); dac.SettingFiatCurrency(accountId, fiatCurrency); }
public IndexOM Index(UserAccount user) { try { var isBillerEnable = bool.Parse(new MasterSettingDAC().Single("BillerMaxAmount", "BillerEnable").Value); var userWallets = new UserWalletDAC().GetUserWallets(user.Id); var currencyId = new CurrenciesDAC().GetByCode(user.FiatCurrency).ID; var exchangeRateList = new PriceInfoDAC().GetByCurrencyId(currencyId); var exchangeRate = exchangeRateList.ToDictionary(item => item.CryptoID); var coins = new CryptocurrencyDAC().GetAllActived().OrderBy(e => e.Sequence).ToList(); var list = coins.Select(a => { var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id); var rate = exchangeRate.ContainsKey(a.Id) ? exchangeRate[a.Id].Price : 0m; return(GetItem(userWallet, a, rate)); }).Where(a => a.ShowInHomePage) //.OrderBy(a => a.HomePageRank) .Select(a => new CurrencyItem { Id = a.Id, Code = a.Code, NewStatus = a.NewStatus, FrozenBalance = a.FrozenBalance, IconUrl = a.IconUrl, UseableBalance = a.UseableBalance, FiatBalance = a.FiatBalance, FiatExchangeRate = exchangeRate.ContainsKey(a.Id) ? exchangeRate[a.Id].Price.ToString(4) : 0m.ToString(4), CryptoEnable = a.CryptoEnable }).ToList(); return(new IndexOM { TotalAmount = GetUserTotalAmount(user, userWallets, coins, exchangeRateList), CurrencyItemList = list, IsLV1Verified = user.L1VerifyStatus == VerifyStatus.Certified, HasSetPin = !string.IsNullOrEmpty(user.Pin), FiatCurrency = user.FiatCurrency, IsBillerEnable = isBillerEnable }); } catch (Exception exception) { Error(exception.StackTrace); return(new IndexOM { TotalAmount = "--", CurrencyItemList = null, FiatCurrency = user.FiatCurrency }); } }
public List <MerchantWalletDTO> GetMerchantWalletList(Guid merchantAccountId) { var account = new MerchantAccountDAC().GetById(merchantAccountId); var cryptoList = new CryptocurrencyDAC().GetAllActived(); cryptoList.MoveTop(t => t.Code == FIIICOIN_CODE); var pos = new POSDAC().GetById(account.POSId.Value); if (!pos.IsWhiteLabel) { cryptoList.RemoveAll(t => t.IsWhiteLabel == 1); } else { cryptoList.MoveTop(t => t.Code == pos.FirstCrypto); } var walletList = new MerchantWalletDAC().GetByAccountId(merchantAccountId); var currencyId = new CurrenciesDAC().GetByCode(account.FiatCurrency).ID; var exchangeRate = new PriceInfoDAC().GetByCurrencyId(currencyId).ToDictionary(item => item.CryptoID); return(cryptoList.Select(e => { var wallet = walletList.FirstOrDefault(w => w.CryptoId == e.Id); return new MerchantWalletDTO { WalletId = wallet?.Id ?? 0, CryptoId = e.Id, CryptoStatus = e.Status, CryptoCode = e.Code, CryptoName = e.Name, IconURL = e.IconURL, DecimalPlace = e.DecimalPlace, Balance = (wallet?.Balance ?? 0).ToString(e.DecimalPlace), FrozenBalance = (wallet?.FrozenBalance ?? 0).ToString(e.DecimalPlace), FiatExchangeRate = (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m).ToString(4), FiatBalance = (((wallet?.Balance ?? 0) + (wallet?.FrozenBalance ?? 0)) * (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m)).ToString(4), FiatCode = account.FiatCurrency, CryptoEnable = e.Enable }; }).ToList()); }
public List <Currencies> GetList(bool isZH) { var currencyList = new CurrenciesDAC().GetAll(); var list = new List <Currencies>(); if (currencyList == null || currencyList.Count <= 0) { return(new List <Currencies>()); } foreach (var item in currencyList) { list.Add(new Currencies { ID = item.ID, Name = isZH ? item.Name_CN : item.Name, Code = item.Code }); } return(list); }
public MerchantWalletDTO GetWalletInfoById(Guid accountId, int cryptoId) { var crypto = new CryptocurrencyDAC().GetById(cryptoId); var wallet = new MerchantWalletDAC().GetByAccountId(accountId, cryptoId); var merchant = new MerchantAccountDAC().GetById(accountId); var currencyId = new CurrenciesDAC().GetByCode(merchant.FiatCurrency).ID; var exchangeRate = new PriceInfoDAC().GetByCurrencyId(currencyId).ToDictionary(item => item.CryptoID); return(new MerchantWalletDTO { WalletId = wallet?.Id ?? 0, CryptoId = crypto.Id, CryptoCode = crypto.Code, CryptoName = crypto.Name, IconURL = crypto.IconURL, DecimalPlace = crypto.DecimalPlace, Balance = (wallet?.Balance ?? 0).ToString(crypto.DecimalPlace), FrozenBalance = (wallet?.FrozenBalance ?? 0).ToString(crypto.DecimalPlace), FiatExchangeRate = (exchangeRate.ContainsKey(crypto.Id) ? exchangeRate[crypto.Id].Price : 0m).ToString(4), FiatBalance = (((wallet?.Balance ?? 0) + (wallet?.FrozenBalance ?? 0)) * (exchangeRate.ContainsKey(crypto.Id) ? exchangeRate[crypto.Id].Price : 0m)).ToString(4), FiatCode = merchant.FiatCurrency }); }