From d9d3211804a48fc465968c4a4819c2e92a60c593 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Thu, 21 Sep 2023 17:06:21 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=9F=AB=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BillCorrection/BillCorrectionBusiness.cs | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs b/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs index 00b4f497..c7808e19 100644 --- a/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs +++ b/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs @@ -36,31 +36,55 @@ namespace BBWY.Server.Business var orderIds = orderList.Select(o => o.OrderId).ToList(); var sdOrderIds = orderList.Where(o => o.StorageType == Model.Enums.StorageType.SD).Select(o => o.OrderId).ToArray(); - var orderCostDetailList = fsql.Select() - .Where(ocd => orderIds.Contains(ocd.OrderId) && ocd.IsEnabled == true) - .GroupBy(ocd => ocd.OrderId) - .ToList(g => new - { - OrderId = g.Key, - DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight), - SkuAmount = g.Sum(g.Value.SkuAmount), - PurchaseFreight = g.Sum(g.Value.PurchaseFreight), - FirstFreight = g.Sum(g.Value.FirstFreight), - InStorageAmount = g.Sum(g.Value.InStorageAmount), - OutStorageAmount = g.Sum(g.Value.OutStorageAmount), - ConsumableAmount = g.Sum(g.Value.ConsumableAmount), - StorageAmount = g.Sum(g.Value.StorageAmount) - }); + //var orderCostDetailList = fsql.Select() + // .Where(ocd => orderIds.Contains(ocd.OrderId) && ocd.IsEnabled == true) + // .GroupBy(ocd => ocd.OrderId) + // .ToList(g => new + // { + // OrderId = g.Key, + // DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight), + // SkuAmount = g.Sum(g.Value.SkuAmount), + // PurchaseFreight = g.Sum(g.Value.PurchaseFreight), + // FirstFreight = g.Sum(g.Value.FirstFreight), + // InStorageAmount = g.Sum(g.Value.InStorageAmount), + // OutStorageAmount = g.Sum(g.Value.OutStorageAmount), + // ConsumableAmount = g.Sum(g.Value.ConsumableAmount), + // StorageAmount = g.Sum(g.Value.StorageAmount) + // }); + var orderCostDetailList = fsql.Select().InnerJoin((ocd, o) => ocd.OrderId == o.Id) + .Where((ocd, o) => ocd.IsEnabled == true) + .Where((ocd, o) => request.ShopIds.Contains(o.ShopId) && + o.StartTime >= request.StartTime && + o.StartTime <= request.EndTime && + o.IsGift == false) + .GroupBy((ocd, o) => ocd.OrderId) + .ToList(g => new + { + OrderId = g.Key, + DeliveryExpressFreight = g.Sum(g.Value.Item1.DeliveryExpressFreight), + SkuAmount = g.Sum(g.Value.Item1.SkuAmount), + PurchaseFreight = g.Sum(g.Value.Item1.PurchaseFreight), + FirstFreight = g.Sum(g.Value.Item1.FirstFreight), + InStorageAmount = g.Sum(g.Value.Item1.InStorageAmount), + OutStorageAmount = g.Sum(g.Value.Item1.OutStorageAmount), + ConsumableAmount = g.Sum(g.Value.Item1.ConsumableAmount), + StorageAmount = g.Sum(g.Value.Item1.StorageAmount) + }); + var sdOrderCostList = fsql.Select(sdOrderIds).ToList(); - var afterOrderList = fsql.Select() - .Where(aso => orderIds.Contains(aso.OrderId)) - .GroupBy(aso => aso.OrderId) + var afterOrderList = fsql.Select() + .InnerJoin((aso, o) => aso.OrderId == o.Id) + .Where((aso, o) => request.ShopIds.Contains(o.ShopId) && + o.StartTime >= request.StartTime && + o.StartTime <= request.EndTime && + o.IsGift == false) + .GroupBy((aso, o) => aso.OrderId) .ToList(g => new { OrderId = g.Key, - AfterTotalCost = g.Sum(g.Value.AfterTotalCost) + AfterTotalCost = g.Sum(g.Value.Item1.AfterTotalCost) }); foreach (var order in orderList) From ed32e929b348eaf1b2fe1adb726b80f863365794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E8=81=AA?= Date: Thu, 28 Sep 2023 14:54:01 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Server.Business/Sync/ProductSyncBusiness.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BBWY.Server.Business/Sync/ProductSyncBusiness.cs b/BBWY.Server.Business/Sync/ProductSyncBusiness.cs index d12574e0..a3dc48c3 100644 --- a/BBWY.Server.Business/Sync/ProductSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/ProductSyncBusiness.cs @@ -304,13 +304,15 @@ namespace BBWY.Server.Business.Sync #endregion #region 找出状态变化的SKU - var stateChangeProductSkuList = productSkuList.Where(p => dbProductSkuList.Any(dp => dp.Id == p.Id && (dp.State != p.State || dp.Title != p.Title))).ToList(); + var stateChangeProductSkuList = productSkuList.Where(p => dbProductSkuList.Any(dp => dp.Id == p.Id && (dp.State != p.State || dp.Title != p.Title || dp.Price != p.Price || dp.Logo != p.Logo))).ToList(); if (stateChangeProductSkuList.Count() > 0) { foreach (var productSku in stateChangeProductSkuList) { var update = fsql.Update(productSku.Id).Set(p => p.State, productSku.State) - .Set(p => p.Title, productSku.Title); + .Set(p => p.Title, productSku.Title) + .Set(p => p.Price, productSku.Price) + .Set(p => p.Logo, productSku.Logo); updateProductSkuList.Add(update); } } From d3b3587cf40c7862ec857c5ab497368064e70e20 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Fri, 29 Sep 2023 23:55:07 +0800 Subject: [PATCH 3/7] 1 --- .../EvaluationAssistantBusiness.cs | 111 ++++++++++-------- .../PlatformSDK/JDBusiness.cs | 6 +- .../StartPromotionTaskRequest.cs | 14 +++ BBWY.Test/Program.cs | 40 ++++--- 4 files changed, 97 insertions(+), 74 deletions(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index efdfcdc4..846d3f84 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -525,30 +525,34 @@ namespace BBWY.Server.Business CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku); } - - + var joinSkuCount = 0; var host = GetPlatformRelayAPIHost(Enums.Platform.京东); var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0; string barCode = string.Empty, categoryId = string.Empty; IList multiCateProps = null; var mainProductSkuInStore = false; - if (haveGiftTemplateSku) + + var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest() { - var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest() - { - AppKey = request.AppKey, - AppSecret = request.AppSecret, - AppToken = request.AppToken, - IsContainSource = true, - Platform = request.Platform, - Spu = dbPromotionTask.MainProductSpu - }, GetYunDingRequestHeader(), HttpMethod.Post); - if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK) - throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}"); - var mainSkuListResponse = JsonConvert.DeserializeObject>>(mainSkuResult.Content); - if (!mainSkuListResponse.Success) - throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); + AppKey = request.AppKey, + AppSecret = request.AppSecret, + AppToken = request.AppToken, + IsContainSource = true, + Platform = request.Platform, + Spu = dbPromotionTask.MainProductSpu + }, GetYunDingRequestHeader(), HttpMethod.Post); + if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK) + throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}"); + var mainSkuListResponse = JsonConvert.DeserializeObject>>(mainSkuResult.Content); + if (!mainSkuListResponse.Success) + throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); + joinSkuCount = mainSkuListResponse.Data.Count(); + //开启延迟任务 + if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku)) + joinSkuCount += dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count(); + if (haveGiftTemplateSku) + { barCode = mainSkuListResponse.Data[0].Source.Value("barCode"); categoryId = mainSkuListResponse.Data[0].Source.Value("categoryId"); multiCateProps = mainSkuListResponse.Data[0].Source["multiCateProps"] != null ? mainSkuListResponse.Data[0].Source["multiCateProps"].ToList() : null; @@ -620,12 +624,12 @@ namespace BBWY.Server.Business startResponse.DeleteGiftSkuList.Count() != 0) dbPromotionTask.GiftTemplatePutNewSku = string.Join(",", startResponse.DeleteGiftSkuList); - try - { - if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) - dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{dbPromotionTask.ActivityName}]已开始,请及时查看任务是否正常进行"); - } - catch { } + //try + //{ + // if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) + // dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{dbPromotionTask.ActivityName}]已开始,请及时查看任务是否正常进行"); + //} + //catch { } fsql.Update(request.Id).Set(pt => pt.PromotionId, startResponse.JDPromotionId) .SetIf(!string.IsNullOrEmpty(dbPromotionTask.GiftTemplatePutNewSku), pt => pt.GiftTemplatePutNewSku, dbPromotionTask.GiftTemplatePutNewSku) @@ -634,11 +638,10 @@ namespace BBWY.Server.Business .Set(pt => pt.Status, Enums.PromitionTaskStatus.进行中) .ExecuteAffrows(); - //开启延迟任务 - Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler); + Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop, joinSkuCount), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler); } - private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop) + private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop, int joinSkuCount) { var host = GetPlatformRelayAPIHost(Enums.Platform.京东); @@ -653,8 +656,12 @@ namespace BBWY.Server.Business JDPromotionId = startResponse.JDPromotionId, MainProductSpu = promotionTask.MainProductSpu, HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0, - DeleteGiftSkuList = startResponse.DeleteGiftSkuList - }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 300); + DeleteGiftSkuList = startResponse.DeleteGiftSkuList, + ActivityName = promotionTask.ActivityName, + JoinSkuCount = joinSkuCount, + PJZSDingDingKey = shop.PJZSDingDingKey, + PJZSDingDingWebHook = shop.PJZSDingDingWebHook + }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 400); var errorBack = new Action((id, errorMsg) => { @@ -995,31 +1002,31 @@ namespace BBWY.Server.Business { #region 提前完成任务量,暂停JD活动 { - var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), - "api/platformsdk/SuspendJDPromotionTask", - new SuspendDPromotionTaskRequest() - { - AppKey = shop.AppKey2, - AppSecret = shop.AppSecret2, - AppToken = shop.AppToken2, - Platform = Enums.Platform.京东, - PromotionId = promotionTask.PromotionId.Value - }, - GetYunDingRequestHeader(), - HttpMethod.Post); + //var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), + // "api/platformsdk/SuspendJDPromotionTask", + // new SuspendDPromotionTaskRequest() + // { + // AppKey = shop.AppKey2, + // AppSecret = shop.AppSecret2, + // AppToken = shop.AppToken2, + // Platform = Enums.Platform.京东, + // PromotionId = promotionTask.PromotionId.Value + // }, + // GetYunDingRequestHeader(), + // HttpMethod.Post); - //if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) - //{ - // Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(httpResult.Content)); - //} - //else - //{ - // var response = JsonConvert.DeserializeObject(httpResult.Content); - // if (!response.Success) - // { - // Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(response.Msg)); - // } - //} + var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), + "api/platformsdk/DeleteJDPromotionTask", + new DeleteJDPromotionTaskRequest() + { + AppKey = shop.AppKey2, + AppSecret = shop.AppSecret2, + AppToken = shop.AppToken2, + Platform = Enums.Platform.京东, + PromotionId = promotionTask.PromotionId.Value + }, + GetYunDingRequestHeader(), + HttpMethod.Post); } #endregion } diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index fccbbae0..4f850cec 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1294,7 +1294,7 @@ namespace BBWY.Server.Business } } - public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request) + public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request { Thread.Sleep(60 * 1000); try @@ -1312,13 +1312,13 @@ namespace BBWY.Server.Business #region 检查奶妈sku是否完全生效 { var i = 0; - while (i < 10) + while (i < 2) { i++; var promotionTaskSkuList = GetPromotionTaskSku(request.AppKey, request.AppSecret, request.AppToken, request.JDPromotionId); if (promotionTaskSkuList.Any(s => s.Value("bind_type") == 1 && s.Value("sku_status") == 0)) { - Thread.Sleep(2000); + Thread.Sleep(30000); continue; } break; diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs index 0eac4de1..05281206 100644 --- a/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs +++ b/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs @@ -94,5 +94,19 @@ namespace BBWY.Server.Model.Dto /// 是否包含赠品模板 /// public bool HaveGiftTemplate { get; set; } + + /// + /// 参与活动的SKU数 (不含赠品) + /// + public int JoinSkuCount { get; set; } + + /// + /// 活动名称 + /// + public string ActivityName { get; set; } + + public string PJZSDingDingKey { get; set; } + + public string PJZSDingDingWebHook { get; set; } } } diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index 0197f527..624d20ea 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.Http; @@ -46,31 +47,32 @@ namespace BBWY.Test static void Main(string[] args) { - //var appkey = "E1AA9247D5583A6D87449CE6AB290185"; - //var appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c"; + var appkey = "E1AA9247D5583A6D87449CE6AB290185"; + var appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c"; - var appkey = "120EA9EC65AB017567D78CC1139EEEA5"; - var appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; + // var appkey = "120EA9EC65AB017567D78CC1139EEEA5"; + // var appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; ////0e61c4a8ec3e4df4b5836e10884db9220yth 齐盛 - var token = "2ace3023200c4ea9aa682bbf8bffee18jztm"; //布莱特玩具 - //var token = "01f5be2cb4d741dda66bce2356941597mdfm"; //布莱特玩具 token2 - //var token = "01dc6f6e7fc34dcd99090d690312556cmdfk"; //齐盛 - //var token = "9fffa982da23446fb035499ae5622f49odjk"; //腾奇 - //var token = "c22ff4d37b6c4bbd82cd9e8d0dab42dbziyz"; //森王车品 - //var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具 - //var token = "4a0ddc095e054c7aa90adcaccb14f83cwzgr"; //可比车品 - //var token = "50a4c0f5c55848b5a8a715709e8d6fe0jntb"; //卿卿玩具专营店 + var token = "8404898e42d04358879785f0e576019cwndg"; //爱维亲玩具专营店 + //布莱特玩具 + //var token = "01f5be2cb4d741dda66bce2356941597mdfm"; //布莱特玩具 token2 + //var token = "01dc6f6e7fc34dcd99090d690312556cmdfk"; //齐盛 + //var token = "9fffa982da23446fb035499ae5622f49odjk"; //腾奇 + //var token = "c22ff4d37b6c4bbd82cd9e8d0dab42dbziyz"; //森王车品 + //var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具 + //var token = "4a0ddc095e054c7aa90adcaccb14f83cwzgr"; //可比车品 + //var token = "50a4c0f5c55848b5a8a715709e8d6fe0jntb"; //卿卿玩具专营店 - { - var nNogManager = new NLogManager(); - var pid = Process.GetCurrentProcess().Id; - var message = $"{pid}-{Guid.NewGuid()}"; - Console.WriteLine(message); - nNogManager.GetLogger(pid.ToString()).Info(message); - } + + + var list1 = new List() { 10079228186359, 10082297500241, 10082297500240, 10080447316056, 10079220447523, 10079201912937, 10079200088836, 10079200088833, 10079200088835, 10079200088832, 10079200088837, 10079194625126, 10083879389389, 10079200088834, 10083879389388, 10079124348172, 10079124348173, 10079144365199, 10079144365198, 10079115478818, 10079115478817, 10079115478819, 10079139644032, 10079139644033, 10079080505031, 10079080505032, 10079075020922, 10079075020921, 10079179600978, 10079178664215, 10079140753258, 10079123319498, 10079123319497, 10079140753259, 10079139644034, 10079075020917, 10079075020916, 10079075020919, 10079075020915, 10079075020920, 10079068398356, 10079068398357, 10079068398359, 10079068398358, 10079068398355, 10079070766630, 10079070766628, 10079070766629, 10079070766627, 10079061727434, 10079061727435, 10079067078716, 10079067078715, 10079051550275, 10079065234196, 10078949765112, 10079051550272, 10079051550273, 10078995578574, 10081271571077, 10078995578584, 10081271571078, 10079005060684, 10079005060685, 10078954770972, 10078954770970, 10078954770973, 10078954770971, 10078954090365, 10078950737155, 10078950737156, 10078950737154, 10078995578575, 10078995578573, 10079051550274, 10078942630181, 10078942630178, 10078942630180, 10078942630179, 10078949642109, 10078949642110, 10078949765111, 10078932762284, 10078932762282, 10078932762283, 10078932762285, 10078932762281, 10078932762280, 10078929048530, 10078929048529, 10078936875484, 10078936875486, 10078936875483, 10078936875482, 10078936875485, 10078927516637, 10078927516638, 10078927516636, 10078929048528, 10078924483318, 10078923909230, 10078923909232, 10078923909231, 10078915305594, 10078915305595, 10078915305596, 10078914570530, 10078913764603, 10078913764604, 10078893084597, 10078893084596, 10078895132329, 10078895132330, 10078926484276, 10078889852852, 10078885484651, 10078886812153, 10078887252150, 10078887252149, 10078881382522, 10078888593569, 10078884983577, 10078888593568, 10078886812154, 10078886812152, 10078888998815, 10078882492446, 10078882492445, 10078882939250, 10078886812151, 10078882939249, 10078889511230, 10078886812150, 10078887717699, 10078887717700, 10078881382521, 10078881382520, 10078881382519, 10078881382518, 10078878463607, 10078878463601, 10078878463603, 10078878463600, 10078878463606, 10078878463604, 10078878463602, 10078880399096, 10078878463608, 10078880399097, 10078878463605, 10078880399094, 10078875403071, 10079281444782, 10078880399095, 10078875403072, 10078874775401, 10078872017883, 10079059750532, 10079059750533, 10079059750534, 10079059750529, 10079059750530, 10078872696834, 10078872311300, 10078873232966, 10078873585555, 10078872311299, 10078872311301, 10079277073137, 10079277073138, 10079277073139, 10079277073140, 10079277073141 }.Distinct().ToList(); + + + + Console.WriteLine(list1.Count()); Console.ReadKey(); } From fb886aad89717ba002c19bf524accee8bd67f3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E8=81=AA?= Date: Sat, 30 Sep 2023 03:49:13 +0800 Subject: [PATCH 4/7] =?UTF-8?q?pjzs=E9=AA=8C=E8=AF=81=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EvaluationAssistantBusiness.cs | 6 ++- .../PlatformSDK/JDBusiness.cs | 54 +++++++++++++++---- JD.API/Startup.cs | 1 + 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index 846d3f84..478cdfc5 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -526,6 +526,7 @@ namespace BBWY.Server.Business } var joinSkuCount = 0; + var joinSkuNoGiftList = new List(); var host = GetPlatformRelayAPIHost(Enums.Platform.京东); var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0; string barCode = string.Empty, categoryId = string.Empty; @@ -546,10 +547,10 @@ namespace BBWY.Server.Business var mainSkuListResponse = JsonConvert.DeserializeObject>>(mainSkuResult.Content); if (!mainSkuListResponse.Success) throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); - joinSkuCount = mainSkuListResponse.Data.Count(); + joinSkuNoGiftList.AddRange(mainSkuListResponse.Data.Select(s => s.Id)); //开启延迟任务 if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku)) - joinSkuCount += dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count(); + joinSkuNoGiftList.AddRange(dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); if (haveGiftTemplateSku) { @@ -638,6 +639,7 @@ namespace BBWY.Server.Business .Set(pt => pt.Status, Enums.PromitionTaskStatus.进行中) .ExecuteAffrows(); + joinSkuCount = joinSkuNoGiftList.Distinct().Count(); Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop, joinSkuCount), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler); } diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index 4f850cec..7593f9eb 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -21,6 +21,7 @@ namespace BBWY.Server.Business { public class JDBusiness : PlatformSDKBusiness { + private DingDingBusiness dingDingBusiness; public override Enums.Platform Platform => Enums.Platform.京东; private readonly string searchFields = "orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,orderState,orderStateRemark,orderRemark,orderStartTime,orderEndTime,modified,consigneeInfo,itemInfoList,couponDetailList,taxFee,venderRemark,pin,waybill,storeOrder,storeId,sellerDiscount"; @@ -36,7 +37,10 @@ namespace BBWY.Server.Business }; - public JDBusiness(IMemoryCache memoryCache, NLogManager nLogManager) : base(memoryCache, nLogManager) { } + public JDBusiness(IMemoryCache memoryCache, NLogManager nLogManager, DingDingBusiness dingDingBusiness) : base(memoryCache, nLogManager) + { + this.dingDingBusiness = dingDingBusiness; + } private IJdClient GetJdClient(string appKey, string appSecret) { @@ -1294,7 +1298,7 @@ namespace BBWY.Server.Business } } - public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request + public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request) { Thread.Sleep(60 * 1000); try @@ -1307,23 +1311,53 @@ namespace BBWY.Server.Business throw; } - Thread.Sleep(30 * 1000); + Thread.Sleep(10000); #region 检查奶妈sku是否完全生效 + var lastQueryJoinCount = 0; + var isJoinCompleted = false; { - var i = 0; - while (i < 2) + var repeatCount = 0; + while (true) { - i++; var promotionTaskSkuList = GetPromotionTaskSku(request.AppKey, request.AppSecret, request.AppToken, request.JDPromotionId); - if (promotionTaskSkuList.Any(s => s.Value("bind_type") == 1 && s.Value("sku_status") == 0)) + var currentQueryJoinCount = promotionTaskSkuList.Count(s => s.Value("bind_type") == 1 && s.Value("sku_status") == 1); + if (currentQueryJoinCount == request.JoinSkuCount) { - Thread.Sleep(30000); - continue; + isJoinCompleted = true; + break; } - break; + + if (lastQueryJoinCount == 0) + lastQueryJoinCount = currentQueryJoinCount; + else if (lastQueryJoinCount == currentQueryJoinCount) + { + repeatCount++; + if (repeatCount > 2) + break; + } + lastQueryJoinCount = currentQueryJoinCount; + Thread.Sleep(30000); + } + } + #endregion + + #region 发送钉钉消息 + try + { + var ddMsg = new StringBuilder(); + ddMsg.AppendLine($"活动名称:{request.ActivityName}"); + ddMsg.AppendLine("任务状态:开始"); + if (!isJoinCompleted) + { + ddMsg.AppendLine($"任务奶妈数:{request.JoinSkuCount}"); + ddMsg.AppendLine($"参与奶妈数:{lastQueryJoinCount}"); + ddMsg.AppendLine("参与任务的奶妈数异常请检查"); } + if (!string.IsNullOrEmpty(request.PJZSDingDingKey) && !string.IsNullOrEmpty(request.PJZSDingDingWebHook)) + dingDingBusiness.SendDingDingBotMessage(request.PJZSDingDingKey, request.PJZSDingDingWebHook, ddMsg.ToString()); } + catch { } #endregion RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true); diff --git a/JD.API/Startup.cs b/JD.API/Startup.cs index 171f7ff1..6e3f8762 100644 --- a/JD.API/Startup.cs +++ b/JD.API/Startup.cs @@ -67,6 +67,7 @@ namespace JD.API }); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); From 3314e340ad7842171d600b55702d1dd4a1226ecd Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 30 Sep 2023 17:42:48 +0800 Subject: [PATCH 5/7] 1 --- .../EvaluationAssistant/EvaluationAssistantBusiness.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index 478cdfc5..ee48e9b9 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -663,7 +663,7 @@ namespace BBWY.Server.Business JoinSkuCount = joinSkuCount, PJZSDingDingKey = shop.PJZSDingDingKey, PJZSDingDingWebHook = shop.PJZSDingDingWebHook - }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 400); + }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 500); var errorBack = new Action((id, errorMsg) => { From 9d73f3a43096b714855174ad13ce169451ee45bf Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 30 Sep 2023 18:14:14 +0800 Subject: [PATCH 6/7] 1 --- BBWY.Server.Business/DingDingBusiness.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BBWY.Server.Business/DingDingBusiness.cs b/BBWY.Server.Business/DingDingBusiness.cs index 91c2a184..a8e6da12 100644 --- a/BBWY.Server.Business/DingDingBusiness.cs +++ b/BBWY.Server.Business/DingDingBusiness.cs @@ -10,11 +10,11 @@ using Yitter.IdGenerator; namespace BBWY.Server.Business { - public class DingDingBusiness : BaseBusiness, IDenpendency + public class DingDingBusiness : IDenpendency { private RestApiService restApiService; - public DingDingBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService) : base(fsql, nLogManager, idGenerator) + public DingDingBusiness(RestApiService restApiService) { this.restApiService = restApiService; } From 6bfea14038865a02de48aa319d95c2f6a5a7af76 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Fri, 6 Oct 2023 11:10:44 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E6=95=B0?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/Converters/InputNumberConverter.cs | 5 ++++- BBWY.Client/GlobalContext.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/BBWY.Client/Converters/InputNumberConverter.cs b/BBWY.Client/Converters/InputNumberConverter.cs index 1d951673..ce9c2890 100644 --- a/BBWY.Client/Converters/InputNumberConverter.cs +++ b/BBWY.Client/Converters/InputNumberConverter.cs @@ -18,7 +18,10 @@ namespace BBWY.Client.Converters if (string.IsNullOrEmpty(strValue)) return null; decimal result; - if (strValue.IndexOf('.') == strValue.Length - 1 || !decimal.TryParse(strValue, out result)) + var dotIndex = strValue.IndexOf('.'); + if (dotIndex == strValue.Length - 1 || + (dotIndex != -1 && strValue.EndsWith("0")) || + !decimal.TryParse(strValue, out result)) return DependencyProperty.UnsetValue; return result; } diff --git a/BBWY.Client/GlobalContext.cs b/BBWY.Client/GlobalContext.cs index 31a74106..c8e7d4bb 100644 --- a/BBWY.Client/GlobalContext.cs +++ b/BBWY.Client/GlobalContext.cs @@ -13,7 +13,7 @@ namespace BBWY.Client { ShopServiceGroupList = new List(); ShopServiceGroupLowerList = new List(); - ClientVersion = "10185"; + ClientVersion = "10186"; } private User user;