コード例 #1
0
        public static ShoppingCartInfo GetShoppingCart(Member member)
        {
            // 支持 App api
            //Member member = HiContext.Current.User as Member;
            ShoppingCartInfo result;

            if (member != null)
            {
                ShoppingCartInfo shoppingCart = new ShoppingCartDao().GetShoppingCart(member);
                if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
                {
                    result = null;
                }
                else
                {
                    decimal       reducedPromotionAmount = 0m;
                    PromotionInfo reducedPromotion       = new PromotionDao().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 = new PromotionDao().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentGift);
                    if (sendPromotion != null)
                    {
                        shoppingCart.SendGiftPromotionId   = sendPromotion.ActivityId;
                        shoppingCart.SendGiftPromotionName = sendPromotion.Name;
                        shoppingCart.IsSendGift            = true;
                    }
                    PromotionInfo sendPromotion2 = new PromotionDao().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 = new PromotionDao().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentFreight);
                    if (sendPromotion3 != null)
                    {
                        shoppingCart.FreightFreePromotionId   = sendPromotion3.ActivityId;
                        shoppingCart.FreightFreePromotionName = sendPromotion3.Name;
                        shoppingCart.IsFreightFree            = true;
                    }
                    result = shoppingCart;
                }
            }
            else
            {
                result = new CookieShoppingDao().GetShoppingCart();
            }
            return(result);
        }
コード例 #2
0
        public static bool AddGiftItem(int giftId, int quantity, PromoteType promotype)
        {
            bool result;

            if (HiContext.Current.User.IsAnonymous)
            {
                result = new CookieShoppingDao().AddGiftItem(giftId, quantity);
            }
            else
            {
                result = new ShoppingCartDao().AddGiftItem(giftId, quantity, promotype);
            }
            return(result);
        }
コード例 #3
0
        public static AddCartItemStatus AddLineItem(Member member, string skuId, int quantity, int storeId)
        {
            //Member member = HiContext.Current.User as Member;
            if (quantity <= 0)
            {
                quantity = 1;
            }
            AddCartItemStatus result;

            if (member != null)
            {
                result = new ShoppingCartDao().AddLineItem(member, skuId, quantity, storeId);
            }
            else
            {
                result = new CookieShoppingDao().AddLineItem(skuId, quantity, storeId);
            }
            return(result);
        }