|
|
@ -174,7 +174,9 @@ namespace BBWY.Server.Business |
|
|
|
!string.IsNullOrEmpty(searchProductSkuRequest.Sku) && |
|
|
|
skuIdList.Count() != skuList.Count()) |
|
|
|
{ |
|
|
|
throw new BusinessException($"{searchProductSkuRequest.CheckStep}-sku条件数量和查询结果数量不一致"); |
|
|
|
var targetSkuIdList = skuList.Select(s => s.Id); |
|
|
|
var exceptSkuIdList = skuIdList.Except(targetSkuIdList); |
|
|
|
throw new BusinessException($"{searchProductSkuRequest.CheckStep}-sku条件数量和查询结果数量不一致\r\n{string.Join(",", exceptSkuIdList)}"); |
|
|
|
} |
|
|
|
return skuList; |
|
|
|
|
|
|
@ -256,6 +258,8 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
else if (searchOrderRequest.JDColType == "0") |
|
|
|
{ |
|
|
|
var pageIndex = 1; |
|
|
|
var pageSize = 100; |
|
|
|
var sopReq = new PopOrderEnSearchRequest(); |
|
|
|
if (searchOrderRequest.StartDate != null) |
|
|
|
sopReq.startDate = searchOrderRequest.StartDate.Value.ToString("yyyy-MM-dd HH:mm:ss"); |
|
|
@ -271,13 +275,16 @@ namespace BBWY.Server.Business |
|
|
|
sopReq.orderState = searchOrderRequest.OrderState; //待转换
|
|
|
|
} |
|
|
|
sopReq.optionalFields = searchFields; |
|
|
|
sopReq.page = searchOrderRequest.PageIndex.ToString(); |
|
|
|
sopReq.pageSize = searchOrderRequest.PageSize.ToString(); |
|
|
|
//sopReq.page = searchOrderRequest.PageIndex.ToString();
|
|
|
|
sopReq.pageSize = pageSize.ToString(); |
|
|
|
sopReq.sortType = "1"; |
|
|
|
if (searchOrderRequest.SortTimeType != null) |
|
|
|
sopReq.dateType = ((int)searchOrderRequest.SortTimeType).ToString(); |
|
|
|
//sopReq.dateType = "";
|
|
|
|
|
|
|
|
|
|
|
|
while (true) |
|
|
|
{ |
|
|
|
sopReq.page = pageIndex.ToString(); |
|
|
|
var sopResponse = jdClient.Execute(sopReq, searchOrderRequest.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (searchOrderRequest.SaveResponseLog) |
|
|
|
nLogManager.Default().Info($"sopRequest\r\n{JsonConvert.SerializeObject(searchOrderRequest)} \r\nsopResponse\r\n{JsonConvert.SerializeObject(sopResponse)}"); |
|
|
@ -288,7 +295,12 @@ namespace BBWY.Server.Business |
|
|
|
sopResponse.Json = JObject.Parse(sopResponse.Body); |
|
|
|
|
|
|
|
//orderCount = sopResponse.Json["jingdong_pop_order_enSearch_responce"]["searchorderinfo_result"].Value<int>("orderTotal");
|
|
|
|
orderJtokens.AddRange((JArray)sopResponse.Json["jingdong_pop_order_enSearch_responce"]["searchorderinfo_result"]["orderInfoList"]); |
|
|
|
var orderJarray = (JArray)sopResponse.Json["jingdong_pop_order_enSearch_responce"]["searchorderinfo_result"]["orderInfoList"]; |
|
|
|
orderJtokens.AddRange(orderJarray); |
|
|
|
if (orderJarray.Count() < pageSize) |
|
|
|
break; |
|
|
|
pageIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@ -739,8 +751,9 @@ namespace BBWY.Server.Business |
|
|
|
/// <param name="promotionId"></param>
|
|
|
|
/// <param name="skuList"></param>
|
|
|
|
/// <param name="isGift"></param>
|
|
|
|
/// <param name="taskCount"></param>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
private void AddJDPromotionSku(IJdClient jdClient, string token, long promotionId, IList<ProductSkuResponse> skuList, bool isGift) |
|
|
|
private void AddJDPromotionSku(IJdClient jdClient, string token, long promotionId, IList<ProductSkuResponse> skuList, bool isGift, int taskCount) |
|
|
|
{ |
|
|
|
var req = new SellerPromotionSkuAddRequest(); |
|
|
|
req.promoId = promotionId; |
|
|
@ -763,7 +776,7 @@ namespace BBWY.Server.Business |
|
|
|
req.skuIds = $"{req.skuIds}{sku.Id},"; |
|
|
|
req.jdPrices = $"{req.jdPrices}{sku.Price},"; |
|
|
|
req.bindType = $"{req.bindType}{(isGift ? 2 : 1)},"; |
|
|
|
req.num = $"{req.num}{(isGift ? 1 : 100)},"; |
|
|
|
req.num = $"{req.num}{(isGift ? 1 : taskCount)},"; |
|
|
|
req.promoPrices = $"{req.promoPrices}{(isGift ? 0 : sku.Price)},"; |
|
|
|
} |
|
|
|
|
|
|
@ -893,36 +906,36 @@ namespace BBWY.Server.Business |
|
|
|
if (haveGiftTemplateSku) |
|
|
|
{ |
|
|
|
#region 上架赠品
|
|
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
|
IList<JToken> multiCateProps = null; |
|
|
|
|
|
|
|
#region 获取主商品sku信息 barCode,categoryId,multiCateProps
|
|
|
|
{ |
|
|
|
stepText = "获取主商品sku信息"; |
|
|
|
var mainSkuList = GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
IsContainSource = true, |
|
|
|
Platform = request.Platform, |
|
|
|
Spu = request.MainProductSpu |
|
|
|
}); |
|
|
|
if (mainSkuList.Count() == 0) |
|
|
|
throw new BusinessException($"获取主商品sku信息-未查询到sku信息"); |
|
|
|
|
|
|
|
barCode = mainSkuList[0].Source.Value<string>("barCode"); |
|
|
|
categoryId = mainSkuList[0].Source.Value<string>("categoryId"); |
|
|
|
multiCateProps = mainSkuList[0].Source["multiCateProps"] != null ? mainSkuList[0].Source["multiCateProps"].ToList() : null; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
//string barCode = string.Empty, categoryId = string.Empty;
|
|
|
|
//IList<JToken> multiCateProps = null;
|
|
|
|
|
|
|
|
//#region 获取主商品sku信息 barCode,categoryId,multiCateProps
|
|
|
|
//{
|
|
|
|
// stepText = "获取主商品sku信息";
|
|
|
|
// var mainSkuList = GetProductSkuList(new SearchProductSkuRequest()
|
|
|
|
// {
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// IsContainSource = true,
|
|
|
|
// Platform = request.Platform,
|
|
|
|
// Spu = request.MainProductSpu
|
|
|
|
// });
|
|
|
|
// if (mainSkuList.Count() == 0)
|
|
|
|
// throw new BusinessException($"获取主商品sku信息-未查询到sku信息");
|
|
|
|
|
|
|
|
// barCode = mainSkuList[0].Source.Value<string>("barCode");
|
|
|
|
// categoryId = mainSkuList[0].Source.Value<string>("categoryId");
|
|
|
|
// multiCateProps = mainSkuList[0].Source["multiCateProps"] != null ? mainSkuList[0].Source["multiCateProps"].ToList() : null;
|
|
|
|
//}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
#region 获取销售属性
|
|
|
|
stepText = "获取销售属性"; |
|
|
|
IList<JToken> colorSaleAttrs = null; |
|
|
|
{ |
|
|
|
var req = new CategoryReadFindAttrsByCategoryIdUnlimitCateRequest(); |
|
|
|
req.cid = long.Parse(categoryId); |
|
|
|
req.cid = long.Parse(request.MainProductCategoryId); |
|
|
|
req.attributeType = 4; |
|
|
|
req.field = "attrValueList,attrGroup"; |
|
|
|
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
@ -954,7 +967,7 @@ namespace BBWY.Server.Business |
|
|
|
//skuId = long.Parse(sku.Id),
|
|
|
|
jdPrice = giftSku.Price ?? 0, |
|
|
|
stockNum = 9999, |
|
|
|
barCode = barCode, |
|
|
|
barCode = request.MainProductBarCode, |
|
|
|
saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>() |
|
|
|
{ |
|
|
|
new SkuWriteUpdateSkusItemSaleAttrs() |
|
|
@ -968,9 +981,9 @@ namespace BBWY.Server.Business |
|
|
|
}; |
|
|
|
|
|
|
|
p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>(); |
|
|
|
if (multiCateProps != null && multiCateProps.Count() > 0) |
|
|
|
if (request.MainProductMultiCateProps != null && request.MainProductMultiCateProps.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var multiCateProp in multiCateProps) |
|
|
|
foreach (var multiCateProp in request.MainProductMultiCateProps) |
|
|
|
{ |
|
|
|
var m = new SkuWriteUpdateSkusItemSaleAttrs(); |
|
|
|
m.type = "com.jd.pop.ware.ic.api.domain.Prop"; |
|
|
@ -1020,6 +1033,9 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
|
|
|
|
if (res.Body.Contains("en_desc")) |
|
|
|
throw new BusinessException($"上架sku失败-{res.Json["error_response"].Value<string>("en_desc")}"); |
|
|
|
else |
|
|
|
throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
|
|
|
|
/*{"error_response":{"code":"501","en_desc":"com.jd.bk.saf.exception.SafJosException:京东价超出该类目允许范围:12.15-39437元!#821c1c3b382f476abeb21f1f515274c7(Solution reference: https://jos.jd.com/commondoc?listId=171)","zh_desc":"调用参数错误(解决方案参考: https://jos.jd.com/commondoc?listId=171)"}}*/ |
|
|
@ -1055,6 +1071,8 @@ namespace BBWY.Server.Business |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 设置sku全国仓库存
|
|
|
|
{ |
|
|
|
if (request.MainProductSkuInStore) |
|
|
|
{ |
|
|
|
stepText = "设置sku全国仓库存"; |
|
|
|
try |
|
|
@ -1076,6 +1094,7 @@ namespace BBWY.Server.Business |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
@ -1131,25 +1150,25 @@ namespace BBWY.Server.Business |
|
|
|
if (motherTemplateSkuList != null && motherTemplateSkuList.Count() > 0) |
|
|
|
{ |
|
|
|
stepText = "添加奶妈模板SKU"; |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, motherTemplateSkuList, false); |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, motherTemplateSkuList, false, request.TaskCount); |
|
|
|
} |
|
|
|
|
|
|
|
if (customerMotherSkuList != null && customerMotherSkuList.Count() > 0) |
|
|
|
{ |
|
|
|
stepText = "添加自定义奶妈SKU"; |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, customerMotherSkuList, false); |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, customerMotherSkuList, false, request.TaskCount); |
|
|
|
} |
|
|
|
|
|
|
|
if (mainProductSkuList != null && mainProductSkuList.Count() > 0) |
|
|
|
{ |
|
|
|
stepText = "添加主商品SKU"; |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, mainProductSkuList, false); |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, mainProductSkuList, false, request.TaskCount); |
|
|
|
} |
|
|
|
|
|
|
|
if (giftSkuList != null && giftSkuList.Count() > 0) |
|
|
|
{ |
|
|
|
stepText = "添加赠品SKU"; |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, giftSkuList, true); |
|
|
|
AddJDPromotionSku(jdClient, request.AppToken, promotionId, giftSkuList, true, request.TaskCount); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|