|
|
@ -5,9 +5,11 @@ using BBWY.Server.Model; |
|
|
|
using BBWY.Server.Model.Db; |
|
|
|
using BBWY.Server.Model.Dto; |
|
|
|
using FreeSql; |
|
|
|
//using Jd.Api.Domain;
|
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using NLog.LayoutRenderers.Wrappers; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
@ -713,6 +715,26 @@ namespace BBWY.Server.Business |
|
|
|
errorBack(promotionTask.Id, response.Msg); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
#region 检测是否有后续任务
|
|
|
|
var shopId = long.Parse(shop.ShopId); |
|
|
|
var haveNextTask = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId && |
|
|
|
pt.Status == Enums.PromitionTaskStatus.等待 && |
|
|
|
pt.IsEnabled == true && |
|
|
|
(pt.PreTaskId == promotionTask.Id || |
|
|
|
pt.PreTaskId == -1)).Any(); |
|
|
|
if (!haveNextTask) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"评价助手\n店铺:{shop.ShopName}\n任务列表无后续任务,为避免空档请及时设置后续任务"); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -1099,6 +1121,17 @@ namespace BBWY.Server.Business |
|
|
|
}); |
|
|
|
|
|
|
|
#region 任务结束之后的处理
|
|
|
|
|
|
|
|
if (jobDoneTaskIdList.Count() == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
var statusList = new List<Enums.PromitionTaskStatus?>() { Enums.PromitionTaskStatus.等待, Enums.PromitionTaskStatus.进行中 }; |
|
|
|
|
|
|
|
var effectiveTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId && |
|
|
|
statusList.Contains(pt.Status) && |
|
|
|
pt.IsEnabled == true) |
|
|
|
.ToList(pt => new { pt.Id, pt.ShopId, TaskName = pt.ActivityName, pt.PreTaskId, pt.Status }); |
|
|
|
|
|
|
|
foreach (var jobDoneTask in jobDoneTaskList) |
|
|
|
{ |
|
|
|
#region 恢复新品任务的完整标题
|
|
|
@ -1126,18 +1159,10 @@ namespace BBWY.Server.Business |
|
|
|
catch { } |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 开始后续任务
|
|
|
|
//下一轮开始任务
|
|
|
|
if (jobDoneTaskIdList.Count() > 0) |
|
|
|
{ |
|
|
|
var childTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId && |
|
|
|
pt.Status == Enums.PromitionTaskStatus.等待 && |
|
|
|
pt.IsEnabled == true && |
|
|
|
jobDoneTaskIdList.Contains(pt.PreTaskId.Value)) |
|
|
|
.ToList(pt => new { Id = pt.Id, ShopId = pt.ShopId, TaskName = pt.ActivityName }); |
|
|
|
var childTaskList = effectiveTaskList.Where(pt => pt.PreTaskId == jobDoneTask.Id && |
|
|
|
pt.Status == Enums.PromitionTaskStatus.等待).ToList(); |
|
|
|
if (childTaskList.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var task in childTaskList) |
|
|
@ -1145,8 +1170,45 @@ namespace BBWY.Server.Business |
|
|
|
Task.Factory.StartNew(() => AutoStart(task.Id, task.TaskName, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionAutoStartTaskScheduler); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
#region 检测是否所有任务完成
|
|
|
|
if (effectiveTaskList.Count() == 0) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"评价助手\n店铺:{shop.ShopName}\n任务全部执行完成,请及时设置后续任务!!"); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//#region 开始后续任务
|
|
|
|
////下一轮开始任务
|
|
|
|
//if (jobDoneTaskIdList.Count() > 0)
|
|
|
|
//{
|
|
|
|
// var childTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId &&
|
|
|
|
// pt.Status == Enums.PromitionTaskStatus.等待 &&
|
|
|
|
// pt.IsEnabled == true &&
|
|
|
|
// jobDoneTaskIdList.Contains(pt.PreTaskId.Value))
|
|
|
|
// .ToList(pt => new { Id = pt.Id, ShopId = pt.ShopId, TaskName = pt.ActivityName });
|
|
|
|
// if (childTaskList.Count() > 0)
|
|
|
|
// {
|
|
|
|
// foreach (var task in childTaskList)
|
|
|
|
// {
|
|
|
|
// Task.Factory.StartNew(() => AutoStart(task.Id, task.TaskName, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionAutoStartTaskScheduler);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void AutoStart(long taskId, string taskName, ShopResponse shop) |
|
|
|