Ejemplo n.º 1
0
        /// <summary>
        /// 计算商品的折扣价
        /// </summary>
        /// <param name="shopPrice">商城价格</param>
        /// <param name="singlePromotionInfo">单品促销活动</param>
        /// <returns></returns>
        public static decimal ComputeDiscountPrice(decimal shopPrice, SinglePromotionInfo singlePromotionInfo)
        {
            decimal discountPrice = shopPrice;

            if (singlePromotionInfo != null)
            {
                switch (singlePromotionInfo.DiscountType)
                {
                case 0:    //折扣
                    discountPrice = Math.Ceiling(shopPrice * singlePromotionInfo.DiscountValue / 10);
                    break;

                case 1:    //直降
                    discountPrice = shopPrice - singlePromotionInfo.DiscountValue;
                    break;

                case 2:    //折后价
                    discountPrice = singlePromotionInfo.DiscountValue;
                    break;
                }
            }
            if (discountPrice < 0 || discountPrice > shopPrice)
            {
                discountPrice = shopPrice;
            }

            return(discountPrice);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成商品的促销信息
        /// </summary>
        /// <param name="singlePromotionInfo">单品促销活动</param>
        /// <param name="buySendPromotionList">买送促销活动列表</param>
        /// <param name="fullSendPromotionInfo">满赠促销活动</param>
        /// <param name="fullCutPromotionInfo">满减促销活动</param>
        /// <returns></returns>
        public static string GeneratePromotionMsg(SinglePromotionInfo singlePromotionInfo, List <BuySendPromotionInfo> buySendPromotionList, FullSendPromotionInfo fullSendPromotionInfo, FullCutPromotionInfo fullCutPromotionInfo)
        {
            StringBuilder promotionMsg = new StringBuilder();

            //单品促销
            if (singlePromotionInfo != null)
            {
                //折扣类别
                switch (singlePromotionInfo.DiscountType)
                {
                case 0:    //折扣
                    promotionMsg.AppendFormat("折扣:{0}折<br/>", singlePromotionInfo.DiscountValue);
                    break;

                case 1:    //直降
                    promotionMsg.AppendFormat("直降:{0}元<br/>", singlePromotionInfo.DiscountValue);
                    break;

                case 2:    //折后价
                    promotionMsg.AppendFormat("折后价:{0}元<br/>", singlePromotionInfo.DiscountValue);
                    break;
                }

                //积分
                if (singlePromotionInfo.PayCredits > 0)
                {
                    promotionMsg.AppendFormat("赠送{0}:{1}<br/>", Credits.PayCreditName, singlePromotionInfo.PayCredits);
                }

                //优惠劵
                if (singlePromotionInfo.CouponTypeId > 0)
                {
                    CouponTypeInfo couponTypeInfo = Coupons.GetCouponTypeById(singlePromotionInfo.CouponTypeId);
                    if (couponTypeInfo != null)
                    {
                        promotionMsg.AppendFormat("赠送优惠劵:{0}<br/>", couponTypeInfo.Name);
                    }
                }
            }
            //买送促销
            if (buySendPromotionList != null && buySendPromotionList.Count > 0)
            {
                promotionMsg.Append("买送促销:");
                foreach (BuySendPromotionInfo buySendPromotionInfo in buySendPromotionList)
                {
                    promotionMsg.AppendFormat("买{0}送{1},", buySendPromotionInfo.BuyCount, buySendPromotionInfo.SendCount);
                }
                promotionMsg.Remove(promotionMsg.Length - 1, 1);
                promotionMsg.Append("<br/>");
            }
            //满赠促销
            if (fullSendPromotionInfo != null)
            {
                promotionMsg.Append("满赠促销:");
                promotionMsg.AppendFormat("满{0}元加{1}元<br/>", fullSendPromotionInfo.LimitMoney, fullSendPromotionInfo.AddMoney);
            }
            //满减促销
            if (fullCutPromotionInfo != null)
            {
                promotionMsg.Append("满减促销:");
                promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney1, fullCutPromotionInfo.CutMoney1);
                if (fullCutPromotionInfo.LimitMoney2 > 0 && fullCutPromotionInfo.CutMoney2 > 0)
                {
                    promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney2, fullCutPromotionInfo.CutMoney2);
                }
                if (fullCutPromotionInfo.LimitMoney3 > 0 && fullCutPromotionInfo.CutMoney3 > 0)
                {
                    promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney3, fullCutPromotionInfo.CutMoney3);
                }
                promotionMsg.Remove(promotionMsg.Length - 1, 1);
                promotionMsg.Append("<br/>");
            }

            return(promotionMsg.Length > 0 ? promotionMsg.Remove(promotionMsg.Length - 5, 5).ToString() : "");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 创建单品促销活动
 /// </summary>
 public static void CreateSinglePromotion(SinglePromotionInfo singlePromotionInfo)
 {
     BrnShop.Data.Promotions.CreateSinglePromotion(singlePromotionInfo);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 更新单品促销活动
 /// </summary>
 public static void UpdateSinglePromotion(SinglePromotionInfo singlePromotionInfo)
 {
     BrnMall.Data.Promotions.UpdateSinglePromotion(singlePromotionInfo);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新单品促销活动
 /// </summary>
 public static void UpdateSinglePromotion(SinglePromotionInfo singlePromotionInfo)
 {
     NStore.Data.Promotions.UpdateSinglePromotion(singlePromotionInfo);
 }