From 3ed452c80391b76086b4b2104a1ab5e3de005daf Mon Sep 17 00:00:00 2001 From: "AERWEN\\26795" <123456789a> Date: Thu, 26 Oct 2023 09:40:25 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B1=BB=E7=9B=AE=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShopGoodsCategoryDto.cs | 3 ++ .../ShopGoodsCategorys/ShopGoodsCategory.cs | 9 +++++ .../ShopGoodsCategorys/ShopGoodsCategoryVo.cs | 9 ++++- .../GoodsCategorys/GoodsCategoryServiceApi.cs | 37 ++++++++++++++++--- .../GoodsManager/Goodss/GoodsServiceApi.cs | 24 ++++++++++-- .../IGoodsCategoryServiceApi.cs | 8 ++++ .../ShopGoodsCategoryService.cs | 3 +- .../GoodsCategoryApiController.cs | 16 ++++++++ 8 files changed, 98 insertions(+), 11 deletions(-) diff --git a/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs b/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs index b8e5c34..5ad1fc7 100644 --- a/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs +++ b/ARW.Model/Dto/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryDto.cs @@ -33,6 +33,9 @@ namespace ARW.Model.Dto.Business.GoodsManager.ShopGoodsCategorys [Required(ErrorMessage = "显示状态不能为空")] public int ShopGoodsCategoryDisplayStatus { get; set; } + [Required(ErrorMessage = "是否为热门不能为空")] + public int ShopGoodsCategoryIsPopular { get; set; } + [Required(ErrorMessage = "排序不能为空")] public int ShopGoodsCategorySort { get; set; } diff --git a/ARW.Model/Models/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategory.cs b/ARW.Model/Models/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategory.cs index 7110d7f..9493cfc 100644 --- a/ARW.Model/Models/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategory.cs +++ b/ARW.Model/Models/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategory.cs @@ -83,6 +83,15 @@ namespace ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys public string ShopGoodsCategoryImg { get; set; } + /// + /// 描述 :是否为热门 + /// 空值 : false + /// + [EpplusTableColumn(Header = "是否为热门")] + [SugarColumn(ColumnName = "shop_goods_category_is_popular")] + public int ShopGoodsCategoryIsPopular { get; set; } + + /// /// 描述 :显示状态 /// 空值 : false diff --git a/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs b/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs index 21a7a82..3246d1f 100644 --- a/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs +++ b/ARW.Model/Vo/Business/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryVo.cs @@ -89,7 +89,14 @@ namespace ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys [EpplusIgnore] public int ShopGoodsCategoryDisplayStatus { get; set; } - + + /// + /// 描述 :是否为热门 + /// + [EpplusTableColumn(Header = "是否为热门")] + public int ShopGoodsCategoryIsPopular { get; set; } + + /// /// 描述 :显示状态名称 /// diff --git a/ARW.Service/Api/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryServiceApi.cs b/ARW.Service/Api/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryServiceApi.cs index 028ea38..eeeff00 100644 --- a/ARW.Service/Api/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryServiceApi.cs +++ b/ARW.Service/Api/BusinessService/GoodsManager/GoodsCategorys/GoodsCategoryServiceApi.cs @@ -14,6 +14,7 @@ using ARW.Model.Dto.Api.GoodsManager.GoodsCategorys; using ARW.Model.Models.Business.GoodsManager.GoodsCategorys; using ARW.Model.Vo.Api.GoodsManager.GoodsCategorys; using ARW.Model.Vo.Api.Home; +using ARW.Repository.Business.GoodsManager.ShopGoodsCategorys; namespace ARW.Service.Api.BusinessService.GoodsManager.GoodsCategorys { @@ -27,10 +28,12 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.GoodsCategorys public class GoodsCategoryServiceImplApi : BaseService, IGoodsCategoryServiceApi { private readonly GoodsCategoryRepository _GoodsCategoryRepository; + private readonly ShopGoodsCategoryRepository _ShopGoodsCategoryRepository; - public GoodsCategoryServiceImplApi(GoodsCategoryRepository GoodsCategoryRepository) + public GoodsCategoryServiceImplApi(GoodsCategoryRepository GoodsCategoryRepository, ShopGoodsCategoryRepository shopGoodsCategoryRepository) { this._GoodsCategoryRepository = GoodsCategoryRepository; + _ShopGoodsCategoryRepository = shopGoodsCategoryRepository; } #region Api接口代码 @@ -65,20 +68,42 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.GoodsCategorys } + /// + /// 获取店铺类目树形列表(Api) + /// + /// + /// + public async Task> GetShopGoodsCategoryTreeListApi(GoodsCategoryQueryDtoApi parm) + { + var query = _ShopGoodsCategoryRepository + .Queryable() + .OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc) + .Select((s) => new GoodsCategoryVoApi + { + GroupId = s.ShopGoodsCategoryGuid, + ParentGuid = s.ShopGoodsCategoryParentGuid, + Name = s.ShopGoodsCategoryName, + Thumbnail = s.ShopGoodsCategoryImg, + }); + + return await query.ToTreeAsync(it => it.Children, it => it.ParentGuid, 0); + } + + /// /// 获取首页推荐类目列表(Api) /// /// public async Task> GetHomeCategoryListApi() { - var query = _GoodsCategoryRepository + var query = _ShopGoodsCategoryRepository .Queryable() - .Where(s => s.GoodsCategoryIsPopular == 1) - .OrderBy(s => s.ProductCategorySort, OrderByType.Asc) + .Where(s => s.ShopGoodsCategoryIsPopular == 1) + .OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc) .Select((s) => new HomeCategoryApiVo { - Key = s.GoodsCategoryGuid, - Text = s.GoodsCategoryName, + Key = s.ShopGoodsCategoryGuid, + Text = s.ShopGoodsCategoryName, }); var list = await query.ToListAsync(); diff --git a/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs b/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs index c03c126..eaa84db 100644 --- a/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs +++ b/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs @@ -30,6 +30,8 @@ using Infrastructure; using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; using ARW.Model.Vo.Business.GoodsManager.Goodss; using ARW.Service.Business.IBusinessService.Custom.GoodsCollections; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; +using ARW.Repository.Business.GoodsManager.ShopGoodsCategorys; namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss { @@ -51,10 +53,11 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss private readonly DeliveryRepository _DeliveryRepository; private readonly DeliveryRuleRepository _DeliveryRuleRepository; private readonly CustomerAddressRepository _CustomerAddressRepository; + private readonly ShopGoodsCategoryRepository _ShopGoodsCategoryRepository; private readonly IGoodsCollectionService _GoodsCollectionService; - public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository, DeliveryRepository deliveryRepository, CustomerAddressRepository customerAddressRepository, DeliveryRuleRepository deliveryRuleRepository, IGoodsCollectionService goodsCollectionService) + public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository, DeliveryRepository deliveryRepository, CustomerAddressRepository customerAddressRepository, DeliveryRuleRepository deliveryRuleRepository, IGoodsCollectionService goodsCollectionService, ShopGoodsCategoryRepository shopGoodsCategoryRepository) { this._GoodsRepository = GoodsRepository; _GoodsSpecRelRepository = goodsSpecRelRepository; @@ -66,6 +69,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss _CustomerAddressRepository = customerAddressRepository; _DeliveryRuleRepository = deliveryRuleRepository; _GoodsCollectionService = goodsCollectionService; + _ShopGoodsCategoryRepository = shopGoodsCategoryRepository; } #region Api接口代码 @@ -95,8 +99,22 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss // goodsCategoryArr = SewGoodsCategorys.Select(s => s.GoodsCategoryGuid.ToString()).ToArray(); //} + // 检索商品类目 + if (parm.ShopGoodsCategoryGuid != 0) + { + var data = await _ShopGoodsCategoryRepository.GetListAsync(); + + var SewshopGoodsCategorys = data.FindAll(delegate (ShopGoodsCategory shopGoodsCategory) + { + string[] parentShopGoodsCategoryId = shopGoodsCategory.ShopGoodsCategoryAncestralGuid.Split(",", StringSplitOptions.RemoveEmptyEntries); + return parentShopGoodsCategoryId.Contains(parm.ShopGoodsCategoryGuid.ToString()); + }); + string[] shopGoodsCategoryArr = SewshopGoodsCategorys.Select(s => s.ShopGoodsCategoryGuid.ToString()).ToArray(); + predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid || shopGoodsCategoryArr.Contains(s.ShopGoodsCategoryGuid.ToString())); + } + predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid); - predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid); + //predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsName), s => s.GoodsName.Contains(parm.GoodsName)); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCoding), s => s.GoodsCoding.Contains(parm.GoodsCoding)); predicate = predicate.AndIF(parm.MinPrice != 0, s => s.GoodsPriceLowest >= parm.MinPrice); @@ -109,7 +127,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss .Queryable() .LeftJoin((s, c) => s.ShopGuid == c.ShopGuid) .Where(predicate.ToExpression()) - .WhereIF(parm.GoodsCategoryGuid != 0, (s, c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid) + //.WhereIF(parm.GoodsCategoryGuid != 0, (s, c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid) //.WhereIF(parm.GoodsCategoryGuid != null, (s, c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid || goodsCategoryArr.Contains(c.ShopBusinessCategoryGuid.ToString())) .Where(s => s.GoodsShelfStatus == 1) .OrderByIF(parm.GoodsSort == 0, s => s.GoodsSort, OrderByType.Asc) diff --git a/ARW.Service/Api/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryServiceApi.cs b/ARW.Service/Api/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryServiceApi.cs index e13821f..aa51aba 100644 --- a/ARW.Service/Api/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryServiceApi.cs +++ b/ARW.Service/Api/IBusinessService/GoodsManager/GoodsCategorys/IGoodsCategoryServiceApi.cs @@ -27,6 +27,14 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.GoodsCategorys Task> GetGoodsCategoryTreeListApi(GoodsCategoryQueryDtoApi parm); + /// + /// 获取店铺类目树形列表(Api) + /// + /// + /// + Task> GetShopGoodsCategoryTreeListApi(GoodsCategoryQueryDtoApi parm); + + /// /// 获取首页推荐类目列表(Api) /// diff --git a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs index 5d2997f..89e975f 100644 --- a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs +++ b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs @@ -74,7 +74,8 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys ShopGoodsCategoryDisplayStatus = s.ShopGoodsCategoryDisplayStatus, ShopGoodsCategorySort = s.ShopGoodsCategorySort, ParentName = c.ShopGoodsCategoryName, - ShopGoodsCategoryImg = s.ShopGoodsCategoryImg + ShopGoodsCategoryImg = s.ShopGoodsCategoryImg, + ShopGoodsCategoryIsPopular = s.ShopGoodsCategoryIsPopular }); return await query.ToTreeAsync(it => it.Children, it => it.ShopGoodsCategoryParentGuid, 0); diff --git a/ARW.WebApi/Controllers/Api/GoodsManager/GoodsCategorys/GoodsCategoryApiController.cs b/ARW.WebApi/Controllers/Api/GoodsManager/GoodsCategorys/GoodsCategoryApiController.cs index a068b60..e88cd43 100644 --- a/ARW.WebApi/Controllers/Api/GoodsManager/GoodsCategorys/GoodsCategoryApiController.cs +++ b/ARW.WebApi/Controllers/Api/GoodsManager/GoodsCategorys/GoodsCategoryApiController.cs @@ -55,5 +55,21 @@ namespace ARW.WebApi.Controllers.Api.GoodsManager.GoodsCategorys return SUCCESS(res); } + + /// + /// 获取店铺类目树形列表(Api) + /// + /// 查询参数 + /// + [HttpGet("getShopGoodsCategoryTreeList")] + public async Task GetShopGoodsCategoryTreeListApi([FromQuery] GoodsCategoryQueryDtoApi parm) + { + var res = await _GoodsCategoryServiceApi.GetShopGoodsCategoryTreeListApi(parm); + if (res == null) + res = new List(); + + return SUCCESS(res); + } + } }