Пример #1
0
        public ActionResult Index()
        {
            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators"))
            {
                var allRoles         = _customerService.GetAllCustomerRoles(true);
                var registeredRoleId = allRoles.First(x => x.SystemName.IsCaseInsensitiveEqual(SystemCustomerRoleNames.Registered)).Id;

                AdminDashboardModel model = new AdminDashboardModel();
                model.RegisteredMembers = _customerService.GetAllCustomers(null, null, new int[] { registeredRoleId }, null,
                                                                           null, null, null, 0, 0, null, null, null,
                                                                           false, null, 0, int.MaxValue).TotalCount;
                model.ActiveMembers = _customerPlanService.GetAllCustomerPlans().Select(x => x.CustomerId).Distinct().Count();
                model.ActiveMembers = model.ActiveMembers + _boardService.GetAllPosition(1, 0, false, 0, int.MaxValue).Select(x => x.CustomerId).Distinct().Count();
                int[] StatusIds          = "2".ToIntArray();
                int[] TranscationTypeIds = { (int)TransactionType.Withdrawal };
                var   transcation        = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                                  StatusIds, TranscationTypeIds, 0, int.MaxValue);

                model.CompletedWithdrawals = transcation.Sum(x => x.Amount);

                StatusIds   = "1".ToIntArray();
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIds, 0, int.MaxValue);
                model.PendingWithdrawals = transcation.Sum(x => x.Amount);

                StatusIds = "2".ToIntArray();
                int[] TranscationTypeIdsC = { (int)TransactionType.Commission };
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIdsC, 0, int.MaxValue);
                model.CommissionPaid = transcation.Sum(x => x.Amount);

                StatusIds = "2".ToIntArray();
                int[] TranscationTypeIdsD = { (int)TransactionType.Funding };
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIdsD, 0, int.MaxValue);
                model.TotalDeposit  = transcation.Sum(x => x.Amount);
                model.TodaysDeposit = transcation.Where(x => x.TransactionDate.Day == DateTime.Today.Day &&
                                                        x.TransactionDate.Month == DateTime.Today.Month &&
                                                        x.TransactionDate.Year == DateTime.Today.Year).Sum(x => x.Amount);

                StatusIds   = "1,2".ToIntArray();
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIds, 0, int.MaxValue);
                model.TodaysWithdrawal = transcation.Where(x => x.TransactionDate.Day == DateTime.Today.Day &&
                                                           x.TransactionDate.Month == DateTime.Today.Month &&
                                                           x.TransactionDate.Year == DateTime.Today.Year).Sum(x => x.Amount);

                var    plans = _planService.GetAllPlans();
                double totalInvestors = 0, totalInvestment = 0, totalROIPaid = 0, totalROIToPay = 0, totalPendingROI = 0;
                foreach (var plan in plans)
                {
                    var           plandetails   = _customerPlanService.GetAllCustomerPlans(0, plan.Id).ToList();
                    DashboardPlan dashboardPlan = new DashboardPlan();
                    dashboardPlan.Name               = plan.Name;
                    dashboardPlan.TotalInvestors     = plandetails.Select(x => x.CustomerId).Distinct().Count().ToString();
                    dashboardPlan.TotalInvestment    = plandetails.Sum(x => x.AmountInvested).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.ROIPaid            = plandetails.Sum(x => x.ROIPaid).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.ROIToPay           = plandetails.Sum(x => x.ROIToPay).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.PendingROI         = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.TotalInvestorsInt  = plandetails.Select(x => x.CustomerId).Distinct().Count();
                    dashboardPlan.TotalInvestmentInt = plandetails.Sum(x => x.AmountInvested);
                    dashboardPlan.ROIPaidInt         = plandetails.Sum(x => x.ROIPaid);
                    dashboardPlan.ROIToPayInt        = plandetails.Sum(x => x.ROIToPay);
                    dashboardPlan.PendingROIInt      = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid));

                    totalInvestors  = Convert.ToInt32(totalInvestors) + Convert.ToInt32(dashboardPlan.TotalInvestorsInt);
                    totalInvestment = Convert.ToDouble(totalInvestment) + Convert.ToDouble(dashboardPlan.TotalInvestmentInt);
                    totalROIPaid    = Convert.ToDouble(totalROIPaid) + Convert.ToDouble(dashboardPlan.ROIPaidInt);
                    totalROIToPay   = Convert.ToDouble(totalROIToPay) + Convert.ToDouble(dashboardPlan.ROIToPayInt);
                    totalPendingROI = Convert.ToDouble(totalPendingROI) + Convert.ToDouble(dashboardPlan.PendingROIInt);
                    model.Plans.Add(dashboardPlan);
                }
                DashboardPlan plantotal = new DashboardPlan();
                plantotal.Name            = "Total";
                plantotal.TotalInvestors  = totalInvestors.ToString();
                plantotal.TotalInvestment = totalInvestment.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.ROIPaid         = totalROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.ROIToPay        = totalROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.PendingROI      = totalPendingROI.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                model.Plans.Add(plantotal);
                return(View("Dashboard", model));
            }
            else
            {
                HomeModel model = new HomeModel();
                model.ReferralLink = _services.StoreContext.CurrentStore.Url + "?r=" + _workContext.CurrentCustomer.Id;
                var id = _workContext.CurrentCustomer.Id;
                model.AvailableBalance = _customerService.GetAvailableBalance(id);
                //model.RepurchaseBalance = _customerService.GetRepurchaseBalance(id);
                model.CompletedWithdrawal = _customerService.GetCustomerCompletedWithdrawal(id);
                model.PendingWithdrawal   = _customerService.GetCustomerPendingWithdrawal(id);
                model.TotalEarning        = _customerService.GetCustomerTotalEarnings(id);
                model.TotalIncome         = model.TotalEarning;
                model.CyclerIncome        = _customerService.GetCustomerCyclerBonus(id);
                model.DirectBonus         = _customerService.GetCustomerDirectBonus(id);
                model.UnilevelEarning     = _customerService.GetCustomerUnilevelBonus(id);
                model.PoolShare           = _customerService.GetCustomerROI(id) + _customerService.GetRepurchaseROI(id);
                model.TotalReferral       = _customerService.GetCustomerDirectReferral(id).Count();
                model.InvestorId          = id.ToString();
                model.Name                    = _workContext.CurrentCustomer.GetFullName();
                model.ReferredBy              = _customerService.GetCustomerById(_workContext.CurrentCustomer.AffiliateId).GetFullName();
                model.RegistrationDate        = _workContext.CurrentCustomer.CreatedOnUtc.ToLongDateString();
                model.Status                  = _workContext.CurrentCustomer.CustomerPosition.Count() > 0 ? "Active" : "Inactive";
                model.VacationModelExpiryDate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate).ToShortDateString();
                var custPositions   = _boardService.GetAllPosition(0, _workContext.CurrentCustomer.Id, false, 0, int.MaxValue).ToList();
                var cycledPositions = _boardService.GetAllPosition(0, _workContext.CurrentCustomer.Id, true, 0, int.MaxValue).ToList();
                var lastsurfeddate  = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.LastSurfDate);
                ViewBag.Standard       = custPositions.Where(x => x.BoardId == 1).Count();
                ViewBag.StandardCycled = cycledPositions.Where(x => x.BoardId == 1 && x.IsCycled == true).Count();
                ViewBag.Business       = custPositions.Where(x => x.BoardId == 2).Count();
                ViewBag.BusinessCycled = cycledPositions.Where(x => x.BoardId == 2 && x.IsCycled == true).Count();
                ViewBag.Premium        = custPositions.Where(x => x.BoardId == 3).Count();
                ViewBag.PremiumCycled  = cycledPositions.Where(x => x.BoardId == 3 && x.IsCycled == true).Count();
                ViewBag.Ultimate       = custPositions.Where(x => x.BoardId == 4).Count();
                ViewBag.UltimateCycled = cycledPositions.Where(x => x.BoardId == 4 && x.IsCycled == true).Count();
                ViewBag.Diamond        = custPositions.Where(x => x.BoardId == 5).Count();
                ViewBag.DiamondCycled  = cycledPositions.Where(x => x.BoardId == 5 && x.IsCycled == true).Count();
                ViewBag.CustomerId     = _workContext.CurrentCustomer.Id;

                //if(lastsurfeddate.Date < DateTime.Today)
                //{
                //	model.NoOfAdsToSurf = 10;
                //}
                //else
                //{
                //	model.NoOfAdsToSurf = _workContext.CurrentCustomer.GetAttribute<int>(SystemCustomerAttributeNames.NoOfAdsSurfed);
                //	int ads = (10 - model.NoOfAdsToSurf);
                //	if (ads < 0)
                //	{
                //		model.NoOfAdsToSurf = 0;
                //	}
                //	else
                //	{
                //		model.NoOfAdsToSurf = (10 - model.NoOfAdsToSurf);
                //	}
                //}
                //var vacationdate = _workContext.CurrentCustomer.GetAttribute<DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate);
                //if(vacationdate > DateTime.Today)
                //{
                //	model.NoOfAdsToSurf = 0;
                //}
                ViewBag.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode;
                var substrans = _workContext.CurrentCustomer.Transaction.Where(x => x.StatusId == 2 && x.TranscationNote == "subscription").FirstOrDefault();
                if (substrans != null)
                {
                    var noOfDays = substrans.NoOfPosition * 30;
                    ViewBag.SubscriptionDate = substrans.CreatedOnUtc.AddDays(noOfDays).ToShortDateString();
                }
                return(View(model));
            }
        }
