Esempio n. 1
0
        public static AddCartItemStatus AddLineItem(int productId, string skuId, string skuContent, int quantity)
        {
            Member user = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                quantity = 1;
            }
            if (user != null)
            {
                int num;
                int num2;
                ProductSaleStatus status;
                ShoppingProvider  provider = ShoppingProvider.Instance();
                if (!provider.GetShoppingProductInfo(user, productId, skuId, out status, out num, out num2))
                {
                    return(AddCartItemStatus.ProductNotExists);
                }
                if (status != ProductSaleStatus.OnSale)
                {
                    return(AddCartItemStatus.Offsell);
                }
                if ((num <= 0) || (num < num2))
                {
                    return(AddCartItemStatus.Shortage);
                }
                return(provider.AddLineItem(user, productId, skuId, quantity));
            }
            return(CookieShoppingProvider.Instance().AddLineItem(productId, skuId, quantity));
        }
Esempio n. 2
0
 public static bool AddGiftItem(int giftId, int quantity)
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         return(CookieShoppingProvider.Instance().AddGiftItem(giftId, quantity));
     }
     return(ShoppingProvider.Instance().AddGiftItem(giftId, quantity));
 }
 public static void ClearShoppingCart()
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         CookieShoppingProvider.Instance().ClearShoppingCart();
     }
     else
     {
         ShoppingProvider.Instance().ClearShoppingCart(HiContext.Current.User.UserId);
     }
 }
 public static void RemoveGiftItem(int giftId, PromoteType promotype)
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         CookieShoppingProvider.Instance().RemoveGiftItem(giftId);
     }
     else
     {
         ShoppingProvider.Instance().RemoveGiftItem(giftId, promotype);
     }
 }
 public static void RemoveLineItem(string skuId)
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         CookieShoppingProvider.Instance().RemoveLineItem(skuId);
     }
     else
     {
         ShoppingProvider.Instance().RemoveLineItem(HiContext.Current.User.UserId, skuId);
     }
 }
        public static ShoppingCartInfo GetShoppingCart()
        {
            Member           member = HiContext.Current.User as Member;
            ShoppingCartInfo result;

            if (member != null)
            {
                ShoppingCartInfo shoppingCart = ShoppingProvider.Instance().GetShoppingCart(HiContext.Current.User.UserId);
                if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
                {
                    result = null;
                }
                else
                {
                    decimal       reducedPromotionAmount = 0m;
                    PromotionInfo reducedPromotion       = ShoppingProvider.Instance().GetReducedPromotion(member, shoppingCart.GetAmount(), shoppingCart.GetQuantity(), out reducedPromotionAmount);
                    if (reducedPromotion != null)
                    {
                        shoppingCart.ReducedPromotionId     = reducedPromotion.ActivityId;
                        shoppingCart.ReducedPromotionName   = reducedPromotion.Name;
                        shoppingCart.ReducedPromotionAmount = reducedPromotionAmount;
                        shoppingCart.IsReduced = true;
                    }
                    PromotionInfo sendPromotion = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentGift);
                    if (sendPromotion != null)
                    {
                        shoppingCart.SendGiftPromotionId   = sendPromotion.ActivityId;
                        shoppingCart.SendGiftPromotionName = sendPromotion.Name;
                        shoppingCart.IsSendGift            = true;
                    }
                    PromotionInfo sendPromotion2 = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                    if (sendPromotion2 != null)
                    {
                        shoppingCart.SentTimesPointPromotionId   = sendPromotion2.ActivityId;
                        shoppingCart.SentTimesPointPromotionName = sendPromotion2.Name;
                        shoppingCart.IsSendTimesPoint            = true;
                        shoppingCart.TimesPoint = sendPromotion2.DiscountValue;
                    }
                    PromotionInfo sendPromotion3 = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentFreight);
                    if (sendPromotion3 != null)
                    {
                        shoppingCart.FreightFreePromotionId   = sendPromotion3.ActivityId;
                        shoppingCart.FreightFreePromotionName = sendPromotion3.Name;
                        shoppingCart.IsFreightFree            = true;
                    }
                    result = shoppingCart;
                }
            }
            else
            {
                result = CookieShoppingProvider.Instance().GetShoppingCart();
            }
            return(result);
        }
        public static bool AddGiftItem(int giftId, int quantity, PromoteType promotype)
        {
            bool result;

            if (HiContext.Current.User.IsAnonymous)
            {
                result = CookieShoppingProvider.Instance().AddGiftItem(giftId, quantity);
            }
            else
            {
                result = ShoppingProvider.Instance().AddGiftItem(giftId, quantity, promotype);
            }
            return(result);
        }
        public static void AddLineItem(string skuId, int quantity)
        {
            Member member = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                quantity = 1;
            }
            if (member != null)
            {
                ShoppingProvider.Instance().AddLineItem(member, skuId, quantity);
            }
            else
            {
                CookieShoppingProvider.Instance().AddLineItem(skuId, quantity);
            }
        }
        public static void UpdateGiftItemQuantity(int giftId, int quantity, PromoteType promotype)
        {
            Member member = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                ShoppingCartProcessor.RemoveGiftItem(giftId, promotype);
            }
            if (member == null)
            {
                CookieShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity);
            }
            else
            {
                ShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity, promotype);
            }
        }
