Пример #1
0
        public BaseApiResponse DashBoard()
        {
            var users   = _userQueryService.UserList();
            var wallets = _walletQueryService.AllWallets();
            var stores  = _storeQueryService.StoreList();
            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),
                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)
            });
        }
Пример #2
0
        public GetBenevolenceTransfersResponse BenevolenceTransfers(BenevolenceTransfersRequest request)
        {
            request.CheckNotNull(nameof(request));

            TryInitUserModel();
            //获取数据
            int pageSize             = 10;
            var benevolenceTransfers = _walletQueryService.GetBenevolenceTransfers(_wallet.Id);
            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,
                    Remark = x.Remark,
                    CreatedOn = x.CreatedOn.ToShortDateString(),
                    Type = x.Type.ToDescription(),
                    Direction = x.Direction.ToDescription()
                }).ToList()
            });
        }