public static ShoppingCartInfo GetShoppingCart(string productSkuId, int buyAmount)
        {
            int               num;
            int               num2;
            string            str2;
            ProductSaleStatus status;
            ShoppingCartInfo  info             = new ShoppingCartInfo();
            DataTable         productInfoBySku = ShoppingProcessor.GetProductInfoBySku(productSkuId);

            if ((productInfoBySku == null) || (productInfoBySku.Rows.Count <= 0))
            {
                return(null);
            }
            string skuContent = string.Empty;

            foreach (DataRow row in productInfoBySku.Rows)
            {
                if (!((((row["AttributeName"] == DBNull.Value) || string.IsNullOrEmpty((string)row["AttributeName"])) || (row["ValueStr"] == DBNull.Value)) || string.IsNullOrEmpty((string)row["ValueStr"])))
                {
                    object obj2 = skuContent;
                    skuContent = string.Concat(new object[] { obj2, row["AttributeName"], ":", row["ValueStr"], "; " });
                }
            }
            ShoppingCartItemInfo info2 = ShoppingProvider.Instance().GetCartItemInfo(HiContext.Current.User as Member, (int)productInfoBySku.Rows[0]["ProductId"], productSkuId, skuContent, buyAmount, out status, out str2, out num, out num2);

            if ((((info2 == null) || (status != ProductSaleStatus.OnSale)) || (num <= 0)) || (num < num2))
            {
                return(null);
            }
            info.LineItems.Add(productSkuId, info2);
            if (!HiContext.Current.User.IsAnonymous)
            {
                int               num3;
                int               num4;
                string            str3;
                string            str4;
                decimal           num5;
                DiscountValueType type;
                bool              flag;
                bool              flag2;
                bool              flag3;
                ShoppingProvider.Instance().GetPromotionsWithAmount(info.GetAmount(), out num3, out str3, out num5, out type, out num4, out str4, out flag, out flag2, out flag3);
                if (!((num3 <= 0) || string.IsNullOrEmpty(str3)))
                {
                    info.DiscountActivityId = num3;
                    info.DiscountName       = str3;
                    info.DiscountValue      = num5;
                    info.DiscountValueType  = type;
                }
                if (!((num4 <= 0) || string.IsNullOrEmpty(str4)))
                {
                    info.FeeFreeActivityId = num4;
                    info.FeeFreeName       = str4;
                    info.EightFree         = flag;
                    info.ProcedureFeeFree  = flag3;
                    info.OrderOptionFree   = flag2;
                }
            }
            return(info);
        }
Example #2
0
        public static bool CutNeedPoint(int needPoint, string orderId)
        {
            Member        member        = HiContext.Current.User as Member;
            UserPointInfo userPointInfo = new UserPointInfo();

            userPointInfo.OrderId   = orderId;
            userPointInfo.UserId    = member.UserId;
            userPointInfo.TradeDate = DateTime.Now;
            userPointInfo.TradeType = UserPointTradeType.Change;
            userPointInfo.Reduced   = new int?(needPoint);
            userPointInfo.Points    = member.Points - needPoint;
            int arg_5B_0 = userPointInfo.Points;

            if (userPointInfo.Points < 0)
            {
                userPointInfo.Points = 0;
            }
            bool result;

            if (ShoppingProvider.Instance().AddMemberPoint(userPointInfo))
            {
                Users.ClearUserCache(member);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        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));
        }
        public static ShoppingCartInfo GetCountDownShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     info  = new ShoppingCartInfo();
            Member               user  = HiContext.Current.User as Member;
            ShoppingCartItemInfo info2 = ShoppingProvider.Instance().GetCartItemInfo(user, productSkuId, buyAmount);

            if (info2 == null)
            {
                return(null);
            }
            CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(info2.ProductId);

            if (countDownInfo == null)
            {
                return(null);
            }
            ShoppingCartItemInfo info4 = new ShoppingCartItemInfo();

            info4.SkuId           = info2.SkuId;
            info4.ProductId       = info2.ProductId;
            info4.SKU             = info2.SKU;
            info4.Name            = info2.Name;
            info4.MemberPrice     = info4.AdjustedPrice = countDownInfo.CountDownPrice;
            info4.SkuContent      = info2.SkuContent;
            info4.Quantity        = info4.ShippQuantity = buyAmount;
            info4.Weight          = info2.Weight;
            info4.ThumbnailUrl40  = info2.ThumbnailUrl40;
            info4.ThumbnailUrl60  = info2.ThumbnailUrl60;
            info4.ThumbnailUrl100 = info2.ThumbnailUrl100;
            info.LineItems.Add(productSkuId, info4);
            return(info);
        }
 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));
 }
