Example #1
0
        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));
        }
Example #2
0
        /// <summary>
        /// 门店首页
        /// </summary>
        /// <param name="shopBranchId">门店ID</param>
        /// <returns></returns>
        public object GetStoreHome(long shopBranchId)
        {
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                return(Json(new { Success = false, Message = "获取当前门店信息错误!" }));
            }

            shopBranch.ShopImages    = string.IsNullOrWhiteSpace(shopBranch.ShopImages) ? "" : Core.HimallIO.GetRomoteImagePath(shopBranch.ShopImages);
            shopBranch.AddressDetail = ShopBranchApplication.RenderAddress(shopBranch.AddressPath, shopBranch.AddressDetail, 2);
            var shopCategory = ShopCategoryApplication.GetCategoryByParentId(0, shopBranch.ShopId).Select(item =>
            {
                return(new
                {
                    Id = item.Id,
                    Name = item.Name
                });
            });

            var result = new
            {
                Success      = true,
                StoreInfo    = shopBranch,
                ShopCategory = shopCategory
            };

            return(Json(result));
        }
Example #3
0
        /// <summary>
        /// 获取商铺分类
        /// </summary>
        /// <param name="shopId"></param>
        /// <param name="pid"></param>
        /// <returns></returns>
        public JsonResult <Result <List <ShopCategory> > > GetShopCategory(long shopId, long pid = 0, long shopBranchId = 0)
        {
            var cate = ShopCategoryApplication.GetCategoryByParentId(pid, shopId);

            if (shopBranchId > 0)
            {
                //屏蔽没有商品的分类
                List <long> noshowcid = new List <long>();
                foreach (var item in cate)
                {
                    ShopBranchProductQuery query = new ShopBranchProductQuery();
                    query.PageSize                = 1;
                    query.PageNo                  = 1;
                    query.ShopId                  = shopId;
                    query.ShopBranchId            = shopBranchId;
                    query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;
                    query.ShopCategoryId          = item.Id;
                    //query.FilterVirtualProduct = true;//过滤虚拟商品
                    var _pros = ShopBranchApplication.GetShopBranchProducts(query);
                    if (_pros.Total <= 0)
                    {
                        noshowcid.Add(item.Id);
                    }
                }
                if (noshowcid.Count > 0)
                {
                    cate = cate.Where(d => !noshowcid.Contains(d.Id)).ToList();
                }
            }
            return(JsonResult(cate));
        }
Example #4
0
        public object GetSellerMobileHomePageProducts(long shopId, PlatformType platformType, int page, int rows, string brandName, long?categoryId = null)
        {
            var data      = MobileHomeProductApplication.GetSellerMobileHomePageProducts(shopId, platformType, page, rows, brandName, categoryId);
            var products  = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));
            var brands    = BrandApplication.GetBrands(products.Select(p => p.BrandId).ToList());
            var categorys = ShopCategoryApplication.GetCategorysByProduct(products.Select(p => p.Id).ToList());

            var list = data.Models.Select(item =>
            {
                var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                var brand    = brands.FirstOrDefault(p => p.Id == product.BrandId);
                var category = categorys.FirstOrDefault(p => p.ProductId == product.Id);
                return(new
                {
                    id = item.Id,
                    productId = item.ProductId,
                    name = product.ProductName,
                    image = product.GetImage(ImageSize.Size_50),
                    price = product.MinSalePrice.ToString("F2"),
                    brand = brand?.Name ?? string.Empty,
                    sequence = item.Sequence,
                    categoryName = category?.ShopCategoryName ?? string.Empty,
                });
            });


            return(new { rows = list, total = data.Total });
        }
Example #5
0
        /// <summary>
        /// 门店商品管理
        /// </summary>
        /// <param name="shopBranchId"></param>
        /// <returns></returns>
        public ActionResult ProductManagement(long shopBranchId)
        {
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            ViewBag.ShopBranchName = shopBranch.ShopBranchName;
            ViewBag.ShopCategorys  = ShopCategoryApplication.GetShopCategory(shopBranch.ShopId);
            return(View());
        }
        public ActionResult Category()
        {
            var firstLevel = ShopCategoryApplication.GetMainCategory(CurrentSellerManager.ShopId);
            List <ShopCategoryModel> list = new List <ShopCategoryModel>();

            foreach (var item in firstLevel)
            {
                list.Add(new ShopCategoryModel(item));
            }
            return(View(list));
        }
