Browse Source

上架sku返回原始错误

.开始,完成发钉钉
促销sku数量使用任务数量
qianyi
shanji 2 years ago
parent
commit
694049cba1
  1. 52
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 18
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  3. 5
      BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs

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

@ -534,7 +534,8 @@ namespace BBWY.Server.Business
CustomMotherSku = dbPromotionTask.CustomMotherSku,
MainProductSpu = dbPromotionTask.MainProductSpu,
Platform = Enums.Platform.,
ShopId = dbPromotionTask.ShopId.Value
ShopId = dbPromotionTask.ShopId.Value,
TaskCount = dbPromotionTask.TaskCount
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
@ -550,6 +551,13 @@ namespace BBWY.Server.Business
startResponse.DeleteGiftSkuList.Count() != 0)
dbPromotionTask.GiftTemplatePutNewSku = string.Join(",", startResponse.DeleteGiftSkuList);
try
{
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{dbPromotionTask.ActivityName}]已开始");
}
catch { }
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.PromotionId, startResponse.JDPromotionId)
.SetIf(!string.IsNullOrEmpty(dbPromotionTask.GiftTemplatePutNewSku), pt => pt.GiftTemplatePutNewSku, dbPromotionTask.GiftTemplatePutNewSku)
.Set(pt => pt.StartTime, DateTime.Now)
@ -827,7 +835,7 @@ namespace BBWY.Server.Business
List<IUpdate<PromotionTask>> updatePromotionTaskList = new List<IUpdate<PromotionTask>>();
List<PromotionTaskSkuRecord> insertPromotionTaskSkuRecordList = new List<PromotionTaskSkuRecord>();
IList<long> jobDoneTaskIdList = new List<long>();
IList<PromotionTask> jobDoneTaskList = new List<PromotionTask>();
foreach (var promotionTask in runningTaskList)
{
var productSkuList = new List<string>();
@ -915,23 +923,24 @@ namespace BBWY.Server.Business
GetYunDingRequestHeader(),
HttpMethod.Post);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
{
Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(httpResult.Content));
}
else
{
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
if (!response.Success)
{
Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(response.Msg));
}
}
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
//{
// Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(httpResult.Content));
//}
//else
//{
// var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
// if (!response.Success)
// {
// Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(response.Msg));
// }
//}
}
#endregion
}
jobDoneTaskIdList.Add(promotionTask.Id); //记录完成任务
jobDoneTaskList.Add(promotionTask);
}
}
}
@ -945,6 +954,21 @@ namespace BBWY.Server.Business
fsql.Insert(insertPromotionTaskSkuRecordList).ExecuteAffrows();
});
#region 钉钉通知结束
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
{
foreach (var jobDoneTask in jobDoneTaskList)
{
try
{
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{jobDoneTask.ActivityName}]已结束");
}
catch { }
}
}
#endregion
#region 开始后续任务
//下一轮开始任务
if (jobDoneTaskIdList.Count() > 0)

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

@ -739,8 +739,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 +764,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)},";
}
@ -1020,7 +1021,10 @@ namespace BBWY.Server.Business
{
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
throw new BusinessException($"上架sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
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)"}}*/
}
@ -1131,25 +1135,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

5
BBWY.Server.Model/Dto/Request/PromotionTask/StartPromotionTaskRequest.cs

@ -55,6 +55,11 @@ namespace BBWY.Server.Model.Dto
/// 自定义奶妈sku
/// </summary>
public string CustomMotherSku { get; set; }
/// <summary>
/// 任务量
/// </summary>
public int TaskCount { get; set; }
}
public class StartPromotionTaskDelayRequest : PlatformRequest

Loading…
Cancel
Save