Browse Source

评价助手上架完成改停用

pjzs_starttask_update
sanji 1 year ago
parent
commit
25b23d9092
  1. 8
      BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs
  2. 80
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs

8
BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs

@ -26,9 +26,11 @@ namespace Jd.Api.Request
[JsonProperty("@type")]
public string type { get; set; } = "com.jd.pop.ware.ic.api.domain.Sku";
public Nullable<long> wareId { get; set; }
public long? wareId { get; set; }
public long? skuId { get; set; }
public Nullable<long> skuId { get; set; }
public int? enable { get; set; }
public List<SkuWriteUpdateSkusItemSaleAttrs> saleAttrs { get; set; }
@ -50,7 +52,7 @@ namespace Jd.Api.Request
public class SkuWriteUpdateSkusItemSaleAttrs
{
[JsonProperty("@type")]
public string type { get; set; }
public string type { get; set; } = "com.jd.pop.ware.ic.api.domain.Prop";
public string attrId { get; set; }

80
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -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>();
@ -834,6 +834,72 @@ namespace BBWY.Server.Business
#endregion
}
private void DisableGiftSkuAndRecoverFullTitle(string appKey,
string appSecret,
string appToken,
IList<string> deleteSkuList,
string mainProductSpu,
string fullTitle,
string brandName,
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() { wareId = wareId };
if (!fullTitle.StartsWith(brandName))
req.title = $"{brandName}{fullTitle}";
else
req.title = fullTitle;
var response = jdClient.Execute(req, appToken, DateTime.Now.ToLocalTime());
if (response.IsError)
throw new BusinessException($"设置完整标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}");
}
#endregion
}
/// <summary>
/// 添加JD促销活动sku
/// </summary>
@ -1046,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");
@ -1241,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,
@ -1645,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)

Loading…
Cancel
Save