Exemplo n.º 1
0
        public IPriceValue GetDiscountPrice(IPriceValue price, EntryContentBase entry, Currency currency, PromotionHelperFacade promotionHelper)
        {
            var promotionEntry = CreatePromotionEntry(entry, price);
            var filter = new PromotionFilter
            {
                IgnoreConditions = false,
                IgnorePolicy = false,
                IgnoreSegments = false,
                IncludeCoupons = false
            };

            var sourceSet = new PromotionEntriesSet();
            sourceSet.Entries.Add(promotionEntry);
            var promotionContext = promotionHelper.Evaluate(filter, sourceSet, sourceSet, false);

            if (promotionContext.PromotionResult.PromotionRecords.Count > 0)
            {
                return new PriceValue
                {
                    CatalogKey = price.CatalogKey,
                    CustomerPricing = CustomerPricing.AllCustomers,
                    MarketId = price.MarketId,
                    MinQuantity = 1,
                    UnitPrice = new Money(price.UnitPrice.Amount - GetDiscountPrice(promotionContext), currency),
                    ValidFrom = DateTime.UtcNow,
                    ValidUntil = null
                };
            }
            return price;
        }
Exemplo n.º 2
0
 public PromotionService(
     IPricingService pricingService, 
     IMarketService marketService, 
     IContentLoader contentLoader, 
     ReferenceConverter referenceConverter, 
     PromotionHelperFacade promotionHelper,
     IPromotionEntryService promotionEntryService)
 {
     _contentLoader = contentLoader;
     _marketService = marketService;
     _pricingService = pricingService;
     _referenceConverter = referenceConverter;
     _promotionEntryService = promotionEntryService;
     _promotionHelper = promotionHelper;
 }
Exemplo n.º 3
0
 private decimal GetDiscountPrice(PromotionHelperFacade promotionHelper)
 {
     var result = promotionHelper.PromotionContext.PromotionResult;
     return result.PromotionRecords.Sum(record => GetDiscountAmount(record, record.PromotionReward));
 }