public List <StatementDTO> List(long accountId, long?startTimestamp, long?endTimestamp, InvestorTransactionType?transactionType, string cellphone, int pageIndex, int pageSize) { InvestorOrderDAC orderDac = new InvestorOrderDAC(); var results = string.IsNullOrEmpty(cellphone) ? orderDac.SelectAndStatments(accountId, startTimestamp, endTimestamp, pageIndex, pageSize, transactionType) : orderDac.SelectByUserCellphone(accountId, startTimestamp, endTimestamp, cellphone, pageIndex, pageSize); return(results.Select(e => new StatementDTO { Id = e.Id, TransactionType = e.TransactionType, Amount = e.Amount.ToString(FiiiCoinUtility.Cryptocurrency.DecimalPlace), Timestamp = e.Timestamp.ToUnixTime() }).ToList()); }
public OrderDetailDTO OrderDetail(long accountId, Guid orderId) { InvestorOrder order = new InvestorOrderDAC().GetById(accountId, orderId); if (order == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.订单不存在); } UserAccount userAccount = new UserAccountDAC().GetById(order.UserAccountId); if (userAccount == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在); } Country country = new CountryDAC().GetById(userAccount.CountryId); if (country == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在); } var profile = new UserProfileAgent().GetUserProfile(userAccount.Id); Cryptocurrency crypto = new CryptocurrencyDAC().GetById(order.CryptoId); return(new OrderDetailDTO { OrderId = order.Id, OrderNo = order.OrderNo, TransactionType = order.TransactionType, Status = order.Status, CryptoCode = crypto.Code, Amount = order.CryptoAmount.ToString(crypto.DecimalPlace), UserAccount = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone), Username = profile == null ? "" : ((string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName), Timestamp = order.Timestamp.ToUnixTime() }); }
public TransferResult Transfer(InvestorAccount account, int countryId, string cellphone, decimal amount, string pinToken) { new SecurityVerification(SystemPlatform.FiiiCoinWork).VerifyToken(pinToken, SecurityMethod.Pin); CountryDAC countryDac = new CountryDAC(); UserAccountDAC userAccountDac = new UserAccountDAC(); Country country = countryDac.GetById(countryId); if (country == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist); } UserAccount userAccount = userAccountDac.GetByCountryIdAndCellphone(countryId, cellphone); if (userAccount == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist); } InvestorAccountDAC accountDac = new InvestorAccountDAC(); if (account.Balance < amount) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.余额不足); } UserWalletDAC userWalletDac = new UserWalletDAC(); UserWallet userWallet = userWalletDac.GetByAccountId(userAccount.Id, FiiiCoinUtility.Cryptocurrency.Id); InvestorOrder investorOrder; UserDeposit userDeposit; using (var scope = new TransactionScope()) { if (userWallet == null) { userWallet = new UserWalletComponent().GenerateWallet(userAccount.Id, FiiiCoinUtility.Cryptocurrency.Id); } accountDac.Decrease(account.Id, amount); investorOrder = new InvestorOrderDAC().Insert(new InvestorOrder { Id = Guid.NewGuid(), OrderNo = CreateOrderNo(), TransactionType = InvestorTransactionType.Transfer, Status = 1, InverstorAccountId = account.Id, UserAccountId = userAccount.Id, CryptoId = FiiiCoinUtility.Cryptocurrency.Id, CryptoAmount = amount, Timestamp = DateTime.UtcNow }); new InvestorWalletStatementDAC().Insert(new InvestorWalletStatement { Id = Guid.NewGuid(), InvestorId = account.Id, TagAccountId = userAccount.Id, Action = InvestorTransactionType.Transfer, Amount = -amount, Balance = account.Balance - amount, Timestamp = DateTime.UtcNow }); // 2018-06-26: new rules IncreaseFrozen -> Increase userWalletDac.Increase(userWallet.Id, amount); userDeposit = new UserDepositDAC().Insert(new UserDeposit { UserAccountId = userAccount.Id, UserWalletId = userWallet.Id, FromAddress = null, FromTag = null, ToAddress = null, ToTag = null, Amount = amount, Status = TransactionStatus.Confirmed, Timestamp = DateTime.UtcNow, OrderNo = CreateOrderNo(), TransactionId = account.Id.ToString(), SelfPlatform = true, RequestId = null }); scope.Complete(); } InvestorMSMQ.PubUserDeposit(userDeposit.Id, 0); return(new TransferResult { OrderId = investorOrder.Id, OrderNo = investorOrder.OrderNo, TargetAccount = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone), Timestamp = DateTime.UtcNow.ToUnixTime() }); }