public SpCartKeyHelper(string opKey)
        {
            string[] keys = opKey.Split('_');
            spCart = CartFactory.Instance().GetShopCart(keys[0]);

            if (keys.Length==2)
            {
                spOrderProduct = spCart.GetOrderProduct(opKey);
            }
        }
示例#2
0
        public override OrderProduct AddToCart(OrderType opType, int productId, int quantity, NameValueCollection paras)
        {
            int typecode;

            if (!int.TryParse(paras["typecode"], out typecode))
            {
                typecode = 0;
            }

            ShopIdentity user   = HttpContext.Current.User.Identity as ShopIdentity;
            MemberInfo   member = MemberInfo.GetBaseInfo(user.UserId);

            OrderProduct op = OrderProducts.Find(c => c.ProductID == productId && c.TypeCode == typecode);

            if (op == null)
            {
                op                   = OrderProductFactory.Instance().CreateOrderProduct(productId, quantity, opType, paras);
                op.Key               = this.Key + "_op" + this.GetSerial();
                op.Container         = this;
                this.ContinueShopUrl = op.ProductUrl;


                if (op != null)
                {
                    if (this.TotalScore + op.TotalScore <= member.CurScore)
                    {
                        OrderProducts.Add(op);
                    }
                    else
                    {
                        op = null;
                    }
                }
            }
            else
            {
                int oldQuantity = op.Quantity;
                op.SetQuantiy(op.Quantity + quantity);
                if (this.TotalScore > member.CurScore)
                {
                    op.SetQuantiy(oldQuantity);
                }
            }
            return(op);
        }
示例#3
0
        private OrderProduct GetOrderProductBll(OrderType opType)
        {
            OrderProduct bll = null;

            switch (opType)
            {
            case OrderType.Common:
                bll = new CommOrderProduct();
                break;

            case OrderType.Gift:
                bll = new GiftOrderProduct();
                break;

            case OrderType.Suit:
                bll = new SuitOrderProduct();
                break;
            }
            return(bll);
        }
示例#4
0
        /// <summary>
        /// 从cookie的值中恢复购物商品参数信息
        /// </summary>
        /// <param name="opType"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        internal NameValueCollection GetParasFromCookieValue(OrderType opType, string[] paras)
        {
            OrderProduct bll = GetOrderProductBll(opType);

            return(bll.GetParasFromCookieValue(paras));
        }