public MerchantSupportReceiptWalletDTO GetSupportReceiptByFiatCurrency(Guid accountId, string fiatCurrency, int coinId) { var account = new MerchantAccountDAC().GetById(accountId); var crypto = new CryptocurrencyDAC().GetById(coinId); var marketPriceComponent = new MarketPriceComponent(); var marketPrice = marketPriceComponent.GetMarketPrice(fiatCurrency, crypto.Code); var supportReceiptWallets = new MerchantWalletDAC().SupportReceiptList(accountId); var singleSupportWallet = supportReceiptWallets.FirstOrDefault(e => e.CryptoId == crypto.Id); if (singleSupportWallet == null) { return(new MerchantSupportReceiptWalletDTO()); } return(new MerchantSupportReceiptWalletDTO { WalletId = singleSupportWallet.Id, CryptoId = crypto.Id, CryptoStatus = crypto.Status, CryptoCode = crypto.Code, CryptoName = crypto.Name, IconURL = crypto.IconURL, DecimalPlace = crypto.DecimalPlace, Markup = account.Markup, MarketPrice = marketPrice?.Price.ToString("F"), CryptoEnable = crypto.Enable }); }
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()); }