|
|
@ -155,7 +155,7 @@ namespace BBWY.Server.Business |
|
|
|
var req_skuList = new SkuReadSearchSkuListRequest() |
|
|
|
{ |
|
|
|
pageSize = 50,//50
|
|
|
|
field = "logo,saleAttrs,status,created,barCode,categoryId,multiCateProps" |
|
|
|
field = "logo,saleAttrs,status,created,barCode,categoryId,multiCateProps,promiseId,saleAttrTemplateId,enable,stockNum" |
|
|
|
}; |
|
|
|
|
|
|
|
var skuList = new List<ProductSkuResponse>(); |
|
|
@ -844,18 +844,51 @@ namespace BBWY.Server.Business |
|
|
|
bool haveGiftTemplateSku) |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(appKey, appSecret); |
|
|
|
|
|
|
|
var wareId = long.Parse(mainProductSpu); |
|
|
|
if (haveGiftTemplateSku && deleteSkuList != null && deleteSkuList.Count() > 0 && !deleteSkuList.Any(s => string.IsNullOrEmpty(s))) |
|
|
|
{ |
|
|
|
var disableSkuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = appKey, |
|
|
|
AppSecret = appSecret, |
|
|
|
AppToken = appToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Sku = string.Join(",", deleteSkuList), |
|
|
|
IsContainSource = true, |
|
|
|
CheckStep = "", |
|
|
|
IsCheckSkuCount = false |
|
|
|
}); |
|
|
|
|
|
|
|
var req = new SkuWriteUpdateSkusRequest(); |
|
|
|
req.wareId = wareId; |
|
|
|
req.skus = disableSkuList.Select(ps => |
|
|
|
{ |
|
|
|
var p = JsonConvert.DeserializeObject<SkuWriteUpdateSkusItem>(ps.Source.ToString()); |
|
|
|
p.enable = 2; //禁用
|
|
|
|
return p; |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var res = jdClient.Execute(req, appToken, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
|
|
if (res.Json == null) |
|
|
|
res.Json = JObject.Parse(res.Body); |
|
|
|
|
|
|
|
if (res.IsError) |
|
|
|
{ |
|
|
|
var errorMsg = res.Body.Contains("en_desc") ? |
|
|
|
res.Json["error_response"].Value<string>("en_desc") : |
|
|
|
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); |
|
|
|
|
|
|
|
RollBackWhenStartPromotionError(appKey, appSecret, appToken, deleteSkuList, mainProductSpu, fullTitle, brandName, false); |
|
|
|
throw new BusinessException($"禁用赠品sku失败-{errorMsg}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 设置完整标题
|
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(brandName)) |
|
|
|
return; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
|
req.wareId = long.Parse(mainProductSpu); |
|
|
|
var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId }; |
|
|
|
if (!fullTitle.StartsWith(brandName)) |
|
|
|
req.title = $"{brandName}{fullTitle}"; |
|
|
|
else |
|
|
@ -1079,13 +1112,14 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
//非结构属性
|
|
|
|
var tempDataJarray = JArray.Parse(res.Json["jingdong_category_read_findSaleAttrTemplates_responce"]["categoryAttrTemplates"]["templateData"].ToString()); |
|
|
|
var colorProperty = tempDataJarray.FirstOrDefault(j => j.Value<string>("name") == "颜色"); |
|
|
|
if (colorProperty == null) |
|
|
|
colorProperty = tempDataJarray.FirstOrDefault(j => j["attrValueList"] != null && j["attrValueList"].Count() > 0); |
|
|
|
var colorProperty = tempDataJarray.FirstOrDefault(j => (j.Value<string>("name") == "颜色" || |
|
|
|
j.Value<string>("name") == "规格" || |
|
|
|
j.Value<string>("name") == "类别") && |
|
|
|
j["attrValueList"].Children().Count() > 0); |
|
|
|
if (colorProperty == null) |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku); |
|
|
|
throw new BusinessException("缺少销售属性"); |
|
|
|
throw new BusinessException("缺少包含attrValueList的销售属性"); |
|
|
|
} |
|
|
|
var colorSaleAttrs = colorProperty["attrValueList"].ToList(); |
|
|
|
attrId = colorSaleAttrs[0].Value<string>("attId"); |
|
|
@ -1274,6 +1308,7 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
type = "com.jd.pop.ware.ic.api.domain.Sku", |
|
|
|
wareId = wareId, |
|
|
|
enable = 1, |
|
|
|
jdPrice = giftSku.Price ?? 0, |
|
|
|
stockNum = 9999, |
|
|
|
barCode = request.MainProductBarCode, |
|
|
@ -1678,7 +1713,7 @@ namespace BBWY.Server.Business |
|
|
|
catch { } |
|
|
|
#endregion
|
|
|
|
|
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true); |
|
|
|
DisableGiftSkuAndRecoverFullTitle(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true); |
|
|
|
} |
|
|
|
|
|
|
|
public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request) |
|
|
|