Esempio n. 10
0
        public static void UpdateLineItemQuantity(string skuId, int quantity)
        {
            Member member = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                ShoppingCartProcessor.RemoveLineItem(skuId);
            }
            if (member == null)
            {
                CookieShoppingProvider.Instance().UpdateLineItemQuantity(skuId, quantity);
            }
            else
            {
                ShoppingProvider.Instance().UpdateLineItemQuantity(member, skuId, quantity);
            }
        }
Esempio n. 11
0
        public static void UpdateLineItemQuantity(int productId, string skuId, int quantity)
        {
            Member user = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                RemoveLineItem(skuId);
            }
            if (user == null)
            {
                CookieShoppingProvider.Instance().UpdateLineItemQuantity(productId, skuId, quantity);
            }
            else
            {
                ShoppingProvider.Instance().UpdateLineItemQuantity(user, productId, skuId, quantity);
            }
        }
Esempio n. 12
0
        public static void UpdateGiftItemQuantity(int giftId, int quantity)
        {
            Member user = HiContext.Current.User as Member;

            if (quantity <= 0)
            {
                RemoveGiftItem(giftId);
            }
            if (user == null)
            {
                CookieShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity);
            }
            else
            {
                ShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity);
            }
        }
        public static ShoppingCartInfo GetShoppingCart()
        {
            Member user = HiContext.Current.User as Member;

            if (user != null)
            {
                ShoppingCartInfo shoppingCart = ShoppingProvider.Instance().GetShoppingCart(HiContext.Current.User.UserId);
                if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
                {
                    return(null);
                }
                decimal       reducedAmount = 0M;
                PromotionInfo info2         = ShoppingProvider.Instance().GetReducedPromotion(user, shoppingCart.GetAmount(), shoppingCart.GetQuantity(), out reducedAmount);
                if (info2 != null)
                {
                    shoppingCart.ReducedPromotionId     = info2.ActivityId;
                    shoppingCart.ReducedPromotionName   = info2.Name;
                    shoppingCart.ReducedPromotionAmount = reducedAmount;
                    shoppingCart.IsReduced = true;
                }
                PromotionInfo info3 = ShoppingProvider.Instance().GetSendPromotion(user, shoppingCart.GetTotal(), PromoteType.FullAmountSentGift);
                if (info3 != null)
                {
                    shoppingCart.SendGiftPromotionId   = info3.ActivityId;
                    shoppingCart.SendGiftPromotionName = info3.Name;
                    shoppingCart.IsSendGift            = true;
                }
                PromotionInfo info4 = ShoppingProvider.Instance().GetSendPromotion(user, shoppingCart.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                if (info4 != null)
                {
                    shoppingCart.SentTimesPointPromotionId   = info4.ActivityId;
                    shoppingCart.SentTimesPointPromotionName = info4.Name;
                    shoppingCart.IsSendTimesPoint            = true;
                    shoppingCart.TimesPoint = info4.DiscountValue;
                }
                PromotionInfo info5 = ShoppingProvider.Instance().GetSendPromotion(user, shoppingCart.GetTotal(), PromoteType.FullAmountSentFreight);
                if (info5 != null)
                {
                    shoppingCart.FreightFreePromotionId   = info5.ActivityId;
                    shoppingCart.FreightFreePromotionName = info5.Name;
                    shoppingCart.IsFreightFree            = true;
                }
                return(shoppingCart);
            }
            return(CookieShoppingProvider.Instance().GetShoppingCart());
        }
Esempio n. 14
0
        public static ShoppingCartInfo GetShoppingCart()
        {
            int               num;
            int               num2;
            string            str;
            string            str2;
            decimal           num3;
            DiscountValueType type;
            bool              flag;
            bool              flag2;
            bool              flag3;

            if (HiContext.Current.User.IsAnonymous)
            {
                return(CookieShoppingProvider.Instance().GetShoppingCart());
            }
            ShoppingProvider provider     = ShoppingProvider.Instance();
            ShoppingCartInfo shoppingCart = provider.GetShoppingCart(HiContext.Current.User.UserId);

            if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
            {
                return(null);
            }
            provider.GetPromotionsWithAmount(shoppingCart.GetAmount(), out num, out str, out num3, out type, out num2, out str2, out flag, out flag2, out flag3);
            if (!((num <= 0) || string.IsNullOrEmpty(str)))
            {
                shoppingCart.DiscountActivityId = num;
                shoppingCart.DiscountName       = str;
                shoppingCart.DiscountValue      = num3;
                shoppingCart.DiscountValueType  = type;
            }
            if (!((num2 <= 0) || string.IsNullOrEmpty(str2)))
            {
                shoppingCart.FeeFreeActivityId = num2;
                shoppingCart.FeeFreeName       = str2;
                shoppingCart.EightFree         = flag;
                shoppingCart.ProcedureFeeFree  = flag3;
                shoppingCart.OrderOptionFree   = flag2;
            }
            return(shoppingCart);
        }