Browse Source

Merge branch 'master' of http://code.qiyue666.com/pengcong001/bbwy

pjzs_starttask_update
shanji 1 year ago
parent
commit
3d0a19fd28
  1. 2
      BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs
  2. 67
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs

2
BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs

@ -52,7 +52,7 @@ namespace Jd.Api.Request
public class SkuWriteUpdateSkusItemSaleAttrs public class SkuWriteUpdateSkusItemSaleAttrs
{ {
[JsonProperty("@type")] [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; } public string attrId { get; set; }

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

@ -155,7 +155,7 @@ namespace BBWY.Server.Business
var req_skuList = new SkuReadSearchSkuListRequest() var req_skuList = new SkuReadSearchSkuListRequest()
{ {
pageSize = 50,//50 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>(); var skuList = new List<ProductSkuResponse>();
@ -835,27 +835,60 @@ namespace BBWY.Server.Business
} }
private void DisableGiftSkuAndRecoverFullTitle(string appKey, private void DisableGiftSkuAndRecoverFullTitle(string appKey,
string appSecret, string appSecret,
string appToken, string appToken,
IList<string> deleteSkuList, IList<string> deleteSkuList,
string mainProductSpu, string mainProductSpu,
string fullTitle, string fullTitle,
string brandName, string brandName,
bool haveGiftTemplateSku) bool haveGiftTemplateSku)
{ {
var jdClient = GetJdClient(appKey, appSecret); var jdClient = GetJdClient(appKey, appSecret);
var wareId = long.Parse(mainProductSpu);
if (haveGiftTemplateSku && deleteSkuList != null && deleteSkuList.Count() > 0 && !deleteSkuList.Any(s => string.IsNullOrEmpty(s))) 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 设置完整标题 #region 设置完整标题
{ {
if (string.IsNullOrEmpty(brandName)) if (string.IsNullOrEmpty(brandName))
return; return;
var req = new WareWriteUpdateWareTitleRequest(); var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId };
req.wareId = long.Parse(mainProductSpu);
if (!fullTitle.StartsWith(brandName)) if (!fullTitle.StartsWith(brandName))
req.title = $"{brandName}{fullTitle}"; req.title = $"{brandName}{fullTitle}";
else else
@ -1079,13 +1112,14 @@ namespace BBWY.Server.Business
{ {
//非结构属性 //非结构属性
var tempDataJarray = JArray.Parse(res.Json["jingdong_category_read_findSaleAttrTemplates_responce"]["categoryAttrTemplates"]["templateData"].ToString()); var tempDataJarray = JArray.Parse(res.Json["jingdong_category_read_findSaleAttrTemplates_responce"]["categoryAttrTemplates"]["templateData"].ToString());
var colorProperty = tempDataJarray.FirstOrDefault(j => j.Value<string>("name") == "颜色"); var colorProperty = tempDataJarray.FirstOrDefault(j => (j.Value<string>("name") == "颜色" ||
if (colorProperty == null) j.Value<string>("name") == "规格" ||
colorProperty = tempDataJarray.FirstOrDefault(j => j["attrValueList"] != null && j["attrValueList"].Count() > 0); j.Value<string>("name") == "类别") &&
j["attrValueList"].Children().Count() > 0);
if (colorProperty == null) if (colorProperty == null)
{ {
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku); 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(); var colorSaleAttrs = colorProperty["attrValueList"].ToList();
attrId = colorSaleAttrs[0].Value<string>("attId"); attrId = colorSaleAttrs[0].Value<string>("attId");
@ -1274,6 +1308,7 @@ namespace BBWY.Server.Business
{ {
type = "com.jd.pop.ware.ic.api.domain.Sku", type = "com.jd.pop.ware.ic.api.domain.Sku",
wareId = wareId, wareId = wareId,
enable = 1,
jdPrice = giftSku.Price ?? 0, jdPrice = giftSku.Price ?? 0,
stockNum = 9999, stockNum = 9999,
barCode = request.MainProductBarCode, barCode = request.MainProductBarCode,
@ -1678,7 +1713,7 @@ namespace BBWY.Server.Business
catch { } catch { }
#endregion #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) public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request)

Loading…
Cancel
Save