public ServiceResult <WithdrawalResult> Withdrawal(WithdrawalModel model) { var result = new ServiceResult <WithdrawalResult>(); if (!ModelState.IsValid) { result.Code = ReasonCode.MISSING_REQUIRED_FIELDS; foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage))) { result.Message += error + Environment.NewLine; } return(result); } var ip = this.GetClientIPAddress(); var accountId = this.GetMerchantAccountId(); var data = new MerchantWalletComponent().Withdrawal(accountId, model.Amount, model.CryptoId, model.Address, model.Tag, ip); result.Data = new WithdrawalResult { Id = data.Id, Timestamp = data.Timestamp.ToUnixTime(), OrderNo = data.OrderNo }; result.Success(); return(result); }
public ServiceResult <MerchantSupportReceiptWalletDTO> GetSupportReceiptByFiatCurrency(string fiatCurrency, int coinId) { var result = new ServiceResult <MerchantSupportReceiptWalletDTO>(); var accountId = this.GetMerchantAccountId(); var cpt = new MerchantWalletComponent(); result.Data = cpt.GetSupportReceiptByFiatCurrency(accountId, fiatCurrency, coinId); return(result); }
public ServiceResult <List <MerchantSupportReceiptWalletDTO> > SupportReceiptList() { var result = new ServiceResult <List <MerchantSupportReceiptWalletDTO> >(); var accountId = this.GetMerchantAccountId(); var cpt = new MerchantWalletComponent(); result.Data = cpt.SupportReceiptList(accountId); return(result); }
public string FiiiPOSTransferInto(MerchantAccount account, Cryptocurrency coin, decimal amount) { var walletDac = new MerchantWalletDAC(); var wallet = walletDac.GetByAccountId(account.Id, coin.Id); MerchantExTransferOrder order; using (var scope = new TransactionScope()) { if (wallet == null) { wallet = new MerchantWalletComponent().GenerateWallet(account.Id, coin.Id); } walletDac.Increase(wallet.Id, amount); order = new MerchantExTransferOrder { Timestamp = DateTime.UtcNow, OrderNo = CreateOrderNo(), OrderType = ExTransferType.FromEx, AccountId = account.Id, WalletId = wallet.Id, CryptoId = coin.Id, CryptoCode = coin.Code, Amount = amount, Status = 1, Remark = null, ExId = null }; new MerchantExTransferOrderDAC().Create(order); scope.Complete(); } try { FiiiEXTransferMSMQ.PubMerchantTransferFromEx(order.Id, 0); } catch (Exception ex) { LogHelper.Info("PubMerchantTransferFromEx - error", ex); } return(order.OrderNo); }
public ServiceResult Setting(SettingCrytocurrencyModel model) { var result = new ServiceResult(); if (!ModelState.IsValid) { result.Code = ReasonCode.MISSING_REQUIRED_FIELDS; foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage))) { result.Message += error + Environment.NewLine; } return(result); } var component = new MerchantWalletComponent(); var accountId = this.GetMerchantAccountId(); component.SettingCrytocurrencies(accountId, model.CryptoIds); result.Success(); return(result); }
public TransferResult FiiiPOSTransferFromEx(Guid accountId, int cryptoId, decimal amount, string pinToken) { var securityVerify = new SecurityVerification(SystemPlatform.FiiiPOS); securityVerify.VerifyToken(accountId, pinToken, SecurityMethod.Pin); var openAccountDac = new OpenAccountDAC(); var openAccount = openAccountDac.GetOpenAccount(FiiiType.FiiiPOS, accountId); if (openAccount == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.FiiiExAccountNotExist); } var crypto = new CryptocurrencyDAC().GetById(cryptoId); if (crypto == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.CurrencyForbidden); } var balance = this.FiiiExBalance(FiiiType.FiiiPOS, accountId, crypto); if (balance < amount) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.余额不足); } var walletDac = new MerchantWalletDAC(); var wallet = walletDac.GetByAccountId(accountId, crypto.Id); //10091=参数不符合要求 10013=用户信息不存在 10024=用户币不存在 10025=用户币种余额不足 0=成功 int result = FiiiExCoinOut(openAccount.OpenId, crypto.Code, amount, out string recordId); if (result != 0) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.划转到FiiiEx失败); } MerchantExTransferOrder order; using (var scope = new TransactionScope()) { if (wallet == null) { wallet = new MerchantWalletComponent().GenerateWallet(accountId, cryptoId); } walletDac.Increase(wallet.Id, amount); order = new MerchantExTransferOrder { Timestamp = DateTime.UtcNow, OrderNo = CreateOrderNo(), OrderType = ExTransferType.FromEx, AccountId = accountId, WalletId = wallet.Id, CryptoId = crypto.Id, CryptoCode = crypto.Code, Amount = amount, Status = 1, Remark = null, ExId = recordId }; new MerchantExTransferOrderDAC().Create(order); scope.Complete(); } try { FiiiEXTransferMSMQ.PubMerchantTransferFromEx(order.Id, 0); } catch (Exception ex) { LogHelper.Info("PubMerchantTransferFromEx - error", ex); } return(new TransferResult { Id = order.Id, Amount = order.Amount.ToString(crypto.DecimalPlace), OrderNo = order.OrderNo, Timestamp = order.Timestamp.ToUnixTime(), CryptoCode = crypto.Code }); }