diff --git a/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs b/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs index a41e5417..7ec11e0c 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs @@ -59,6 +59,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers private ICoreCmsAgentServices _agentServices; private ICoreCmsAgentProductsServices _agentProductsServices; private ICoreCmsAgentGradeServices _agentGradeServices; + private ICoreCmsGoodsCategoryExtendServices _goodsCategoryExtendServices; /// /// 构造函数 @@ -75,7 +76,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers , ICoreCmsGoodsParamsServices goodsParamsServices , ICoreCmsGoodsCollectionServices goodsCollectionServices , ICoreCmsUserServices userServices - , ICoreCmsAgentServices agentServices, ICoreCmsAgentProductsServices agentProductsServices, ICoreCmsAgentGradeServices agentGradeServices) + , ICoreCmsAgentServices agentServices, ICoreCmsAgentProductsServices agentProductsServices, ICoreCmsAgentGradeServices agentGradeServices, ICoreCmsGoodsCategoryExtendServices goodsCategoryExtendServices) { _mapper = mapper; _user = user; @@ -92,6 +93,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers _agentServices = agentServices; _agentProductsServices = agentProductsServices; _agentGradeServices = agentGradeServices; + _goodsCategoryExtendServices = goodsCategoryExtendServices; } //公共接口==================================================================================================== @@ -205,7 +207,17 @@ namespace CoreCms.Net.Web.WebApi.Controllers var categories = await _goodsCategoryServices.QueryAsync(true, true); var ids = GoodsHelper.GetChildIds(categories, catId); - where = where.And(p => ids.Contains(p.goodsCategoryId)); + //扩展分类 + var extends = await _goodsCategoryExtendServices.QueryListByClauseAsync(p => p.goodsCategroyId == catId); + if (extends.Any()) + { + var extGoodIds = extends.Select(p => p.goodsId).ToList(); + where = where.And(p => ids.Contains(p.goodsCategoryId) || extGoodIds.Contains(p.id)); + } + else + { + where = where.And(p => ids.Contains(p.goodsCategoryId)); + } } } if (!string.IsNullOrWhiteSpace(obj.brandId))