|
@ -525,30 +525,35 @@ namespace BBWY.Server.Business |
|
|
CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku); |
|
|
CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var joinSkuCount = 0; |
|
|
|
|
|
var joinSkuNoGiftList = new List<string>(); |
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0; |
|
|
var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0; |
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
IList<JToken> multiCateProps = null; |
|
|
IList<JToken> multiCateProps = null; |
|
|
var mainProductSkuInStore = false; |
|
|
var mainProductSkuInStore = false; |
|
|
if (haveGiftTemplateSku) |
|
|
|
|
|
|
|
|
var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest() |
|
|
{ |
|
|
{ |
|
|
var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest() |
|
|
AppKey = request.AppKey, |
|
|
{ |
|
|
AppSecret = request.AppSecret, |
|
|
AppKey = request.AppKey, |
|
|
AppToken = request.AppToken, |
|
|
AppSecret = request.AppSecret, |
|
|
IsContainSource = true, |
|
|
AppToken = request.AppToken, |
|
|
Platform = request.Platform, |
|
|
IsContainSource = true, |
|
|
Spu = dbPromotionTask.MainProductSpu |
|
|
Platform = request.Platform, |
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
Spu = dbPromotionTask.MainProductSpu |
|
|
if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}"); |
|
|
if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content); |
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}"); |
|
|
if (!mainSkuListResponse.Success) |
|
|
var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content); |
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); |
|
|
if (!mainSkuListResponse.Success) |
|
|
joinSkuNoGiftList.AddRange(mainSkuListResponse.Data.Select(s => s.Id)); |
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); |
|
|
//开启延迟任务
|
|
|
|
|
|
if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku)) |
|
|
|
|
|
joinSkuNoGiftList.AddRange(dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
|
|
|
|
|
|
|
|
if (haveGiftTemplateSku) |
|
|
|
|
|
{ |
|
|
barCode = mainSkuListResponse.Data[0].Source.Value<string>("barCode"); |
|
|
barCode = mainSkuListResponse.Data[0].Source.Value<string>("barCode"); |
|
|
categoryId = mainSkuListResponse.Data[0].Source.Value<string>("categoryId"); |
|
|
categoryId = mainSkuListResponse.Data[0].Source.Value<string>("categoryId"); |
|
|
multiCateProps = mainSkuListResponse.Data[0].Source["multiCateProps"] != null ? mainSkuListResponse.Data[0].Source["multiCateProps"].ToList() : null; |
|
|
multiCateProps = mainSkuListResponse.Data[0].Source["multiCateProps"] != null ? mainSkuListResponse.Data[0].Source["multiCateProps"].ToList() : null; |
|
@ -620,12 +625,12 @@ namespace BBWY.Server.Business |
|
|
startResponse.DeleteGiftSkuList.Count() != 0) |
|
|
startResponse.DeleteGiftSkuList.Count() != 0) |
|
|
dbPromotionTask.GiftTemplatePutNewSku = string.Join(",", startResponse.DeleteGiftSkuList); |
|
|
dbPromotionTask.GiftTemplatePutNewSku = string.Join(",", startResponse.DeleteGiftSkuList); |
|
|
|
|
|
|
|
|
try |
|
|
//try
|
|
|
{ |
|
|
//{
|
|
|
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) |
|
|
// if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
|
|
|
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{dbPromotionTask.ActivityName}]已开始,请及时查看任务是否正常进行"); |
|
|
// dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"任务[{dbPromotionTask.ActivityName}]已开始,请及时查看任务是否正常进行");
|
|
|
} |
|
|
//}
|
|
|
catch { } |
|
|
//catch { }
|
|
|
|
|
|
|
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.PromotionId, startResponse.JDPromotionId) |
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.PromotionId, startResponse.JDPromotionId) |
|
|
.SetIf(!string.IsNullOrEmpty(dbPromotionTask.GiftTemplatePutNewSku), pt => pt.GiftTemplatePutNewSku, dbPromotionTask.GiftTemplatePutNewSku) |
|
|
.SetIf(!string.IsNullOrEmpty(dbPromotionTask.GiftTemplatePutNewSku), pt => pt.GiftTemplatePutNewSku, dbPromotionTask.GiftTemplatePutNewSku) |
|
@ -634,11 +639,11 @@ namespace BBWY.Server.Business |
|
|
.Set(pt => pt.Status, Enums.PromitionTaskStatus.进行中) |
|
|
.Set(pt => pt.Status, Enums.PromitionTaskStatus.进行中) |
|
|
.ExecuteAffrows(); |
|
|
.ExecuteAffrows(); |
|
|
|
|
|
|
|
|
//开启延迟任务
|
|
|
joinSkuCount = joinSkuNoGiftList.Distinct().Count(); |
|
|
Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler); |
|
|
Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop, joinSkuCount), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop) |
|
|
private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop, int joinSkuCount) |
|
|
{ |
|
|
{ |
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
|
|
|
|
|
@ -653,8 +658,12 @@ namespace BBWY.Server.Business |
|
|
JDPromotionId = startResponse.JDPromotionId, |
|
|
JDPromotionId = startResponse.JDPromotionId, |
|
|
MainProductSpu = promotionTask.MainProductSpu, |
|
|
MainProductSpu = promotionTask.MainProductSpu, |
|
|
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0, |
|
|
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0, |
|
|
DeleteGiftSkuList = startResponse.DeleteGiftSkuList |
|
|
DeleteGiftSkuList = startResponse.DeleteGiftSkuList, |
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 300); |
|
|
ActivityName = promotionTask.ActivityName, |
|
|
|
|
|
JoinSkuCount = joinSkuCount, |
|
|
|
|
|
PJZSDingDingKey = shop.PJZSDingDingKey, |
|
|
|
|
|
PJZSDingDingWebHook = shop.PJZSDingDingWebHook |
|
|
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 500); |
|
|
|
|
|
|
|
|
var errorBack = new Action<long, string>((id, errorMsg) => |
|
|
var errorBack = new Action<long, string>((id, errorMsg) => |
|
|
{ |
|
|
{ |
|
@ -995,31 +1004,31 @@ namespace BBWY.Server.Business |
|
|
{ |
|
|
{ |
|
|
#region 提前完成任务量,暂停JD活动
|
|
|
#region 提前完成任务量,暂停JD活动
|
|
|
{ |
|
|
{ |
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
|
|
|
"api/platformsdk/SuspendJDPromotionTask", |
|
|
// "api/platformsdk/SuspendJDPromotionTask",
|
|
|
new SuspendDPromotionTaskRequest() |
|
|
// new SuspendDPromotionTaskRequest()
|
|
|
{ |
|
|
// {
|
|
|
AppKey = shop.AppKey2, |
|
|
// AppKey = shop.AppKey2,
|
|
|
AppSecret = shop.AppSecret2, |
|
|
// AppSecret = shop.AppSecret2,
|
|
|
AppToken = shop.AppToken2, |
|
|
// AppToken = shop.AppToken2,
|
|
|
Platform = Enums.Platform.京东, |
|
|
// Platform = Enums.Platform.京东,
|
|
|
PromotionId = promotionTask.PromotionId.Value |
|
|
// PromotionId = promotionTask.PromotionId.Value
|
|
|
}, |
|
|
// },
|
|
|
GetYunDingRequestHeader(), |
|
|
// GetYunDingRequestHeader(),
|
|
|
HttpMethod.Post); |
|
|
// HttpMethod.Post);
|
|
|
|
|
|
|
|
|
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
//{
|
|
|
"api/platformsdk/DeleteJDPromotionTask", |
|
|
// Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(httpResult.Content));
|
|
|
new DeleteJDPromotionTaskRequest() |
|
|
//}
|
|
|
{ |
|
|
//else
|
|
|
AppKey = shop.AppKey2, |
|
|
//{
|
|
|
AppSecret = shop.AppSecret2, |
|
|
// var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
|
|
|
AppToken = shop.AppToken2, |
|
|
// if (!response.Success)
|
|
|
Platform = Enums.Platform.京东, |
|
|
// {
|
|
|
PromotionId = promotionTask.PromotionId.Value |
|
|
// Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", new Exception(response.Msg));
|
|
|
}, |
|
|
// }
|
|
|
GetYunDingRequestHeader(), |
|
|
//}
|
|
|
HttpMethod.Post); |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|