Example #6
0
 public static bool CreatOrder(OrderInfo orderInfo)
 {
     if (orderInfo == null)
     {
         return(false);
     }
     return(ShoppingProvider.Instance().CreatOrder(orderInfo));
 }
 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 void RemoveGiftItem(int giftId, PromoteType promotype)
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         CookieShoppingProvider.Instance().RemoveGiftItem(giftId);
     }
     else
     {
         ShoppingProvider.Instance().RemoveGiftItem(giftId, promotype);
     }
 }
 public static void ClearShoppingCart()
 {
     if (HiContext.Current.User.IsAnonymous)
     {
         CookieShoppingProvider.Instance().ClearShoppingCart();
     }
     else
     {
         ShoppingProvider.Instance().ClearShoppingCart(HiContext.Current.User.UserId);
     }
 }
        public static ShoppingCartInfo GetShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     shoppingCartInfo = new ShoppingCartInfo();
            Member               member           = HiContext.Current.User as Member;
            ShoppingCartItemInfo cartItemInfo     = ShoppingProvider.Instance().GetCartItemInfo(member, productSkuId, buyAmount);
            ShoppingCartInfo     result;

            if (cartItemInfo == null)
            {
                result = null;
            }
            else
            {
                shoppingCartInfo.LineItems.Add(productSkuId, cartItemInfo);
                if (member != null)
                {
                    decimal       reducedPromotionAmount = 0m;
                    PromotionInfo reducedPromotion       = ShoppingProvider.Instance().GetReducedPromotion(member, shoppingCartInfo.GetAmount(), shoppingCartInfo.GetQuantity(), out reducedPromotionAmount);
                    if (reducedPromotion != null)
                    {
                        shoppingCartInfo.ReducedPromotionId     = reducedPromotion.ActivityId;
                        shoppingCartInfo.ReducedPromotionName   = reducedPromotion.Name;
                        shoppingCartInfo.ReducedPromotionAmount = reducedPromotionAmount;
                        shoppingCartInfo.IsReduced = true;
                    }
                    PromotionInfo sendPromotion = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentGift);
                    if (sendPromotion != null)
                    {
                        shoppingCartInfo.SendGiftPromotionId   = sendPromotion.ActivityId;
                        shoppingCartInfo.SendGiftPromotionName = sendPromotion.Name;
                        shoppingCartInfo.IsSendGift            = true;
                    }
                    PromotionInfo sendPromotion2 = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                    if (sendPromotion2 != null)
                    {
                        shoppingCartInfo.SentTimesPointPromotionId   = sendPromotion2.ActivityId;
                        shoppingCartInfo.SentTimesPointPromotionName = sendPromotion2.Name;
                        shoppingCartInfo.IsSendTimesPoint            = true;
                        shoppingCartInfo.TimesPoint = sendPromotion2.DiscountValue;
                    }
                    PromotionInfo sendPromotion3 = ShoppingProvider.Instance().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentFreight);
                    if (sendPromotion3 != null)
                    {
                        shoppingCartInfo.FreightFreePromotionId   = sendPromotion3.ActivityId;
                        shoppingCartInfo.FreightFreePromotionName = sendPromotion3.Name;
                        shoppingCartInfo.IsFreightFree            = true;
                    }
                }
                result = shoppingCartInfo;
            }
            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 ShoppingCartInfo GetShoppingCart(int Boundlingid, int buyAmount)
        {
            ShoppingCartInfo        info = new ShoppingCartInfo();
            List <BundlingItemInfo> bundlingItemsByID = ProductBrowser.GetBundlingItemsByID(Boundlingid);
            Member user = HiContext.Current.User as Member;

            foreach (BundlingItemInfo info2 in bundlingItemsByID)
            {
                ShoppingCartItemInfo info3 = ShoppingProvider.Instance().GetCartItemInfo(user, info2.SkuId, buyAmount * info2.ProductNum);
                if (info3 != null)
                {
                    info.LineItems.Add(info2.SkuId, info3);
                }
            }
            return(info);
        }
        public static ShoppingCartInfo GetShoppingCart(int Boundlingid, int buyAmount)
        {
            ShoppingCartInfo        shoppingCartInfo  = new ShoppingCartInfo();
            List <BundlingItemInfo> bundlingItemsByID = ProductBrowser.GetBundlingItemsByID(Boundlingid);
            Member member = HiContext.Current.User as Member;

            foreach (BundlingItemInfo current in bundlingItemsByID)
            {
                ShoppingCartItemInfo cartItemInfo = ShoppingProvider.Instance().GetCartItemInfo(member, current.SkuId, buyAmount * current.ProductNum);
                if (cartItemInfo != null)
                {
                    shoppingCartInfo.LineItems.Add(current.SkuId, cartItemInfo);
                }
            }
            return(shoppingCartInfo);
        }
        public static ShoppingCartInfo GetShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     info  = new ShoppingCartInfo();
            Member               user  = HiContext.Current.User as Member;
            ShoppingCartItemInfo info2 = ShoppingProvider.Instance().GetCartItemInfo(user, productSkuId, buyAmount);

            if (info2 == null)
            {
                return(null);
            }
            info.LineItems.Add(productSkuId, info2);
            if (user != null)
            {
                decimal       reducedAmount = 0M;
                PromotionInfo info3         = ShoppingProvider.Instance().GetReducedPromotion(user, info.GetAmount(), info.GetQuantity(), out reducedAmount);
                if (info3 != null)
                {
                    info.ReducedPromotionId     = info3.ActivityId;
                    info.ReducedPromotionName   = info3.Name;
                    info.ReducedPromotionAmount = reducedAmount;
                    info.IsReduced = true;
                }
                PromotionInfo info4 = ShoppingProvider.Instance().GetSendPromotion(user, info.GetTotal(), PromoteType.FullAmountSentGift);
                if (info4 != null)
                {
                    info.SendGiftPromotionId   = info4.ActivityId;
                    info.SendGiftPromotionName = info4.Name;
                    info.IsSendGift            = true;
                }
                PromotionInfo info5 = ShoppingProvider.Instance().GetSendPromotion(user, info.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                if (info5 != null)
                {
                    info.SentTimesPointPromotionId   = info5.ActivityId;
                    info.SentTimesPointPromotionName = info5.Name;
                    info.IsSendTimesPoint            = true;
                    info.TimesPoint = info5.DiscountValue;
                }
                PromotionInfo info6 = ShoppingProvider.Instance().GetSendPromotion(user, info.GetTotal(), PromoteType.FullAmountSentFreight);
                if (info6 != null)
                {
                    info.FreightFreePromotionId   = info6.ActivityId;
                    info.FreightFreePromotionName = info6.Name;
                    info.IsFreightFree            = true;
                }
            }
            return(info);
        }
        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);
            }
        }
        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 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);
            }
        }
        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());
        }
        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);
            }
        }
        public static ShoppingCartInfo GetGroupBuyShoppingCart(string productSkuId, int buyAmount)
        {
            int               num3;
            int               num4;
            string            str2;
            ProductSaleStatus status;
            ShoppingCartInfo  info             = new ShoppingCartInfo();
            DataTable         productInfoBySku = ShoppingProcessor.GetProductInfoBySku(productSkuId);

            if ((productInfoBySku == null) || (productInfoBySku.Rows.Count <= 0))
            {
                return(null);
            }
            GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo((int)productInfoBySku.Rows[0]["ProductId"]);

            if (productGroupBuyInfo == null)
            {
                return(null);
            }
            int     orderCount   = ProductBrowser.GetOrderCount(productGroupBuyInfo.GroupBuyId);
            decimal currentPrice = ProductBrowser.GetCurrentPrice(productGroupBuyInfo.GroupBuyId, orderCount);
            string  skuContent   = string.Empty;

            foreach (DataRow row in productInfoBySku.Rows)
            {
                if (!((((row["AttributeName"] == DBNull.Value) || string.IsNullOrEmpty((string)row["AttributeName"])) || (row["ValueStr"] == DBNull.Value)) || string.IsNullOrEmpty((string)row["ValueStr"])))
                {
                    object obj2 = skuContent;
                    skuContent = string.Concat(new object[] { obj2, row["AttributeName"], ":", row["ValueStr"], "; " });
                }
            }
            ShoppingProvider     provider = ShoppingProvider.Instance();
            Member               user     = HiContext.Current.User as Member;
            ShoppingCartItemInfo info3    = provider.GetCartItemInfo(user, (int)productInfoBySku.Rows[0]["ProductId"], productSkuId, skuContent, buyAmount, out status, out str2, out num3, out num4);

            if ((((info3 == null) || (status != ProductSaleStatus.OnSale)) || (num3 <= 0)) || (num3 < num4))
            {
                return(null);
            }
            ShoppingCartItemInfo info4 = new ShoppingCartItemInfo(info3.SkuId, info3.ProductId, info3.SKU, info3.Name, currentPrice, info3.SkuContent, buyAmount, info3.Weight, 0, string.Empty, 0, 0, string.Empty, null, info3.CategoryId, info3.ThumbnailUrl40, info3.ThumbnailUrl60, info3.ThumbnailUrl100);

            info.LineItems.Add(productSkuId, info4);
            return(info);
        }
        public static ShoppingCartInfo GetGroupBuyShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     shoppingCartInfo = new ShoppingCartInfo();
            Member               member           = HiContext.Current.User as Member;
            ShoppingCartItemInfo cartItemInfo     = ShoppingProvider.Instance().GetCartItemInfo(member, productSkuId, buyAmount);
            ShoppingCartInfo     result;

            if (cartItemInfo == null)
            {
                result = null;
            }
            else
            {
                GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(cartItemInfo.ProductId);
                if (productGroupBuyInfo == null)
                {
                    result = null;
                }
                else
                {
                    int     orderCount   = ProductBrowser.GetOrderCount(productGroupBuyInfo.GroupBuyId);
                    decimal currentPrice = ProductBrowser.GetCurrentPrice(productGroupBuyInfo.GroupBuyId, orderCount);
                    ShoppingCartItemInfo shoppingCartItemInfo = new ShoppingCartItemInfo();
                    shoppingCartItemInfo.SkuId       = cartItemInfo.SkuId;
                    shoppingCartItemInfo.ProductId   = cartItemInfo.ProductId;
                    shoppingCartItemInfo.SKU         = cartItemInfo.SKU;
                    shoppingCartItemInfo.Name        = cartItemInfo.Name;
                    shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = currentPrice);
                    shoppingCartItemInfo.SkuContent  = cartItemInfo.SkuContent;
                    ShoppingCartItemInfo arg_DC_0 = shoppingCartItemInfo;
                    shoppingCartItemInfo.ShippQuantity = buyAmount;
                    arg_DC_0.Quantity                    = buyAmount;
                    shoppingCartItemInfo.Weight          = cartItemInfo.Weight;
                    shoppingCartItemInfo.ThumbnailUrl40  = cartItemInfo.ThumbnailUrl40;
                    shoppingCartItemInfo.ThumbnailUrl60  = cartItemInfo.ThumbnailUrl60;
                    shoppingCartItemInfo.ThumbnailUrl100 = cartItemInfo.ThumbnailUrl100;
                    shoppingCartInfo.LineItems.Add(productSkuId, shoppingCartItemInfo);
                    result = shoppingCartInfo;
                }
            }
            return(result);
        }
        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);
        }
