Example #1
0
        public GetBenevolenceTransfersResponse BenevolenceTransfers([FromBody] BenevolenceTransfersRequest request)
        {
            request.CheckNotNull(nameof(request));

            //获取数据
            int pageSize             = 10;
            var benevolenceTransfers = _walletQueryService.GetBenevolenceTransfers(request.WalletId);
            var total = benevolenceTransfers.Count();

            //筛选数据
            if (request.Type != BenevolenceTransferType.All)
            {
                benevolenceTransfers = benevolenceTransfers.Where(x => x.Type == request.Type);
            }
            total = benevolenceTransfers.Count();
            //分页
            benevolenceTransfers = benevolenceTransfers.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new GetBenevolenceTransfersResponse
            {
                Total = total,
                BenevolenceTransfers = benevolenceTransfers.Select(x => new BenevolenceTransfer
                {
                    Number = x.Number,
                    Amount = x.Amount,
                    Fee = x.Fee,
                    FinallyValue = x.FinallyValue,
                    Remark = x.Remark,
                    CreatedOn = x.CreatedOn.ToShortDateString(),
                    Type = x.Type.ToDescription(),
                    Direction = x.Direction.ToDescription(),
                    Status = x.Status.ToDescription()
                }).ToList()
            });
        }
Example #2
0
        public BaseApiResponse DashBoard()
        {
            var users           = _userQueryService.UserList();
            var wallets         = _walletQueryService.AllWallets();
            var stores          = _storeQueryService.StoreList();
            var storeOrders     = _storeOrderQueryService.StoreOrderList();
            var rechargeApplyes = _walletQueryService.RechargeApplyLogs();
            var incentiveBenevolenceTransfers = _walletQueryService.GetBenevolenceTransfers(BenevolenceTransferType.Incentive);

            return(new DashBoardResponse
            {
                UserCount = users.Count(),
                NewRegCount = users.Where(x => x.CreatedOn > DateTime.Now.AddDays(-7)).Count(),
                AmbassadorCount = users.Where(x => x.Role == UserRole.Ambassador).Count(),
                NewAmbassadorCount = users.Where(x => x.CreatedOn > DateTime.Now.AddDays(-7) && x.Role == UserRole.Ambassador).Count(),

                CashTotal = wallets.Sum(x => x.Cash),
                LockedCashTotal = wallets.Sum(x => x.LockedCash),
                RechargeApplysTotal = rechargeApplyes.Where(x => x.Status == RechargeApplyStatus.Placed).Sum(x => x.Amount),
                BenevolenceTotal = wallets.Sum(x => x.Benevolence),
                TodayBenevolenceAddedTotal = wallets.Sum(x => x.TodayBenevolenceAdded),
                LastIncentiveAmount = incentiveBenevolenceTransfers.Where(x => x.CreatedOn.Date.Equals(DateTime.Now.Date)).Sum(x => x.Amount),
                TotalIncentiveAmount = incentiveBenevolenceTransfers.Sum(x => x.Amount),

                TotalSale = stores.Sum(x => x.TotalSale),
                TodaySale = stores.Sum(x => x.TodaySale),
                StoreOrderCount = stores.Sum(x => x.TotalOrder),
                TodayStoreOrderCount = stores.Sum(x => x.TodayOrder),

                TodayOrderProfit = storeOrders.Where(x => x.CreatedOn.Date == DateTime.Now.Date).Sum(x => x.Total) - storeOrders.Where(x => x.CreatedOn.Date == DateTime.Now.Date).Sum(x => x.StoreTotal),
                TotalOrderProfit = storeOrders.Sum(x => x.Total) - storeOrders.Sum(x => x.StoreTotal)
            });
        }