Ejemplo n.º 1
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)
            });
        }
Ejemplo n.º 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));
            }
            if (!request.Region.IsNullOrEmpty())
            {
                stores = stores.Where(x => x.Region.Contains(request.Region));
            }
            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,
                    Mobile = x.Mobile,
                    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(),
                    IsLocked = x.IsLocked,
                    Status = x.Status.ToString()
                }).ToList()
            });
        }
Ejemplo n.º 3
0
        public void ResetTodayStatistic()
        {
            //遍历所有的店铺发送指令
            var stores = _storeQueryService.StoreList().Where(x => x.TodayOrder > 0 || x.TodaySale > 0);

            if (stores.Any())
            {
                foreach (var store in stores)
                {
                    var command = new ResetTodayStatisticCommand
                    {
                        AggregateRootId = store.Id
                    };
                    _commandService.SendAsync(command);
                }
            }
        }