Example #7
0
        private ProductCreateModel InitCreateModel(ProductCreateModel model = null)
        {
            if (model == null)
            {
                model = new ProductCreateModel();
            }
            long id = base.CurrentShop.Id;

            model.ShopCategorys = ShopCategoryApplication.GetShopCategory(id);
            return(model);
        }
Example #8
0
        /// <summary>
        /// 门店商品管理
        /// </summary>
        /// <param name="shopBranchId"></param>
        /// <returns></returns>
        public ActionResult ProductManagement(long shopBranchId)
        {
            var shopBranch     = ShopBranchApplication.GetShopBranchById(shopBranchId);
            var shopBranchName = string.Empty;

            if (shopBranch != null)
            {
                shopBranchName = shopBranch.ShopBranchName;
            }
            ViewBag.ShopBranchName = shopBranchName;
            ViewBag.ShopCategorys  = ShopCategoryApplication.GetShopCategory(CurrentSellerManager.ShopId);
            return(View());
        }
Example #9
0
        /// <summary>
        /// 门店首页
        /// </summary>
        /// <param name="id">门店ID</param>
        /// <returns></returns>
        public ActionResult Index(long id = 0)
        {
            bool isOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore;

            if (!isOpenStore)
            {
                throw new Core.HimallException("门店未授权!");
            }
            var shopBranch = ShopBranchApplication.GetShopBranchById(id);

            if (shopBranch == null)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            shopBranch.AddressDetail = ShopBranchApplication.RenderAddress(shopBranch.AddressPath, shopBranch.AddressDetail, 2);
            ViewBag.ShopBranch       = shopBranch;
            ViewBag.ShopCategory     = ShopCategoryApplication.GetCategoryByParentId(0, shopBranch.ShopId);

            return(View());
        }
Example #10
0
        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));
        }
