/// <summary>
        /// 添加SKU,并过滤已添加的
        /// </summary>
        /// <param name="pids"></param>
        /// <param name="shopBranchId"></param>
        /// <param name="shopId"></param>
        public static void AddProductSkus(IEnumerable <long> pids, long shopBranchId, long shopId)
        {
            var productsInfo = ProductManagerApplication.GetProductsByIds(pids).Where(e => e.ShopId == shopId);

            if (productsInfo == null)
            {
                throw new HimallException("未找到商品数据");
            }
            //查询已添加的SKU,用于添加时过滤
            var oldskus = _shopBranchService.GetSkus(shopId, new List <long> {
                shopBranchId
            }, null).Select(e => e.SkuId);
            var allSkus        = SKUApplication.GetByProductIds(productsInfo.Select(p => p.Id));
            var shopBranchSkus = new List <ShopBranchSkusInfo> {
            };

            var skus = allSkus.Where(s => !oldskus.Any(sku => sku == s.Id)).Select(e => new ShopBranchSkusInfo
            {
                ProductId    = e.ProductId,
                SkuId        = e.Id,
                ShopId       = shopId,
                ShopBranchId = shopBranchId,
                Stock        = 0,
                CreateDate   = DateTime.Now
            });

            shopBranchSkus.AddRange(skus);

            _shopBranchService.AddSkus(shopBranchSkus);
        }
        public static bool CanOnSaleProduct(IEnumerable <long> productIds)
        {
            bool flag = false;

            if (Enumerable.Count <Product>((IEnumerable <Product>)ProductManagerApplication.GetProductsByIds(productIds)) == Enumerable.Count <long>(productIds))
            {
                flag = true;
            }
            return(flag);
        }
Example #3
0
        public static bool IsOpenLadderInProducts(IEnumerable <long> productIds)
        {
            bool result   = false;
            var  products = ProductManagerApplication.GetProductsByIds(productIds);

            if (products.Where(p => p.IsOpenLadder).Count() > 0)
            {
                result = true;
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// 检测商品是否可以上架
        /// </summary>
        /// <param name="productIds"></param>
        /// <returns></returns>
        public static bool CanOnSaleProduct(IEnumerable <long> productIds)
        {
            bool result   = false;
            var  products = ProductManagerApplication.GetProductsByIds(productIds);

            if (products.Count() == productIds.Count())
            {
                result = true;
            }
            return(result);
        }