|
|
|
@ -658,12 +658,42 @@ namespace BBWY.Server.Business |
|
|
|
try |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(request.AppKey, request.AppSecret); |
|
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
|
IList<JToken> multiCateProps = null; |
|
|
|
long wareId = long.Parse(request.MainProductSpu); |
|
|
|
List<string> giftSkuList = new List<string>(); |
|
|
|
List<string> giftSkuIdList = new List<string>(); |
|
|
|
long promotionId = 0; |
|
|
|
var brandName = string.Empty; |
|
|
|
#region 获取主商品品牌
|
|
|
|
{ |
|
|
|
var req = new WareReadFindWareByIdRequest(); |
|
|
|
req.wareId = wareId; |
|
|
|
req.field = "barCode,categoryId,brandName"; |
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (res.IsError) |
|
|
|
throw new BusinessException($"获取主商品品牌失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
if (res.Json == null) |
|
|
|
res.Json = JObject.Parse(res.Body); |
|
|
|
brandName = res.Json["jingdong_ware_read_findWareById_responce"]["ware"].Value<string>("brandName"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 设置精简标题
|
|
|
|
{ |
|
|
|
stepText = "设置精简标题"; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
|
req.wareId = wareId; |
|
|
|
//req.title = request.SimpleTitle;
|
|
|
|
req.title = $"{brandName}{request.SimpleTitle}"; |
|
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (response.IsError) |
|
|
|
throw new BusinessException($"设置精简标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) |
|
|
|
{ |
|
|
|
#region 上架赠品
|
|
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
|
IList<JToken> multiCateProps = null; |
|
|
|
#region 获取主商品sku信息 barCode,categoryId,multiCateProps
|
|
|
|
{ |
|
|
|
stepText = "获取主商品sku信息"; |
|
|
|
@ -683,27 +713,8 @@ namespace BBWY.Server.Business |
|
|
|
categoryId = mainSkuList[0].Source.Value<string>("categoryId"); |
|
|
|
multiCateProps = mainSkuList[0].Source["multiCateProps"] != null ? mainSkuList[0].Source["multiCateProps"].ToList() : null; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 设置精简标题
|
|
|
|
{ |
|
|
|
stepText = "设置精简标题"; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
|
req.wareId = wareId; |
|
|
|
req.title = request.SimpleTitle; |
|
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (response.IsError) |
|
|
|
throw new BusinessException($"设置精简标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) |
|
|
|
{ |
|
|
|
stepText = "上架赠品"; |
|
|
|
|
|
|
|
#region 上架赠品
|
|
|
|
|
|
|
|
#region 获取赠品sku信息
|
|
|
|
stepText = "获取赠品sku信息"; |
|
|
|
var selectGiftSkuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
@ -819,7 +830,7 @@ namespace BBWY.Server.Business |
|
|
|
if (res.IsError) |
|
|
|
throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList(); |
|
|
|
giftSkuList.AddRange(newSkuList); |
|
|
|
giftSkuIdList.AddRange(newSkuList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -852,7 +863,7 @@ namespace BBWY.Server.Business |
|
|
|
else |
|
|
|
{ |
|
|
|
var skuList = request.MainProductGiftSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
|
giftSkuList.AddRange(skuList); |
|
|
|
giftSkuIdList.AddRange(skuList); |
|
|
|
} |
|
|
|
|
|
|
|
#region 创建活动
|
|
|
|
@ -879,7 +890,7 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
foreach (var deleteSku in giftSkuList) |
|
|
|
foreach (var deleteSku in giftSkuIdList) |
|
|
|
{ |
|
|
|
DeleteSku(new DeleteSkuRequest() |
|
|
|
{ |
|
|
|
@ -903,12 +914,79 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
#region 添加活动sku
|
|
|
|
{ |
|
|
|
#region 查询奶妈和主商品sku
|
|
|
|
var mainSkuList = new List<ProductSkuResponse>(); |
|
|
|
if (!string.IsNullOrEmpty(request.MotherTemplateSku)) |
|
|
|
{ |
|
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Sku = request.MotherTemplateSku |
|
|
|
}); |
|
|
|
mainSkuList.AddRange(skuList); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(request.MainProductSku)) |
|
|
|
{ |
|
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Sku = request.MainProductSku |
|
|
|
}); |
|
|
|
mainSkuList.AddRange(skuList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 查询赠品sku
|
|
|
|
|
|
|
|
var giftSkuList = new List<ProductSkuResponse>(); |
|
|
|
if (giftSkuIdList.Count() > 0) |
|
|
|
{ |
|
|
|
var giftSkuIds = string.Join(",", giftSkuIdList); |
|
|
|
var skuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Sku = giftSkuIds |
|
|
|
}); |
|
|
|
giftSkuList.AddRange(skuList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
stepText = "添加活动sku"; |
|
|
|
var req = new SellerPromotionSkuAddRequest(); |
|
|
|
|
|
|
|
req.promoId = promotionId; |
|
|
|
|
|
|
|
req.skuIds = ""; |
|
|
|
foreach (var sku in mainSkuList) |
|
|
|
{ |
|
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
|
req.bindType = $"{req.bindType}1,"; |
|
|
|
req.num = $"{req.num}1,"; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var sku in giftSkuList) |
|
|
|
{ |
|
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
|
req.bindType = $"{req.bindType}2,"; |
|
|
|
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); |
|
|
|
|
|
|
|
//req.skuIds = "";
|
|
|
|
|
|
|
|
//req.jdPrices = ;
|
|
|
|
|
|
|
|
@ -921,7 +999,39 @@ namespace BBWY.Server.Business |
|
|
|
//req.bindType = ;
|
|
|
|
|
|
|
|
|
|
|
|
SellerPromotionSkuAddResponse response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
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
|
|
|
|
|
|
|
|
#region 提交活动
|
|
|
|
{ |
|
|
|
var req = new SellerPromotionCommitRequest(); |
|
|
|
req.promoId = promotionId; |
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (res.IsError) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
foreach (var deleteSku in giftSkuIdList) |
|
|
|
{ |
|
|
|
DeleteSku(new DeleteSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = request.Platform, |
|
|
|
Sku = deleteSku |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -931,12 +1041,34 @@ namespace BBWY.Server.Business |
|
|
|
var req = new SellerPromotionCheckRequest(); |
|
|
|
req.promoId = promotionId; |
|
|
|
req.status = 4; |
|
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (res.IsError) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
foreach (var deleteSku in giftSkuIdList) |
|
|
|
{ |
|
|
|
DeleteSku(new DeleteSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = request.Platform, |
|
|
|
Sku = deleteSku |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
throw new BusinessException($"审核活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 下架赠品sku
|
|
|
|
foreach (var deleteSku in giftSkuList) |
|
|
|
foreach (var deleteSku in giftSkuIdList) |
|
|
|
{ |
|
|
|
DeleteSku(new DeleteSkuRequest() |
|
|
|
{ |
|
|
|
|