Example #11
0
        public ActionResult ExportToExcel(long?categoryId = null, string brandName = "", string productCode = "", int?auditStatus = null, string ids = "", string keyWords = "", string shopName = "", int?saleStatus = null, sbyte?productType = null)
        {
            var query = new ProductQuery()
            {
                PageSize           = int.MaxValue,
                PageNo             = 1,
                BrandName          = brandName,
                KeyWords           = keyWords,
                CategoryId         = categoryId,
                Ids                = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopName           = shopName,
                ProductCode        = productCode,
                NotIncludedInDraft = true
            };

            if (productType.HasValue && productType.Value > -1)
            {
                query.ProductType = productType.Value;
            }
            if (auditStatus.HasValue)
            {
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)auditStatus };
                if (auditStatus == (int)ProductInfo.ProductAuditStatus.WaitForAuditing)
                {
                    query.SaleStatus = ProductInfo.ProductSaleStatus.OnSale;
                }
            }
            if (saleStatus.HasValue)
            {
                query.SaleStatus = (ProductInfo.ProductSaleStatus)saleStatus;
            }


            var data = ProductManagerApplication.GetProducts(query);

            #region 先查询到列表,便于下面循环读取
            List <CategoryInfo>                 listproductcate = new List <CategoryInfo>();            //商品分类
            List <BrandInfo>                    listbrand       = new List <BrandInfo>();               //品牌
            List <FreightTemplateInfo>          listtemplate    = new List <FreightTemplateInfo>();     //运费模板
            List <Mall.DTO.ProductShopCategory> listshopcate    = new List <DTO.ProductShopCategory>(); //商铺分类
            Dictionary <long, string>           shopnames       = new Dictionary <long, string>();
            if (data.Models != null)
            {
                List <long> cateids = data.Models.Select(p => p.CategoryId).ToList();
                listproductcate = CategoryApplication.GetCateogryListByIds(cateids);//平台分类
                if (listproductcate == null)
                {
                    listproductcate = new List <CategoryInfo>();
                }

                List <long> templateIds = data.Models.Select(p => p.FreightTemplateId).ToList();
                listtemplate = FreightTemplateApplication.GetFreightTemplateList(templateIds);//运费模板
                if (listtemplate == null)
                {
                    listtemplate = new List <FreightTemplateInfo>();              //实例下便免下面循环里判断空
                }
                IEnumerable <long> brandIds = data.Models.Select(p => p.BrandId); //品牌
                listbrand = BrandApplication.GetBrands(brandIds);
                if (listbrand == null)
                {
                    listbrand = new List <BrandInfo>();
                }

                List <long> productids = data.Models.Select(p => p.Id).ToList();//商铺分类
                listshopcate = ShopCategoryApplication.GetCategorysByProduct(productids);
                if (listshopcate == null)
                {
                    listshopcate = new List <DTO.ProductShopCategory>();
                }

                List <long> shopids = data.Models.Select(p => p.ShopId).ToList();
                shopnames = ShopApplication.GetShopNames(shopids);
                if (shopnames == null)
                {
                    shopnames = new Dictionary <long, string>();
                }
            }
            #endregion

            var products = data.Models.Select(item =>
            {
                var desc = ProductManagerApplication.GetProductDescription(item.Id);
                var skus = _iProductService.GetSKUs(item.Id);

                var brand        = (item.BrandId <= 0) ? null : listbrand.Where(p => p.Id == item.BrandId).FirstOrDefault();                        //品牌
                var freightTem   = (item.FreightTemplateId <= 0) ? null : listtemplate.Where(p => p.Id == item.FreightTemplateId).FirstOrDefault(); //运费模板
                var platFormCate = (item.CategoryId <= 0) ? null : listproductcate.Where(p => p.Id == item.CategoryId).FirstOrDefault();            //平台分类
                var shopcate     = listshopcate.Where(p => p.ProductId == item.Id).FirstOrDefault();                                                //商铺分类

                return(new ProductModel()
                {
                    //TODO:FG 循环内查询调用(大数据量)
                    name = item.ProductName,
                    brandName = brand == null ? "" : brand.Name,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    state = item.ShowProductState,
                    auditStatus = (int)item.AuditStatus,
                    url = "",
                    auditReason = desc?.AuditReason ?? string.Empty,
                    //shopName = shopService.GetShopBasicInfo(item.ShopId) == null ? "" : shopService.GetShopBasicInfo(item.ShopId).ShopName,
                    shopName = shopnames[item.ShopId],
                    saleStatus = (int)item.SaleStatus,
                    productCode = item.ProductCode,

                    categoryName = platFormCate == null ? "" : platFormCate.Name,         //平台分类
                    ShopCategoryName = shopcate == null ? "" : shopcate.ShopCategoryName, //商家分类
                    AuditStatusText = (item.AuditStatus == ProductInfo.ProductAuditStatus.Audited ? "已审核" : "待审核"),
                    MeasureUnit = item.MeasureUnit,
                    HasSKU = item.HasSKU,
                    SKUInfo = skus,
                    FreightTemplateName = freightTem == null ? "" : freightTem.Name,                                                       //运费模板名称
                    IsOpenLadder = item.IsOpenLadder,                                                                                      //是否开启阶梯批发
                    ProductLadderPrice = ProductManagerApplication.GetLadderPriceInfosByProductId(item.Id, item.IsOpenLadder),
                    ProductTypeName = item.ProductType == 1 ? "虚拟商品" : "实物商品",                                                             //商品类型(虚拟或实物)
                    VirtualProduct = (item.ProductType == 1 ? ProductManagerApplication.GetVirtualProductInfoByProductId(item.Id) : null), //虚拟商品
                    AuditReason = desc == null?"":desc.AuditReason,                                                                        //审核备注
                    AddedDate = item.AddedDate.ToString(),                                                                                 //发布日期
                    MarketPrice = item.MarketPrice,                                                                                        //市场价
                });
            });

            #region 构建Excel文档
            ViewData.Model = products;
            string viewHtml = RenderPartialViewToString(this, "ExportProductinfo");
            return(File(System.Text.Encoding.UTF8.GetBytes(viewHtml), "application/ms-excel", string.Format("平台商品信息_{0}.xls", DateTime.Now.ToString("yyyy-MM-dd"))));

            #endregion
        }