Browse Source

GOI综合查询过滤空sku spu

GOIAggregation
shanji 2 years ago
parent
commit
db29cdda92
  1. 23
      SiNan.Business/GOIBusiness.cs

23
SiNan.Business/GOIBusiness.cs

@ -201,16 +201,31 @@ namespace SiNan.Business
if (request.PageSize > 5)
request.PageSize = 5;
ISelect<ProductSku>? skuChildSelect = string.IsNullOrEmpty(request.Sku) ?
null :
fsql.Select<ProductSku>().As("ps").Where(ps => ps.ShopId == request.ShopId && ps.Id == request.Sku);
//ISelect<ProductSku>? skuChildSelect = string.IsNullOrEmpty(request.Sku) ?
// null :
// fsql.Select<ProductSku>().As("ps").Where(ps => ps.ShopId == request.ShopId && ps.Id == request.Sku);
//var productList = fsql.Select<Product>().Where(p => p.ShopId == request.ShopId)
// .WhereIf(!string.IsNullOrEmpty(request.Spu), p => p.Id == request.Spu)
// .WhereIf(skuChildSelect != null, p => skuChildSelect.Where(ps => ps.ProductId == p.Id).Any())
// .OrderByDescending(p => p.CreateTime)
// .Page(request.PageIndex, request.PageSize)
// .Count(out var productCount)
// .ToList<ProductResponse>();
var productList = fsql.Select<Product>().Where(p => p.ShopId == request.ShopId)
.WhereIf(!string.IsNullOrEmpty(request.SpuTitle), p => p.Title.Contains(request.SpuTitle))
.WhereIf(!string.IsNullOrEmpty(request.Spu), p => p.Id == request.Spu)
.WhereIf(skuChildSelect != null, p => skuChildSelect.Where(ps => ps.ProductId == p.Id).Any())
.Where(p => fsql.Select<ProductSku, JDPopularizeAdSku>()
.InnerJoin((ps, jas) => ps.Id == jas.Sku)
.WhereIf(!string.IsNullOrEmpty(request.Sku), (ps, jas) => ps.Id == request.Sku)
.Where((ps, jas) => jas.ShopId == request.ShopId && ps.ProductId == p.Id)
.Any())
.OrderByDescending(p => p.CreateTime)
.Page(request.PageIndex, request.PageSize)
.Count(out var productCount)
.ToList<ProductResponse>();
if (productList.Count == 0)
return new ListResponse<ProductGOIResponse>() { ItemList = new List<ProductGOIResponse>() };

Loading…
Cancel
Save