public List <GetMerchantInfoOM> GetMerchantInfoList(GetMerchantInfoListIM im) { if (im.PageSize > 20) { im.PageSize = 20; } List <MerchantBriefInformation> list; if (im.Location == null) { list = new MerchantInformationDAC().QueryMerchantListByCountryId(im.Filter.CountryId, im.PageIndex, im.PageSize, im.Filter.KeyWord, im.Filter.Category); } else { list = new MerchantInformationDAC().QueryNearbyMerchantList(im.Location.Latitude, im.Location.Longitude, im.Filter.CountryId, im.PageSize, im.PageIndex, im.Filter.KeyWord, im.Filter.Category); } var mwDAC = new MerchantWalletDAC(); var mscDAC = new MerchantSupportCryptoDAC(); var cryptoList = new CryptoComponent().GetList(); return(list.Select(item => { List <int> supportCryptoIdList = new List <int>(); if (item.AccountType == (byte)AccountType.Merchant) { supportCryptoIdList = mwDAC.SupportReceiptList(item.MerchantAccountId).Select(t => t.CryptoId).ToList(); } else { supportCryptoIdList = mscDAC.GetList(item.Id).Select(t => t.CryptoId).ToList(); } return new GetMerchantInfoOM() { AccountType = item.AccountType, IsAllowExpense = item.IsAllowExpense, Address = item.Address, AvailableCryptoIconList = cryptoList.Where(c => supportCryptoIdList.Contains(c.Id)).Select(t => t.IconURL.ToString()).ToList(), Distance = item.Distance.ToSpecificDecimal(2).ToString(CultureInfo.InvariantCulture), OriginIconId = item.FileId, CompressIconId = item.ThumbnailId ?? Guid.Empty, Id = item.MerchantInformationId, Location = new Location() { Longitude = item.Lng, Latitude = item.Lat }, Tags = item.Tags.Split(',').ToList(), Title = item.MerchantName }; }).ToList()); }
public List <MerchantSupportReceiptWalletDTO> SupportReceiptList(Guid accountId) { var account = new MerchantAccountDAC().GetById(accountId); var dac = new MerchantWalletDAC(); var cryptoList = new CryptocurrencyDAC().GetAllActived(); var fiiiCrypto = cryptoList.First(w => w.Code == FIIICOIN_CODE); var fiiiWallet = dac.GetByAccountId(account.Id, fiiiCrypto.Id) ?? GenerateWallet(accountId, fiiiCrypto.Id, fiiiCrypto.Code, FIIICOIN_SEQUENCE, true); if (!fiiiWallet.SupportReceipt || fiiiWallet.Sequence != FIIICOIN_SEQUENCE) { dac.Support(account.Id, fiiiWallet.CryptoId, FIIICOIN_SEQUENCE); } List <MerchantWallet> supportReceiptList; var pos = new POSDAC().GetById(account.POSId.Value); if (pos.IsWhiteLabel) { var whiteCrypto = cryptoList.First(w => w.Code == pos.FirstCrypto); var whiteWallet = dac.GetByAccountId(account.Id, whiteCrypto.Id); if (whiteWallet == null) { GenerateWallet(accountId, whiteCrypto.Id, whiteCrypto.Code, WHITECOIN_SEQUENCE, true); } else if (!whiteWallet.SupportReceipt || whiteWallet.Sequence != WHITECOIN_SEQUENCE) { dac.Support(account.Id, whiteWallet.CryptoId, WHITECOIN_SEQUENCE); } supportReceiptList = dac.SupportReceiptList(accountId).OrderBy(e => e.Sequence).ToList(); } else { var whiteCryptoList = cryptoList.Where(e => e.IsWhiteLabel == 1).ToList(); supportReceiptList = dac.SupportReceiptList(accountId).OrderBy(e => e.Sequence).ToList(); supportReceiptList.RemoveAll(e => whiteCryptoList.Exists(a => a.Id == e.CryptoId)); } var marketPriceList = new PriceInfoDAC().GetPrice(account.FiatCurrency); return(supportReceiptList.Select(e => { var crypto = cryptoList.FirstOrDefault(w => w.Id == e.CryptoId); if (crypto == null) { return null; } return new MerchantSupportReceiptWalletDTO { WalletId = e.Id, CryptoId = crypto.Id, CryptoStatus = crypto.Status, CryptoCode = crypto.Code, CryptoName = crypto.Name, IconURL = crypto.IconURL, DecimalPlace = crypto.DecimalPlace, Markup = account.Markup, MarketPrice = marketPriceList.FirstOrDefault(m => crypto.Code == m.CryptoName)?.Price.ToString(4), Balance = string.Equals("FIII", crypto.Code, StringComparison.CurrentCultureIgnoreCase) ? e.Balance : 0, IsDefault = e.CryptoId == fiiiCrypto.Id || (pos.IsWhiteLabel && crypto.Code == pos.FirstCrypto) ? 1 : 0, CryptoEnable = crypto.Enable }; }).Where(w => w != null).ToList()); }