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();