/// <summary>
        /// 修改请购买数量
        /// </summary>
        /// <param name="product"></param>
        /// <param name="quantity"></param>
        /// <returns>0:成功 -1:购物车中不包括此产品 -2:已超可请购数量 -3:小于最小单次请购数量 -4:大于最大单次请购数量</returns>
        public int ModifyQuantity(int product, int quantity)
        {
            ORD_OrderCart cartitem = Items.FirstOrDefault(m => m.Product == product);

            if (cartitem == null)
            {
                return(-1);
            }

            cartitem.AvailableQuantity = cartitem.AvailableQuantity;
            cartitem.SubmitQuantity    = ORD_OrderApplyBLL.GetSubmitQuantity(_publish, product);

            if (cartitem.AvailableQuantity > 0 && quantity > cartitem.AvailableQuantity - cartitem.SubmitQuantity)
            {
                return(-2);
            }
            if (cartitem.MinQuantity > 0 && cartitem.MinQuantity > quantity || quantity < 0)
            {
                return(-3);
            }
            if (cartitem.MaxQuantity > 0 && cartitem.MaxQuantity < quantity)
            {
                return(-4);
            }

            cartitem.BookQuantity = quantity;

            return(0);
        }
        /// <summary>
        /// 向购物车中新增产品
        /// </summary>
        /// <param name="product"></param>
        /// <param name="price"></param>
        /// <returns>0:成功 -1:发布目录中不包括此产品 -2:已超可请购数量 -3:该产品已在购物车中 -4:该产品不在指定客户的价表中</returns>
        public int AddProduct(int product, decimal price)
        {
            if (Items.FirstOrDefault(m => m.Product == product) != null)
            {
                return(-3);
            }

            ORD_ApplyPublishDetail _m = new ORD_ApplyPublishBLL(_publish).Items.FirstOrDefault(m => m.Product == product);

            if (_m != null)
            {
                ORD_OrderCart cartitem = new ORD_OrderCart();
                cartitem.Product           = _m.Product;
                cartitem.MinQuantity       = _m.MinQuantity;
                cartitem.MaxQuantity       = _m.MaxQuantity;
                cartitem.Price             = price;
                cartitem.AvailableQuantity = _m.AvailableQuantity;
                cartitem.SubmitQuantity    = ORD_OrderApplyBLL.GetSubmitQuantity(_publish, product);

                cartitem.BookQuantity = cartitem.MinQuantity > 0 ? cartitem.MinQuantity : new PDT_ProductBLL(product).Model.ConvertFactor;

                if (cartitem.AvailableQuantity > 0 && cartitem.BookQuantity > cartitem.AvailableQuantity - cartitem.SubmitQuantity)
                {
                    return(-2);
                }

                _items.Add(cartitem);

                return(0);
            }
            return(-1);
        }
        /// <summary>
        /// 根据请购买申请单重新初始化购物车
        /// </summary>
        /// <param name="ApplyID"></param>
        /// <returns></returns>
        public static ORD_OrderCartBLL InitByOrderApply(int ApplyID)
        {
            ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL(ApplyID);

            if (apply.Model == null)
            {
                return(null);
            }

            ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(apply.Model.PublishID);

            if (publish.Model == null)
            {
                return(null);
            }
            int addressid = 0;

            int.TryParse(apply.Model["AddressID"], out addressid);
            ORD_OrderCartBLL cart = new ORD_OrderCartBLL(apply.Model.PublishID, apply.Model.OrganizeCity, apply.Model.Client, apply.Model.AccountMonth, addressid);

            foreach (ORD_OrderApplyDetail item in apply.Items)
            {
                ORD_ApplyPublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product);
                if (_m == null)
                {
                    continue;
                }

                ORD_OrderCart cartitem = new ORD_OrderCart();
                cartitem.ID                = _m.ID;
                cartitem.Product           = _m.Product;
                cartitem.MinQuantity       = _m.MinQuantity;
                cartitem.MaxQuantity       = _m.MaxQuantity;
                cartitem.Price             = item.Price;
                cartitem.AvailableQuantity = _m.AvailableQuantity;
                cartitem.SubmitQuantity    = ORD_OrderApplyBLL.GetSubmitQuantity(cart.Publish, cartitem.Product);

                cartitem.BookQuantity = item.BookQuantity;

                cart.Items.Add(cartitem);
            }

            return(cart);
        }