Browse Source

后续任务

pjzs_starttask_update
shanji 1 year ago
parent
commit
bad92d77c5
  1. 21
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 137
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs

21
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -635,8 +635,8 @@ namespace BBWY.Server.Business
MainProductCategoryId = categoryId, MainProductCategoryId = categoryId,
MainProductMultiCateProps = multiCateProps, MainProductMultiCateProps = multiCateProps,
MainProductSkuInStore = mainProductSkuInStore, MainProductSkuInStore = mainProductSkuInStore,
OuterId = dbPromotionTask.OuterId OuterId = dbPromotionTask.OuterId,
IsNewProduct = dbPromotionTask.IsNewProduct ?? 1
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 800); }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 800);
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK) if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
@ -1042,19 +1042,6 @@ namespace BBWY.Server.Business
{ {
#region 提前完成任务量,暂停JD活动 #region 提前完成任务量,暂停JD活动
{ {
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
// "api/platformsdk/SuspendJDPromotionTask",
// new SuspendDPromotionTaskRequest()
// {
// AppKey = shop.AppKey2,
// AppSecret = shop.AppSecret2,
// AppToken = shop.AppToken2,
// Platform = Enums.Platform.京东,
// PromotionId = promotionTask.PromotionId.Value
// },
// GetYunDingRequestHeader(),
// HttpMethod.Post);
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.), var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/DeleteJDPromotionTask", "api/platformsdk/DeleteJDPromotionTask",
new DeleteJDPromotionTaskRequest() new DeleteJDPromotionTaskRequest()
@ -1110,6 +1097,10 @@ namespace BBWY.Server.Business
fsql.Insert(insertPromotionTaskSkuRecordList).ExecuteAffrows(); fsql.Insert(insertPromotionTaskSkuRecordList).ExecuteAffrows();
}); });
#region 任务结束之后的处理
#endregion
#region 钉钉通知结束 #region 钉钉通知结束
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
{ {

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

@ -803,7 +803,8 @@ namespace BBWY.Server.Business
string mainProductSpu, string mainProductSpu,
string fullTitle, string fullTitle,
string brandName, string brandName,
bool haveGiftTemplateSku) bool haveGiftTemplateSku,
int isNewProduct)
{ {
var jdClient = GetJdClient(appKey, appSecret); var jdClient = GetJdClient(appKey, appSecret);
@ -819,7 +820,7 @@ namespace BBWY.Server.Business
#region 设置完整标题 #region 设置完整标题
{ {
if (string.IsNullOrEmpty(brandName)) if (isNewProduct == 0 || string.IsNullOrEmpty(brandName) || string.IsNullOrEmpty(fullTitle))
return; return;
var req = new WareWriteUpdateWareTitleRequest(); var req = new WareWriteUpdateWareTitleRequest();
req.wareId = long.Parse(mainProductSpu); req.wareId = long.Parse(mainProductSpu);
@ -841,7 +842,8 @@ namespace BBWY.Server.Business
string mainProductSpu, string mainProductSpu,
string fullTitle, string fullTitle,
string brandName, string brandName,
bool haveGiftTemplateSku) bool haveGiftTemplateSku,
int isNewProduct)
{ {
var jdClient = GetJdClient(appKey, appSecret); var jdClient = GetJdClient(appKey, appSecret);
var wareId = long.Parse(mainProductSpu); var wareId = long.Parse(mainProductSpu);
@ -879,25 +881,25 @@ namespace BBWY.Server.Business
res.Json["error_response"].Value<string>("en_desc") : res.Json["error_response"].Value<string>("en_desc") :
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); (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}"); throw new BusinessException($"禁用赠品sku失败-{errorMsg}");
} }
} }
#region 设置完整标题 //#region 设置完整标题
{ //{
if (string.IsNullOrEmpty(brandName)) // if (string.IsNullOrEmpty(brandName))
return; // return;
var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId }; // var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId };
if (!fullTitle.StartsWith(brandName)) // if (!fullTitle.StartsWith(brandName))
req.title = $"{brandName}{fullTitle}"; // req.title = $"{brandName}{fullTitle}";
else // else
req.title = fullTitle; // req.title = fullTitle;
var response = jdClient.Execute(req, appToken, DateTime.Now.ToLocalTime()); // var response = jdClient.Execute(req, appToken, DateTime.Now.ToLocalTime());
if (response.IsError) // if (response.IsError)
throw new BusinessException($"设置完整标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}"); // throw new BusinessException($"设置完整标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}");
} //}
#endregion //#endregion
} }
/// <summary> /// <summary>
@ -1051,7 +1053,8 @@ namespace BBWY.Server.Business
} }
#endregion #endregion
#region 设置精简标题 #region 新品设置精简标题
if (request.IsNewProduct == 1)
{ {
stepText = "设置精简标题"; stepText = "设置精简标题";
var req = new WareWriteUpdateWareTitleRequest(); var req = new WareWriteUpdateWareTitleRequest();
@ -1073,27 +1076,6 @@ namespace BBWY.Server.Business
#region 获取销售属性 #region 获取销售属性
stepText = "获取销售属性"; stepText = "获取销售属性";
var attrId = string.Empty; 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>>(); List<List<AttrValueAliasJson>> strutsSaleAttrValueList = new List<List<AttrValueAliasJson>>();
var isStruts = false; var isStruts = false;
{ {
@ -1119,7 +1101,7 @@ namespace BBWY.Server.Business
j["attrValueList"].Children().Count() > 0); 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("缺少包含attrValueList的销售属性"); throw new BusinessException("缺少包含attrValueList的销售属性");
} }
var colorSaleAttrs = colorProperty["attrValueList"].ToList(); var colorSaleAttrs = colorProperty["attrValueList"].ToList();
@ -1133,7 +1115,7 @@ namespace BBWY.Server.Business
j.Value<string>("valueRules").Contains("规格")); j.Value<string>("valueRules").Contains("规格"));
if (tempDataJToken == null) 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("缺少必要的结构化属性"); throw new BusinessException("缺少必要的结构化属性");
} }
attrId = tempDataJToken.Value<string>("attrId"); attrId = tempDataJToken.Value<string>("attrId");
@ -1354,7 +1336,7 @@ namespace BBWY.Server.Business
req.skus = skusParamList; 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()); 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()); var shixiaoRes = jdClient.Execute(shixiaoReq, request.AppToken, DateTime.Now.ToLocalTime());
if (shixiaoRes.IsError) 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)}"); throw new BusinessException($"查询时效模板失败-{(string.IsNullOrEmpty(shixiaoRes.ErrorMsg) ? shixiaoRes.ErrMsg : shixiaoRes.ErrorMsg)}");
} }
if (shixiaoRes.Json == null) 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(); var shixiaoJToken = shixiaoRes.Json["jingdong_seller_delivery_SendPromiseTemplateJsfService_querySendTemplateByCategory_responce"]["returnType"]["bizResponse"]["promiseTemplateDtoList"].Children().FirstOrDefault();
if (shixiaoJToken == null) 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($"查询时效模板失败-未查询到时效模板"); throw new BusinessException($"查询时效模板失败-未查询到时效模板");
} }
promiseId = shixiaoJToken.Value<int>("templateId"); promiseId = shixiaoJToken.Value<int>("templateId");
@ -1401,14 +1383,14 @@ namespace BBWY.Server.Business
res.Json["error_response"].Value<string>("en_desc") : res.Json["error_response"].Value<string>("en_desc") :
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); (string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg);
errorMsg = SkuShangJiaFanYi(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}"); throw new BusinessException($"上架sku失败-{errorMsg}");
} }
} }
else else
{ {
errorMsg = SkuShangJiaFanYi(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}"); 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) foreach (var ps in newMainProductSkuList)
{ {
@ -1494,46 +1476,29 @@ namespace BBWY.Server.Business
{ {
stepText = "设置sku全国仓库存"; stepText = "设置sku全国仓库存";
Thread.Sleep(60 * 1000); Thread.Sleep(60 * 1000);
try //try
//{
foreach (var giftSkuId in giftSkuIdList)
{ {
foreach (var giftSkuId in giftSkuIdList) var req = new StockWriteUpdateSkuStockRequest();
{ req.skuId = long.Parse(giftSkuId);
var req = new StockWriteUpdateSkuStockRequest(); req.stockNum = 9999;
req.skuId = long.Parse(giftSkuId); req.storeId = 0;
req.stockNum = 9999; var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
req.storeId = 0; if (res.IsError)
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); throw new BusinessException($"设置全国仓库存失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
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
#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 创建活动 #region 创建活动
@ -1566,7 +1531,7 @@ namespace BBWY.Server.Business
res.Json = JObject.Parse(res.Body); res.Json = JObject.Parse(res.Body);
if (res.IsError) 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)}"); 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()); var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.IsError) 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)}"); throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
} }
@ -1630,7 +1595,7 @@ namespace BBWY.Server.Business
catch (Exception ex) catch (Exception ex)
{ {
nLogManager.Default().Error(ex, $"任务Id {request.Id} 店铺Id {request.ShopId} 执行步骤 {stepText}"); 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; throw ex;
} }
} }
@ -1644,7 +1609,7 @@ namespace BBWY.Server.Business
} }
catch (Exception ex) 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; throw;
} }
@ -1714,7 +1679,7 @@ namespace BBWY.Server.Business
catch { } catch { }
#endregion #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) public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request)

Loading…
Cancel
Save