|
|
@ -775,7 +775,7 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(appKey, appSecret); |
|
|
|
|
|
|
|
if (haveGiftTemplateSku) |
|
|
|
if (haveGiftTemplateSku && deleteSkuList != null && deleteSkuList.Count() > 0 && !deleteSkuList.Any(s => string.IsNullOrEmpty(s))) |
|
|
|
DeleteSkuList(new DeleteSkuListRequest() |
|
|
|
{ |
|
|
|
AppKey = appKey, |
|
|
@ -853,15 +853,15 @@ namespace BBWY.Server.Business |
|
|
|
public override StartPromotionTaskResponse StartJDPromotionTask(StartPromotionTaskRequest2 request) |
|
|
|
{ |
|
|
|
var stepText = string.Empty; |
|
|
|
//stepText.AppendLine($"任务Id {request.Id} 店铺Id {request.ShopId}");
|
|
|
|
List<string> giftSkuIdList = new List<string>(); |
|
|
|
var brandName = string.Empty; |
|
|
|
var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0; |
|
|
|
try |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(request.AppKey, request.AppSecret); |
|
|
|
long wareId = long.Parse(request.MainProductSpu); |
|
|
|
List<string> giftSkuIdList = new List<string>(); |
|
|
|
long promotionId = 0; |
|
|
|
var brandName = string.Empty; |
|
|
|
var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0; |
|
|
|
|
|
|
|
|
|
|
|
#region 前置检查各项sku
|
|
|
|
var searchProductSkuRequest = new SearchProductSkuRequest() |
|
|
@ -921,9 +921,6 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
if (giftSkuList != null && giftSkuList.Any(s => s.ProductId != request.MainProductSpu)) |
|
|
|
throw new BusinessException("主商品赠品SKU归属有误"); |
|
|
|
|
|
|
|
//stepText = "添加赠品SKU";
|
|
|
|
//AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, true);
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
@ -949,7 +946,6 @@ namespace BBWY.Server.Business |
|
|
|
stepText = "设置精简标题"; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
|
req.wareId = wareId; |
|
|
|
//req.title = request.SimpleTitle;
|
|
|
|
if (string.IsNullOrEmpty(request.SimpleTitle) || !request.SimpleTitle.StartsWith(brandName)) |
|
|
|
req.title = $"{brandName}{request.SimpleTitle}"; |
|
|
|
else |
|
|
@ -975,9 +971,6 @@ namespace BBWY.Server.Business |
|
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (response.Json == null) |
|
|
|
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.Value<string>("name") == "颜色"); |
|
|
|
if (colorProperty == null) |
|
|
|
{ |
|
|
@ -1008,34 +1001,23 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
type = "com.jd.pop.ware.ic.api.domain.Sku", |
|
|
|
wareId = wareId, |
|
|
|
//skuId = long.Parse(sku.Id),
|
|
|
|
jdPrice = giftSku.Price ?? 0, |
|
|
|
stockNum = 9999, |
|
|
|
barCode = request.MainProductBarCode, |
|
|
|
outerId = $"{request.OuterId}{(i + 1).ToString().PadLeft(3, '0')}", |
|
|
|
saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>() |
|
|
|
{ |
|
|
|
//new SkuWriteUpdateSkusItemSaleAttrs()
|
|
|
|
//{
|
|
|
|
// type = "com.jd.pop.ware.ic.api.domain.Prop",
|
|
|
|
// attrId = colorProperty.Value<string>("attId"),
|
|
|
|
// attrValues = new List<string>() { colorProperty.Value<string>("id") },
|
|
|
|
// index = takeColorIndex,
|
|
|
|
// attrValuesSeqNo = new List<int?>(){ takeColorIndex }
|
|
|
|
//}
|
|
|
|
|
|
|
|
new SkuWriteUpdateSkusItemSaleAttrs() |
|
|
|
{ |
|
|
|
type = "com.jd.pop.ware.ic.api.domain.Prop", |
|
|
|
attrId = colorPropertyValue.Value<string>("attId"), |
|
|
|
//attrValues = new List<string>() { colorPropertyValue.Value<string>("id") },
|
|
|
|
attrValueAlias = new List<string>(){ giftSku.Title }, // colorPropertyValue.Value<string>("name")
|
|
|
|
attrValueAlias = new List<string>(){ giftSku.Title }, |
|
|
|
index = takeColorIndex, |
|
|
|
attrValuesSeqNo = new List<int?>(){ takeColorIndex } |
|
|
|
} |
|
|
|
}, |
|
|
|
saleAttrTemplateId = "POP_MODEL" |
|
|
|
//promiseId = 30603710 //固定时效模板Id 48小时发货
|
|
|
|
}; |
|
|
|
|
|
|
|
p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>(); |
|
|
@ -1051,27 +1033,6 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
////修改标题参数
|
|
|
|
//updateSkuTitleParamList.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem()
|
|
|
|
//{
|
|
|
|
// attrId = p.saleAttrs[0].attrId,
|
|
|
|
// attrValues = p.saleAttrs[0].attrValues,
|
|
|
|
// attrValueAlias = new List<string>() { giftSku.Title }
|
|
|
|
//});
|
|
|
|
|
|
|
|
////修改商品细节图参数
|
|
|
|
//var imgUrlBuilder = new StringBuilder();
|
|
|
|
//var imgIndexBuilder = new StringBuilder();
|
|
|
|
//imgUrlBuilder.Append($"{giftSku.Logo.Substring(giftSku.Logo.IndexOf("jfs"))},");
|
|
|
|
//imgIndexBuilder.Append("1,");
|
|
|
|
//imageWriteUpdateRequestList.Add(new ImageWriteUpdateRequest()
|
|
|
|
//{
|
|
|
|
// wareId = wareId,
|
|
|
|
// colorId = colorProperty.Value<string>("id"),
|
|
|
|
// imgUrl = imgUrlBuilder.ToString().Trim(','),
|
|
|
|
// imgIndex = imgIndexBuilder.ToString().Trim(',')
|
|
|
|
//});
|
|
|
|
|
|
|
|
takeColorIndex--; |
|
|
|
skusParamList.Add(p); |
|
|
|
} |
|
|
@ -1101,6 +1062,7 @@ namespace BBWY.Server.Business |
|
|
|
int? promiseId = null; |
|
|
|
#region 查询时效模板
|
|
|
|
{ |
|
|
|
stepText = "查询时效模板"; |
|
|
|
var shixiaoReq = new SellerDeliverySendPromiseTemplateJsfServiceQuerySendTemplateByCategoryRequest(); |
|
|
|
shixiaoReq.categoryId = int.Parse(request.MainProductCategoryId); |
|
|
|
shixiaoReq.dzSku = true; |
|
|
@ -1121,7 +1083,7 @@ namespace BBWY.Server.Business |
|
|
|
promiseId = shixiaoJToken.Value<int>("templateId"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
stepText = "再次上架sku"; |
|
|
|
foreach (var skuParam in req.skus) |
|
|
|
skuParam.promiseId = promiseId; |
|
|
|
res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
@ -1141,10 +1103,14 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//记录上架返回值
|
|
|
|
nLogManager.Default().Info($"任务Id {request.Id} 店铺Id {request.ShopId} 上架赠品返回值 {res.Body}"); |
|
|
|
|
|
|
|
stepText = "获取上架skuId"; |
|
|
|
var newSkuIdList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList(); |
|
|
|
giftSkuIdList.AddRange(newSkuIdList); |
|
|
|
|
|
|
|
|
|
|
|
stepText = "获取上架sku"; |
|
|
|
var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList(); |
|
|
|
var imgIndex = 1; |
|
|
|
StringBuilder colorBuilder = new StringBuilder(); |
|
|
@ -1153,7 +1119,12 @@ namespace BBWY.Server.Business |
|
|
|
foreach (var skuJToken in newSkuList) |
|
|
|
{ |
|
|
|
var skuTitle = skuJToken["saleAttrs"][0]["attrValueAlias"][0].ToString(); |
|
|
|
var colorId = skuJToken["saleAttrs"][0]["attrValues"][0].ToString(); |
|
|
|
var colorId = "0000000000"; |
|
|
|
try |
|
|
|
{ |
|
|
|
colorId = skuJToken["saleAttrs"][0]["attrValues"][0].ToString(); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
var currentImgIndex = imgIndex; |
|
|
|
imgIndex++; |
|
|
|
var giftSku = request.GiftTemplateSkuList.FirstOrDefault(x => x.Title == skuTitle); |
|
|
@ -1324,6 +1295,7 @@ namespace BBWY.Server.Business |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
nLogManager.Default().Error(ex, $"任务Id {request.Id} 店铺Id {request.ShopId} 执行步骤 {stepText}"); |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku); |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|