示例#1
0
        private async Task <DashboardActivityModel> PrepareActivityModel()
        {
            var    model    = new DashboardActivityModel();
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            var storeId = string.Empty;

            if (await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }

            model.OrdersPending  = (await _orderReportService.GetOrderAverageReportLine(storeId: storeId, os: (int)OrderStatusSystem.Pending)).CountOrders;
            model.AbandonedCarts = (await _mediator.Send(new GetCustomerQuery()
            {
                StoreId = storeId, LoadOnlyWithShoppingCart = true
            })).Count();

            var lowStockProducts = await _productsReportService.LowStockProducts(vendorId, storeId);

            model.LowStockProducts = lowStockProducts.products.Count + lowStockProducts.combinations.Count;

            model.MerchandiseReturns = await _mediator.Send(new GetMerchandiseReturnCountQuery()
            {
                RequestStatusId = 0, StoreId = storeId
            });

            model.TodayRegisteredCustomers =
                (await _mediator.Send(new GetCustomerQuery()
            {
                StoreId = storeId,
                CustomerGroupIds = new string[] { (await _groupService.GetCustomerGroupBySystemName(SystemCustomerGroupNames.Registered)).Id },
                CreatedFromUtc = DateTime.UtcNow.Date
            })).Count();
            return(model);
        }