public JsonResult ProductList(ShopBranchProductQuery query, int rows, int page)
        {
            query.ShopBranchProductStatus = 0;
            //查询商品
            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            //查询门店SKU库存
            var           allSKU         = ProductManagerApplication.GetSKUByProducts(pageModel.Models.Select(p => p.Id));
            List <string> skuids         = allSKU.Select(p => p.Id).ToList();
            var           shopBranchSkus = ShopBranchApplication.GetSkusByIds(query.ShopBranchId.Value, skuids);

            var dataGrid = new DataGridModel <ProductModel>();

            dataGrid.total = pageModel.Total;
            dataGrid.rows  = pageModel.Models.Select(item =>
            {
                var cate = ShopCategoryApplication.GetCategoryByProductId(item.Id);
                return(new ProductModel()
                {
                    name = item.ProductName,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    categoryName = cate == null ? "" : cate.Name,
                    saleCounts = item.SaleCounts,
                    stock = shopBranchSkus.Where(e => e.ProductId == item.Id).Sum(s => s.Stock),
                    price = item.MinSalePrice,
                    MinPrice = allSKU.Where(s => s.ProductId == item.Id).Min(s => s.SalePrice),
                    MaxPrice = allSKU.Where(s => s.ProductId == item.Id).Max(s => s.SalePrice),
                    ProductType = item.ProductType,
                    shopBranchId = query.ShopBranchId.Value
                });
            }).ToList();
            return(Json(dataGrid));
        }
        /// <summary>
        /// 查询门店诊疗项目
        /// </summary>
        /// <param name="keywords"></param>
        /// <param name="cid"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <param name="branchProductStatus"></param>
        /// <returns></returns>
        public object GetShopBranchProducts(
            string keywords         = "", /* 搜索关键字 */
            long cid                = 0,  /* 分类ID */
            int pageNo              = 1,  /*页码*/
            int pageSize            = 10, /*每页显示数据量*/
            int branchProductStatus = 0
            )
        {
            CheckUserLogin();
            ShopBranchProductQuery query = new ShopBranchProductQuery
            {
                PageNo                  = pageNo,
                PageSize                = pageSize,
                KeyWords                = keywords,
                ShopId                  = CurrentShopBranch.ShopId,
                shopBranchId            = CurrentShopBranch.Id,
                ShopBranchProductStatus = (CommonModel.ShopBranchSkuStatus)branchProductStatus
            };

            if (cid > 0)
            {
                query.CategoryId = cid;
            }
            //查询诊疗项目
            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            //查询门店SKU库存
            List <string> skuids = new List <string>();

            foreach (var p in pageModel.Models)
            {
                skuids.AddRange(p.SKUInfo.Select(e => e.Id));
            }
            var shopBranchSkus = ShopBranchApplication.GetSkusByIds(CurrentShopBranch.Id, skuids);
            //
            var product = pageModel.Models.ToList().Select(item =>
            {
                return(new
                {
                    id = item.Id,
                    name = item.ProductName,
                    price = item.MinSalePrice,
                    salesCount = item.SaleCounts,
                    img = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350),
                    stock = shopBranchSkus.Where(e => e.ProductId == item.Id).Sum(s => s.Stock),
                    productCode = item.ProductCode
                });
            });
            var result = new
            {
                success  = true,
                products = product,
                skus     = shopBranchSkus,
                total    = pageModel.Total
            };

            return(Json(result));
        }
        public object GetShopBranchProducts(
            string keywords         = "", /* 搜索关键字 */
            long cid                = 0,  /* 分类ID */
            int pageNo              = 1,  /*页码*/
            int pageSize            = 10, /*每页显示数据量*/
            int branchProductStatus = 0
            )
        {
            CheckUserLogin();
            ShopBranchProductQuery query = new ShopBranchProductQuery
            {
                PageNo                  = pageNo,
                PageSize                = pageSize,
                KeyWords                = keywords,
                ShopId                  = CurrentShopBranch.ShopId,
                ShopBranchId            = CurrentShopBranch.Id,
                ShopBranchProductStatus = (CommonModel.ShopBranchSkuStatus)branchProductStatus,
                HasLadderProduct        = true
            };

            if (cid > 0)
            {
                query.ShopCategoryId = cid;
            }
            //查询商品
            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            //查询门店SKU库存


            var           allSKU         = ProductManagerApplication.GetSKUByProducts(pageModel.Models.Select(p => p.Id));
            List <string> skuids         = allSKU.Select(p => p.Id).ToList();
            var           shopBranchSkus = ShopBranchApplication.GetSkusByIds(CurrentShopBranch.Id, skuids);

            var product = pageModel.Models.Select(item =>
            {
                return(new
                {
                    id = item.Id,
                    name = item.ProductName,
                    price = item.MinSalePrice,
                    salesCount = item.SaleCounts,
                    img = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350),
                    stock = shopBranchSkus.Where(e => e.ProductId == item.Id).Sum(s => s.Stock),
                    productCode = item.ProductCode
                });
            });
            var result = new
            {
                success  = true,
                products = product,
                skus     = shopBranchSkus,
                total    = pageModel.Total
            };

            return(result);
        }
