|
|
@ -803,7 +803,8 @@ namespace BBWY.Server.Business |
|
|
|
string mainProductSpu, |
|
|
|
string fullTitle, |
|
|
|
string brandName, |
|
|
|
bool haveGiftTemplateSku) |
|
|
|
bool haveGiftTemplateSku, |
|
|
|
int isNewProduct) |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(appKey, appSecret); |
|
|
|
|
|
|
@ -819,7 +820,7 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
#region 设置完整标题
|
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(brandName)) |
|
|
|
if (isNewProduct == 0 || string.IsNullOrEmpty(brandName) || string.IsNullOrEmpty(fullTitle)) |
|
|
|
return; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
|
req.wareId = long.Parse(mainProductSpu); |
|
|
@ -841,7 +842,8 @@ namespace BBWY.Server.Business |
|
|
|
string mainProductSpu, |
|
|
|
string fullTitle, |
|
|
|
string brandName, |
|
|
|
bool haveGiftTemplateSku) |
|
|
|
bool haveGiftTemplateSku, |
|
|
|
int isNewProduct) |
|
|
|
{ |
|
|
|
var jdClient = GetJdClient(appKey, appSecret); |
|
|
|
var wareId = long.Parse(mainProductSpu); |
|
|
@ -879,25 +881,25 @@ namespace BBWY.Server.Business |
|
|
|
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); |
|
|
|
RollBackWhenStartPromotionError(appKey, appSecret, appToken, deleteSkuList, mainProductSpu, fullTitle, brandName, false, isNewProduct); |
|
|
|
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
|
|
|
|
//#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>
|
|
|
@ -1051,7 +1053,8 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 设置精简标题
|
|
|
|
#region 新品设置精简标题
|
|
|
|
if (request.IsNewProduct == 1) |
|
|
|
{ |
|
|
|
stepText = "设置精简标题"; |
|
|
|
var req = new WareWriteUpdateWareTitleRequest(); |
|
|
@ -1073,27 +1076,6 @@ namespace BBWY.Server.Business |
|
|
|
#region 获取销售属性
|
|
|
|
stepText = "获取销售属性"; |
|
|
|
var attrId = string.Empty; |
|
|
|
//IList<JToken> colorSaleAttrs = null;
|
|
|
|
//{
|
|
|
|
// var req = new CategoryReadFindAttrsByCategoryIdUnlimitCateRequest();
|
|
|
|
// req.cid = long.Parse(request.MainProductCategoryId);
|
|
|
|
// req.attributeType = 4;
|
|
|
|
// req.field = "attrValueList,attrGroup";
|
|
|
|
// var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
|
|
|
|
// if (response.Json == null)
|
|
|
|
// response.Json = JObject.Parse(response.Body);
|
|
|
|
// var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j.Value<string>("name") == "颜色");
|
|
|
|
// if (colorProperty == null)
|
|
|
|
// {
|
|
|
|
// colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j["attrValueList"] != null && j["attrValueList"].Count() > 0);
|
|
|
|
// }
|
|
|
|
// if (colorProperty == null)
|
|
|
|
// {
|
|
|
|
// RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku);
|
|
|
|
// throw new BusinessException("缺少销售属性");
|
|
|
|
// }
|
|
|
|
// colorSaleAttrs = colorProperty["attrValueList"].ToList();
|
|
|
|
//}
|
|
|
|
List<List<AttrValueAliasJson>> strutsSaleAttrValueList = new List<List<AttrValueAliasJson>>(); |
|
|
|
var isStruts = false; |
|
|
|
{ |
|
|
@ -1119,7 +1101,7 @@ namespace BBWY.Server.Business |
|
|
|
j["attrValueList"].Children().Count() > 0); |
|
|
|
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("缺少包含attrValueList的销售属性"); |
|
|
|
} |
|
|
|
var colorSaleAttrs = colorProperty["attrValueList"].ToList(); |
|
|
@ -1133,7 +1115,7 @@ namespace BBWY.Server.Business |
|
|
|
j.Value<string>("valueRules").Contains("规格")); |
|
|
|
if (tempDataJToken == 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("缺少必要的结构化属性"); |
|
|
|
} |
|
|
|
attrId = tempDataJToken.Value<string>("attrId"); |
|
|
@ -1354,7 +1336,7 @@ namespace BBWY.Server.Business |
|
|
|
req.skus = skusParamList; |
|
|
|
|
|
|
|
//输出日志
|
|
|
|
nLogManager.Default().Info($"上架赠品请求参数,任务Id{request.Id},{JsonConvert.SerializeObject(req)}"); |
|
|
|
//nLogManager.Default().Info($"上架赠品请求参数,任务Id{request.Id},{JsonConvert.SerializeObject(req)}");
|
|
|
|
|
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
|
|
|
@ -1377,7 +1359,7 @@ namespace BBWY.Server.Business |
|
|
|
var shixiaoRes = jdClient.Execute(shixiaoReq, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (shixiaoRes.IsError) |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
//RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
|
|
|
|
throw new BusinessException($"查询时效模板失败-{(string.IsNullOrEmpty(shixiaoRes.ErrorMsg) ? shixiaoRes.ErrMsg : shixiaoRes.ErrorMsg)}"); |
|
|
|
} |
|
|
|
if (shixiaoRes.Json == null) |
|
|
@ -1385,7 +1367,7 @@ namespace BBWY.Server.Business |
|
|
|
var shixiaoJToken = shixiaoRes.Json["jingdong_seller_delivery_SendPromiseTemplateJsfService_querySendTemplateByCategory_responce"]["returnType"]["bizResponse"]["promiseTemplateDtoList"].Children().FirstOrDefault(); |
|
|
|
if (shixiaoJToken == null) |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
//RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
|
|
|
|
throw new BusinessException($"查询时效模板失败-未查询到时效模板"); |
|
|
|
} |
|
|
|
promiseId = shixiaoJToken.Value<int>("templateId"); |
|
|
@ -1401,14 +1383,14 @@ namespace BBWY.Server.Business |
|
|
|
res.Json["error_response"].Value<string>("en_desc") : |
|
|
|
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); |
|
|
|
errorMsg = SkuShangJiaFanYi(errorMsg); |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
//RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
|
|
|
|
throw new BusinessException($"上架sku失败-{errorMsg}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
errorMsg = SkuShangJiaFanYi(errorMsg); |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); |
|
|
|
//RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
|
|
|
|
throw new BusinessException($"上架sku失败-{errorMsg}"); |
|
|
|
} |
|
|
|
} |
|
|
@ -1427,7 +1409,7 @@ namespace BBWY.Server.Business |
|
|
|
}); |
|
|
|
|
|
|
|
//记录上架返回值
|
|
|
|
nLogManager.Default().Info($"查询上架的赠品,任务Id {request.Id} 店铺Id {request.ShopId}, {JsonConvert.SerializeObject(newMainProductSkuList)}"); |
|
|
|
//nLogManager.Default().Info($"查询上架的赠品,任务Id {request.Id} 店铺Id {request.ShopId}, {JsonConvert.SerializeObject(newMainProductSkuList)}");
|
|
|
|
|
|
|
|
foreach (var ps in newMainProductSkuList) |
|
|
|
{ |
|
|
@ -1494,8 +1476,8 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
stepText = "设置sku全国仓库存"; |
|
|
|
Thread.Sleep(60 * 1000); |
|
|
|
try |
|
|
|
{ |
|
|
|
//try
|
|
|
|
//{
|
|
|
|
foreach (var giftSkuId in giftSkuIdList) |
|
|
|
{ |
|
|
|
var req = new StockWriteUpdateSkuStockRequest(); |
|
|
@ -1506,34 +1488,17 @@ namespace BBWY.Server.Business |
|
|
|
if (res.IsError) |
|
|
|
throw new BusinessException($"设置全国仓库存失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, true); |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
//}
|
|
|
|
//catch (Exception ex)
|
|
|
|
//{
|
|
|
|
//RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, true);
|
|
|
|
// throw ex;
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//#region 查询上架的赠品
|
|
|
|
//stepText = "查询上架的赠品SKU";
|
|
|
|
//Thread.Sleep(60 * 1000);
|
|
|
|
//searchProductSkuRequest.Sku = string.Join(",", giftSkuIdList);
|
|
|
|
//searchProductSkuRequest.CheckStep = "上架的赠品";
|
|
|
|
//try
|
|
|
|
//{
|
|
|
|
// giftSkuList = GetProductSkuList(searchProductSkuRequest);
|
|
|
|
//}
|
|
|
|
//catch
|
|
|
|
//{
|
|
|
|
// RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku);
|
|
|
|
// throw;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
#region 创建活动
|
|
|
@ -1566,7 +1531,7 @@ namespace BBWY.Server.Business |
|
|
|
res.Json = JObject.Parse(res.Body); |
|
|
|
if (res.IsError) |
|
|
|
{ |
|
|
|
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($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
} |
|
|
|
|
|
|
@ -1612,7 +1577,7 @@ namespace BBWY.Server.Business |
|
|
|
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); |
|
|
|
if (res.IsError) |
|
|
|
{ |
|
|
|
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($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); |
|
|
|
} |
|
|
|
} |
|
|
@ -1630,7 +1595,7 @@ namespace BBWY.Server.Business |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
nLogManager.Default().Error(ex, $"任务Id {request.Id} 店铺Id {request.ShopId} 执行步骤 {stepText}"); |
|
|
|
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, request.IsNewProduct); |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
@ -1644,7 +1609,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, request.HaveGiftTemplate); |
|
|
|
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, request.HaveGiftTemplate, request.IsNewProduct); |
|
|
|
throw; |
|
|
|
} |
|
|
|
|
|
|
@ -1714,7 +1679,7 @@ namespace BBWY.Server.Business |
|
|
|
catch { } |
|
|
|
#endregion
|
|
|
|
|
|
|
|
DisableGiftSkuAndRecoverFullTitle(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, request.IsNewProduct); |
|
|
|
} |
|
|
|
|
|
|
|
public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request) |
|
|
|