public void CleanRenta(Renta renta) { if (!string.IsNullOrEmpty(renta.QRRecorded)) { var ereminService = new EreminService(); ereminService.CleanQR(renta.QRRecorded).GetAwaiter().GetResult(); renta.QRRecorded = $"deleted {renta.QRRecorded}"; } renta.Expired = true; SaveContext(); }
protected bool GetAnon(int modelId) { try { var erService = new EreminService(); return(erService.GetAnonimous(modelId)); } catch (Exception e) { Console.Error.WriteLine("Ошибка получения anonimous"); } return(false); }
public BalanceDto InitCharacter(int modelId) { if (modelId == 0) { throw new BillingNotFoundException($"character {modelId} not found"); } var character = GetAsNoTracking <Character>(c => c.Model == modelId); if (character == null) { throw new BillingNotFoundException($"character {modelId} not found"); } var sin = Get <SIN>(s => s.Character.Model == modelId, s => s.Passport, s => s.Character); if (sin == null) { throw new BillingNotFoundException($"character {modelId} not found"); } if (sin.PassportId == 0) { throw new BillingNotFoundException($"Не найден пасспорт при инициализации персонажа {modelId}"); } sin.EVersion = "1"; SaveContext(); InitEcoFirstStage(sin); //проверяем, что персонаж присутствует во внешней системе try { var service = new EreminService(); service.GetCharacter(sin.Character.Model); sin.EVersion = "3"; SaveContext(); try { InitEcoSecondStage(sin); } catch (Exception e2) { Console.Error.WriteLine(e2.ToString()); } } catch (Exception e) { Console.Error.WriteLine(e.ToString()); } return(new BalanceDto(sin)); }
protected Price CreateNewPrice(Sku sku, ShopWallet shop, SIN sin) { decimal modeldiscount; try { var eService = new EreminService(); modeldiscount = eService.GetDiscount(sin.Character.Model, BillingHelper.GetDiscountType(sku.Nomenklatura.Specialisation.ProductType.DiscountType)); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); modeldiscount = 1; } decimal discount = 1; if (sin.Passport.Mortgagee == sku.Corporation.Alias) { discount *= 0.9m; } discount *= modeldiscount; var currentScoring = sin.Scoring.CurrentFix + sin.Scoring.CurerentRelative; if (currentScoring == 0) { currentScoring = 1; } var price = new Price { Sku = sku, Shop = shop, BasePrice = sku.Nomenklatura.BasePrice, CurrentScoring = currentScoring, DateCreated = DateTime.Now.ToUniversalTime(), Discount = discount, Sin = sin, ShopComission = BillingHelper.GetShopComission(shop.LifeStyle), ShopPrice = BillingHelper.GetShopPrice(sku) }; price.FinalPrice = BillingHelper.GetFinalPrice(price); Add(price); SaveContext(); return(price); }
public MemoryStream LoadMainExcel() { var billing = IocContainer.Get <IBillingManager>(); var settings = IocContainer.Get <ISettingsManager>(); var sins = billing.GetSinsInGame(); var result = new List <MainExcelDto>(); var ikarkoef = settings.GetDecimalValue(SystemSettingsEnum.ikar_k); var karmakoef = settings.GetDecimalValue(SystemSettingsEnum.karma_k); var inflationkoef = settings.GetDecimalValue(SystemSettingsEnum.pre_inflation); var lifestyle = BillingHelper.GetLifeStyleDto(); foreach (var sin in sins) { var allRents = billing.GetRentas(sin.Character.Model); decimal karma = 0; try { var eService = new EreminService(); karma = eService.GetCharacter(sin.Character.Model)?.workModel?.karma?.spent ?? 0; } catch (Exception e) { Console.WriteLine(e.ToString()); } var excelCharacter = new MainExcelDto { Balance = sin.Wallet.Balance, PersonName = sin.Passport?.PersonName, KarmaKoef = karmakoef, InflationKoef = inflationkoef, ScoringFix = sin.Scoring.CurrentFix, ScoringRelative = sin.Scoring.CurerentRelative, ModelId = sin.Character.Model.ToString(), LifeStyle = lifestyle.GetLifeStyle(sin.Wallet).ToString(), SumRents = allRents.Sum, Karma = karma }; result.Add(excelCharacter); } return(ExcelWriter.CreateExcelAsStream(result)); }
private void LoadCharacters(List <SIN> sins, ConcurrentQueue <ImportDto> concurrent) { var erService = new EreminService(); Parallel.ForEach(sins, new ParallelOptions { MaxDegreeOfParallelism = 5 }, sin => { var dto = new ImportDto { Sin = sin }; try { dto.EreminModel = erService.GetCharacter(sin.Character.Model); } catch (Exception e) { LogException(e); dto.ErrorText = e.Message; } concurrent.Enqueue(dto); }); }
protected Renta CreateRenta(int modelId, int priceId, int beat, int count = 1) { var sin = BillingBlocked(modelId, s => s.Wallet, s => s.Character, s => s.Passport, s => s.Scoring); if (count == 0) { count = 1; } var price = Get <Price>(p => p.Id == priceId, p => p.Sku.Nomenklatura.Specialisation.ProductType, p => p.Sku.Corporation.Wallet, s => s.Shop.Wallet, s => s.Sin.Character); if (price == null) { throw new BillingException("Персональное предложение не найдено"); } if (price.Confirmed) { throw new Exception("Персональным предложением уже воспользовались"); } if (price.Sin.Character.Model != modelId) { throw new Exception("Персональное предложение заведено на другого персонажа"); } var dateTill = price.DateCreated.AddMinutes(_settings.GetIntValue(SystemSettingsEnum.price_minutes)); if (dateTill < DateTime.Now.ToUniversalTime()) { throw new BillingException($"Персональное предложение больше не действительно, оно истекло {dateTill:HH:mm:ss}"); } var allowed = SkuAllowed(price.ShopId, price.SkuId); if (allowed == null) { throw new BillingException("Sku недоступно для продажи в данный момент"); } price.FinalPrice *= count; if (sin.Wallet.Balance - price.FinalPrice < 0) { throw new BillingException("Недостаточно средств"); } price.Sku.Count -= count; var instantConsume = price.Sku.Nomenklatura.Specialisation.ProductType.InstantConsume; var anon = GetAnon(sin.Character.Model); var gmdescript = BillingHelper.GetGmDescription(sin.Passport, price.Sku, anon); var renta = new Renta { BasePrice = price.BasePrice, Sin = sin, CurrentScoring = price.CurrentScoring, Sku = price.Sku, DateCreated = DateTime.Now.ToUniversalTime(), Discount = price.Discount, ShopComission = price.ShopComission, ShopPrice = price.ShopPrice, ShopId = price.ShopId, Shop = price.Shop, HasQRWrite = instantConsume ? false : BillingHelper.HasQrWrite(price.Sku.Nomenklatura.Code), PriceId = priceId, Secret = gmdescript, LifeStyle = price.Sku.Nomenklatura.Lifestyle, Count = count, FullPrice = price.Sku.Nomenklatura.Specialisation.ProductType.Alias == ProductTypeEnum.Charity.ToString(), BeatId = beat }; Add(renta); price.Confirmed = true; SaveContext(); ProcessBuyScoring(sin, price.Sku, price.Shop); var mir = GetMIR(); ProcessRenta(renta, mir, sin, true); SaveContext(); if (instantConsume) { var erService = new EreminService(); erService.ConsumeFood(renta.Id, (Lifestyles)renta.LifeStyle, modelId).GetAwaiter().GetResult(); } return(renta); }