Пример #2
0
        //public ActionResult LoginAd()
        //{
        //	var banner = _adCampaignService.GetRandomAds("Login", "Click", "", 1);
        //	var b = banner.FirstOrDefault();
        //	if (b == null || _workContext.CurrentCustomer.IsAdmin())
        //	{
        //		return RedirectToAction("Index");
        //	}
        //	return View(b);
        //}

        public ActionResult Index()
        {
            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators"))
            {
                var allRoles         = _customerService.GetAllCustomerRoles(true);
                var registeredRoleId = allRoles.First(x => x.SystemName.IsCaseInsensitiveEqual(SystemCustomerRoleNames.Registered)).Id;

                AdminDashboardModel model = new AdminDashboardModel();
                model.RegisteredMembers = _customerService.GetAllCustomers(null, null, new int[] { registeredRoleId }, null,
                                                                           null, null, null, 0, 0, null, null, null,
                                                                           false, null, 0, int.MaxValue).TotalCount;
                model.ActiveMembers = _customerPlanService.GetAllCustomerPlans().Select(x => x.CustomerId).Distinct().Count();

                int[] StatusIds          = "2".ToIntArray();
                int[] TranscationTypeIds = { (int)TransactionType.Withdrawal };
                var   transcation        = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                                  StatusIds, TranscationTypeIds, 0, int.MaxValue);

                model.CompletedWithdrawals = transcation.Sum(x => x.Amount);

                StatusIds   = "1".ToIntArray();
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIds, 0, int.MaxValue);
                model.PendingWithdrawals = transcation.Sum(x => x.Amount);

                StatusIds = "2".ToIntArray();
                int[] TranscationTypeIdsC = { (int)TransactionType.Commission };
                transcation = _transactionService.GetAllTransactions(0, 0, null, null,
                                                                     StatusIds, TranscationTypeIdsC, 0, int.MaxValue);
                model.CommissionPaid = transcation.Sum(x => x.Amount);

                var    plans = _planService.GetAllPlans();
                double totalInvestors = 0, totalInvestment = 0, totalROIPaid = 0, totalROIToPay = 0, totalPendingROI = 0;
                foreach (var plan in plans)
                {
                    var           plandetails   = _customerPlanService.GetAllCustomerPlans(0, plan.Id).ToList();
                    DashboardPlan dashboardPlan = new DashboardPlan();
                    dashboardPlan.Name               = plan.Name;
                    dashboardPlan.TotalInvestors     = plandetails.Select(x => x.CustomerId).Distinct().Count().ToString();
                    dashboardPlan.TotalInvestment    = plandetails.Sum(x => x.AmountInvested).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.ROIPaid            = plandetails.Sum(x => x.ROIPaid).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.ROIToPay           = plandetails.Sum(x => x.ROIToPay).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.PendingROI         = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid)).ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                    dashboardPlan.TotalInvestorsInt  = plandetails.Select(x => x.CustomerId).Distinct().Count();
                    dashboardPlan.TotalInvestmentInt = plandetails.Sum(x => x.AmountInvested);
                    dashboardPlan.ROIPaidInt         = plandetails.Sum(x => x.ROIPaid);
                    dashboardPlan.ROIToPayInt        = plandetails.Sum(x => x.ROIToPay);
                    dashboardPlan.PendingROIInt      = (plandetails.Sum(x => x.ROIToPay) - plandetails.Sum(x => x.ROIPaid));

                    totalInvestors  = Convert.ToInt32(totalInvestors) + Convert.ToInt32(dashboardPlan.TotalInvestorsInt);
                    totalInvestment = Convert.ToDouble(totalInvestment) + Convert.ToDouble(dashboardPlan.TotalInvestmentInt);
                    totalROIPaid    = Convert.ToDouble(totalROIPaid) + Convert.ToDouble(dashboardPlan.ROIPaidInt);
                    totalROIToPay   = Convert.ToDouble(totalROIToPay) + Convert.ToDouble(dashboardPlan.ROIToPayInt);
                    totalPendingROI = Convert.ToDouble(totalPendingROI) + Convert.ToDouble(dashboardPlan.PendingROIInt);
                    model.Plans.Add(dashboardPlan);
                }
                DashboardPlan plantotal = new DashboardPlan();
                plantotal.Name            = "Total";
                plantotal.TotalInvestors  = totalInvestors.ToString();
                plantotal.TotalInvestment = totalInvestment.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.ROIPaid         = totalROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.ROIToPay        = totalROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                plantotal.PendingROI      = totalPendingROI.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode;
                model.Plans.Add(plantotal);
                return(View("Dashboard", model));
            }
            else
            {
                HomeModel model = new HomeModel();
                model.ReferralLink = _services.StoreContext.CurrentStore.Url + "?r=" + _workContext.CurrentCustomer.Id;
                var id = _workContext.CurrentCustomer.Id;
                model.AvailableBalance = _customerService.GetAvailableBalance(id);
                //model.RepurchaseBalance = _customerService.GetRepurchaseBalance(id);
                model.CompletedWithdrawal = _customerService.GetCustomerCompletedWithdrawal(id);
                model.PendingWithdrawal   = _customerService.GetCustomerPendingWithdrawal(id);
                model.TotalEarning        = _customerService.GetCustomerTotalEarnings(id);
                model.TotalIncome         = model.TotalEarning;
                model.CyclerIncome        = _customerService.GetCustomerCyclerBonus(id);
                model.DirectBonus         = _customerService.GetCustomerDirectBonus(id);
                model.UnilevelEarning     = _customerService.GetCustomerUnilevelBonus(id);
                model.PoolShare           = _customerService.GetCustomerROI(id) + _customerService.GetRepurchaseROI(id);
                model.TotalReferral       = _customerService.GetCustomerReferral(id).Count();
                model.InvestorId          = "MTH" + id.ToString();
                model.Name                    = _workContext.CurrentCustomer.GetFullName();
                model.ReferredBy              = _customerService.GetCustomerById(_workContext.CurrentCustomer.AffiliateId).GetFullName();
                model.RegistrationDate        = _workContext.CurrentCustomer.CreatedOnUtc.ToLongDateString();
                model.Status                  = _workContext.CurrentCustomer.Transaction.Where(x => x.StatusId == 2 && x.TranscationTypeId == 1).Sum(x => x.Amount) > 0 ? "Active" : "Inactive";
                model.VacationModelExpiryDate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate).ToShortDateString();
                var lastsurfeddate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.LastSurfDate);
                if (lastsurfeddate.Date < DateTime.Today)
                {
                    model.NoOfAdsToSurf = 10;
                }
                else
                {
                    model.NoOfAdsToSurf = _workContext.CurrentCustomer.GetAttribute <int>(SystemCustomerAttributeNames.NoOfAdsSurfed);
                    int ads = (10 - model.NoOfAdsToSurf);
                    if (ads < 0)
                    {
                        model.NoOfAdsToSurf = 0;
                    }
                    else
                    {
                        model.NoOfAdsToSurf = (10 - model.NoOfAdsToSurf);
                    }
                }
                var vacationdate = _workContext.CurrentCustomer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate);
                if (vacationdate > DateTime.Today)
                {
                    model.NoOfAdsToSurf = 0;
                }
                ViewBag.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode;

                return(View(model));
            }
        }
