public static CouponCodeResponse CouponCodeResponseMapping(CouponHistoryEntity source, ProductEntity product,
                                                                   PromotionEntity promotion)
        {
            if (source == null)
            {
                return null;
            }

            var target = Mapper.Map<CouponHistoryEntity, CouponCodeResponse>(source);

            var productname = String.Empty;
            var producttype = 0;
            var productid = 0;
            var productDescription = String.Empty;
            if (promotion != null)
            {
                productname = promotion.Name;
                producttype = (int)SourceType.Promotion;
                productid = promotion.Id;
                productDescription =
                promotion.Description;
                target.Stype = SourceType.Promotion;
            }
            else
            {
                if (product != null)
                {
                    productname = product.Name;
                    producttype = (int)SourceType.Product;
                    productid = product.Id;
                    productDescription =
                    product.Description;
                    target.Stype = SourceType.Product;
                }
            }

            target.ProductId = productid;
            target.ProductName = productname;
            target.ProductType = producttype;
            target.ProductDescription = productDescription;


            return target;
        }
        /// <summary>
        /// 优惠码
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public CouponCodeResponse CouponCodeResponseMapping(CouponHistoryEntity source)
        {
            if (source == null)
            {
                return null;
            }

            if (source.FromPromotion > 0)
            {
                var promotion = _promotionRepository.GetItem(source.FromPromotion);

                return CouponCodeResponseMapping(source, null, promotion);
            }

            if (source.FromProduct > 0)
            {
                var product = _productRepository.GetItem(source.FromProduct);

                return CouponCodeResponseMapping(source, product, null);
            }

            return Mapper.Map<CouponHistoryEntity, CouponCodeResponse>(source);
        }
        public CouponInfoResponse CouponInfoResponseMapping(CouponHistoryEntity source)
        {
            if (source == null)
            {
                return null;
            }

            var target = Mapper.Map<CouponHistoryEntity, CouponInfoResponse>(source);

            if (source.FromPromotion > 0)
            {
                var promotion = PromotionResponseMapping(_promotionRepository.GetItem(source.FromPromotion));

                return CouponInfoResponseMapping(target, null, promotion);
            }

            if (source.FromProduct > 0)
            {
                var product = ProductInfoResponseMapping(_productRepository.GetItem(source.FromProduct));

                return CouponInfoResponseMapping(target, product, null);
            }

            return target;
        }