public DetailOM Detail(UserAccount user, long id, bool isZH)
        {
            var data = new UserDepositDAC().GetById(user.Id, id);

            if (data == null || data.UserAccountId != user.Id)
            {
                throw new SystemErrorException();
            }

            var om = new DetailOM
            {
                CryptoAmount  = data.Amount.ToString(),
                Code          = data.CryptoCode,
                Id            = data.Id,
                OrderNo       = data.OrderNo,
                StatusStr     = new UserStatementComponent().GetStatusStr(0, (int)data.Status, isZH),
                Status        = data.Status,
                Timestamp     = data.Timestamp.ToUtcTimeTicks().ToString(),
                Type          = Resources.Deposit,
                SelfPlatform  = data.SelfPlatform,
                TransactionId = data.SelfPlatform ? null : data.TransactionId,
            };

            bool showCheckTime = data.CryptoCode != "XRP";

            if (showCheckTime && !data.SelfPlatform &&
                om.Status == TransactionStatus.Pending &&
                data.RequestId.HasValue)
            {
                var agent      = new FiiiFinanceAgent();
                var statusInfo = agent.GetDepositStatus(data.RequestId.Value);
                om.CheckTime = $"{statusInfo.TotalConfirmation}/{statusInfo.MinRequiredConfirmation}";
            }
            return(om);
        }
        public PreDepositOM PreDeposit(UserAccount user, int cryptoId)
        {
            var dac    = new UserWalletDAC();
            var wallet = dac.GetByAccountId(user.Id, cryptoId) ?? new UserWalletComponent().GenerateWallet(user.Id, cryptoId);
            var coin   = new CryptocurrencyDAC().GetById(cryptoId);

            if (string.IsNullOrEmpty(wallet.Address))
            {
                var agent       = new FiiiFinanceAgent();
                var addressInfo = agent.CreateWallet(coin.Code, user.Id, AccountTypeEnum.User, user.Email, user.Cellphone);
                if (string.IsNullOrWhiteSpace(addressInfo.Address))
                {
                    throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.FailedGenerateAddress);
                }

                wallet.Address = addressInfo.Address;
                wallet.Tag     = addressInfo.DestinationTag;

                dac.UploadAddress(wallet.Id, wallet.Address, wallet.Tag);
            }

            return(new PreDepositOM
            {
                Address = wallet.Address,
                Tag = wallet.Tag,
                Code = coin.Code,
                NeedTag = coin.NeedTag
            });
        }
Example #3
0
 public SaveResult GetStatus(int CountryId, long RequestId)
 {
     try
     {
         var status = new FiiiFinanceAgent().GetStatus(RequestId);
         return(new SaveResult(true, status.TotalConfirmation + " / " + status.MinRequiredConfirmation));
     }
     catch (CommonException ex)
     {
         return(new SaveResult(false, ex.Message));
     }
 }
        //private string CreateOrderno()
        //{
        //    return DateTime.Now.ToUnixTime() + new Random().Next(0, 100).ToString("00");
        //}

        public WithdrawDetailOM Detail(UserAccount user, long id, bool isZH)
        {
            var data = new UserWithdrawalDAC().GetById(user.Id, id);
            //var agent = FiiiFinanceFactory.GetByCountryId(user.CountryId.Value);
            //var markPrice = agent.GetMarketPrice(user.FiatCurrency, data.CryptoCode);
            var wallet = new UserWalletDAC().GetById(data.UserWalletId);
            var coin   = new CryptocurrencyDAC().GetById(wallet.CryptoId);

            var fee = new UserWithdrawalFeeDAC().GetByWithdrawalId(id) ?? new UserWithdrawalFee {
                Amount = 0
            };

            data.Amount = data.Amount - fee.Fee;

            var om = new WithdrawDetailOM
            {
                Address      = data.Address,
                Tag          = data.Tag,
                CryptoAmount = data.Amount.ToString(coin.DecimalPlace),
                //FiatAmount = (markPrice.Price * data.Amount.Value).ToString(2),
                Code    = coin.Code,
                NeedTag = coin.NeedTag,
                //FiatCurrency = user.FiatCurrency,
                Id             = data.Id,
                OrderNo        = data.OrderNo,
                StatusStr      = new UserStatementComponent().GetStatusStr(1, (int)data.Status, isZH),
                Status         = data.Status,
                Timestamp      = data.Timestamp.ToUnixTime().ToString(),
                TransactionFee = data.WithdrawalFee.ToString(coin.DecimalPlace),
                Type           = Resources.Withdrawal,
                SelfPlatform   = data.SelfPlatform,
                TransactionId  = data.SelfPlatform ? "-" : data.TransactionId ?? "-",
                Remark         = data.Remark// data.Status == TransactionStatus.Cancelled ? MessageResources.提币失败备注 : null
            };

            bool showCheckTime = coin.Code != "XRP";

            if (showCheckTime && !data.SelfPlatform &&
                om.Status == TransactionStatus.Pending &&
                data.RequestId.HasValue)
            {
                var agent      = new FiiiFinanceAgent();
                var statusInfo = agent.GetStatus(data.RequestId.Value);
                om.CheckTime     = $"{statusInfo.TotalConfirmation}/{statusInfo.MinRequiredConfirmation}";
                om.TransactionId = statusInfo.TransactionID;
            }

            return(om);
        }
        public DepositAddressInfo GetDepositAddressById(Guid accountId, int cryptoId)
        {
            var crypto = new CryptocurrencyDAC().GetById(cryptoId);

            if (crypto == null)
            {
                throw new CommonException(ReasonCode.RECORD_NOT_EXIST, Resources.支持的币种);
            }

            if (!crypto.Status.HasFlag(CryptoStatus.Deposit))
            {
                throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden);
            }

            if (crypto.Enable == (byte)CurrencyStatus.Forbidden)
            {
                throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden);
            }

            var dac    = new MerchantWalletDAC();
            var wallet = dac.GetByAccountId(accountId, cryptoId) ?? GenerateWallet(accountId, cryptoId, crypto.Code);

            if (string.IsNullOrEmpty(wallet.Address))
            {
                var accountDAC = new MerchantAccountDAC();
                var account    = accountDAC.GetById(accountId);

                var result = new FiiiFinanceAgent().CreateWallet(crypto.Code, account.Id, AccountTypeEnum.Merchant, account.Email, $"{account.PhoneCode}{account.Cellphone}");
                if (string.IsNullOrWhiteSpace(result.Address))
                {
                    throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.FailedGenerateAddress);
                }

                wallet.Address = result.Address;
                wallet.Tag     = result.DestinationTag;

                dac.UploadAddress(wallet.Id, wallet.Address, wallet.Tag);
            }

            return(new DepositAddressInfo {
                Address = wallet.Address, Tag = wallet.Tag, NeedTag = crypto.NeedTag
            });
        }
