From 7ec2949f9fc091795bb89247878faa4edec2cfbf Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 12 Apr 2024 21:24:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=B8=E5=8D=97=E5=90=8C?= =?UTF-8?q?=E6=AD=A5spu=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiNan.Business/AggregationBusiness.cs | 51 ++++++++++++++++++++------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/SiNan.Business/AggregationBusiness.cs b/SiNan.Business/AggregationBusiness.cs index aaeb7ef..e435197 100644 --- a/SiNan.Business/AggregationBusiness.cs +++ b/SiNan.Business/AggregationBusiness.cs @@ -115,18 +115,45 @@ namespace SiNan.Business var startDate_aggregationDate = aggregationDate; var endDate_aggregationDate = aggregationDate.AddDays(1).AddSeconds(-1); var IsAggregationDateEqualsYesterDay = (DateTime.Now.Date - aggregationDate).TotalDays == 1; - var spuIdList = fsql.Select().Where(p => p.ShopId == shopId && p.State == 8) - .WhereIf(!string.IsNullOrEmpty(querySpu), p => p.Id == querySpu) - .OrderBy(p => p.CreateTime) - .ToList(p => p.Id); - var skuList = fsql.Select().Where(ps => ps.ShopId == shopId && ps.State == 1 && ps.Price > 0) - .WhereIf(!string.IsNullOrEmpty(querySpu), ps => ps.ProductId == querySpu) - .OrderBy(ps => ps.CreateTime) - .ToList(ps => new - { - ps.ProductId, - ps.Id - }); + + + var spuQueryStartTime = DateTime.Now.Date.AddDays(-30); + + //查询最近30天有销量的spu + var saleSpuList = fsql.Select().Where(osku => osku.ShopId == shopId && !string.IsNullOrEmpty(osku.ProductId)) + .WhereIf(!string.IsNullOrEmpty(querySpu), osku => osku.ProductId == querySpu) + .WhereIf(string.IsNullOrEmpty(querySpu), osku => osku.CreateTime >= spuQueryStartTime) + .OrderByDescending(osku => osku.CreateTime) + .Distinct() + .ToList(osku => osku.ProductId); + //查询最近30天有推广的spu + var popularizeSpuList = fsql.Select() + .InnerJoin((jas, ps) => jas.Sku == ps.Id) + .Where((jas, ps) => jas.ShopId == shopId && jas.Date >= spuQueryStartTime) + .WhereIf(!string.IsNullOrEmpty(querySpu), (jas, ps) => ps.ProductId == querySpu) + .OrderByDescending((jas, ps) => jas.Date) + .Distinct() + .ToList((jas, ps) => ps.ProductId); + + var spuIdList = saleSpuList.Union(popularizeSpuList).Distinct().ToList(); + var skuList = fsql.Select() + .Where(ps => spuIdList.Contains(ps.ProductId) && ps.Price > 0 && ps.State == 1) + .ToList(ps => new { ps.ProductId, ps.Id }); + + + + //var spuIdList = fsql.Select().Where(p => p.ShopId == shopId && p.State == 8) + // .WhereIf(!string.IsNullOrEmpty(querySpu), p => p.Id == querySpu) + // .OrderBy(p => p.CreateTime) + // .ToList(p => p.Id); + //var skuList = fsql.Select().Where(ps => ps.ShopId == shopId && ps.State == 1 && ps.Price > 0) + // .WhereIf(!string.IsNullOrEmpty(querySpu), ps => ps.ProductId == querySpu) + // .OrderBy(ps => ps.CreateTime) + // .ToList(ps => new + // { + // ps.ProductId, + // ps.Id + // }); var dbAggregationJDPopularizeSpuList = fsql.Select() .InnerJoin((aspu, p) => aspu.Id == p.Id)