/// <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)); }
/// <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)); }
/// <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()); }