Ejemplo n.º 1
0
 public ServiceResult <PrePayOM> PrePay(PrePayIM im)
 {
     return(new ServiceResult <PrePayOM>
     {
         Data = new OrderComponent().PrePay(this.GetUser(), im)
     });
 }
Ejemplo n.º 2
0
        public PrePayOM PrePay(UserAccount user, PrePayIM im)
        {
            var merchantAccount = GetMerchantAccountByIdOrCode(im.MerchantId, im.MerchantCode);
            var userWallets     = new UserWalletDAC().GetUserWallets(user.Id);
            var merchantWallets = new MerchantWalletDAC().GetByAccountId(merchantAccount.Id);
            var coins           = new CryptocurrencyDAC().GetAllActived();
            var priceList       = new PriceInfoDAC().GetPrice(merchantAccount.FiatCurrency);

            bool showWhiteLable = false;

            if (merchantAccount.POSId.HasValue)
            {
                var pos = new POSDAC().GetById(merchantAccount.POSId.Value);
                if (pos.IsWhiteLabel)
                {
                    showWhiteLable = true;
                }
            }

            if (!showWhiteLable)
            {
                var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode();
                coins.RemoveAll(t => t.Code == whilteLabelCryptoCode);
            }

            return(new PrePayOM
            {
                FiatCurrency = merchantAccount.FiatCurrency,
                MarkupRate = merchantAccount.Markup.ToString(CultureInfo.InvariantCulture),
                WaletList = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    decimal rate = 0;
                    rate = priceList.Where(t => t.CryptoID == a.Id).Select(t => t.Price).FirstOrDefault();
                    return GetItem(userWallet, a, merchantWallets, rate);
                }).OrderByDescending(a => a.MerchantSupported).ThenBy(a => a.PayRank).Select(a => new WalletItem
                {
                    Code = a.Code,
                    NewStatus = a.NewStatus,
                    ExchangeRate = a.ExchangeRate,
                    FrozenBalance = a.FrozenBalance,
                    IconUrl = a.IconUrl,
                    Id = a.Id,
                    MerchantSupported = a.MerchantSupported,
                    Name = a.Name,
                    UseableBalance = a.UseableBalance,
                    FiatBalance = a.FiatBalance,
                    DecimalPlace = a.DecimalPlace,
                    CryptoEnable = a.CryptoEnable
                }).ToList()
            });
        }