Beispiel #1
0
        //private void AddDish

        private GKANReportCats GetToGoCats(DateTime sDt, DateTime eDt)
        {
            var data     = ToGoOrdersModelSingleton.Instance.Orders.Where(a => a.OrderStatus != AlohaService.ServiceDataContracts.OrderStatus.Cancelled && a.DeliveryDate >= sDt && a.DeliveryDate < eDt);
            var dataCats = new GKANReportCats();

            foreach (var catP in DataExtension.DataCatalogsSingleton.Instance.Payments.Where(x => x.ToGo && x.IsActive && x.PaymentGroup != null))
            {
                var dataCat = new GKANReportCat()
                {
                    Admin      = !catP.PaymentGroup.Sale,
                    PaymentCat = true,
                    CatName    = catP.Name,

                    CatSumm = data.Where(x => x.PaymentType != null && x.PaymentId == catP.Id).Sum(x => x.OrderTotalSumm) +
                              data.Sum(x => x.GetSpisDishesOfPaimentId(catP.Id).Sum(d => d.TotalSumm)),

                    Catcount = data
                               .Where(x => x.PaymentType != null && x.PaymentId == catP.Id)
                               .Count()
                };


                dataCats.Cats.Add(dataCat);
            }

            var dataCatd = new GKANReportCat()
            {
                Admin      = false,
                PaymentCat = false,
                CatName    = "Удаленные блюда",
                CatSumm    = data.Sum(x => x.GetSpisDishesOfPaimentId(0).Sum(d => d.TotalSumm)),
                Id         = 1
            };

            dataCats.Cats.Add(dataCatd);

            foreach (var lCat in DataExtension.DataCatalogsSingleton.Instance.DishLogicGroup.Where(x => x.IsActive))
            {
                var dataCat = new GKANReportCat()
                {
                    Admin      = false,
                    PaymentCat = false,
                    CatName    = lCat.Name,
                    CatSumm    = data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Sum(x => (x.GetNoSpisDishesOfCat(lCat.Id).Sum(d => d.TotalSumm) *
                                                                                                                     (x.OrderDishesSumm == 0 ? 1 : ((x.OrderDishesSumm - x.DiscountSumm) / x.OrderDishesSumm))
                                                                                                                     )),
                    Catcount = data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(lCat.Id).Count()),
                };
                if (lCat.Id == 7)//Доп услуги - доставка
                {
                    dataCat.CatSumm  += data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Sum(x => x.DeliveryPrice);
                    dataCat.Catcount += data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Where(x => x.DeliveryPrice > 0).Count();
                }



                dataCats.Cats.Add(dataCat);
            }

            var dataCatW = new GKANReportCat()
            {
                Admin      = false,
                PaymentCat = false,
                CatName    = "Без категории",
                CatSumm    = data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(null).Sum(d => d.TotalSumm) *
                                                                                                           (x.OrderDishesSumm == 0 ? 1 : ((x.OrderDishesSumm - x.DiscountSumm) / x.OrderDishesSumm))
                                                                                                           ),
                Catcount = data.Where(x => x.PaymentType != null && x.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(null).Count()),
            };

            dataCats.Cats.Add(dataCatW);

            return(dataCats);
        }
Beispiel #2
0
        private GKANReportCats GetSVOCats(DateTime sDt, DateTime eDt)
        {
            try
            {
                var data     = AirOrdersModelSingleton.Instance.SVOorders.Where(a => a.OrderStatus != AlohaService.ServiceDataContracts.OrderStatus.Cancelled && a.DeliveryDate >= sDt && a.DeliveryDate < eDt);
                var dataCats = new GKANReportCats();
                foreach (var catP in DataExtension.DataCatalogsSingleton.Instance.AllAirCompanies.Where(x => x.IsActive && DBProvider.SharAirs.Contains(x.Id)))
                {
                    var dataCat = new GKANReportCat()
                    {
                        Admin      = !catP.PaymentType.PaymentGroup.Sale,
                        PaymentCat = true,
                        CatName    = catP.Name,

                        CatSumm = data.Where(x => x.AirCompany.PaymentType != null && x.AirCompany.Id == catP.Id).Sum(x => x.OrderTotalSumm),
                        //data.Sum(x => x.GetSpisDishesOfPaimentId(catP.Id).Sum(d => d.TotalSumm)),

                        Catcount = data
                                   .Where(x => x.AirCompany.PaymentType != null && x.AirCompany.Id == catP.Id)
                                   .Count()
                    };


                    dataCats.Cats.Add(dataCat);
                }

                /*
                 * var dataCatd = new GKANReportCat()
                 * {
                 *  Admin = false,
                 *  PaymentCat = false,
                 *  CatName = "Удаленные блюда",
                 *  CatSumm = data.Sum(x => x.GetSpisDishesOfPaimentId(0).Sum(d => d.TotalSumm)),
                 *  Id = 1
                 *
                 * };
                 * dataCats.Cats.Add(dataCatd);
                 */
                foreach (var lCat in DataExtension.DataCatalogsSingleton.Instance.DishLogicGroup.Where(x => x.IsActive))
                {
                    var dataCat = new GKANReportCat()
                    {
                        Admin      = false,
                        PaymentCat = false,
                        CatName    = lCat.Name,
                        CatSumm    = data.Where(x => x.AirCompany.PaymentType != null && x.AirCompany.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(lCat.Id).Sum(d => d.TotalSumm)),
                        Catcount   = data.Where(x => x.AirCompany.PaymentType != null && x.AirCompany.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(lCat.Id).Count()),
                    };
                    if (lCat.Id == 7)//Доп услуги - наценка
                    {
                        dataCat.CatSumm  += data.Sum(x => x.ExtraChargeSumm);
                        dataCat.Catcount += data.Where(x => x.ExtraChargeSumm > 0).Count();
                    }
                    dataCats.Cats.Add(dataCat);
                }
                var dataCatW = new GKANReportCat()
                {
                    Admin      = false,
                    PaymentCat = false,
                    CatName    = "Без категории",
                    CatSumm    = data.Where(x => x.AirCompany.PaymentType != null && x.AirCompany.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(null).Sum(d => d.TotalSumm)),
                    Catcount   = data.Where(x => x.AirCompany.PaymentType != null && x.AirCompany.PaymentType.PaymentGroup.Sale).Sum(x => x.GetNoSpisDishesOfCat(null).Count()),
                };
                dataCats.Cats.Add(dataCatW);
                return(dataCats);
            }
            catch (Exception e)
            {
                logger.Error($"Error GetSVOCats  err: {e.Message}");
                return(new GKANReportCats());
            }
        }