예제 #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 ListPageResponse ListPage(ListPageRequest request)
        {
            request.CheckNotNull(nameof(request));

            var pageSize = 20;
            var stores   = _storeQueryService.StoreList();
            var total    = stores.Count();

            //筛选
            if (request.Type != StoreType.All)
            {
                stores = stores.Where(x => x.Type == request.Type);
            }
            if (request.Status != StoreStatus.All)
            {
                stores = stores.Where(x => x.Status == request.Status);
            }
            if (!request.Name.IsNullOrEmpty())
            {
                stores = stores.Where(x => x.Name.Contains(request.Name));
            }
            total = stores.Count();

            //分页
            stores = stores.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new ListPageResponse
            {
                Total = total,
                Stores = stores.Select(x => new Store
                {
                    Id = x.Id,
                    UserId = x.UserId,
                    Name = x.Name,
                    Region = x.Region,
                    Address = x.Address,
                    TodayOrder = x.TodayOrder,
                    OnSaleGoodsCount = x.OnSaleGoodsCount,
                    TodaySale = x.TodaySale,
                    Description = x.Description,
                    TotalOrder = x.TotalOrder,
                    TotalSale = x.TotalSale,

                    SubjectName = x.SubjectName,
                    SubjectNumber = x.SubjectNumber,
                    SubjectPic = x.SubjectPic,
                    Type = x.Type.ToString(),
                    Status = x.Status.ToString()
                }).ToList()
            });
        }