Exemplo n.º 1
0
        private PriceRatio CalculateRatios(CampaignInfoDto campaignData, ProductDto productData)
        {
            var hourlyManipulationRatio = campaignData.PriceManipulationLimit / campaignData.Duration;
            var priceManipulationRatio  = productData.Price * campaignData.PriceManipulationLimit / 100;

            var priceRatios = new PriceRatio
            {
                HourlyManipulationRatio = hourlyManipulationRatio,
                PriceManipulationRatio  = priceManipulationRatio
            };

            return(priceRatios);
        }
Exemplo n.º 2
0
        private CampaignInfoDto MapCampaignInfoData(Campaign campaign)
        {
            var returnData = new CampaignInfoDto
            {
                Name                   = campaign.Name,
                ProductCode            = campaign.ProductCode,
                Duration               = campaign.Duration,
                PriceManipulationLimit = campaign.PriceManipulationLimit,
                TargetSalesCount       = campaign.TotalSalesCount,
                CampaignStatus         = GetCampaignStatus(campaign.Duration)
            };

            return(returnData);
        }
Exemplo n.º 3
0
        private float CalculateNewPrice(CampaignInfoDto campaignData, ProductDto productData,
                                        PriceRatio priceRatios, float minimumProductPrice, float maximumProductPrice)
        {
            var orderInfo = _model.OrderService.GetOrdersByProductCode(productData.ProductCode);
            var orders    = orderInfo.Data;

            var totalSales         = orders.Sum(x => x.Quantity);
            var ratio              = totalSales * 100 / campaignData.TargetSalesCount;
            var manipulationAmount = productData.Price * priceRatios.HourlyManipulationRatio / 100;
            var newProductPrice    = productData.Price;

            if (ratio <= MinimumSalesRatio && productData.Price >= minimumProductPrice)
            {
                newProductPrice -= manipulationAmount;
            }
            else if (ratio >= maximumProductPrice && productData.Price <= maximumProductPrice)
            {
                newProductPrice += manipulationAmount;
            }

            return(newProductPrice);
        }