|
|
@ -26,8 +26,9 @@ namespace BBWY.Server.Business |
|
|
|
private DingDingBusiness dingDingBusiness; |
|
|
|
private NLogManager nLogManager; |
|
|
|
private List<Enums.OrderState> validOrderStateList; |
|
|
|
private ProductBusiness productBusiness; |
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager) : base(restApiService, options, yunDingBusiness) |
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness) : base(restApiService, options, yunDingBusiness) |
|
|
|
{ |
|
|
|
this.fsql = fsql; |
|
|
|
this.idGenerator = idGenerator; |
|
|
@ -35,6 +36,7 @@ namespace BBWY.Server.Business |
|
|
|
this.venderBusiness = venderBusiness; |
|
|
|
this.dingDingBusiness = dingDingBusiness; |
|
|
|
this.nLogManager = nLogManager; |
|
|
|
this.productBusiness = productBusiness; |
|
|
|
validOrderStateList = new List<Enums.OrderState>() |
|
|
|
{ |
|
|
|
Enums.OrderState.待出库, |
|
|
@ -463,8 +465,11 @@ namespace BBWY.Server.Business |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
} |
|
|
|
|
|
|
|
fsql.Delete<PromotionTask>(request.TaskId).ExecuteAffrows(); |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Delete<PromotionTask>(request.TaskId).ExecuteAffrows(); |
|
|
|
fsql.Delete<PromotionTaskSkuRecord>().Where(psr => psr.PromotionTaskId == request.TaskId).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -504,7 +509,12 @@ namespace BBWY.Server.Business |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
} |
|
|
|
fsql.Delete<PromotionTask>(request.TaskId).ExecuteAffrows(); |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Delete<PromotionTask>(request.TaskId).ExecuteAffrows(); |
|
|
|
fsql.Delete<PromotionTaskSkuRecord>().Where(psr => psr.PromotionTaskId == request.TaskId).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -564,7 +574,7 @@ namespace BBWY.Server.Business |
|
|
|
.InnerJoin((osku, o) => osku.OrderId == o.Id) |
|
|
|
.WhereIf(shopId != null, (osku, o) => o.ShopId == shopId) |
|
|
|
.Where((osku, o) => validOrderStateList.Contains(o.OrderState.Value)) |
|
|
|
.Where((osku, o) => osku.Price > 0 && osku.CreateTime >= querySkuTime) |
|
|
|
.Where((osku, o) => osku.CreateTime >= querySkuTime) |
|
|
|
.ToList((osku, o) => new OrderSku |
|
|
|
{ |
|
|
|
CreateTime = osku.CreateTime, |
|
|
@ -622,20 +632,42 @@ namespace BBWY.Server.Business |
|
|
|
IList<OrderSku> orderSkuList, |
|
|
|
IList<PromotionTaskSkuRecord> promotionTaskSkuRecordList) |
|
|
|
{ |
|
|
|
var loggerName = $"库存预警-{shop.ShopName}"; |
|
|
|
var loggerName = $"评价助手任务监控-{shop.ShopName}"; |
|
|
|
List<IUpdate<PromotionTask>> updatePromotionTaskList = new List<IUpdate<PromotionTask>>(); |
|
|
|
List<PromotionTaskSkuRecord> insertPromotionTaskSkuRecordList = new List<PromotionTaskSkuRecord>(); |
|
|
|
IList<long> jobDoneTaskIdList = new List<long>(); |
|
|
|
|
|
|
|
foreach (var promotionTask in runningTaskList) |
|
|
|
{ |
|
|
|
var motherSkuList = new List<string>(); |
|
|
|
if (!string.IsNullOrEmpty(promotionTask.CustomMotherSku)) |
|
|
|
motherSkuList.AddRange(promotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
if (!string.IsNullOrEmpty(promotionTask.MainProductSku)) |
|
|
|
motherSkuList.AddRange(promotionTask.MainProductSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
var productSkuList = new List<string>(); |
|
|
|
|
|
|
|
#region 读取主商品sku
|
|
|
|
{ |
|
|
|
var productResponseSkuList = productBusiness.GetProductSkuList(new SearchProductSkuRequest() |
|
|
|
{ |
|
|
|
AppKey = shop.AppKey2, |
|
|
|
AppSecret = shop.AppSecret2, |
|
|
|
AppToken = shop.AppToken2, |
|
|
|
IsContainSource = false, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
Spu = promotionTask.MainProductSpu |
|
|
|
}); |
|
|
|
if (productResponseSkuList == null || productResponseSkuList.Count() == 0) |
|
|
|
{ |
|
|
|
LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-查询主商品sku", "未查询到主商品sku信息"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
productSkuList.AddRange(productResponseSkuList.Select(p => p.Id)); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(promotionTask.GiftTemplatePutNewSku)) |
|
|
|
{ |
|
|
|
productSkuList.AddRange(promotionTask.GiftTemplatePutNewSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var newOrderSkuList = orderSkuList.Where(osku => motherSkuList.Contains(osku.SkuId) && |
|
|
|
var newOrderSkuList = orderSkuList.Where(osku => productSkuList.Contains(osku.SkuId) && |
|
|
|
osku.CreateTime > promotionTask.StartTime && |
|
|
|
promotionTaskSkuRecordList.Count(psr => psr.PromotionTaskId == promotionTask.Id && |
|
|
|
psr.OrderId == osku.OrderId) == 0).ToList(); |
|
|
@ -694,14 +726,14 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
{ |
|
|
|
LogMonitorError(shop, loggerName, "自动任务-暂停京东活动", httpResult.Content); |
|
|
|
LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-暂停京东活动", httpResult.Content); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
{ |
|
|
|
LogMonitorError(shop, loggerName, "自动任务-暂停京东活动", response.Msg); |
|
|
|
LogMonitorError(shop, loggerName, $"{promotionTask.Id}-监控任务-暂停京东活动", response.Msg); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|