diff --git a/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs b/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs index 3d6375b..b07a3e3 100644 --- a/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs +++ b/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs @@ -358,7 +358,7 @@ public class ShopRevenueStatisticsService : ITransientDependency /// 更新 /// - public void UpdateStats(DateTime date) + public void UpdateStats(DateTime date, List shopIds = null) { /* 商铺新增订单创建时间 @@ -406,8 +406,13 @@ public class ShopRevenueStatisticsService : ITransientDependency //查询订单归属商铺和时间 foreach (string[] batch in Batch(allUpdateOrderIds, BatchSize)) { - allUpdateStats.AddRange(_freeSql.Select() - .Where(a => batch.Contains(a.OrderId)) + var query = _freeSql.Select() + .Where(a => batch.Contains(a.OrderId)); + if (shopIds != null && shopIds.Count > 0) + { + query.Where(a => shopIds.Contains(a.ShopId)); + } + allUpdateStats.AddRange(query .ToList(a => new UpdateStatsInfo { ShopId = a.ShopId.ToString(), @@ -432,16 +437,19 @@ public class ShopRevenueStatisticsService : ITransientDependency // 2. 这些日期走"全量执行":对所有商铺跑 foreach (var item in dict) { + string _date = DateTime.Now.ToString("yyyy-MM-dd"); if (item.Value.Count > 1000) { + _logger.Info($"更新全天:{_date}"); ShopDailyStats(item.Key); } else { - ShopDailyStats(item.Key, item.Value); + var _shopIds = item.Value.Distinct().ToList(); + _logger.Info($"{_date} 更新指定商铺:{string.Join(",", _shopIds)}"); + ShopDailyStats(item.Key, _shopIds); } } - string log = $"更新统计:{dict.Count}天数据"; _logger.Info(log); Debug.WriteLine(log); diff --git a/test/WebServiceTest/GiftLogisticsTest.cs b/test/WebServiceTest/GiftLogisticsTest.cs index 761d9c0..cdcb6d1 100644 --- a/test/WebServiceTest/GiftLogisticsTest.cs +++ b/test/WebServiceTest/GiftLogisticsTest.cs @@ -129,7 +129,7 @@ internal class GiftLogisticsTest public void GetOrderStatus() { var logisticsService = _container.Resolve(); - var data = logisticsService.GetOrderStatus(["260927-623588227382767"]); + var data = logisticsService.GetOrderStatus(["261013-396791693624092_1"]); Console.WriteLine(string.Join(" ", data.Select(a => $"{a.OrderSn}:{a.KuaidiSn}:{a.ShopOrder}:{a.DeliveryStatus}"))); } } diff --git a/test/WebServiceTest/ShopTest.cs b/test/WebServiceTest/ShopTest.cs index deee5d0..d4de4a8 100644 --- a/test/WebServiceTest/ShopTest.cs +++ b/test/WebServiceTest/ShopTest.cs @@ -105,8 +105,8 @@ internal class ShopTest { get { - DateTime startDate = DateTime.Parse("2026/06/01"); - DateTime endDate = DateTime.Parse("2026/07/31"); + DateTime startDate = DateTime.Parse("2026/10/5"); + DateTime endDate = DateTime.Parse("2026/10/14"); for (DateTime d = startDate; d <= endDate; d = d.AddDays(1)) { @@ -137,10 +137,10 @@ internal class ShopTest public void GetShopSalesOrderTest() { var shopService = _container.Resolve(); - var shopIds =shopService.GetShopIds("taiyuanqiji"); - shopIds = null; + var shopIds =shopService.GetShopIds("15937791563"); + //shopIds = null; var shopStatsService = _container.Resolve(); - DateTime date = DateTime.Parse("2026/10/11"); + DateTime date = DateTime.Parse("2026/10/17"); Console.WriteLine($"开始:{date.ToLongDateString()}"); try @@ -159,7 +159,15 @@ internal class ShopTest public void UpdateStatsTest() { var shopService = _container.Resolve(); - shopService.UpdateStats(DateTime.Now.AddDays(-1).Date); + shopService.UpdateStats(DateTime.Now.AddDays(-2).Date,new List + { +1960967267443628991, +1960967267443628989, +1960967267443628993, +1960967267443628994, +1960967267443628990, +1960967267443628992, + }); } [Test]