From 694049cba1068c820beb2680e4c357e81ad32711 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Fri, 10 Feb 2023 03:49:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=9E=B6sku=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E9=94=99=E8=AF=AF=20.=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E6=88=90=E5=8F=91=E9=92=89=E9=92=89=20?= =?UTF-8?q?=E4=BF=83=E9=94=80sku=E6=95=B0=E9=87=8F=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EvaluationAssistantBusiness.cs | 52 ++++++++++++++----- .../PlatformSDK/JDBusiness.cs | 18 ++++--- .../StartPromotionTaskRequest.cs | 5 ++ 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index abb7fd32..67510544 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -534,7 +534,8 @@ namespace BBWY.Server.Business CustomMotherSku = dbPromotionTask.CustomMotherSku, MainProductSpu = dbPromotionTask.MainProductSpu, Platform = Enums.Platform.京东, - ShopId = dbPromotionTask.ShopId.Value + ShopId = dbPromotionTask.ShopId.Value, + TaskCount = dbPromotionTask.TaskCount }, GetYunDingRequestHeader(), HttpMethod.Post); if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK) @@ -550,6 +551,13 @@ 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 { } + fsql.Update(request.Id).Set(pt => pt.PromotionId, startResponse.JDPromotionId) .SetIf(!string.IsNullOrEmpty(dbPromotionTask.GiftTemplatePutNewSku), pt => pt.GiftTemplatePutNewSku, dbPromotionTask.GiftTemplatePutNewSku) .Set(pt => pt.StartTime, DateTime.Now) @@ -827,7 +835,7 @@ namespace BBWY.Server.Business List> updatePromotionTaskList = new List>(); List insertPromotionTaskSkuRecordList = new List(); IList jobDoneTaskIdList = new List(); - + IList jobDoneTaskList = new List(); foreach (var promotionTask in runningTaskList) { var productSkuList = new List(); @@ -915,23 +923,24 @@ namespace BBWY.Server.Business 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)); - } - } + //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)); + // } + //} } #endregion } jobDoneTaskIdList.Add(promotionTask.Id); //记录完成任务 + jobDoneTaskList.Add(promotionTask); } } } @@ -945,6 +954,21 @@ namespace BBWY.Server.Business fsql.Insert(insertPromotionTaskSkuRecordList).ExecuteAffrows(); }); + #region 钉钉通知结束 + if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) + { + foreach (var jobDoneTask in jobDoneTaskList) + { + try + { + dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{jobDoneTask.ActivityName}]已结束"); + } + catch { } + } + } + + #endregion + #region 开始后续任务 //下一轮开始任务 if (jobDoneTaskIdList.Count() > 0) diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index 43594011..e0025c72 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -739,8 +739,9 @@ namespace BBWY.Server.Business /// /// /// + /// /// - private void AddJDPromotionSku(IJdClient jdClient, string token, long promotionId, IList skuList, bool isGift) + private void AddJDPromotionSku(IJdClient jdClient, string token, long promotionId, IList skuList, bool isGift, int taskCount) { var req = new SellerPromotionSkuAddRequest(); req.promoId = promotionId; @@ -763,7 +764,7 @@ namespace BBWY.Server.Business req.skuIds = $"{req.skuIds}{sku.Id},"; req.jdPrices = $"{req.jdPrices}{sku.Price},"; req.bindType = $"{req.bindType}{(isGift ? 2 : 1)},"; - req.num = $"{req.num}{(isGift ? 1 : 100)},"; + req.num = $"{req.num}{(isGift ? 1 : taskCount)},"; req.promoPrices = $"{req.promoPrices}{(isGift ? 0 : sku.Price)},"; } @@ -1020,7 +1021,10 @@ namespace BBWY.Server.Business { RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); - throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); + if (res.Body.Contains("en_desc")) + throw new BusinessException($"上架sku失败-{res.Json["error_response"].Value("en_desc")}"); + else + throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); /*{"error_response":{"code":"501","en_desc":"com.jd.bk.saf.exception.SafJosException:京东价超出该类目允许范围:12.15-39437元!#821c1c3b382f476abeb21f1f515274c7(Solution reference: https://jos.jd.com/commondoc?listId=171)","zh_desc":"调用参数错误(解决方案参考: https://jos.jd.com/commondoc?listId=171)"}}*/ } @@ -1131,25 +1135,25 @@ namespace BBWY.Server.Business if (motherTemplateSkuList != null && motherTemplateSkuList.Count() > 0) { stepText = "添加奶妈模板SKU"; - AddJDPromotionSku(jdClient, request.AppToken, promotionId, motherTemplateSkuList, false); + AddJDPromotionSku(jdClient, request.AppToken, promotionId, motherTemplateSkuList, false, request.TaskCount); } if (customerMotherSkuList != null && customerMotherSkuList.Count() > 0) { stepText = "添加自定义奶妈SKU"; - AddJDPromotionSku(jdClient, request.AppToken, promotionId, customerMotherSkuList, false); + AddJDPromotionSku(jdClient, request.AppToken, promotionId, customerMotherSkuList, false, request.TaskCount); } if (mainProductSkuList != null && mainProductSkuList.Count() > 0) { stepText = "添加主商品SKU"; - AddJDPromotionSku(jdClient, request.AppToken, promotionId, mainProductSkuList, false); + AddJDPromotionSku(jdClient, request.AppToken, promotionId, mainProductSkuList, false, request.TaskCount); } if (giftSkuList != null && giftSkuList.Count() > 0) { stepText = "添加赠品SKU"; - AddJDPromotionSku(jdClient, request.AppToken, promotionId, giftSkuList, true); + AddJDPromotionSku(jdClient, request.AppToken, promotionId, giftSkuList, true, request.TaskCount); } } #endregion diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs index 0a4fd60f..8908a072 100644 --- a/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs +++ b/BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs @@ -55,6 +55,11 @@ namespace BBWY.Server.Model.Dto /// 自定义奶妈sku /// public string CustomMotherSku { get; set; } + + /// + /// 任务量 + /// + public int TaskCount { get; set; } } public class StartPromotionTaskDelayRequest : PlatformRequest