Exemplo n.º 1
0
        public TransactionHistoryResponse GetTransactions(int page, DateTime?startDate = null, DateTime?endDate = null, TransactionType?transactionType = null)
        {
            var pageSize = 10;

            var dateTimeOffset = DateTimeOffset.Now.AddYears(-1);

            var filteredQueryable = _reportQueries.GetPlayerTransactionRecords(PlayerId, false)
                                    .Where(o => o.CreatedOn >= dateTimeOffset);

            if (startDate != null)
            {
                filteredQueryable = filteredQueryable
                                    .Where(o => o.CreatedOn >= startDate.Value);
            }

            if (endDate != null)
            {
                filteredQueryable = filteredQueryable
                                    .Where(o => o.CreatedOn <= endDate.Value);
            }

            if (transactionType != null)
            {
                filteredQueryable = filteredQueryable
                                    .Where(o => o.Type == transactionType.ToString());
            }

            var orderedQueryable = filteredQueryable
                                   .OrderByDescending(o => o.CreatedOn);

            var transactions = orderedQueryable
                               .Skip(pageSize * page)
                               .Take(pageSize)
                               .ToList();

            var totalItemsCount = orderedQueryable.Count();

            var result = transactions.Select(o => new Transaction
            {
                CreatedOn            = o.CreatedOn.ToString("yyyy/MM/dd HH:mm"),
                TransactionType      = o.Type.ToString(),
                TransactionNumber    = o.TransactionNumber,
                Amount               = o.MainBalanceAmount,
                AmountFormatted      = o.MainBalanceAmount.Format(o.CurrencyCode, false),
                MainBalance          = o.MainBalance,
                MainBalanceFormatted = o.MainBalance.Format(o.CurrencyCode, false)
            });

            return(new TransactionHistoryResponse
            {
                Transactions = result,
                PageSize = pageSize,
                TotalItemsCount = totalItemsCount
            });
        }
Exemplo n.º 2
0
        public IHttpActionResult Transactions([FromUri] SearchPackage searchPackage, Guid playerId)
        {
            var dataBuilder = new SearchPackageDataBuilder <PlayerTransactionRecord>(searchPackage, _reportQueries.GetPlayerTransactionRecords(playerId, false));

            return(Ok(dataBuilder
                      .Map(r => r.TransactionId, r => new object[]
            {
                r.Type,
                r.MainBalanceAmount + r.BonusBalanceAmount + r.TemporaryBalanceAmount
                + r.LockBonusAmount + r.LockFraudAmount + r.LockWithdrawalAmount,
                r.MainBalance + r.BonusBalance + r.TemporaryBalance,
                r.CreatedOn.ToString("yyyy/MM/dd HH:mm:ss zzz"),
                r.Wallet,
                r.CurrencyCode,
                r.Description,
                r.PerformedBy,
                //r.TransactionNumber
                r.TransactionId,
                r.RelatedTransactionId
            })
                      .GetPageData(r => r.TransactionId)));
        }
Exemplo n.º 3
0
        public TransactionListResponse PlayerTransactionItems(int page, DateTime?startDate = null, DateTime?endDate = null, Guid?gameId = null)
        {
            var pageSize = 10;

            var items = _reportQueries
                        .GetPlayerTransactionRecords(PlayerId)
                        .Where(x =>
                               x.Type == TransactionType.BetWon.ToString() ||
                               x.Type == TransactionType.BetLost.ToString());

            if (startDate.HasValue)
            {
                items = items.Where(x => x.CreatedOn >= startDate.Value);
            }
            if (endDate.HasValue)
            {
                items = items.Where(x => x.CreatedOn <= endDate.Value);
            }
            if (gameId.HasValue)
            {
                items = items.Where(x => x.GameId == gameId.Value);
            }
            var totalCount = items.Count();

            items = items.OrderBy(x => x.CreatedOn)
                    .Skip(pageSize * page)
                    .Take(pageSize);
            var transactionItemsResponses = items
                                            .ToList()
                                            .Select(x =>
            {
                TransactionType type;
                Enum.TryParse(x.Type, out type);
                var lastBet = _reportQueries
                              .GetPlayerTransactionRecords(PlayerId)
                              .Where(y => y.Type == TransactionType.BetPlaced.ToString())
                              .Where(y => y.CreatedOn < x.CreatedOn)
                              .Where(y => y.GameId == x.GameId)
                              .OrderByDescending(y => y.CreatedOn)
                              .First();
                var amount = x.MainBalanceAmount + x.BonusBalanceAmount + x.TemporaryBalanceAmount
                             + x.LockBonusAmount + x.LockFraudAmount + x.LockWithdrawalAmount;
                if (type == TransactionType.BetLost)
                {
                    amount = amount + -1;
                }

                var transactionItemResponse = new TransactionItemResponse
                {
                    Id = x.TransactionId,
                    TransactionType = type,
                    Amount          = amount,
                    AmountFormatted = amount.Format(lastBet.CurrencyCode, false, DecimalDisplay.ShowNonZeroOnly),
                    GameName        = _gameQueries.GetGameDto(x.GameId.Value).Name,
                    Date            = x.CreatedOn,
                    RoundId         = x.RoundId.ToString(),
                    Bet             = (lastBet.MainBalanceAmount + lastBet.BonusBalanceAmount + lastBet.TemporaryBalanceAmount
                                       + lastBet.LockBonusAmount + lastBet.LockFraudAmount + lastBet.LockWithdrawalAmount) * -1
                };

                transactionItemResponse.BetFormatted = transactionItemResponse.Bet.Format(
                    lastBet.CurrencyCode,
                    false,
                    DecimalDisplay.ShowNonZeroOnly);

                return(transactionItemResponse);
            });

            return(new TransactionListResponse
            {
                Items = transactionItemsResponses,
                TotalItemsCount = totalCount
            });
        }