Пример #3
0
        /// <summary>
        /// Executes a task
        /// </summary>
        public void Execute(TaskExecutionContext ctx)
        {
            string weekday = DateTime.Today.DayOfWeek.ToString();
            //WritetoLog("Executing roi");
            var customerplans = _customerPlanService.GetAllCustomerPlans().ToList();

            //WritetoLog("totalpurchase"+customerplans.Count().ToString());
            foreach (var cp in customerplans)
            {
                if (cp.Customer.Active && cp.IsActive && !cp.IsExpired)
                {
                    //WritetoLog("isactive"+cp.Customer.Id);
                    var      plan          = _planService.GetPlanById(cp.PlanId);
                    int      PayEveryXHour = plan.PayEveryXDays;
                    TimeSpan diff          = DateTime.Now - cp.LastPaidDate;
                    double   LastPaidHours = diff.TotalHours;
                    var      vacationdate  = cp.Customer.GetAttribute <DateTime>(SystemCustomerAttributeNames.VacationModeExpiryDate);
                    var      nextSurfdate  = cp.Customer.GetAttribute <DateTime>(SystemCustomerAttributeNames.NextSurfDate);
                    int      NoOfAdsToSurf = 10;
                    if (vacationdate > DateTime.Today || nextSurfdate > DateTime.Now)
                    {
                        NoOfAdsToSurf = 0;
                    }
                    NoOfAdsToSurf = 0;
                    if (cp.AmountInvested > 0 && NoOfAdsToSurf == 0)
                    {
                        //WritetoLog("sharing now");
                        float repurchaseAmount = 0;
                        float DailyROIToPay    = 0;
                        float HourlyROIToPay   = 0;
                        DailyROIToPay  = ((cp.AmountInvested * plan.ROIPercentage) / 100);
                        HourlyROIToPay = DailyROIToPay;                        // / 24;
                        //repurchaseAmount = (HourlyROIToPay * 30) / 100;
                        //Transaction transaction = new Transaction();
                        //transaction.CustomerId = cp.CustomerId;
                        //transaction.Amount = HourlyROIToPay;
                        //transaction.FinalAmount = transaction.Amount;
                        //transaction.RefId = cp.Id;
                        //transaction.StatusId = (int)Status.Completed;
                        //transaction.TransactionDate = DateTime.Now;
                        //transaction.TranscationTypeId = (int)TransactionType.ROI;
                        //_transactionService.InsertTransaction(transaction);
                        //WritetoLog("sharing now1"+ transaction.Amount);
                        //transaction = new Transaction();
                        //transaction.CustomerId = cp.CustomerId;
                        //transaction.Amount = repurchaseAmount;
                        //transaction.FinalAmount = transaction.Amount;
                        //transaction.RefId = cp.Id;
                        //transaction.StatusId = (int)Status.Completed;
                        //transaction.TransactionDate = DateTime.Now;
                        //transaction.TranscationTypeId = (int)TransactionType.RepurchaseROI;
                        //_transactionService.InsertTransaction(transaction);

                        //Update CustomerPlan
                        cp.LastPaidDate = DateTime.Now;
                        cp.ROIPaid      = cp.ROIPaid + HourlyROIToPay;
                        //cp.RepurchaseWallet = cp.RepurchaseWallet + repurchaseAmount;
                        cp.NoOfPayoutPaid = cp.NoOfPayoutPaid + 1;
                        if (cp.ROIPaid >= cp.ROIToPay)
                        {
                            cp.ExpiredDate = DateTime.Now;
                            cp.IsExpired   = true;
                            cp.IsActive    = false;
                            //if (plan.IsPrincipalBack)
                            //{
                            //	//Retrun Principal
                            //	transaction = new Transaction();
                            //	transaction.CustomerId = cp.CustomerId;
                            //	transaction.Amount = cp.AmountInvested;
                            //	transaction.FinalAmount = transaction.Amount;
                            //	transaction.RefId = cp.Id;
                            //	transaction.StatusId = (int)Status.Completed;
                            //	transaction.TransactionDate = DateTime.Now;
                            //	transaction.TranscationTypeId = (int)TransactionType.ROI;
                            //	_transactionService.InsertTransaction(transaction);
                            //}
                        }
                        _customerPlanService.UpdateCustomerPlan(cp);
                    }
                }
            }
        }