|
@ -11,6 +11,8 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Net.Http; |
|
|
using System.Net.Http; |
|
|
|
|
|
using System.Threading; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using Yitter.IdGenerator; |
|
|
using Yitter.IdGenerator; |
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business |
|
|
namespace BBWY.Server.Business |
|
@ -21,10 +23,16 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
private IIdGenerator idGenerator; |
|
|
private IIdGenerator idGenerator; |
|
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator) : base(restApiService, options, yunDingBusiness) |
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
|
|
|
|
|
|
|
|
|
private VenderBusiness venderBusiness; |
|
|
|
|
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness) : base(restApiService, options, yunDingBusiness) |
|
|
{ |
|
|
{ |
|
|
this.fsql = fsql; |
|
|
this.fsql = fsql; |
|
|
this.idGenerator = idGenerator; |
|
|
this.idGenerator = idGenerator; |
|
|
|
|
|
this.taskSchedulerManager = taskSchedulerManager; |
|
|
|
|
|
this.venderBusiness = venderBusiness; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#region 赠品模板
|
|
|
#region 赠品模板
|
|
@ -475,5 +483,30 @@ namespace BBWY.Server.Business |
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.已停止).ExecuteAffrows(); |
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.已停止).ExecuteAffrows(); |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public void StartMonitor(long? shopId) |
|
|
|
|
|
{ |
|
|
|
|
|
var shopList = venderBusiness.GetShopList(shopId, Enums.Platform.京东); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var shop in shopList) |
|
|
|
|
|
{ |
|
|
|
|
|
Task.Factory.StartNew(() => MonitorTaskCore(shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionMonitorTaskScheduler); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 自动任务
|
|
|
|
|
|
private void MonitorTaskCore(ShopResponse shop) |
|
|
|
|
|
{ |
|
|
|
|
|
var shopId = long.Parse(shop.ShopId); |
|
|
|
|
|
|
|
|
|
|
|
#region 查询正在进行的任务
|
|
|
|
|
|
var runningTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId && pt.Status == Enums.PromitionTaskStatus.进行中).ToList(); |
|
|
|
|
|
if (runningTaskList == null || runningTaskList.Count() == 0) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|