|
@ -1,5 +1,6 @@ |
|
|
using BBWY.Common.Extensions; |
|
|
using BBWY.Common.Extensions; |
|
|
using BBWY.Common.Models; |
|
|
using BBWY.Common.Models; |
|
|
|
|
|
using BBWY.JDSDK.Request; |
|
|
using BBWY.Server.Model; |
|
|
using BBWY.Server.Model; |
|
|
using BBWY.Server.Model.Dto; |
|
|
using BBWY.Server.Model.Dto; |
|
|
using Jd.ACES; |
|
|
using Jd.ACES; |
|
@ -967,6 +968,9 @@ namespace BBWY.Server.Business |
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
if (response.Json == null) |
|
|
if (response.Json == null) |
|
|
response.Json = JObject.Parse(response.Body); |
|
|
response.Json = JObject.Parse(response.Body); |
|
|
|
|
|
|
|
|
|
|
|
nLogManager.Default().Info($"获取销售属性 任务Id {request.Id} 返回内容 {response.Body} 模板sku数量 {request.GiftTemplateSkuList.Count()}"); |
|
|
|
|
|
|
|
|
var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j["attrValueList"] != null && j["attrValueList"].Count() > 0); |
|
|
var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j["attrValueList"] != null && j["attrValueList"].Count() > 0); |
|
|
if (colorProperty == null) |
|
|
if (colorProperty == null) |
|
|
{ |
|
|
{ |
|
@ -999,15 +1003,16 @@ namespace BBWY.Server.Business |
|
|
barCode = request.MainProductBarCode, |
|
|
barCode = request.MainProductBarCode, |
|
|
outerId = $"{request.OuterId}{(i + 1).ToString().PadLeft(3, '0')}", |
|
|
outerId = $"{request.OuterId}{(i + 1).ToString().PadLeft(3, '0')}", |
|
|
saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>() |
|
|
saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>() |
|
|
{ |
|
|
|
|
|
new SkuWriteUpdateSkusItemSaleAttrs() |
|
|
|
|
|
{ |
|
|
{ |
|
|
type = "com.jd.pop.ware.ic.api.domain.Prop", |
|
|
new SkuWriteUpdateSkusItemSaleAttrs() |
|
|
attrId = colorProperty.Value<string>("attId"), |
|
|
{ |
|
|
attrValues = new List<string>() { colorProperty.Value<string>("id") }, |
|
|
type = "com.jd.pop.ware.ic.api.domain.Prop", |
|
|
index = takeColorIndex |
|
|
attrId = colorProperty.Value<string>("attId"), |
|
|
|
|
|
attrValues = new List<string>() { colorProperty.Value<string>("id") }, |
|
|
|
|
|
index = takeColorIndex |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//promiseId = 30603710 //固定时效模板Id 48小时发货
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>(); |
|
|
p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>(); |
|
@ -1065,14 +1070,52 @@ namespace BBWY.Server.Business |
|
|
res.Json = JObject.Parse(res.Body); |
|
|
res.Json = JObject.Parse(res.Body); |
|
|
if (res.IsError) |
|
|
if (res.IsError) |
|
|
{ |
|
|
{ |
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
var errorMsg = res.Body.Contains("en_desc") ? |
|
|
|
|
|
res.Json["error_response"].Value<string>("en_desc") : |
|
|
|
|
|
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); |
|
|
|
|
|
if (errorMsg.Contains("此类目发货时效必填")) |
|
|
|
|
|
{ |
|
|
|
|
|
int? promiseId = null; |
|
|
|
|
|
#region 查询时效模板
|
|
|
|
|
|
{ |
|
|
|
|
|
var shixiaoReq = new SellerDeliverySendPromiseTemplateJsfServiceQuerySendTemplateByCategoryRequest(); |
|
|
|
|
|
shixiaoReq.categoryId = int.Parse(request.MainProductCategoryId); |
|
|
|
|
|
shixiaoReq.dzSku = true; |
|
|
|
|
|
var shixiaoRes = jdClient.Execute(shixiaoReq, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
if (shixiaoRes.IsError) |
|
|
|
|
|
{ |
|
|
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
|
|
throw new BusinessException($"查询时效模板失败-{(string.IsNullOrEmpty(shixiaoRes.ErrorMsg) ? shixiaoRes.ErrMsg : shixiaoRes.ErrorMsg)}"); |
|
|
|
|
|
} |
|
|
|
|
|
if (shixiaoRes.Json == null) |
|
|
|
|
|
shixiaoRes.Json = JObject.Parse(shixiaoRes.Body); |
|
|
|
|
|
var shixiaoJToken = shixiaoRes.Json["jingdong_seller_delivery_SendPromiseTemplateJsfService_querySendTemplateByCategory_responce"]["returnType"]["bizResponse"]["promiseTemplateDtoList"].Children().FirstOrDefault(); |
|
|
|
|
|
if (shixiaoJToken == null) |
|
|
|
|
|
{ |
|
|
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
|
|
throw new BusinessException($"查询时效模板失败-未查询到时效模板"); |
|
|
|
|
|
} |
|
|
|
|
|
promiseId = shixiaoJToken.Value<int>("templateId"); |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
if (res.Body.Contains("en_desc")) |
|
|
foreach (var skuParam in req.skus) |
|
|
throw new BusinessException($"上架sku失败-{res.Json["error_response"].Value<string>("en_desc")}"); |
|
|
skuParam.promiseId = promiseId; |
|
|
|
|
|
res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
if (res.IsError) |
|
|
|
|
|
{ |
|
|
|
|
|
errorMsg = res.Body.Contains("en_desc") ? |
|
|
|
|
|
res.Json["error_response"].Value<string>("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 |
|
|
else |
|
|
throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
{ |
|
|
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
/*{"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)"}}*/ |
|
|
throw new BusinessException($"上架sku失败-{errorMsg}"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList(); |
|
|
var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList(); |
|
@ -1249,7 +1292,7 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request) |
|
|
public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request) |
|
|
{ |
|
|
{ |
|
|
Thread.Sleep(30 * 1000); |
|
|
Thread.Sleep(60 * 1000); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
CheckJDPromotionTask(request.JDPromotionId, request.AppKey, request.AppSecret, request.AppToken); |
|
|
CheckJDPromotionTask(request.JDPromotionId, request.AppKey, request.AppSecret, request.AppToken); |
|
|