Example #6
0
        public MerchantWithdrawalDTO WithdrawalDetail(Guid accountId, long withdrawalId)
        {
            var dac     = new MerchantWithdrawalDAC();
            var account = new MerchantAccountDAC().GetById(accountId);
            var data    = dac.GetById(accountId, withdrawalId);

            if (data == null)
            {
                return(null);
            }

            var crypto = new CryptocurrencyDAC().GetById(data.CryptoId);
            var result = new MerchantWithdrawalDTO
            {
                TransactionType   = TransactionType.Withdrawal,
                TransactionStatus = data.Status == TransactionStatus.UnSubmit ? TransactionStatus.Pending : data.Status,
                Address           = data.Address,
                Tag            = data.Tag,
                NeedTag        = crypto.NeedTag,
                Amount         = (data.Amount - data.WithdrawalFee).ToString(crypto.DecimalPlace),
                Timestamp      = data.Timestamp.ToUnixTime(),
                OrderNo        = data.OrderNo,
                TransactionFee = data.WithdrawalFee.ToString(crypto.DecimalPlace),
                CryptoCode     = crypto.Code,
                SelfPlatform   = data.SelfPlatform,
                TransactionId  = data.SelfPlatform ? "-" : data.TransactionId ?? "-",
                Remark         = data.Remark,
                AvatarId       = account.Photo
            };

            bool showCheckTime = crypto.Code != "XRP";

            if (showCheckTime && !data.SelfPlatform &&
                result.TransactionStatus == TransactionStatus.Pending &&
                data.RequestId.HasValue)
            {
                var statusInfo = new FiiiFinanceAgent().GetStatus(data.RequestId.Value);
                result.CheckTime     = $"{statusInfo.TotalConfirmation}/{statusInfo.MinRequiredConfirmation}";
                result.TransactionId = statusInfo.TransactionID;
            }

            return(result);
        }
        public AddAddressOM AddAddress(UserAccount user, string address, string tag, string alias, int coinId)
        {
            var crypto = new CryptocurrencyDAC().GetById(coinId);

            CryptoAddressValidation.ValidateAddress(crypto.Code, address);
            if (!string.IsNullOrEmpty(tag))
            {
                CryptoAddressValidation.ValidateTag(crypto.Code, tag);
            }

            var agent = new FiiiFinanceAgent();

            try
            {
                if (!agent.ValidateAddress(crypto.Code, address))
                {
                    throw new CommonException(ReasonCode.GENERAL_ERROR, GeneralResources.EMInvalidAddress);
                }
            }
            catch (FiiiFinanceException ex)
            {
                if (ex.ReasonCode == 20002)
                {
                    throw new CommonException(ReasonCode.GENERAL_ERROR, GeneralResources.EMInvalidAddress);
                }
            }
            var id = new CryptoAddressDAC().Insert(new CryptoAddress
            {
                AccountId   = user.Id,
                AccountType = AccountType.User,
                Address     = address,
                Tag         = tag,
                Alias       = alias,
                CryptoId    = coinId,
            });

            return(new AddAddressOM
            {
                Id = id
            });
        }
Example #8
0
        public MerchantDepositDTO DepositDetail(Guid accountId, long depositId)
        {
            var dac     = new MerchantDepositDAC();
            var account = new MerchantAccountDAC().GetById(accountId);
            var data    = dac.GetById(accountId, depositId);

            if (data == null)
            {
                return(null);
            }
            var crypto = new CryptocurrencyDAC().GetById(data.CryptoId);
            var result = new MerchantDepositDTO
            {
                Id = data.Id,
                TransactionType   = TransactionType.Deposit,
                TransactionStatus = data.Status,
                //Address = data.FromAddress,
                Amount = data.Amount.ToString(crypto.DecimalPlace),
                //FaitAmount = (markPrice.Price * data.Amount.Value).ToString("F", CultureInfo.InvariantCulture),
                //FaitCurrency = account.FiatCurrency,
                Timestamp     = data.Timestamp.ToUnixTime(),
                OrderNo       = data.OrderNo,
                CryptoCode    = crypto.Code,
                SelfPlatform  = data.SelfPlatform,
                TransactionId = data.SelfPlatform ? "-" : data.TransactionId ?? "-"
            };

            if (!data.SelfPlatform &&
                result.TransactionStatus == TransactionStatus.Pending &&
                data.RequestId.HasValue)
            {
                var statusInfo = new FiiiFinanceAgent().GetDepositStatus(data.RequestId.Value);
                result.CheckTime = $"{statusInfo.TotalConfirmation}/{statusInfo.MinRequiredConfirmation}";
            }

            return(result);
        }