From aef56664520201900a5dffb33484200fd2d4ba8d Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 19 Nov 2022 03:01:10 +0800 Subject: [PATCH] 1 --- .../JDStoreHouseWarningBusiness.cs} | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) rename BBWY.Server.Business/EarlyWarning/{StoreHouseWarningBusiness.cs => JD/JDStoreHouseWarningBusiness.cs} (52%) diff --git a/BBWY.Server.Business/EarlyWarning/StoreHouseWarningBusiness.cs b/BBWY.Server.Business/EarlyWarning/JD/JDStoreHouseWarningBusiness.cs similarity index 52% rename from BBWY.Server.Business/EarlyWarning/StoreHouseWarningBusiness.cs rename to BBWY.Server.Business/EarlyWarning/JD/JDStoreHouseWarningBusiness.cs index 6ebd8a29..a37e357c 100644 --- a/BBWY.Server.Business/EarlyWarning/StoreHouseWarningBusiness.cs +++ b/BBWY.Server.Business/EarlyWarning/JD/JDStoreHouseWarningBusiness.cs @@ -6,15 +6,16 @@ using BBWY.Server.Model.Dto; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; +using System.Linq; using Yitter.IdGenerator; namespace BBWY.Server.Business { - public class StoreHouseWarningBusiness : BaseSyncBusiness, IDenpendency + public class JDStoreHouseWarningBusiness : BaseSyncBusiness, IDenpendency { private IList validStorageTypeList; - public StoreHouseWarningBusiness(RestApiService restApiService, IOptions options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness) + public JDStoreHouseWarningBusiness(RestApiService restApiService, IOptions options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness) { validStorageTypeList = new List() { Enums.StorageType.云仓, @@ -25,7 +26,7 @@ namespace BBWY.Server.Business public void StartCheckStockNum() { - var shopList = venderBusiness.GetShopList(filterTurnoverDays: true); + var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东, filterTurnoverDays: true); foreach (var shop in shopList) { CheckStockNum(shop); @@ -50,13 +51,38 @@ namespace BBWY.Server.Business .Distinct() .ToList((s, osku, o) => s.Sku); - var queryStartDate = DateTime.Now.Date.AddDays(-9); + var queryStartDate = yesterDayDate.AddDays(-8); var skuSaleDailyList = fsql.Select() .Where(s => s.Date >= queryStartDate && s.Date <= yesterDayDate) .Where(s => yesterDaySkuIds.Contains(s.Sku)) .ToList(); + var firstCycleStartDate = queryStartDate; + var firstCycleEndDate = queryStartDate.AddDays(2); + var secondCycleStartDate = firstCycleEndDate.AddDays(1); + var secondCycleEndDate = secondCycleStartDate.AddDays(2); + + var thirdCycleStartDate = secondCycleEndDate.AddDays(1); + var thirdCycleEndDate = thirdCycleStartDate.AddDays(2); + + foreach (var sku in yesterDaySkuIds) + { + //第一周期销量 + var firstCycleSaleList = skuSaleDailyList.Where(s => s.Sku == sku && s.Date >= firstCycleStartDate && s.Date <= firstCycleEndDate); + var firstCycleItemTotal = firstCycleSaleList.Count() > 0 ? firstCycleSaleList.Sum(s => s.ItemTotal - s.CancelItemTotal) : 0; + + //第二周期销量 + var secondCycleSaleList = skuSaleDailyList.Where(s => s.Sku == sku && s.Date >= secondCycleStartDate && s.Date <= secondCycleEndDate); + var secondCycleItemTotal = secondCycleSaleList.Count() > 0 ? secondCycleSaleList.Sum(s => s.ItemTotal - s.CancelItemTotal) : 0; + + //第三周期销量 + var thirdCycleSaleList = skuSaleDailyList.Where(s => s.Sku == sku && s.Date >= thirdCycleStartDate && s.Date <= thirdCycleEndDate); + var thirdCycleItemTotal = thirdCycleSaleList.Count() > 0 ? thirdCycleSaleList.Sum(s => s.ItemTotal - s.CancelItemTotal) : 0; + + //判断周期 + + } } } }