|
@ -125,26 +125,50 @@ namespace BBWY.Server.Business |
|
|
field = "logo,saleAttrs,status,created,barCode,categoryId,multiCateProps" |
|
|
field = "logo,saleAttrs,status,created,barCode,categoryId,multiCateProps" |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var skuList = new List<ProductSkuResponse>(); |
|
|
|
|
|
IList<string> skuIdList = null; |
|
|
|
|
|
var pageIndex = 1; |
|
|
|
|
|
var pageSize = 0; |
|
|
if (!string.IsNullOrEmpty(searchProductSkuRequest.Spu)) |
|
|
if (!string.IsNullOrEmpty(searchProductSkuRequest.Spu)) |
|
|
req_skuList.wareId = searchProductSkuRequest.Spu; |
|
|
pageSize = 1; |
|
|
else if (!string.IsNullOrEmpty(searchProductSkuRequest.Sku)) |
|
|
else if (!string.IsNullOrEmpty(searchProductSkuRequest.Sku)) |
|
|
req_skuList.skuId = searchProductSkuRequest.Sku; |
|
|
{ |
|
|
|
|
|
skuIdList = searchProductSkuRequest.Sku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
var rep_skuList = jdClient.Execute(req_skuList, searchProductSkuRequest.AppToken, DateTime.Now.ToLocalTime()); |
|
|
pageSize = (skuIdList.Count() - 1) / 20 + 1; |
|
|
if (rep_skuList.IsError) |
|
|
} |
|
|
throw new BusinessException(string.IsNullOrEmpty(rep_skuList.ErrorMsg) ? rep_skuList.ErrMsg : rep_skuList.ErrorMsg); |
|
|
|
|
|
|
|
|
|
|
|
return ((JArray)rep_skuList.Json["jingdong_sku_read_searchSkuList_responce"]["page"]["data"]).Select(s => new ProductSkuResponse() |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
Id = s.Value<string>("skuId"), |
|
|
if (!string.IsNullOrEmpty(searchProductSkuRequest.Spu)) |
|
|
ProductId = s.Value<string>("wareId"), |
|
|
req_skuList.wareId = searchProductSkuRequest.Spu; |
|
|
Price = s.Value<decimal>("jdPrice"), |
|
|
else if (!string.IsNullOrEmpty(searchProductSkuRequest.Sku)) |
|
|
Title = s["saleAttrs"] != null ? string.Join("-", s["saleAttrs"].Select(a => a["attrValueAlias"][0].ToString())) : string.Empty, |
|
|
req_skuList.skuId = string.Join(",", skuIdList.Skip((pageIndex - 1) * pageSize).Take(pageSize)); |
|
|
Logo = $"https://img13.360buyimg.com/n9/s80x80_{s.Value<string>("logo")}", |
|
|
|
|
|
State = s.Value<int>("status"), |
|
|
var rep_skuList = jdClient.Execute(req_skuList, searchProductSkuRequest.AppToken, DateTime.Now.ToLocalTime()); |
|
|
CreateTime = s.Value<long>("created").StampToDateTime(), |
|
|
if (rep_skuList.IsError) |
|
|
Source = searchProductSkuRequest.IsContainSource ? s : null |
|
|
throw new BusinessException(string.IsNullOrEmpty(rep_skuList.ErrorMsg) ? rep_skuList.ErrMsg : rep_skuList.ErrorMsg); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
var currentList = ((JArray)rep_skuList.Json["jingdong_sku_read_searchSkuList_responce"]["page"]["data"]).Select(s => new ProductSkuResponse() |
|
|
|
|
|
{ |
|
|
|
|
|
Id = s.Value<string>("skuId"), |
|
|
|
|
|
ProductId = s.Value<string>("wareId"), |
|
|
|
|
|
Price = s.Value<decimal>("jdPrice"), |
|
|
|
|
|
Title = s["saleAttrs"] != null ? string.Join("-", s["saleAttrs"].Select(a => a["attrValueAlias"][0].ToString())) : string.Empty, |
|
|
|
|
|
Logo = $"https://img13.360buyimg.com/n9/s80x80_{s.Value<string>("logo")}", |
|
|
|
|
|
State = s.Value<int>("status"), |
|
|
|
|
|
CreateTime = s.Value<long>("created").StampToDateTime(), |
|
|
|
|
|
Source = searchProductSkuRequest.IsContainSource ? s : null |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
if (currentList != null && currentList.Count() > 0) |
|
|
|
|
|
skuList.AddRange(currentList); |
|
|
|
|
|
|
|
|
|
|
|
if (pageIndex >= pageSize) |
|
|
|
|
|
break; |
|
|
|
|
|
pageIndex++; |
|
|
|
|
|
} |
|
|
|
|
|
return skuList; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override IList<SimpleProductSkuResponse> GetSimpleProductSkuList(SearchProductSkuRequest searchProductSkuRequest) |
|
|
public override IList<SimpleProductSkuResponse> GetSimpleProductSkuList(SearchProductSkuRequest searchProductSkuRequest) |
|
@ -662,6 +686,38 @@ namespace BBWY.Server.Business |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加JD促销活动sku
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jdClient"></param>
|
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
|
/// <param name="promotionId"></param>
|
|
|
|
|
|
/// <param name="skuList"></param>
|
|
|
|
|
|
/// <param name="isGift"></param>
|
|
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
|
|
private void AddJDPromotionSku(IJdClient jdClient, string token, long promotionId, IList<ProductSkuResponse> skuList, bool isGift) |
|
|
|
|
|
{ |
|
|
|
|
|
var req = new SellerPromotionSkuAddRequest(); |
|
|
|
|
|
req.promoId = promotionId; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var sku in skuList) |
|
|
|
|
|
{ |
|
|
|
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
|
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
|
|
|
req.bindType = $"{req.bindType}{(isGift ? 2 : 1)},"; |
|
|
|
|
|
req.num = $"{req.num}1,"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req.skuIds = req.skuIds.Substring(0, req.skuIds.Length - 1); |
|
|
|
|
|
req.jdPrices = req.jdPrices.Substring(0, req.jdPrices.Length - 1); |
|
|
|
|
|
req.bindType = req.bindType.Substring(0, req.bindType.Length - 1); |
|
|
|
|
|
req.num = req.num.Substring(0, req.num.Length - 1); |
|
|
|
|
|
|
|
|
|
|
|
var res = jdClient.Execute(req, token, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
if (res.IsError) |
|
|
|
|
|
throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public override long StartJDPromotionTask(StartPromotionTaskRequest2 request) |
|
|
public override long StartJDPromotionTask(StartPromotionTaskRequest2 request) |
|
|
{ |
|
|
{ |
|
|
var stepText = string.Empty; |
|
|
var stepText = string.Empty; |
|
@ -924,81 +980,57 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
#region 添加活动sku
|
|
|
#region 添加活动sku
|
|
|
{ |
|
|
{ |
|
|
#region 查询奶妈和主商品sku
|
|
|
var searchProductSkuRequest = new SearchProductSkuRequest() |
|
|
var mainSkuList = new List<ProductSkuResponse>(); |
|
|
|
|
|
if (!string.IsNullOrEmpty(request.MotherTemplateSku)) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
AppKey = request.AppKey, |
|
|
{ |
|
|
AppSecret = request.AppSecret, |
|
|
AppKey = request.AppKey, |
|
|
AppToken = request.AppToken, |
|
|
AppSecret = request.AppSecret, |
|
|
Platform = Enums.Platform.京东, |
|
|
AppToken = request.AppToken, |
|
|
}; |
|
|
Platform = Enums.Platform.京东, |
|
|
|
|
|
Sku = request.MotherTemplateSku |
|
|
#region 添加奶妈模板SKU
|
|
|
}); |
|
|
if (!string.IsNullOrEmpty(request.MotherTemplateSku)) |
|
|
mainSkuList.AddRange(skuList); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(request.MainProductSku)) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
stepText = "查询奶妈模板SKU"; |
|
|
{ |
|
|
searchProductSkuRequest.Sku = request.MotherTemplateSku; |
|
|
AppKey = request.AppKey, |
|
|
var skuList = GetProductSkuList(searchProductSkuRequest); |
|
|
AppSecret = request.AppSecret, |
|
|
stepText = "添加奶妈模板SKU"; |
|
|
AppToken = request.AppToken, |
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); |
|
|
Platform = Enums.Platform.京东, |
|
|
|
|
|
Sku = request.MainProductSku |
|
|
|
|
|
}); |
|
|
|
|
|
mainSkuList.AddRange(skuList); |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 查询赠品sku
|
|
|
#region 添加自定义奶妈SKU
|
|
|
|
|
|
if (!string.IsNullOrEmpty(request.CustomMotherSku)) |
|
|
var giftSkuList = new List<ProductSkuResponse>(); |
|
|
|
|
|
if (giftSkuIdList.Count() > 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var giftSkuIds = string.Join(",", giftSkuIdList); |
|
|
stepText = "查询自定义奶妈SKU"; |
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
searchProductSkuRequest.Sku = request.CustomMotherSku; |
|
|
{ |
|
|
var skuList = GetProductSkuList(searchProductSkuRequest); |
|
|
AppKey = request.AppKey, |
|
|
stepText = "添加自定义奶妈SKU"; |
|
|
AppSecret = request.AppSecret, |
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); |
|
|
AppToken = request.AppToken, |
|
|
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
|
|
Sku = giftSkuIds |
|
|
|
|
|
}); |
|
|
|
|
|
giftSkuList.AddRange(skuList); |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 添加主商品sku
|
|
|
stepText = "添加活动sku"; |
|
|
if (!string.IsNullOrEmpty(request.MainProductSku)) |
|
|
var req = new SellerPromotionSkuAddRequest(); |
|
|
|
|
|
req.promoId = promotionId; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var sku in mainSkuList) |
|
|
|
|
|
{ |
|
|
{ |
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
stepText = "查询主商品SKU"; |
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
searchProductSkuRequest.Sku = request.MainProductSku; |
|
|
req.bindType = $"{req.bindType}1,"; |
|
|
var skuList = GetProductSkuList(searchProductSkuRequest); |
|
|
req.num = $"{req.num}1,"; |
|
|
stepText = "添加主商品SKU"; |
|
|
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); |
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
foreach (var sku in giftSkuList) |
|
|
#region 添加赠品sku
|
|
|
|
|
|
if (giftSkuIdList.Count() > 0) |
|
|
{ |
|
|
{ |
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
stepText = "查询赠品SKU"; |
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
searchProductSkuRequest.Sku = string.Join(",", giftSkuIdList); |
|
|
req.bindType = $"{req.bindType}2,"; |
|
|
var skuList = GetProductSkuList(searchProductSkuRequest); |
|
|
req.num = $"{req.num}1,"; |
|
|
stepText = "添加赠品SKU"; |
|
|
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, true); |
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
req.skuIds = req.skuIds.Substring(0, req.skuIds.Length - 1); |
|
|
|
|
|
req.jdPrices = req.jdPrices.Substring(0, req.jdPrices.Length - 1); |
|
|
|
|
|
req.bindType = req.bindType.Substring(0, req.bindType.Length - 1); |
|
|
|
|
|
req.num = req.num.Substring(0, req.num.Length - 1); |
|
|
|
|
|
|
|
|
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
if (res.IsError) |
|
|
|
|
|
throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|