Exemple #1
0
        private JobLifeDto DoItemsBeat(JobLifeDto beat)
        {
            Console.WriteLine("Запущен пересчет товаров");
            //Получить список корпораций с специализациями
            var corporations = Factory.Billing.GetList <CorporationWallet>(c => true, c => c.Specialisations);
            var inflation    = Factory.Settings.GetDecimalValue(SystemSettingsEnum.pre_inflation);

            foreach (var corporation in corporations)
            {
                corporation.LastSkuSold = corporation.SkuSold;
                corporation.SkuSold     = 0;
                corporation.LastKPI     = corporation.CurrentKPI;
                corporation.CurrentKPI  = 0;
                var skus  = Factory.Billing.GetList <Sku>(s => s.CorporationId == corporation.Id, s => s.Nomenklatura.Specialisation);
                var specs = corporation.Specialisations.Select(s => s.SpecialisationId);
                foreach (var sku in skus)
                {
                    sku.Count = sku.SkuBaseCount ?? sku.Nomenklatura.BaseCount;
                    decimal price = 0;
                    if (sku.SkuBasePrice == null)
                    {
                        price = BillingHelper.GetSpecialisationPrice(corporation.Specialisations.FirstOrDefault(s => s.SpecialisationId == sku.Nomenklatura.SpecialisationId && s.CorporationId == sku.CorporationId), sku.Nomenklatura);
                    }
                    else
                    {
                        price = sku.SkuBasePrice ?? 0;
                    }

                    sku.Price = price * inflation;
                }
                Factory.Billing.SaveContext();
                Console.WriteLine($"Корпорация {corporation.Name} обработана");
            }
            return(beat);
        }