feat 对接商品分类筛选

This commit is contained in:
lwh 2023-07-15 11:58:43 +08:00
parent f8b50d29d4
commit 2919d9dd98
3 changed files with 26 additions and 5 deletions

View File

@ -18,6 +18,9 @@ using Newtonsoft.Json;
using Senparc.CO2NET.Extensions; using Senparc.CO2NET.Extensions;
using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.GoodsSkus; using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.GoodsSkus;
using ARW.Repository.Business.GoodsManager.GoodsSpecs.GoodsSkus; using ARW.Repository.Business.GoodsManager.GoodsSpecs.GoodsSkus;
using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
using ARW.Repository.Business.GoodsManager.GoodsCategorys;
using System;
namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
{ {
@ -35,14 +38,17 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
private readonly SpecRepository _SpecRepository; private readonly SpecRepository _SpecRepository;
private readonly SpecValueRepository _SpecValueRepository; private readonly SpecValueRepository _SpecValueRepository;
private readonly GoodsSkuRepository _GoodsSkuRepository; private readonly GoodsSkuRepository _GoodsSkuRepository;
private readonly GoodsCategoryRepository _GoodsCategoryRepository;
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository)
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository)
{ {
this._GoodsRepository = GoodsRepository; this._GoodsRepository = GoodsRepository;
_GoodsSpecRelRepository = goodsSpecRelRepository; _GoodsSpecRelRepository = goodsSpecRelRepository;
_SpecRepository = specRepository; _SpecRepository = specRepository;
_SpecValueRepository = specValueRepository; _SpecValueRepository = specValueRepository;
_GoodsSkuRepository = goodsSkuRepository; _GoodsSkuRepository = goodsSkuRepository;
_GoodsCategoryRepository = goodsCategoryRepository;
} }
#region Api接口代码 #region Api接口代码
@ -57,6 +63,20 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
{ {
//开始拼装查询条件 //开始拼装查询条件
var predicate = Expressionable.Create<Goods>(); var predicate = Expressionable.Create<Goods>();
string[] goodsCategoryArr = null;
// 检索经营类目
//if (parm.GoodsCategoryGuid != null)
//{
// var data = await _GoodsCategoryRepository.GetListAsync();
// var SewGoodsCategorys = data.FindAll(delegate (GoodsCategory goodsCategory)
// {
// string[] parentGoodsCategoryId = goodsCategory.GoodsCategoryAncestralGuid.Split(",", StringSplitOptions.RemoveEmptyEntries);
// return parentGoodsCategoryId.Contains(parm.GoodsCategoryGuid.ToString());
// });
// goodsCategoryArr = SewGoodsCategorys.Select(s => s.GoodsCategoryGuid.ToString()).ToArray();
//}
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid); predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
//predicate = predicate.AndIF(parm.GoodsCategoryGuid != null, s => s.GoodsCategoryGuid == parm.GoodsCategoryGuid); //predicate = predicate.AndIF(parm.GoodsCategoryGuid != null, s => s.GoodsCategoryGuid == parm.GoodsCategoryGuid);
@ -67,6 +87,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid) .LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
.Where(predicate.ToExpression()) .Where(predicate.ToExpression())
.WhereIF(parm.GoodsCategoryGuid != null, (s,c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid) .WhereIF(parm.GoodsCategoryGuid != null, (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) .Where(s => s.GoodsShelfStatus == 1)
.OrderBy(s => s.GoodsSort, OrderByType.Desc) .OrderBy(s => s.GoodsSort, OrderByType.Desc)
.Select((s, c) => new GoodsVoApi .Select((s, c) => new GoodsVoApi

View File

@ -32,6 +32,7 @@ using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
using ARW.Model.Models.Business.LogisticsManage.Deliverys; using ARW.Model.Models.Business.LogisticsManage.Deliverys;
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess;
using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys; using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys;
using Aliyun.OSS;
namespace ARW.Service.Business.BusinessService.ShopManager.Shops namespace ARW.Service.Business.BusinessService.ShopManager.Shops
{ {
@ -123,6 +124,9 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
} }
else else
{ {
// 检查是否有重复商店名称
var isRepeat = await CheckRepeatShopName(model.ShopName);
if (isRepeat) throw new CustomException("商铺名称已存在");
model.ShopAuditStatus = 2; model.ShopAuditStatus = 2;
model.ShopAuditUserGuid = 1; model.ShopAuditUserGuid = 1;
var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model); var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model);

View File

@ -108,10 +108,6 @@ namespace ARW.WebApi.Controllers.Business.ShopManager.Shops
{ {
if (parm == null) { throw new CustomException("请求参数错误"); } if (parm == null) { throw new CustomException("请求参数错误"); }
// 检查是否有重复商店名称
var isRepeat = await _ShopService.CheckRepeatShopName(parm.ShopName);
if (isRepeat) throw new CustomException("商铺名称已存在");
var modal = new Shop(); var modal = new Shop();
if (parm.ShopId != 0) modal = parm.Adapt<Shop>().ToUpdate(HttpContext); if (parm.ShopId != 0) modal = parm.Adapt<Shop>().ToUpdate(HttpContext);
else modal = parm.Adapt<Shop>().ToCreate(HttpContext); else modal = parm.Adapt<Shop>().ToCreate(HttpContext);