|
|
@ -18,14 +18,11 @@ using Yitter.IdGenerator; |
|
|
|
|
|
|
|
namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
public class EvaluationAssistantBusiness : BasePlatformRelayBusiness, IDenpendency |
|
|
|
public class EvaluationAssistantBusiness : BaseBusiness, IDenpendency |
|
|
|
{ |
|
|
|
private IFreeSql fsql; |
|
|
|
private IIdGenerator idGenerator; |
|
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
|
private VenderBusiness venderBusiness; |
|
|
|
private DingDingBusiness dingDingBusiness; |
|
|
|
private NLogManager nLogManager; |
|
|
|
private List<Enums.OrderState> validOrderStateList; |
|
|
|
private List<Enums.PromitionTaskStatus> preTaskStateList; |
|
|
|
private ProductBusiness productBusiness; |
|
|
@ -33,7 +30,15 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
private char[] spliter; |
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(restApiService, options, yunDingBusiness) |
|
|
|
public EvaluationAssistantBusiness(IFreeSql fsql, |
|
|
|
IIdGenerator idGenerator, |
|
|
|
TaskSchedulerManager taskSchedulerManager, |
|
|
|
VenderBusiness venderBusiness, |
|
|
|
DingDingBusiness dingDingBusiness, |
|
|
|
NLogManager nLogManager, |
|
|
|
ProductBusiness productBusiness, |
|
|
|
FreeSqlMultiDBManager freeSqlMultiDBManager, |
|
|
|
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList) |
|
|
|
{ |
|
|
|
|
|
|
|
this.fsql = fsql; |
|
|
@ -183,8 +188,7 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
if (request.Id == 0) |
|
|
|
{ |
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
|
var restApiResult_spu = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", new SearchProductRequest() |
|
|
|
var spuResponse = productBusiness.GetProductList(new SearchProductRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
@ -193,12 +197,24 @@ namespace BBWY.Server.Business |
|
|
|
PageSize = 10, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Spu = request.MainProductSpu |
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
|
if (restApiResult_spu.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(restApiResult_spu.Content) { Code = (int)restApiResult_spu.StatusCode }; |
|
|
|
var spuResponse = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(restApiResult_spu.Content); |
|
|
|
if (!spuResponse.Success) |
|
|
|
throw new BusinessException(spuResponse.Msg) { Code = spuResponse.Code }; |
|
|
|
}); |
|
|
|
|
|
|
|
//var relayAPIHost = GetPlatformRelayAPIHost(Enums.Platform.京东);
|
|
|
|
//var restApiResult_spu = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", new SearchProductRequest()
|
|
|
|
//{
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// PageIndex = 1,
|
|
|
|
// PageSize = 10,
|
|
|
|
// Platform = Enums.Platform.京东,
|
|
|
|
// Spu = request.MainProductSpu
|
|
|
|
//}, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
//if (restApiResult_spu.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException(restApiResult_spu.Content) { Code = (int)restApiResult_spu.StatusCode };
|
|
|
|
//var spuResponse = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(restApiResult_spu.Content);
|
|
|
|
//if (!spuResponse.Success)
|
|
|
|
// throw new BusinessException(spuResponse.Msg) { Code = spuResponse.Code };
|
|
|
|
|
|
|
|
var sort = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == request.ShopId).ToAggregate(p => p.Max(p.Key.Sort)); |
|
|
|
var promotionTask = new PromotionTask() |
|
|
@ -219,8 +235,8 @@ namespace BBWY.Server.Business |
|
|
|
PromotionId = 0, |
|
|
|
Sort = sort + 1, |
|
|
|
UpdateSortTime = DateTime.Now, |
|
|
|
SpuLogo = spuResponse.Data.Items[0].Logo, |
|
|
|
SpuPublishTime = spuResponse.Data.Items[0].CreateTime, |
|
|
|
SpuLogo = spuResponse.Items[0].Logo, |
|
|
|
SpuPublishTime = spuResponse.Items[0].CreateTime, |
|
|
|
TaskCount = request.TaskCount, |
|
|
|
CustomMotherSku = request.CustomMotherSku, |
|
|
|
OuterId = request.OuterId |
|
|
@ -523,14 +539,15 @@ namespace BBWY.Server.Business |
|
|
|
CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku); |
|
|
|
|
|
|
|
|
|
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
|
//var host = GetPlatformRelayAPIHost(Enums.Platform.京东);
|
|
|
|
var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0; |
|
|
|
string barCode = string.Empty, categoryId = string.Empty; |
|
|
|
IList<JToken> multiCateProps = null; |
|
|
|
var mainProductSkuInStore = false; |
|
|
|
var platformSdkBusiness = GetPlatformSDKBusiness(Enums.Platform.京东); |
|
|
|
if (haveGiftTemplateSku) |
|
|
|
{ |
|
|
|
var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest() |
|
|
|
var mainSkuListResponse = productBusiness.GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
@ -538,34 +555,52 @@ namespace BBWY.Server.Business |
|
|
|
IsContainSource = true, |
|
|
|
Platform = request.Platform, |
|
|
|
Spu = dbPromotionTask.MainProductSpu |
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
|
if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}"); |
|
|
|
var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content); |
|
|
|
if (!mainSkuListResponse.Success) |
|
|
|
throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}"); |
|
|
|
}); |
|
|
|
|
|
|
|
barCode = mainSkuListResponse.Data[0].Source.Value<string>("barCode"); |
|
|
|
categoryId = mainSkuListResponse.Data[0].Source.Value<string>("categoryId"); |
|
|
|
multiCateProps = mainSkuListResponse.Data[0].Source["multiCateProps"] != null ? mainSkuListResponse.Data[0].Source["multiCateProps"].ToList() : null; |
|
|
|
//var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest()
|
|
|
|
//{
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// IsContainSource = true,
|
|
|
|
// Platform = request.Platform,
|
|
|
|
// Spu = dbPromotionTask.MainProductSpu
|
|
|
|
//}, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
//if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}");
|
|
|
|
//var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content);
|
|
|
|
//if (!mainSkuListResponse.Success)
|
|
|
|
// throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}");
|
|
|
|
|
|
|
|
barCode = mainSkuListResponse[0].Source.Value<string>("barCode"); |
|
|
|
categoryId = mainSkuListResponse[0].Source.Value<string>("categoryId"); |
|
|
|
multiCateProps = mainSkuListResponse[0].Source["multiCateProps"] != null ? mainSkuListResponse[0].Source["multiCateProps"].ToList() : null; |
|
|
|
|
|
|
|
var jyStoreIdList = fsql.Select<Storehouse>().Where(s => s.Type == Enums.StockType.京仓 || s.Name.Contains("云仓")).ToList(s => s.Id); |
|
|
|
|
|
|
|
foreach (var sku in mainSkuListResponse.Data) |
|
|
|
foreach (var sku in mainSkuListResponse) |
|
|
|
{ |
|
|
|
var stockNumApiResult = restApiService.SendRequest(host, "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest() |
|
|
|
var stockNumListResponse = platformSdkBusiness.GetStockNumBySku(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = shop.AppKey, |
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
AppToken = shop.AppToken, |
|
|
|
Platform = shop.PlatformId, |
|
|
|
Sku = sku.Id |
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
|
if (stockNumApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new Exception($"{sku} {stockNumApiResult.Content}"); |
|
|
|
var stockNumListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(stockNumApiResult.Content); |
|
|
|
|
|
|
|
var skuStockNumList = stockNumListResponse.Data.Select(j => new |
|
|
|
}); |
|
|
|
//var stockNumApiResult = restApiService.SendRequest(host, "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest()
|
|
|
|
//{
|
|
|
|
// AppKey = shop.AppKey,
|
|
|
|
// AppSecret = shop.AppSecret,
|
|
|
|
// AppToken = shop.AppToken,
|
|
|
|
// Platform = shop.PlatformId,
|
|
|
|
// Sku = sku.Id
|
|
|
|
//}, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
//if (stockNumApiResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new Exception($"{sku} {stockNumApiResult.Content}");
|
|
|
|
//var stockNumListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(stockNumApiResult.Content);
|
|
|
|
|
|
|
|
var skuStockNumList = stockNumListResponse.Select(j => new |
|
|
|
{ |
|
|
|
StockNum = j.Value<int>("stockNum"), |
|
|
|
StoreId = j.Value<string>("storeId"), |
|
|
@ -577,7 +612,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionTask", new StartPromotionTaskRequest2() |
|
|
|
var startResponse = platformSdkBusiness.StartJDPromotionTask(new StartPromotionTaskRequest2() |
|
|
|
{ |
|
|
|
Id = dbPromotionTask.Id, |
|
|
|
ActivityName = dbPromotionTask.ActivityName, |
|
|
@ -600,15 +635,16 @@ namespace BBWY.Server.Business |
|
|
|
MainProductMultiCateProps = multiCateProps, |
|
|
|
MainProductSkuInStore = mainProductSkuInStore, |
|
|
|
OuterId = dbPromotionTask.OuterId |
|
|
|
}); |
|
|
|
|
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
|
//var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionTask", , GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
|
|
|
|
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(httpApiResult.Content); |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<StartPromotionTaskResponse>>(httpApiResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
var startResponse = response.Data; |
|
|
|
//if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException(httpApiResult.Content);
|
|
|
|
//var response = JsonConvert.DeserializeObject<ApiResponse<StartPromotionTaskResponse>>(httpApiResult.Content);
|
|
|
|
//if (!response.Success)
|
|
|
|
// throw new BusinessException(response.Msg);
|
|
|
|
//var startResponse = response.Data;
|
|
|
|
|
|
|
|
if (dbPromotionTask.GiftTemplateId != null && |
|
|
|
dbPromotionTask.GiftTemplateId != 0 && |
|
|
@ -636,22 +672,6 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop) |
|
|
|
{ |
|
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
|
|
|
|
|
var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionDelayTask", new StartPromotionTaskDelayRequest() |
|
|
|
{ |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
BrandName = startResponse.BrandName, |
|
|
|
FullTitle = promotionTask.FullTitle, |
|
|
|
JDPromotionId = startResponse.JDPromotionId, |
|
|
|
MainProductSpu = promotionTask.MainProductSpu, |
|
|
|
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0, |
|
|
|
DeleteGiftSkuList = startResponse.DeleteGiftSkuList |
|
|
|
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 150); |
|
|
|
|
|
|
|
var errorBack = new Action<long, string>((id, errorMsg) => |
|
|
|
{ |
|
|
|
fsql.Update<PromotionTask>(id).Set(pt => pt.Status, Enums.PromitionTaskStatus.已停止) |
|
|
@ -659,17 +679,59 @@ namespace BBWY.Server.Business |
|
|
|
.ExecuteAffrows(); |
|
|
|
Error(shop, $"评价助手-{shop.ShopName}", $"开始任务-延迟任务-任务Id {request.Id}", new Exception(errorMsg)); |
|
|
|
}); |
|
|
|
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
errorBack(promotionTask.Id, httpApiResult.Content); |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
GetPlatformSDKBusiness(Enums.Platform.京东).StartJDPromotionDelayTask(new StartPromotionTaskDelayRequest() |
|
|
|
{ |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
BrandName = startResponse.BrandName, |
|
|
|
FullTitle = promotionTask.FullTitle, |
|
|
|
JDPromotionId = startResponse.JDPromotionId, |
|
|
|
MainProductSpu = promotionTask.MainProductSpu, |
|
|
|
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0, |
|
|
|
DeleteGiftSkuList = startResponse.DeleteGiftSkuList |
|
|
|
}); |
|
|
|
} |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<object>>(httpApiResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
errorBack(promotionTask.Id, response.Msg); |
|
|
|
errorBack(promotionTask.Id, ex.Message); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//var host = GetPlatformRelayAPIHost(Enums.Platform.京东);
|
|
|
|
|
|
|
|
//var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionDelayTask", new StartPromotionTaskDelayRequest()
|
|
|
|
//{
|
|
|
|
// Platform = Enums.Platform.京东,
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// BrandName = startResponse.BrandName,
|
|
|
|
// FullTitle = promotionTask.FullTitle,
|
|
|
|
// JDPromotionId = startResponse.JDPromotionId,
|
|
|
|
// MainProductSpu = promotionTask.MainProductSpu,
|
|
|
|
// HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0,
|
|
|
|
// DeleteGiftSkuList = startResponse.DeleteGiftSkuList
|
|
|
|
//}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 150);
|
|
|
|
|
|
|
|
|
|
|
|
//if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
//{
|
|
|
|
// errorBack(promotionTask.Id, httpApiResult.Content);
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
//var response = JsonConvert.DeserializeObject<ApiResponse<object>>(httpApiResult.Content);
|
|
|
|
//if (!response.Success)
|
|
|
|
//{
|
|
|
|
// errorBack(promotionTask.Id, response.Msg);
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -681,23 +743,33 @@ namespace BBWY.Server.Business |
|
|
|
var dbPromotionTask = fsql.Select<PromotionTask>(request.TaskId).ToOne(); |
|
|
|
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待) |
|
|
|
{ |
|
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
|
"api/platformsdk/DeleteJDPromotionTask", |
|
|
|
new DeleteJDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value |
|
|
|
}, |
|
|
|
GetYunDingRequestHeader(), |
|
|
|
HttpMethod.Post); |
|
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(httpResult.Content); |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
GetPlatformSDKBusiness(Enums.Platform.京东).DeleteJDPromotionTask( |
|
|
|
new DeleteJDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value |
|
|
|
}); |
|
|
|
|
|
|
|
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
|
|
|
|
// "api/platformsdk/DeleteJDPromotionTask",
|
|
|
|
// new DeleteJDPromotionTaskRequest()
|
|
|
|
// {
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// Platform = Enums.Platform.京东,
|
|
|
|
// PromotionId = dbPromotionTask.PromotionId.Value
|
|
|
|
// },
|
|
|
|
// GetYunDingRequestHeader(),
|
|
|
|
// HttpMethod.Post);
|
|
|
|
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException(httpResult.Content);
|
|
|
|
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
|
|
|
|
//if (!response.Success)
|
|
|
|
// throw new BusinessException(response.Msg);
|
|
|
|
} |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
@ -725,24 +797,34 @@ namespace BBWY.Server.Business |
|
|
|
if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku)) |
|
|
|
motherSkuIdList.AddRange(dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
|
|
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
|
"api/platformsdk/DeleteJDPromotionTaskSku", |
|
|
|
new DeleteJDPromotionTaskSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value, |
|
|
|
SkuId = string.Join(",", motherSkuIdList) |
|
|
|
}, |
|
|
|
GetYunDingRequestHeader(), |
|
|
|
HttpMethod.Post); |
|
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(httpResult.Content); |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
GetPlatformSDKBusiness(Enums.Platform.京东).DeleteJDPromotionTaskSku(new DeleteJDPromotionTaskSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value, |
|
|
|
SkuId = string.Join(",", motherSkuIdList) |
|
|
|
}); |
|
|
|
|
|
|
|
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
|
|
|
|
// "api/platformsdk/DeleteJDPromotionTaskSku",
|
|
|
|
// new DeleteJDPromotionTaskSkuRequest()
|
|
|
|
// {
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// Platform = Enums.Platform.京东,
|
|
|
|
// PromotionId = dbPromotionTask.PromotionId.Value,
|
|
|
|
// SkuId = string.Join(",", motherSkuIdList)
|
|
|
|
// },
|
|
|
|
// GetYunDingRequestHeader(),
|
|
|
|
// HttpMethod.Post);
|
|
|
|
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException(httpResult.Content);
|
|
|
|
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
|
|
|
|
//if (!response.Success)
|
|
|
|
// throw new BusinessException(response.Msg);
|
|
|
|
} |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
@ -766,26 +848,37 @@ namespace BBWY.Server.Business |
|
|
|
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.进行中) |
|
|
|
throw new BusinessException("只能在任务处于进行中时才能停止"); |
|
|
|
|
|
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
|
"api/platformsdk/SuspendJDPromotionTask", |
|
|
|
new SuspendDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value |
|
|
|
}, |
|
|
|
GetYunDingRequestHeader(), |
|
|
|
HttpMethod.Post); |
|
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(httpResult.Content); |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
GetPlatformSDKBusiness(Enums.Platform.京东).SuspendJDPromotionTask(new SuspendDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
if (!response.Msg.Contains("促销已删除")) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
} |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value |
|
|
|
}); |
|
|
|
|
|
|
|
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
|
|
|
|
// "api/platformsdk/SuspendJDPromotionTask",
|
|
|
|
// new SuspendDPromotionTaskRequest()
|
|
|
|
// {
|
|
|
|
// AppKey = request.AppKey,
|
|
|
|
// AppSecret = request.AppSecret,
|
|
|
|
// AppToken = request.AppToken,
|
|
|
|
// Platform = Enums.Platform.京东,
|
|
|
|
// PromotionId = dbPromotionTask.PromotionId.Value
|
|
|
|
// },
|
|
|
|
// GetYunDingRequestHeader(),
|
|
|
|
// HttpMethod.Post);
|
|
|
|
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
// throw new BusinessException(httpResult.Content);
|
|
|
|
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
|
|
|
|
//if (!response.Success)
|
|
|
|
//{
|
|
|
|
// if (!response.Msg.Contains("促销已删除"))
|
|
|
|
// throw new BusinessException(response.Msg);
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.已停止).ExecuteAffrows(); |
|
|
|
} |
|
|
|
|
|
|
@ -979,18 +1072,35 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
#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); |
|
|
|
try |
|
|
|
{ |
|
|
|
GetPlatformSDKBusiness(Enums.Platform.京东).SuspendJDPromotionTask(new SuspendDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
AppKey = shop.AppKey2, |
|
|
|
AppSecret = shop.AppSecret2, |
|
|
|
AppToken = shop.AppToken2, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = promotionTask.PromotionId.Value |
|
|
|
}); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", ex); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
|
|
|
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
//{
|
|
|
|