예제 #1
0
        /// <summary>
        /// 赠品活动中获取销售商品的毛利率:
        /// </summary>
        /// <param name="product"></param>
        /// <param name="minBuyQty"></param>
        /// <param name="giftSaleSysNo"></param>
        /// <returns></returns>
        public virtual decimal GetSaleGift_SaleItemGrossMarginRate(ProductInfo product, int minBuyQty, int giftSaleSysNo, SaleGiftInfo info)
        {
            ProductMarginer productMarginer = new ProductMarginer();

            productMarginer.ProductSysNo = product.SysNo;
            productMarginer.Point        = Convert.ToDecimal(product.ProductPriceInfo.Point);
            productMarginer.UnitCost     = product.ProductPriceInfo.UnitCost;
            productMarginer.CurrentPrice = product.ProductPriceInfo.CurrentPrice.Value;
            productMarginer.CouponAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetCouponCurrentAmountForPM(product) / minBuyQty, 2);
            if (info.GiftComboType == SaleGiftGiftItemType.AssignGift)
            {
                productMarginer.GiftAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGiftAmountForNotFull(product.SysNo, giftSaleSysNo) / minBuyQty, 2);
            }
            else
            {
                var count = info.ItemGiftCount == null ? 0 : info.ItemGiftCount.Value;
                productMarginer.GiftAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGiftAmountForFull(product.SysNo, giftSaleSysNo, count) / minBuyQty, 2);
            }

            if (info.Type == SaleGiftType.Multiple && info.DisCountType == SaleGiftDiscountBelongType.BelongMasterItem)
            {
                decimal?salePriceTotalTmp = info.ProductCondition.Where(ps => ps.Type == SaleGiftSaleRuleType.Item)
                                            .Sum(ps => ps.RelProduct.CurrentPrice);
                productMarginer.GiftAmount = productMarginer.GiftAmount * productMarginer.CurrentPrice / salePriceTotalTmp.Value;
            }

            productMarginer.SalePrice = productMarginer.CurrentPrice;
            return(CalcGrossMarginRate(productMarginer));
        }
예제 #2
0
        /// <summary>
        /// 获取商品按当前售价出售时的毛利率
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public virtual decimal GetSalesGrossMarginRate(ProductInfo product)
        {
            ProductMarginer productMarginer = new ProductMarginer();

            productMarginer.ProductSysNo = product.SysNo;
            productMarginer.Point        = Convert.ToDecimal(product.ProductPriceInfo.Point);
            productMarginer.UnitCost     = product.ProductPriceInfo.UnitCost;
            productMarginer.CurrentPrice = product.ProductPriceInfo.CurrentPrice.Value;
            productMarginer.SalePrice    = productMarginer.CurrentPrice;
            productMarginer.CouponAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetCouponCurrentAmountForPM(product.SysNo), 2);
            productMarginer.GiftAmount   = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGiftCurrentAmountForVendor(product.SysNo), 2);
            return(CalcGrossMarginRate(productMarginer));
        }
예제 #3
0
        /// <summary>
        /// 赠品活动中获取赠品的毛利率
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public virtual decimal GetSaleGift_GiftItemGrossMarginRate(ProductInfo product, SaleGiftDiscountBelongType discountBelongType)
        {
            ProductMarginer productMarginer = new ProductMarginer();

            productMarginer.ProductSysNo = product.SysNo;
            productMarginer.Point        = Convert.ToDecimal(product.ProductPriceInfo.Point);
            productMarginer.UnitCost     = product.ProductPriceInfo.UnitCost;
            productMarginer.CurrentPrice = product.ProductPriceInfo.CurrentPrice.Value;
            productMarginer.CouponAmount = 0.00m;
            productMarginer.GiftAmount   = 0.00m;
            productMarginer.SalePrice    = productMarginer.CurrentPrice;
            if (discountBelongType == SaleGiftDiscountBelongType.BelongMasterItem)
            {
                return(CalcGrossMarginRate(productMarginer));
            }
            return(CalcGiftGrossMarginRate(productMarginer));
        }
예제 #4
0
        /// <summary>
        /// Coupon: 指定商品的Coupon的毛利率
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public virtual decimal GetCouponGrossMarginRate(ProductInfo product)
        {
            decimal         couponAmount    = GetCouponCurrentAmountForPM(product);
            decimal         giftAmount      = GetSaleGiftCurrentAmountForVendor(product.SysNo);
            ProductMarginer productMarginer = new ProductMarginer()
            {
                CurrentPrice = product.ProductPriceInfo.CurrentPrice.Value,
                SalePrice    = product.ProductPriceInfo.CurrentPrice.Value,
                Point        = Convert.ToDecimal(product.ProductPriceInfo.Point),
                UnitCost     = product.ProductPriceInfo.UnitCost,
                CouponAmount = couponAmount,
                GiftAmount   = giftAmount,
                ProductSysNo = product.SysNo
            };

            return(CalcGrossMarginRate(productMarginer));
        }
예제 #5
0
        /// <summary>
        /// 计算单个赠品品的毛利率:含Coupon,SaleGift的计算
        /// </summary>
        /// <param name="myProduct"></param>
        /// <returns></returns>
        public virtual decimal CalcGiftGrossMarginRate(ProductMarginer productMarginer)
        {
            #region Old Calc
            //if ((productMarginer.CurrentPrice - productMarginer.Point / pointExchangeRate) == 0)
            //{
            //    return 0.00m;
            //}
            //decimal calcValue = Math.Round((
            //    (productMarginer.SalePrice - productMarginer.UnitCost - productMarginer.Point / pointExchangeRate - productMarginer.CouponAmount - productMarginer.GiftAmount)
            //    /
            //    (productMarginer.CurrentPrice - productMarginer.Point / pointExchangeRate)
            //    ), 4);
            //return calcValue;

            #endregion

            ////毛利率计算统一归入IM
            decimal calcValue = ObjectFactory <IIMBizInteract> .Instance.GetGiftProductMargin(
                productMarginer.SalePrice, decimal.ToInt32(productMarginer.Point), productMarginer.UnitCost, 0m);

            return(Math.Round(calcValue, 4));
        }