/// <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);
        }
        /// <summary>
        /// 修正商品sku
        /// <para>0库存添加新的sku</para>
        /// </summary>
        /// <param name="productId"></param>
        public static void CorrectBranchProductSkus(long productId, long shopId)
        {
            var productsInfo = ProductManagerApplication.GetProduct(productId);

            if (productsInfo == null || productsInfo.ShopId != shopId)
            {
                throw new HimallException("未找到商品数据");
            }
            var         shopbrids = _shopBranchService.GetAgentShopBranchIds(productId);
            List <long> pids      = new List <long>();

            pids.Add(productId);

            foreach (var shopBranchId in shopbrids)
            {
                //查询已添加的SKU,用于添加时过滤
                var oldskus = _shopBranchService.GetSkus(shopId, new List <long> {
                    shopBranchId
                }, null).Select(e => e.SkuId);
                var allSkus        = SKUApplication.GetByProductIds(pids);
                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);
            }
        }