fixed 修改商品类目切换
This commit is contained in:
parent
006befd766
commit
3ed452c803
@ -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; }
|
||||
|
||||
|
@ -83,6 +83,15 @@ namespace ARW.Model.Models.Business.GoodsManager.ShopGoodsCategorys
|
||||
public string ShopGoodsCategoryImg { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否为热门
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否为热门")]
|
||||
[SugarColumn(ColumnName = "shop_goods_category_is_popular")]
|
||||
public int ShopGoodsCategoryIsPopular { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :显示状态
|
||||
/// 空值 : false
|
||||
|
@ -89,7 +89,14 @@ namespace ARW.Model.Vo.Business.GoodsManager.ShopGoodsCategorys
|
||||
[EpplusIgnore]
|
||||
public int ShopGoodsCategoryDisplayStatus { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否为热门
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "是否为热门")]
|
||||
public int ShopGoodsCategoryIsPopular { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :显示状态名称
|
||||
/// </summary>
|
||||
|
@ -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<GoodsCategory>, 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
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<GoodsCategoryVoApi>> 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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取首页推荐类目列表(Api)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<HomeCategoryApiVo>> 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();
|
||||
|
@ -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<Shop>((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)
|
||||
|
@ -27,6 +27,14 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.GoodsCategorys
|
||||
Task<List<GoodsCategoryVoApi>> GetGoodsCategoryTreeListApi(GoodsCategoryQueryDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GoodsCategoryVoApi>> GetShopGoodsCategoryTreeListApi(GoodsCategoryQueryDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取首页推荐类目列表(Api)
|
||||
/// </summary>
|
||||
|
@ -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);
|
||||
|
@ -55,5 +55,21 @@ namespace ARW.WebApi.Controllers.Api.GoodsManager.GoodsCategorys
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取店铺类目树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getShopGoodsCategoryTreeList")]
|
||||
public async Task<IActionResult> GetShopGoodsCategoryTreeListApi([FromQuery] GoodsCategoryQueryDtoApi parm)
|
||||
{
|
||||
var res = await _GoodsCategoryServiceApi.GetShopGoodsCategoryTreeListApi(parm);
|
||||
if (res == null)
|
||||
res = new List<GoodsCategoryVoApi>();
|
||||
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user