Example #25
0
        public static bool CutNeedPoint(int needPoint)
        {
            Member        user  = HiContext.Current.User as Member;
            UserPointInfo point = new UserPointInfo();

            point.UserId    = user.UserId;
            point.TradeDate = DateTime.Now;
            point.TradeType = UserPointTradeType.Change;
            point.Reduced   = new int?(needPoint);
            point.Points    = user.Points - needPoint;
            if ((point.Points > 0x7fffffff) || (point.Points < 0))
            {
                point.Points = 0;
            }
            if (ShoppingProvider.Instance().AddMemberPoint(point))
            {
                Users.ClearUserCache(user);
                return(true);
            }
            return(false);
        }
        public static void ConvertShoppingCartToDataBase(ShoppingCartInfo shoppingCart)
        {
            Member member = HiContext.Current.User as Member;

            if (member != null)
            {
                if (shoppingCart.LineItems.Count > 0)
                {
                    foreach (ShoppingCartItemInfo current in shoppingCart.LineItems.Values)
                    {
                        ShoppingProvider.Instance().AddLineItem(member, current.SkuId, current.Quantity);
                    }
                }
                if (shoppingCart.LineGifts.Count > 0)
                {
                    foreach (ShoppingCartGiftInfo current2 in shoppingCart.LineGifts)
                    {
                        ShoppingProvider.Instance().AddGiftItem(current2.GiftId, current2.Quantity, (PromoteType)current2.PromoType);
                    }
                }
            }
        }
        public static void ConvertShoppingCartToDataBase(ShoppingCartInfo shoppingCart)
        {
            ShoppingProvider provider = ShoppingProvider.Instance();
            Member           user     = HiContext.Current.User as Member;

            if (user != null)
            {
                if (shoppingCart.LineItems.Count > 0)
                {
                    foreach (ShoppingCartItemInfo info in shoppingCart.LineItems.Values)
                    {
                        provider.AddLineItem(user, info.ProductId, info.SkuId, info.Quantity);
                    }
                }
                if (shoppingCart.LineGifts.Count > 0)
                {
                    foreach (ShoppingCartGiftInfo info2 in shoppingCart.LineGifts)
                    {
                        provider.AddGiftItem(info2.GiftId, info2.Quantity);
                    }
                }
            }
        }
 public static int GetGiftItemQuantity(PromoteType promotype)
 {
     return(ShoppingProvider.Instance().GetGiftItemQuantity(promotype));
 }