Beispiel #4
0
        public object GetUpdateCartItem(string skuId, int count, long shopBranchId)
        {
            CheckUserLogin();
            CheckSkuIdIsValid(skuId, shopBranchId);
            //判断库存
            var sku = ProductManagerApplication.GetSKU(skuId);

            if (sku == null)
            {
                throw new MallException("错误的SKU");
            }
            //if (count > sku.Stock)
            //{
            //    throw new MallException("库存不足");
            //}
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new MallException("错误的门店id");
            }
            var shopBranchSkuList = ShopBranchApplication.GetSkusByIds(shopBranchId, new List <string> {
                skuId
            });

            if (shopBranchSkuList == null || shopBranchSkuList.Count == 0)
            {
                throw new MallException("门店没有该商品");
            }
            if (shopBranchSkuList[0].Status == ShopBranchSkuStatus.InStock)
            {
                throw new MallException("此商品已下架");
            }
            var sbsku = shopBranchSkuList.FirstOrDefault();

            if (sbsku.Stock < count)
            {
                throw new MallException("门店库存不足");
            }
            long memberId = CurrentUser.Id;

            CartApplication.UpdateShopBranchCart(skuId, count, memberId, shopBranchId);
            return(Json(""));
        }
        public JsonResult ProductList(ShopBranchProductQuery query)
        {
            query.ShopBranchProductStatus = 0;
            query.OrderKey = 2;
            //查询商品
            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            //查询门店SKU库存
            var           allSKU         = ProductManagerApplication.GetSKUByProducts(pageModel.Models.Select(p => p.Id));
            List <string> skuids         = allSKU.Select(p => p.Id).ToList();
            var           shopBranchSkus = ShopBranchApplication.GetSkusByIds(query.ShopBranchId.Value, skuids);

            var dataGrid = new DataGridModel <ProductModel>();

            dataGrid.total = pageModel.Total;
            dataGrid.rows  = pageModel.Models.Select(item =>
            {
                var cate = ShopCategoryApplication.GetCategoryByProductId(item.Id);
                return(new ProductModel()
                {
                    Name = item.ProductName,
                    Id = item.Id,
                    Image = item.GetImage(ImageSize.Size_50),
                    CategoryName = cate == null ? "" : cate.Name,
                    SaleCount = item.SaleCounts,
                    Stock = shopBranchSkus.Where(e => e.ProductId == item.Id).Sum(s => s.Stock),
                    Price = item.MinSalePrice,
                    MinPrice = allSKU.Where(s => s.ProductId == item.Id).Min(s => s.SalePrice),
                    MaxPrice = allSKU.Where(s => s.ProductId == item.Id).Max(s => s.SalePrice),
                    Url = "",
                    PublishTime = item.AddedDate.ToString("yyyy-MM-dd HH:mm"),
                    SaleState = (int)item.SaleStatus,
                    CategoryId = item.CategoryId,
                    ProductCode = item.ProductCode,
                    ProductType = item.ProductType
                });
            }).ToList();
            return(Json(dataGrid));
        }
