From 1dd04ebcb7445c0e45db9c8fc7f333498ec95ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E8=81=AA?= Date: Fri, 8 Sep 2023 13:15:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=9E=B6=E8=B5=A0=E5=93=81sku?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=8D=E4=BD=BF=E7=94=A8=E6=97=B6=E6=95=88?= =?UTF-8?q?=E6=A8=A1=E6=9D=BFId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Request/SkuWriteUpdateSkusRequest.cs | 2 +- .../PlatformSDK/JDBusiness.cs | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs b/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs index bcb47afe..96cf0300 100644 --- a/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs +++ b/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs @@ -42,7 +42,7 @@ namespace Jd.Api.Request public List multiCateProps { get; set; } - public int promiseId { get; set; } + public int? promiseId { get; set; } } public class SkuWriteUpdateSkusItemSaleAttrs diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index d1986733..5ef4b0a0 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1007,8 +1007,8 @@ namespace BBWY.Server.Business attrValues = new List() { colorProperty.Value("id") }, index = takeColorIndex } - }, - promiseId = 30603710 //固定时效模板Id 48小时发货 + } + //promiseId = 30603710 //固定时效模板Id 48小时发货 }; p.multiCateProps = new List(); @@ -1066,14 +1066,28 @@ namespace BBWY.Server.Business res.Json = JObject.Parse(res.Body); if (res.IsError) { - RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); - - if (res.Body.Contains("en_desc")) - throw new BusinessException($"上架sku失败-{res.Json["error_response"].Value("en_desc")}"); + var errorMsg = res.Body.Contains("en_desc") ? + res.Json["error_response"].Value("en_desc") : + (string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); + if (errorMsg.Contains("此类目发货时效必填")) + { + foreach (var skuParam in req.skus) + skuParam.promiseId = 30603710; + res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); + if (res.IsError) + { + errorMsg = res.Body.Contains("en_desc") ? + res.Json["error_response"].Value("en_desc") : + (string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); + RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); + throw new BusinessException($"上架sku失败-{errorMsg}"); + } + } 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)"}}*/ + { + RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); + throw new BusinessException($"上架sku失败-{errorMsg}"); + } } var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value("skuId")).ToList();