diff --git a/ARW.Model/Dto/Api/GoodsManager/Goodss/GoodsApiDto.cs b/ARW.Model/Dto/Api/GoodsManager/Goodss/GoodsApiDto.cs index 50a30e6..27e236a 100644 --- a/ARW.Model/Dto/Api/GoodsManager/Goodss/GoodsApiDto.cs +++ b/ARW.Model/Dto/Api/GoodsManager/Goodss/GoodsApiDto.cs @@ -24,7 +24,7 @@ namespace ARW.Model.Dto.Api.GoodsManager.Goodss /// /// 店铺商品类目 /// - public long? ShopGoodsCategoryGuid { get; set; } + public long ShopGoodsCategoryGuid { get; set; } public string GoodsName { get; set; } public string GoodsCoding { get; set; } public int GoodsSort { get; set; } diff --git a/ARW.Model/Dto/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiDto.cs b/ARW.Model/Dto/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiDto.cs new file mode 100644 index 0000000..ddaa820 --- /dev/null +++ b/ARW.Model/Dto/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; + +namespace ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys +{ + + /// + /// 店铺商品类目查询对象Api + /// + /// @author lwh + /// @date 2023-07-20 + /// + public class ShopGoodsCategoryQueryDtoApi : PagerInfo + { + [Required(ErrorMessage = "ShopGuid不能为空")] + public long ShopGuid { get; set; } + public string ShopGoodsCategoryName { get; set; } + } + + + +} diff --git a/ARW.Model/Vo/Api/GoodsManager/Goodss/GoodsApiVo.cs b/ARW.Model/Vo/Api/GoodsManager/Goodss/GoodsApiVo.cs index 879da00..989986a 100644 --- a/ARW.Model/Vo/Api/GoodsManager/Goodss/GoodsApiVo.cs +++ b/ARW.Model/Vo/Api/GoodsManager/Goodss/GoodsApiVo.cs @@ -72,6 +72,9 @@ namespace ARW.Model.Vo.Api.GoodsManager.Goodss /// public string Images { get; set; } + public string Thumb { get; set; } + + /// /// 描述 :价格(最低) diff --git a/ARW.Model/Vo/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiVo.cs b/ARW.Model/Vo/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiVo.cs new file mode 100644 index 0000000..4437c79 --- /dev/null +++ b/ARW.Model/Vo/Api/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryApiVo.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; +using System.Collections.Generic; +using ARW.Model.Vo.Api.GoodsManager.Goodss; + +namespace ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys +{ + /// + /// 店铺商品类目展示对象Api + /// + /// @author lwh + /// @date 2023-07-20 + /// + public class ShopGoodsCategoryVoApi + { + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsTreeKey = true)] + [EpplusIgnore] + public long ShopGoodsCategoryGuid { get; set; } + + + /// + /// 描述 :父级guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsTreeKey = true)] + [EpplusTableColumn(Header = "父级guid")] + public long ShopGoodsCategoryParentGuid { get; set; } + + + /// + /// 描述 :名称 + /// + [EpplusTableColumn(Header = "名称")] + public string Label { get; set; } + + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [SugarColumn(IsIgnore = true)] + public List Items { get; set; } + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [SugarColumn(IsIgnore = true)] + public List Children { get; set; } + } + +} diff --git a/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs b/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs index c3cf2a2..704c10b 100644 --- a/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs +++ b/ARW.Service/Api/BusinessService/GoodsManager/Goodss/GoodsServiceApi.cs @@ -79,7 +79,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss //} predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid); - predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != null, 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); @@ -121,6 +121,54 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss return await query.ToPageAsync(parm); } + + /// + /// 查询商品列表(Api) + /// + /// + /// + public async Task> GetGoodsApi(GoodsQueryDtoApi parm) + { + //开始拼装查询条件 + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(parm.ShopGoodsCategoryGuid != 0, s => s.ShopGoodsCategoryGuid == parm.ShopGoodsCategoryGuid); + + var query = _GoodsRepository + .Queryable() + .LeftJoin((s, c) => s.ShopGuid == c.ShopGuid) + .Where(predicate.ToExpression()) + .Where(s => s.GoodsShelfStatus == 1) + .OrderBy(s => s.GoodsSort, OrderByType.Asc) + .Select((s, c) => new GoodsVoApi + { + SpuId = s.GoodsGuid, + ShopGuid = s.ShopGuid, + ShopName = c.ShopName, + CategoryIds = s.ShopGoodsCategoryGuid, + Title = s.GoodsName, + GoodsCoding = s.GoodsCoding, + Video = s.GoodsMainImageVideo, + PrimaryImage = s.GoodsVideoCover, + Images = s.GoodsPicture, + Price = s.GoodsPriceLowest, + OriginPrice = s.GoodsDashedPriceLowest, + SpuStockQuantity = s.GoodsTotalInventory, + SoldNum = s.GoodsSalesInitial + s.GoodsSalesActual, + IsPutOnSale = s.GoodsShelfStatus, + }); + + + var list = await query.ToListAsync(); + + foreach (var item in list) + { + item.Thumb = item.Images.Split(',').First(); + } + + return list; + } + /// /// 查询商品详情(Api) /// diff --git a/ARW.Service/Api/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryServiceApi.cs b/ARW.Service/Api/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryServiceApi.cs new file mode 100644 index 0000000..0e8b723 --- /dev/null +++ b/ARW.Service/Api/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryServiceApi.cs @@ -0,0 +1,96 @@ +using Infrastructure.Attribute; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Repository; +using ARW.Repository.Business.GoodsManager.ShopGoodsCategorys; +using ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys; +using Senparc.CO2NET.Extensions; +using ARW.Service.Api.IBusinessService.GoodsManager.Goodss; +using ARW.Model.Dto.Api.GoodsManager.Goodss; + +namespace ARW.Service.Api.BusinessService.GoodsManager.ShopGoodsCategorys +{ + /// + /// 店铺商品类目接口实现类Api + /// + /// @author lwh + /// @date 2023-07-20 + /// + [AppService(ServiceType = typeof(IShopGoodsCategoryServiceApi), ServiceLifetime = LifeTime.Transient)] + public class ShopGoodsCategoryServiceImplApi : BaseService, IShopGoodsCategoryServiceApi + { + private readonly IGoodsServiceApi _GoodsServiceApi; + + private readonly ShopGoodsCategoryRepository _ShopGoodsCategoryRepository; + + public ShopGoodsCategoryServiceImplApi(ShopGoodsCategoryRepository ShopGoodsCategoryRepository, IGoodsServiceApi goodsServiceApi) + { + this._ShopGoodsCategoryRepository = ShopGoodsCategoryRepository; + _GoodsServiceApi = goodsServiceApi; + } + + #region Api接口代码 + + + /// + /// 查询店铺商品类目树形列表(Api) + /// + /// + /// + public async Task> GetShopGoodsCategoryTreeListApi(ShopGoodsCategoryQueryDtoApi parm) + { + //开始拼装查询条件 + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopGoodsCategoryName), s => s.ShopGoodsCategoryName.Contains(parm.ShopGoodsCategoryName)); + var query = _ShopGoodsCategoryRepository + .Queryable() + .Where(predicate.ToExpression()) + .Where((s) => s.ShopGoodsCategoryDisplayStatus == 1) + .Where((s) => s.ShopGuid == parm.ShopGuid) + .OrderBy(s => s.ShopGoodsCategorySort, OrderByType.Asc) + .Select((s) => new ShopGoodsCategoryVoApi + { + ShopGoodsCategoryGuid = s.ShopGoodsCategoryGuid, + ShopGoodsCategoryParentGuid = s.ShopGoodsCategoryParentGuid, + Label = s.ShopGoodsCategoryName, + }); + + var treeList = await query.ToTreeAsync(it => it.Children, it => it.ShopGoodsCategoryParentGuid, 0); + + treeList = await GetGoodsList(treeList); + + return treeList; + } + + + public async Task> GetGoodsList(List treeList) + { + foreach (var item in treeList) + { + var goodsQueryDtoApi = new GoodsQueryDtoApi + { + ShopGoodsCategoryGuid = item.ShopGoodsCategoryGuid + }; + item.Items = await _GoodsServiceApi.GetGoodsApi(goodsQueryDtoApi); + if (item.Children != null) + { + await GetGoodsList(item.Children); + } + } + return treeList; + } + + #endregion + + } +} diff --git a/ARW.Service/Api/IBusinessService/GoodsManager/Goodss/IGoodsServiceApi.cs b/ARW.Service/Api/IBusinessService/GoodsManager/Goodss/IGoodsServiceApi.cs index 49aae02..30c1f21 100644 --- a/ARW.Service/Api/IBusinessService/GoodsManager/Goodss/IGoodsServiceApi.cs +++ b/ARW.Service/Api/IBusinessService/GoodsManager/Goodss/IGoodsServiceApi.cs @@ -25,7 +25,15 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.Goodss /// Task> GetGoodsListApi(GoodsQueryDtoApi parm); - /// + + /// + /// 获取商品列表(Api) + /// + /// + /// + Task> GetGoodsApi(GoodsQueryDtoApi parm); + + /// /// 获取商品详情(Api) /// /// diff --git a/ARW.Service/Api/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryServiceApi.cs b/ARW.Service/Api/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryServiceApi.cs new file mode 100644 index 0000000..e60eaab --- /dev/null +++ b/ARW.Service/Api/IBusinessService/GoodsManager/ShopGoodsCategorys/IShopGoodsCategoryServiceApi.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys; + +namespace ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys +{ + /// + /// 店铺商品类目接口类Api + /// + /// @author lwh + /// @date 2023-07-20 + /// + public interface IShopGoodsCategoryServiceApi : IBaseService + { + /// + /// 获取店铺商品类目树形列表(Api) + /// + /// + /// + Task> GetShopGoodsCategoryTreeListApi(ShopGoodsCategoryQueryDtoApi parm); + + + } +} diff --git a/ARW.WebApi/Controllers/Api/ShopManager/ShopGoodsCategorys/ShopGoodsCategoryApiController.cs b/ARW.WebApi/Controllers/Api/ShopManager/ShopGoodsCategorys/ShopGoodsCategoryApiController.cs new file mode 100644 index 0000000..cb09763 --- /dev/null +++ b/ARW.WebApi/Controllers/Api/ShopManager/ShopGoodsCategorys/ShopGoodsCategoryApiController.cs @@ -0,0 +1,59 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using ARW.Admin.WebApi.Extensions; +using ARW.Admin.WebApi.Filters; +using ARW.Common; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Dto.Api.GoodsManager.ShopGoodsCategorys; +using ARW.Service.Api.IBusinessService.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys; +using ARW.Model.Vo.Api.GoodsManager.ShopGoodsCategorys; +using Microsoft.AspNetCore.Authorization; +using Geocoding; + +namespace ARW.WebApi.Controllers.Api.ShopManager.ShopGoodsCategorys +{ + /// + /// 店铺商品类目控制器Api + /// + /// @author lwh + /// @date 2023-07-20 + /// + //[Verify] + [Route("api/[controller]")] + public class ShopGoodsCategoryApiController : BaseController + { + private readonly IShopGoodsCategoryServiceApi _ShopGoodsCategoryServiceApi; + + /// + /// 依赖注入 + /// + /// 店铺商品类目店铺商品类目Api服务 + public ShopGoodsCategoryApiController(IShopGoodsCategoryServiceApi ShopGoodsCategoryServiceApi) + { + _ShopGoodsCategoryServiceApi = ShopGoodsCategoryServiceApi; + } + + + /// + /// 获取店铺商品类目树形列表(Api) + /// + /// 查询参数 + /// + [HttpGet("getShopGoodsCategoryTreeList")] + public async Task GetShopGoodsCategoryTreeListApi([FromQuery] ShopGoodsCategoryQueryDtoApi parm) + { + var res = await _ShopGoodsCategoryServiceApi.GetShopGoodsCategoryTreeListApi(parm); + if (res == null) + res = new List(); + + return SUCCESS(res); + } + + } +}