Beispiel #6
0
        public void AddToCart(string skuId, int count, long memberId, long shopBranchId)
        {
            CheckSkuIdIsValid(skuId, shopBranchId);
            //判断库存
            var sku = ProductManagerApplication.GetSKU(skuId);

            if (sku == null)
            {
                throw new HimallException("错误的SKU");
            }
            if (count > sku.Stock)
            {
                throw new HimallException("库存不足");
            }
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new HimallException("错误的门店id");
            }
            var shopBranchSkuList = ShopBranchApplication.GetSkusByIds(shopBranchId, new List <string> {
                skuId
            });

            if (shopBranchSkuList == null || shopBranchSkuList.Count == 0)
            {
                throw new HimallException("门店没有该商品");
            }
            if (shopBranchSkuList[0].Status == ShopBranchSkuStatus.InStock)
            {
                throw new HimallException("此商品已下架");
            }

            if (memberId > 0)
            {
                CartApplication.AddToShopBranchCart(skuId, count, memberId, shopBranchId);
            }
            else
            {
                string cartInfo = WebHelper.GetCookie(CookieKeysCollection.HIMALL_CART_BRANCH);
                if (!string.IsNullOrWhiteSpace(cartInfo))
                {
                    string[] cartItems   = cartInfo.Split(',');
                    string   newCartInfo = string.Empty;
                    bool     exist       = false;
                    foreach (string cartItem in cartItems)
                    {
                        var cartItemParts = cartItem.Split(':');
                        if (cartItemParts[0] == skuId && cartItemParts[2] == shopBranchId.ToString())
                        {
                            newCartInfo += "," + skuId + ":" + (int.Parse(cartItemParts[1]) + count) + ":" + shopBranchId;
                            exist        = true;
                        }
                        else
                        {
                            newCartInfo += "," + cartItem;
                        }
                    }
                    if (!exist)
                    {
                        newCartInfo += "," + skuId + ":" + count + ":" + shopBranchId;
                    }

                    if (!string.IsNullOrWhiteSpace(newCartInfo))
                    {
                        newCartInfo = newCartInfo.Substring(1);
                    }
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART_BRANCH, newCartInfo);
                }
                else
                {
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART_BRANCH, string.Format("{0}:{1}:{2}", skuId, count, shopBranchId));
                }
            }
        }
Beispiel #7
0
        private List <CartProductModel> PackageCartProducts(Himall.Entities.ShoppingCartInfo cart, decimal discount, bool isBranch = false)
        {
            List <CartProductModel> products = new List <CartProductModel>();
            var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList());//限时购价格
            var groupCart     = cart.Items.Where(item => item.ShopBranchId == 0).Select(c =>
            {
                var cItem   = new Himall.Entities.ShoppingCartItem();
                var skuInfo = _iProductService.GetSku(c.SkuId);
                if (skuInfo != null)
                {
                    cItem = c;
                }
                return(cItem);
            }).GroupBy(i => i.ProductId).ToList();

            foreach (var item in cart.Items)
            {
                var                        product       = ProductManagerApplication.GetProduct(item.ProductId);
                var                        shop          = _iShopService.GetShop(product.ShopId);
                DTO.ShopBranch             shopbranch    = null;
                Entities.ShopBranchSkuInfo shopbranchsku = null;
                if (item.ShopBranchId > 0)
                {
                    shopbranch    = ShopBranchApplication.GetShopBranchById(item.ShopBranchId);
                    shopbranchsku = ShopBranchApplication.GetSkusByIds(item.ShopBranchId, new List <string> {
                        item.SkuId
                    }).FirstOrDefault();
                }

                if (null != shop)
                {
                    var vshop = VshopApplication.GetVShopByShopId(shop.Id);
                    var sku   = ProductManagerApplication.GetSKU(item.SkuId);
                    if (sku == null)
                    {
                        continue;
                    }
                    //处理限时购、会员折扣价格
                    var prod      = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId);
                    var prodPrice = sku.SalePrice;
                    if (prod != null && !isBranch)
                    {
                        prodPrice = prod.MinPrice;
                    }
                    else
                    {
                        if (shop.IsSelf)
                        {//官方自营店才计算会员折扣
                            prodPrice = sku.SalePrice * discount;
                        }
                    }
                    #region 阶梯价--张宇枫
                    //阶梯价
                    if (product.IsOpenLadder)
                    {
                        var quantity = groupCart.Where(i => i.Key == item.ProductId).ToList().Sum(cartitem => cartitem.Sum(i => i.Quantity));
                        prodPrice = ProductManagerApplication.GetProductLadderPrice(item.ProductId, quantity);
                        if (shop.IsSelf)
                        {
                            prodPrice = prodPrice * discount;
                        }
                    }
                    #endregion
                    var    typeInfo     = TypeApplication.GetProductType(product.TypeId);
                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (product != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
                    }
                    if (sku != null)
                    {
                        #region 正在参加限时抢购商品在购物车失效 TDO:ZYF
                        var isLimit = false;
                        //门店商品,在参加限时购,也可以正常购买
                        var limit = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.ProductId);
                        if (limit != null && !isBranch)
                        {
                            isLimit = limit.Status == Entities.FlashSaleInfo.FlashSaleStatus.Ongoing;
                        }
                        #endregion
                        var _tmp = new CartProductModel
                        {
                            cartItemId     = item.Id,
                            skuId          = item.SkuId,
                            id             = product.Id,
                            imgUrl         = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_150),
                            name           = product.ProductName,
                            price          = prodPrice.ToString("F2"),
                            count          = item.Quantity,
                            ShopId         = shop.Id.ToString(),
                            Size           = sku.Size,
                            Color          = sku.Color,
                            Version        = sku.Version,
                            VShopId        = vshop == null ? "0" : vshop.Id.ToString(),
                            ShopName       = shop.ShopName,
                            ShopLogo       = vshop == null ? "" : Core.HimallIO.GetRomoteImagePath(vshop.StrLogo),
                            Url            = Core.HimallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId,
                            ProductStatus  = isLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()),
                            status         = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku, item.Quantity, shopbranch, shopbranchsku),// 0:正常;1:已失效;2:库存不足;3:已下架;
                            ColorAlias     = colorAlias,
                            SizeAlias      = sizeAlias,
                            VersionAlias   = versionAlias,
                            AddTime        = item.AddTime,
                            shopBranchId   = item.ShopBranchId,
                            shopBranchName = null == shopbranch ? "" : shopbranch.ShopBranchName,
                            ShopBranchLogo = null == shopbranch ? "" : Core.HimallIO.GetRomoteImagePath(shopbranch.ShopImages)
                        };
                        products.Add(_tmp);
                    }
                }
            }
            return(products);
        }
