コード例 #1
0
        CartItemWithDetailList GetEventProductList(ShoppingCart_V02 cart)
        {
            var ret = new CartItemWithDetailList();

            if (Helper.Instance.HasData(cart.CurrentItems))
            {
                foreach (var cartItem in cart.CurrentItems)
                {
                    if (!IsEventProduct(cartItem.SKU))
                    {
                        continue;
                    }
                    SKU_V01 sku_v01 = null;
                    SkuList.TryGetValue(cartItem.SKU, out sku_v01);
                    if (sku_v01 == null)
                    {
                        continue;
                    }
                    var child = new CartItemWithDetail
                    {
                        CurrentItem = cartItem,
                        SKU         = sku_v01
                    };
                    ret.Add(child);
                }
            }

            if (Helper.Instance.HasData(cart.CartItems))
            {
                foreach (var cartItem in cart.CartItems)
                {
                    if (!IsEventProduct(cartItem.SKU))
                    {
                        continue;
                    }

                    var child = ret.FirstOrDefault(x => x.SkuCode == cartItem.SKU);
                    if (child != null)
                    {
                        child.CartItem = cartItem;
                    }
                    else
                    {
                        child = new CartItemWithDetail
                        {
                            CartItem = cartItem,
                            SKU      = SkuList[cartItem.SKU],
                        };
                        ret.Add(child);
                    }
                }
            }

            return(ret);
        }
コード例 #2
0
        void DeductEventProductQty(CartItemWithDetail data, int toQty, ShoppingCart_V02 cart)
        {
            if (data.TotalQty <= toQty)
            {
                return;
            }

            var item = data.CurrentItem;

            if ((item != null) && (item.Quantity > 0))
            {
                var diff = data.TotalQty - toQty;
                item.Quantity -= diff;

                if (item.Quantity < 0)
                {
                    item.Quantity = 0;
                }
            }
        }