diff --git a/BBWY.Server.API/Controllers/EvaluationAssistantController.cs b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs index bc5d3578..9cf1fde5 100644 --- a/BBWY.Server.API/Controllers/EvaluationAssistantController.cs +++ b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs @@ -87,5 +87,15 @@ namespace BBWY.Server.API.Controllers { evaluationAssistantBusiness.StartPromotionTask(request); } + + /// + /// 删除任务同时删除京东活动 + /// + /// + [HttpDelete] + public void DeletePromotionTaskAndJDTask([FromBody] DeletePromotionTaskRequest request) + { + evaluationAssistantBusiness.DeletePromotionTaskAndJDTask(request); + } } } diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index aa298952..1df2ae05 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -311,9 +311,51 @@ namespace BBWY.Server.Business .ExecuteAffrows(); } - public void DeletePromotionTask() - { - + /// + /// 删除任务和京东活动 + /// + /// + public void DeletePromotionTaskAndJDTask(DeletePromotionTaskRequest request) + { + var dbPromotionTask = fsql.Select(request.TaskId).ToOne(); + if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待) + { + var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), + "api/platformsdk/DeleteJDPromotionTask", + new DeleteJDPromotionTaskRequest() + { + AppKey = request.AppKey, + AppSecret = request.AppSecret, + AppToken = request.AppToken, + Platform = Enums.Platform.京东, + PromotionId = dbPromotionTask.PromotionId.Value + }, + GetYunDingRequestHeader(), + HttpMethod.Post); + if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) + throw new BusinessException(httpResult.Content); + var response = JsonConvert.DeserializeObject(httpResult.Content); + if (!response.Success) + throw new BusinessException(response.Msg); + } + + fsql.Delete(request.TaskId).ExecuteAffrows(); + + } + + /// + /// 删除任务和奶妈SKU + /// + /// + public void DeletePromotionTaskAndMotherSku(DeletePromotionTaskRequest request) + { + var dbPromotionTask = fsql.Select(request.TaskId).ToOne(); + if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待) + { + + } + + fsql.Delete(request.TaskId).ExecuteAffrows(); } #endregion } diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index 6f88a915..6ab5dc57 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1116,5 +1116,17 @@ namespace BBWY.Server.Business throw ex; } } + + public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request) + { + var jdClient = GetJdClient(request.AppKey, request.AppSecret); + var req = new SellerPromotionDeleteRequest(); + + req.promoId = request.PromotionId; + var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); + + if (res.IsError) + throw new BusinessException($"删除JD活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); + } } } diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs index 0d07bb94..cfcf98a5 100644 --- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs @@ -162,5 +162,10 @@ namespace BBWY.Server.Business { throw new NotImplementedException(); } + + public virtual void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request) + { + throw new NotImplementedException(); + } } } diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/DeletePromotionTaskRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/DeletePromotionTaskRequest.cs new file mode 100644 index 00000000..01c5d8ec --- /dev/null +++ b/BBWY.Server.Model/Dto/Request/PromotionTask/DeletePromotionTaskRequest.cs @@ -0,0 +1,12 @@ +namespace BBWY.Server.Model.Dto +{ + public class DeletePromotionTaskRequest : PlatformRequest + { + public long TaskId { get; set; } + } + + public class DeleteJDPromotionTaskRequest : PlatformRequest + { + public long PromotionId { get; set; } + } +} diff --git a/BBWY.Test/JDProductAPITest.cs b/BBWY.Test/JDProductAPITest.cs index 6439c322..a796de76 100644 --- a/BBWY.Test/JDProductAPITest.cs +++ b/BBWY.Test/JDProductAPITest.cs @@ -334,97 +334,48 @@ namespace BBWY.Test #endregion } - public void 修改属性别名(IJdClient client, string token) + public void GetPromotionDetailById(IJdClient client, string token) { - var mainSpu = "10022905456671"; - var request = new WareWriteUpdateWareSaleAttrvalueAliasRequest(); - request.wareId = long.Parse(mainSpu); - request.props = new List(); - request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() - { - attrId = "1001050679", - attrValues = new List() { "2912651180" }, - attrValueAlias = new List() { "粉丝价" } - }); - - request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() - { - attrId = "1001050679", - attrValues = new List() { "2912655473" }, - attrValueAlias = new List() { "放心购" } - }); - - request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() - { - attrId = "1001050679", - attrValues = new List() { "2912660446" }, - attrValueAlias = new List() { "闪电退款" } - }); - - Console.WriteLine("请求参数"); - Console.WriteLine(JsonConvert.SerializeObject(request)); - var res = client.Execute(request, token, DateTime.Now.ToLocalTime()); - - Console.WriteLine(); - Console.WriteLine("返回内容"); - Console.WriteLine(JsonConvert.SerializeObject(res)); - - } - - public void QuerySPU(IJdClient client,string token) - { - var req_productList = new WareReadSearchWare4ValidRequest() - { - orderField = "modified", - orderType = "desc", - pageSize = 50, - pageNo = 1, - field = "created,logo" - }; - - req_productList.wareId = "10023015553755"; - - var res = client.Execute(req_productList, token, DateTime.Now.ToLocalTime()); - - Console.WriteLine(JsonConvert.SerializeObject(res)); - - //return new ProductListResponse() - //{ - // Count = rep_productList.page.totalItem, - // Items = ((JArray)rep_productList.Json["jingdong_ware_read_searchWare4Valid_responce"]["page"]["data"]).Select(p => new ProductResponse() - // { - // Id = p.Value("wareId"), - // Title = p.Value("title"), - // ProductItemNum = p.Value("itemNum"), - // State = p.Value("wareStatus"), - // CreateTime = p.Value("created").StampToDateTime() - // }).ToList() - //}; - } - - public void FindWareById(IJdClient client, string token) - { - var req = new WareReadFindWareByIdRequest(); - - req.wareId = 10023500913672; - req.field = "barCode,categoryId,brandName"; - + var req = new SellerPromotionV2GetRequest(); + req.promoId = 5606578221; + req.promoType = 4; var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); Console.WriteLine(JsonConvert.SerializeObject(response)); } - public void GetPromotionById(IJdClient client, string token) + public void DeleetePromotion(IJdClient client, string token) { - SellerPromotionV2GetRequest req = new SellerPromotionV2GetRequest(); - //req.ip = "abc"; - //req.port = "abc"; - req.promoId = 5606602511; - req.promoType = 4; + /* + 5606604716 + 5606617011 + 5606602511 + 5606589329 + 5606583569 + 5606578221 + */ + + var list = new List() { + 5606604716, + 5606617011, + 5606602511, + 5606589329, + 5606583569, + 5606578221 + }; - var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); - Console.WriteLine(JsonConvert.SerializeObject(response)); + foreach (var id in list) + { + var req = new SellerPromotionDeleteRequest(); + + req.promoId = id; + + var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); + Console.WriteLine(id); + Console.WriteLine(JsonConvert.SerializeObject(response)); + Console.WriteLine(); + } } } } diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index cea8cf03..b40847c9 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -39,12 +39,9 @@ namespace BBWY.Test IJdClient client = GetJdClient(appkey, appSecret); var test1 = new JDProductAPITest(); - test1.GetPromotionById(client, token); + test1.GetPromotionDetailById(client, token); - var venderJDResponse = client.Execute(new SellerVenderInfoGetRequest(), token, DateTime.Now.ToLocalTime()); - Console.WriteLine(JsonConvert.SerializeObject(venderJDResponse)); - Console.ReadKey(); } } diff --git a/JD.API/Controllers/PlatformSDKController.cs b/JD.API/Controllers/PlatformSDKController.cs index 33d35f82..87a8dd2c 100644 --- a/JD.API/Controllers/PlatformSDKController.cs +++ b/JD.API/Controllers/PlatformSDKController.cs @@ -287,5 +287,15 @@ namespace JD.API.API.Controllers { return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).StartJDPromotionTask(request); } + + /// + /// 删除京东活动 + /// + /// + [HttpPost] + public void DeleteJDPromotionTask([FromBody] DeleteJDPromotionTaskRequest request) + { + platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).DeleteJDPromotionTask(request); + } } }