Beispiel #8
0
        public object GetCart(long shopBranchId)
        {
            //CheckUserLogin();
            long userId = 0;
            //会员折扣
            decimal discount = 1.0M;//默认折扣为1(没有折扣)

            if (CurrentUser != null)
            {
                userId   = CurrentUser.Id;
                discount = CurrentUser.MemberDiscount;
            }
            var cart       = GetCart(userId, shopBranchId);
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new MallException("门店库存不足");
            }
            var     stores    = cart.Items.Where(d => d.ShopBranchId > 0).OrderByDescending(d => d.AddTime).Select(d => d.ShopBranchId).GroupBy(d => d);
            decimal prodPrice = 0.0M;//优惠价格
            //var rets = new List<CartStoreModel>();
            var _store = new CartStoreModel();

            _store.ShopBranchId   = shopBranch.Id;
            _store.ShopId         = shopBranch.ShopId;
            _store.ShopBranchName = shopBranch.ShopBranchName;
            _store.Status         = shopBranch.Status.GetHashCode();
            _store.DeliveFee      = shopBranch.DeliveFee;
            _store.DeliveTotalFee = shopBranch.DeliveTotalFee;
            _store.FreeMailFee    = shopBranch.FreeMailFee;
            var product = cart.Items.Where(d => d.ShopBranchId == shopBranch.Id).OrderBy(s => s.Status).ThenByDescending(o => o.AddTime).ToList();

            _store.Products = new List <CartStoreProduct>();
            foreach (var pitem in product)
            {
                var pro           = ProductManagerApplication.GetProduct(pitem.ProductId);
                var shopbranchsku = ShopBranchApplication.GetSkusByIds(_store.ShopBranchId, new List <string> {
                    pitem.SkuId
                }).FirstOrDefault();
                var     shop       = ShopApplication.GetShop(pro.ShopId);
                var     vshop      = VshopApplication.GetVShopByShopId(pro.ShopId);
                DTO.SKU sku        = ProductManagerApplication.GetSKU(pitem.SkuId);
                string  skuDetails = "";
                if (null != shop && sku != null)
                {
                    prodPrice = sku.SalePrice;
                    if (shop.IsSelf)
                    {
                        //官方自营店才计算会员折扣
                        prodPrice = sku.SalePrice * discount;
                    }
                    prodPrice = decimal.Round(prodPrice, 2, MidpointRounding.AwayFromZero);

                    var typeInfo = TypeApplication.GetProductType(pro.TypeId);
                    skuDetails = "";
                    if (!string.IsNullOrWhiteSpace(sku.Size))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Size;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Color))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Color;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Version))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Version;
                    }
                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (pro != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(pro.ColorAlias) ? pro.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(pro.SizeAlias) ? pro.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(pro.VersionAlias) ? pro.VersionAlias : versionAlias;
                    }
                    var _product = new CartStoreProduct
                    {
                        ShopBranchId = shopBranchId,
                        CartItemId   = pitem.Id,
                        SkuId        = pitem.SkuId,
                        Id           = pro.Id,
                        ProductName  = pro.ProductName,
                        Price        = prodPrice,
                        Count        = pitem.Quantity,
                        Stock        = shopbranchsku == null ? 0 : shopbranchsku.Stock,
                        //阶梯价商品在门店购物车自动下架
                        Status       = ProductManagerApplication.GetProductShowStatus(pro, sku, 1, shopBranch, shopbranchsku),//0:正常;1:冻结;2:库存不足
                        SkuDetails   = skuDetails,
                        ColorAlias   = colorAlias,
                        SizeAlias    = sizeAlias,
                        VersionAlias = versionAlias,
                        Size         = sku.Size,
                        Color        = sku.Color,
                        Version      = sku.Version,
                        AddTime      = pitem.AddTime,
                        DefaultImage = MallIO.GetRomoteProductSizeImage(pro.ImagePath, 1, 500)
                    };
                    _store.Products.Add(_product);
                }
            }
            _store.Amount     = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Price * s.Count) : 0;
            _store.TotalCount = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Count) : 0;
            if (_store.Products.Count > 0)
            {//有商品数据,才返回门店信息
                _store.Products = _store.Products.OrderBy(p => p.Status).ThenByDescending(p => p.AddTime).ToList();
                //rets.Add(_store);
            }
            return(Json(_store));
        }
        /// <summary>
        /// 加载门店编辑商品列表
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="shopbranchId"></param>
        /// <returns></returns>
        public JsonResult GetProductsByIds(string ids, long shopbranchId)
        {
            if (string.IsNullOrWhiteSpace(ids))
            {
                return(Json(new { success = false, msg = "参数传递错误" }));
            }

            var pIds     = ConvertToIEnumerable(ids);
            var products = ProductManagerApplication.GetAllProductByIds(pIds);

            //查询门店SKU库存
            var           allSKU         = ProductManagerApplication.GetSKUByProducts(products.Select(p => p.Id));
            List <string> skuids         = allSKU.Select(p => p.Id).ToList();
            var           shopBranchSkus = ShopBranchApplication.GetSkusByIds(shopbranchId, skuids);

            List <ProductModel> productlist = new List <ProductModel>();

            foreach (var item in products)
            {
                var          skus    = ProductManagerApplication.GetSKUs(item.Id);
                ProductModel product = new ProductModel()
                {
                    Name  = item.ProductName,
                    Id    = item.Id,
                    Image = item.GetImage(ImageSize.Size_50),
                    Price = item.MinSalePrice
                };
                List <SKuModel> skulist = new List <SKuModel>();
                foreach (var skuInfo in skus)
                {
                    var shopbranckSku = shopBranchSkus.Where(s => s.SkuId == skuInfo.Id).FirstOrDefault();
                    var str           = string.Empty;
                    if (!string.IsNullOrWhiteSpace(skuInfo.Color))
                    {
                        str += item.ColorAlias + ":" + skuInfo.Color;
                    }
                    else
                    {
                        str += " " + item.ColorAlias + ";";
                    }
                    if (!string.IsNullOrWhiteSpace(skuInfo.Size))
                    {
                        str += " " + item.SizeAlias + ":" + skuInfo.Size;
                    }
                    else
                    {
                        str += " " + item.SizeAlias + ";";
                    }
                    if (!string.IsNullOrWhiteSpace(skuInfo.Version))
                    {
                        str += " " + item.VersionAlias + ":" + skuInfo.Version;
                    }
                    else
                    {
                        str += " " + item.VersionAlias + ";";
                    }
                    var model = new SKuModel()
                    {
                        ProductName = (item.HasSKU ? str.TrimEnd(';') : ""),
                        Sku         = item.HasSKU ? (skuInfo.Sku ?? string.Empty) : item.ProductCode,
                        Id          = skuInfo.Id,
                        AutoId      = shopbranckSku.Id,
                        Stock       = shopbranckSku.Stock,
                        MarketPrice = item.MarketPrice,
                        SalePrice   = item.HasSKU ? skuInfo.SalePrice : item.MinSalePrice,//有规格则取规格商城价,否则取商品本身商城价
                        ProductId   = item.Id,
                        HasSKU      = item.HasSKU ? 1 : 0
                    };
                    if (skus.IndexOf(skuInfo) == 0)
                    {
                        model.IsFirst = 1;
                    }
                    skulist.Add(model);
                }
                product.Skus = skulist;
                productlist.Add(product);
            }
            return(Json(new
            {
                success = true,
                model = productlist
            }));
        }