Пример #1
0
        /// <summary>
        /// 取消订单的使用优惠券,取消订单商品优惠券的分摊,重新设置商品价格。
        /// 注意:此方法还没有保存到数据库中,是通过 SaveCurrentSO()来保存
        /// </summary>
        protected virtual void CancelCoupon()
        {
            #region 取消优惠券使用

            int    couponSysNo = CouponList != null && CouponList.Count > 0 ? CouponList[0].ProductSysNo.Value : 0;
            string couponCode  = string.Empty;
            //取消优惠券使用
            if (couponSysNo != 0)
            {
                CurrentSO.BaseInfo.CouponAmount = 0;
                foreach (SOItemInfo item in CurrentSO.Items)
                {
                    item.Price = item.OriginalPrice;
                    item.CouponAverageDiscount = 0;
                }
                CurrentSO.SOPromotions.RemoveAll(p =>
                {
                    return(p.PromotionType == SOPromotionType.Coupon);
                });
                if (ExternalDomainBroker.CheckCouponIsValid(couponSysNo, out couponCode))
                {
                    // 作废时把礼券代码临时保存在note信息中。
                    CurrentSO.BaseInfo.Note = CurrentSO.BaseInfo.Note + ";作废前使用的礼券代码=" + couponCode;
                }

                #region 取消优惠券的使用
                if (CurrentSO.BaseInfo.SplitType != SOSplitType.SubSO)
                {
                    int shoppingCartSysNo = SODA.GetShoppingCartSysNoBySOSysNo(SOSysNo);
                    ExternalDomainBroker.CancelCoupon(couponCode, SOSysNo, shoppingCartSysNo);
                }
                #endregion
            }
            #endregion
        }