예제 #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)
            });
        }
예제 #2
0
        private void Process()
        {
            var wallets = _walletQueryService.AllWallets().Where(x => x.WeekWithdrawAmount > 0);

            if (wallets.Any())
            {
                foreach (var wallet in wallets)
                {
                    var command = new ClearWeekWithdrawAmountCommand()
                    {
                        AggregateRootId = wallet.Id
                    };
                    _commandService.SendAsync(command);
                }
            }
        }