From 83fb91947945a54815822aff4b059cea1d9ba0e7 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 3 Feb 2023 14:43:07 +0800 Subject: [PATCH 1/3] 1 --- .../EvaluationAssistantBusiness.cs | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) 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); } } } From a0c227d0d143af8516487a5c37792a9d0d6865ca Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 3 Feb 2023 15:50:17 +0800 Subject: [PATCH 2/3] 1 --- .../EvaluationAssistant/EvaluationAssistantBusiness.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index 8ee220ab..d25ab969 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -653,6 +653,12 @@ namespace BBWY.Server.Business } #endregion + if (!string.IsNullOrEmpty(promotionTask.GiftTemplatePutNewSku)) + { + productSkuList.AddRange(promotionTask.GiftTemplatePutNewSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); + } + + var newOrderSkuList = orderSkuList.Where(osku => productSkuList.Contains(osku.SkuId) && osku.CreateTime > promotionTask.StartTime && promotionTaskSkuRecordList.Count(psr => psr.PromotionTaskId == promotionTask.Id && From 37729489d7360afb66224e05be0b63975d3cd8ba Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 3 Feb 2023 17:24:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=B5=A0=E5=93=81=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EvaluationAssistantBusiness.cs | 16 +++++++--- BBWY.Test/JDPromotionAPITest.cs | 17 ++++++----- BBWY.Test/Program.cs | 29 +++++++------------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index d25ab969..31af9097 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -465,8 +465,11 @@ namespace BBWY.Server.Business throw new BusinessException(response.Msg); } - fsql.Delete(request.TaskId).ExecuteAffrows(); - + fsql.Transaction(() => + { + fsql.Delete(request.TaskId).ExecuteAffrows(); + fsql.Delete().Where(psr => psr.PromotionTaskId == request.TaskId).ExecuteAffrows(); + }); } /// @@ -506,7 +509,12 @@ namespace BBWY.Server.Business if (!response.Success) throw new BusinessException(response.Msg); } - fsql.Delete(request.TaskId).ExecuteAffrows(); + + fsql.Transaction(() => + { + fsql.Delete(request.TaskId).ExecuteAffrows(); + fsql.Delete().Where(psr => psr.PromotionTaskId == request.TaskId).ExecuteAffrows(); + }); } /// @@ -566,7 +574,7 @@ namespace BBWY.Server.Business .InnerJoin((osku, o) => osku.OrderId == o.Id) .WhereIf(shopId != null, (osku, o) => o.ShopId == shopId) .Where((osku, o) => validOrderStateList.Contains(o.OrderState.Value)) - .Where((osku, o) => osku.Price > 0 && osku.CreateTime >= querySkuTime) + .Where((osku, o) => osku.CreateTime >= querySkuTime) .ToList((osku, o) => new OrderSku { CreateTime = osku.CreateTime, diff --git a/BBWY.Test/JDPromotionAPITest.cs b/BBWY.Test/JDPromotionAPITest.cs index 2dd6e842..666daadc 100644 --- a/BBWY.Test/JDPromotionAPITest.cs +++ b/BBWY.Test/JDPromotionAPITest.cs @@ -11,16 +11,17 @@ namespace BBWY.Test { public void GetPromotionDetailById(IJdClient client, string token, long promotionId) { - //{ + { + + var req = new SellerPromotionV2GetRequest(); + req.promoId = promotionId; + req.promoType = 4; + var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); + Console.WriteLine(JsonConvert.SerializeObject(response)); - // var req = new SellerPromotionV2GetRequest(); - // req.promoId = promotionId; - // req.promoType = 4; - // var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); - // Console.WriteLine(JsonConvert.SerializeObject(response)); + Console.WriteLine(); - // Console.WriteLine(); - //} + } { var pageIndex = 1; while (true) diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index 48748790..78c9c801 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -24,8 +24,8 @@ namespace BBWY.Test ////2ace3023200c4ea9aa682bbf8bffee18jztm 布莱特玩具 //var token = "01dc6f6e7fc34dcd99090d690312556cmdfk"; //齐盛 //var token = "9fffa982da23446fb035499ae5622f49odjk"; //腾奇 - //var token = "c22ff4d37b6c4bbd82cd9e8d0dab42dbziyz"; //森王车品 - var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具 + var token = "c22ff4d37b6c4bbd82cd9e8d0dab42dbziyz"; //森王车品 + //var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具 //var appkey = "120EA9EC65AB017567D78CC1139EEEA5"; //var appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; @@ -42,29 +42,20 @@ namespace BBWY.Test IJdClient client = GetJdClient(appkey, appSecret); - //var p = new JDPromotionAPITest(); + var p = new JDPromotionAPITest(); + p.GetPromotionDetailById(client, token, 5625514004); - //var p = new JDProductAPITest(); - //p.GetSkus(client, token); //{ - // var req = new SellerPromotionCheckRequest(); - // req.promoId = 5623871513; - // req.status = 4; - // var res = client.Execute(req, token, DateTime.Now.ToLocalTime()); + // var req = new SellerPromotionV2SuspendRequest(); + + // req.requestId = Guid.NewGuid().ToString(); + // req.promoId = 562425929; + // req.promoType = 4; + // var res = client.Execute(req, "44c19a1c1fbd4641957e6e8985ed1358jmtl", DateTime.Now.ToLocalTime()); // Console.WriteLine(JsonConvert.SerializeObject(res)); //} - { - var req = new SellerPromotionV2SuspendRequest(); - - req.requestId = Guid.NewGuid().ToString(); - req.promoId = 562425929; - req.promoType = 4; - var res = client.Execute(req, "44c19a1c1fbd4641957e6e8985ed1358jmtl", DateTime.Now.ToLocalTime()); - Console.WriteLine(JsonConvert.SerializeObject(res)); - } - Console.ReadKey(); } }