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 }); }