diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index cb41273e..8ee220ab 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -26,8 +26,9 @@ namespace BBWY.Server.Business private DingDingBusiness dingDingBusiness; private NLogManager nLogManager; private List validOrderStateList; + private ProductBusiness productBusiness; - public EvaluationAssistantBusiness(RestApiService restApiService, IOptions options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager) : base(restApiService, options, yunDingBusiness) + public EvaluationAssistantBusiness(RestApiService restApiService, IOptions options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness) : base(restApiService, options, yunDingBusiness) { this.fsql = fsql; this.idGenerator = idGenerator; @@ -35,6 +36,7 @@ namespace BBWY.Server.Business this.venderBusiness = venderBusiness; this.dingDingBusiness = dingDingBusiness; this.nLogManager = nLogManager; + this.productBusiness = productBusiness; validOrderStateList = new List() { Enums.OrderState.待出库, @@ -622,20 +624,36 @@ namespace BBWY.Server.Business IList orderSkuList, IList promotionTaskSkuRecordList) { - var loggerName = $"库存预警-{shop.ShopName}"; + var loggerName = $"评价助手任务监控-{shop.ShopName}"; List> updatePromotionTaskList = new List>(); List insertPromotionTaskSkuRecordList = new List(); IList jobDoneTaskIdList = new List(); foreach (var promotionTask in runningTaskList) { - var motherSkuList = new List(); - if (!string.IsNullOrEmpty(promotionTask.CustomMotherSku)) - motherSkuList.AddRange(promotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); - if (!string.IsNullOrEmpty(promotionTask.MainProductSku)) - motherSkuList.AddRange(promotionTask.MainProductSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); + var productSkuList = new List(); - var newOrderSkuList = orderSkuList.Where(osku => motherSkuList.Contains(osku.SkuId) && + #region 读取主商品sku + { + var productResponseSkuList = productBusiness.GetProductSkuList(new SearchProductSkuRequest() + { + AppKey = shop.AppKey2, + AppSecret = shop.AppSecret2, + AppToken = shop.AppToken2, + IsContainSource = false, + Platform = Enums.Platform.京东, + Spu = promotionTask.MainProductSpu + }); + if (productResponseSkuList == null || productResponseSkuList.Count() == 0) + { + LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-查询主商品sku", "未查询到主商品sku信息"); + continue; + } + productSkuList.AddRange(productResponseSkuList.Select(p => p.Id)); + } + #endregion + + var newOrderSkuList = orderSkuList.Where(osku => productSkuList.Contains(osku.SkuId) && osku.CreateTime > promotionTask.StartTime && promotionTaskSkuRecordList.Count(psr => psr.PromotionTaskId == promotionTask.Id && psr.OrderId == osku.OrderId) == 0).ToList(); @@ -694,14 +712,14 @@ namespace BBWY.Server.Business if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) { - LogMonitorError(shop, loggerName, "自动任务-暂停京东活动", httpResult.Content); + LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-暂停京东活动", httpResult.Content); } else { var response = JsonConvert.DeserializeObject(httpResult.Content); if (!response.Success) { - LogMonitorError(shop, loggerName, "自动任务-暂停京东活动", response.Msg); + LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-暂停京东活动", response.Msg); } } }