From db29cdda922deef6cd50cace26334ae0b2a959fb Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Wed, 8 Nov 2023 00:53:52 +0800 Subject: [PATCH] =?UTF-8?q?GOI=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=A9=BAsku=20spu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiNan.Business/GOIBusiness.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/SiNan.Business/GOIBusiness.cs b/SiNan.Business/GOIBusiness.cs index bcd0157..f5d2320 100644 --- a/SiNan.Business/GOIBusiness.cs +++ b/SiNan.Business/GOIBusiness.cs @@ -201,16 +201,31 @@ namespace SiNan.Business if (request.PageSize > 5) request.PageSize = 5; - ISelect? skuChildSelect = string.IsNullOrEmpty(request.Sku) ? - null : - fsql.Select().As("ps").Where(ps => ps.ShopId == request.ShopId && ps.Id == request.Sku); + //ISelect? skuChildSelect = string.IsNullOrEmpty(request.Sku) ? + // null : + // fsql.Select().As("ps").Where(ps => ps.ShopId == request.ShopId && ps.Id == request.Sku); + //var productList = fsql.Select().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(); + var productList = fsql.Select().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() + .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(); + + if (productList.Count == 0) return new ListResponse() { ItemList = new List() };