Exemple #1
0
        public List <SKU> GetDisplaySKUsByProducts(List <long> products)
        {
            var skus = ProductManagerApplication.GetSKUByProducts(products);

            var types = TypeApplication.GetTypes();

            return(new List <SKU>());
        }
Exemple #2
0
        public static List <CartItem> GetCartItems(long memberId)
        {
            var cart = GetShoppingCart(memberId);
            //会员折扣
            var discount = MemberApplication.GetMemberDiscount(memberId);

            var skuIds   = cart.Items.Select(p => p.SkuId).ToList();
            var skus     = GetService <IProductService>().GetSKUs(skuIds);
            var products = GetService <IProductService>().GetProducts(skus.Select(p => p.ProductId).ToList());
            var shops    = GetService <IShopService>().GetShops(products.Select(p => p.ShopId).ToList());
            var types    = TypeApplication.GetTypes();
            //限时购活动
            var limitProducts = LimitTimeApplication.GetPriceByProducrIds(products.Select(p => p.Id).ToList());
            //阶梯价商品
            var allLadders = GetService <IProductLadderPriceService>().GetLadderPricesByProductIds(products.Where(p => p.IsOpenLadder).Select(p => p.Id).ToList());

            var result = new List <CartItem>();

            foreach (var item in cart.Items)
            {
                var sku     = skus.FirstOrDefault(p => p.Id == item.SkuId);
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                if (product == null)
                {
                    continue;                 //忽略异常数据
                }
                var shop = shops.FirstOrDefault(p => p.Id == product.ShopId);
                var type = types.FirstOrDefault(p => p.Id == product.TypeId);
                if (sku == null || shop == null)
                {
                    continue;                             //忽略异常数据
                }
                #region 价格覆盖
                var minMach = 0;
                //阶梯价格
                if (product.IsOpenLadder)
                {
                    var ladders  = allLadders.Where(p => p.ProductId == item.ProductId).ToList();
                    var quantity = cart.Items.Where(c => c.ProductId == item.ProductId && c.ShopBranchId == 0).ToList().Sum(c => c.Quantity);
                    sku.SalePrice = ProductManagerApplication.GetProductLadderPrice(ladders, quantity);
                    minMach       = ladders.Min(p => p.MinBath);
                }

                var price = -1M;//其他价格
                //限时购价格
                var limit = limitProducts.FirstOrDefault(p => p.ProductId == item.ProductId);
                if (limit != null)
                {
                    price = limit.MinPrice;
                }
                //会员折扣
                if (price < 0 && shop.IsSelf)
                {
                    price = sku.SalePrice * discount;
                }

                if (price >= 0)
                {
                    sku.SalePrice = price;
                }
                #endregion

                //填充SKU别名
                ProductManagerApplication.FillSkuAlias(sku, product, type);
                //是否限时购
                var isLimit = limit != null;



                result.Add(new CartItem
                {
                    ItemId     = item.Id,
                    Quantity   = item.Quantity,
                    AddTime    = item.AddTime,
                    Product    = product,
                    Shop       = shop,
                    Sku        = sku,
                    ShowStatus = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku.Map <DTO.SKU>(), 1),
                    LimitId    = isLimit?limit.Id:0, //参与限时购活动ID
                    IsLimit    = isLimit,            //是否参加限时购
                    MinMach    = minMach,
                });
            }
            return(result);
        }