Example #29
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, bool isSignBuy)
        {
            if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
            {
                return(null);
            }
            OrderInfo info = new OrderInfo();

            info.Points                      = shoppingCart.GetPoint();
            info.ReducedPromotionId          = shoppingCart.ReducedPromotionId;
            info.ReducedPromotionName        = shoppingCart.ReducedPromotionName;
            info.ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount;
            info.IsReduced                   = shoppingCart.IsReduced;
            info.SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId;
            info.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName;
            info.IsSendTimesPoint            = shoppingCart.IsSendTimesPoint;
            info.TimesPoint                  = shoppingCart.TimesPoint;
            info.FreightFreePromotionId      = shoppingCart.FreightFreePromotionId;
            info.FreightFreePromotionName    = shoppingCart.FreightFreePromotionName;
            info.IsFreightFree               = shoppingCart.IsFreightFree;
            string str = string.Empty;

            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    str = str + string.Format("'{0}',", info2.SkuId);
                }
            }
            Dictionary <string, decimal> costPriceForItems = new Dictionary <string, decimal>();

            if (!string.IsNullOrEmpty(str))
            {
                str = str.Substring(0, str.Length - 1);
                costPriceForItems = ShoppingProvider.Instance().GetCostPriceForItems(str);
            }
            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    decimal costPrice = 0M;
                    if ((isGroupBuy || isCountDown) || isSignBuy)
                    {
                        costPrice = ShoppingProvider.Instance().GetCostPrice(info2.SkuId);
                    }
                    else if (costPriceForItems.ContainsKey(info2.SkuId))
                    {
                        costPrice = costPriceForItems[info2.SkuId];
                    }
                    LineItemInfo info3 = new LineItemInfo();
                    info3.SkuId             = info2.SkuId;
                    info3.ProductId         = info2.ProductId;
                    info3.SKU               = info2.SKU;
                    info3.Quantity          = info2.Quantity;
                    info3.ShipmentQuantity  = info2.ShippQuantity;
                    info3.ItemCostPrice     = costPrice;
                    info3.ItemListPrice     = info2.MemberPrice;
                    info3.ItemAdjustedPrice = info2.AdjustedPrice;
                    info3.ItemDescription   = info2.Name;
                    info3.ThumbnailsUrl     = info2.ThumbnailUrl40;
                    info3.ItemWeight        = info2.Weight;
                    info3.SKUContent        = info2.SkuContent;
                    info3.PromotionId       = info2.PromotionId;
                    info3.PromotionName     = info2.PromotionName;
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            info.Tax          = 0.00M;
            info.InvoiceTitle = "";
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo();
                    item.GiftId        = info4.GiftId;
                    item.GiftName      = info4.Name;
                    item.Quantity      = info4.Quantity;
                    item.ThumbnailsUrl = info4.ThumbnailUrl40;
                    item.PromoteType   = info4.PromoType;
                    if (HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        item.CostPrice = info4.PurchasePrice;
                    }
                    else
                    {
                        item.CostPrice = info4.CostPrice;
                    }
                    info.Gifts.Add(item);
                }
            }
            return(info);
        }
 public static int GetSkuStock(string skuId)
 {
     return(ShoppingProvider.Instance().GetSkuStock(skuId));
 }