|
@@ -1,4 +1,5 @@
|
|
|
-using Hotline.Permissions;
|
|
|
+using DotNetCore.CAP;
|
|
|
+using Hotline.Permissions;
|
|
|
using Hotline.Push;
|
|
|
using Hotline.Push.FWMessage;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
@@ -6,6 +7,7 @@ using Hotline.Share.Dtos;
|
|
|
using Hotline.Share.Dtos.Push;
|
|
|
using Hotline.Share.Dtos.Push.FWMessage;
|
|
|
using Hotline.Share.Enums.Push;
|
|
|
+using Hotline.Share.Mq;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
@@ -26,7 +28,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IMessageCodeDomainService _messageCodeDomainService;
|
|
|
private readonly IRepository<BatchSmsTask> _batchSmsTaskRepository;
|
|
|
private readonly IRepository<BatchSmsTaskDetail> _batchSmsTaskDetailRepository;
|
|
|
-
|
|
|
+ private readonly ICapPublisher _capPublisher;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -40,7 +42,8 @@ namespace Hotline.Api.Controllers
|
|
|
IPushDomainService pushDomainService,
|
|
|
IMessageCodeDomainService messageCodeDomainService,
|
|
|
IRepository<BatchSmsTask> batchSmsTaskRepository,
|
|
|
- IRepository<BatchSmsTaskDetail> batchSmsTaskDetailRepository)
|
|
|
+ IRepository<BatchSmsTaskDetail> batchSmsTaskDetailRepository,
|
|
|
+ ICapPublisher capPublisher)
|
|
|
{
|
|
|
_messageRepository = messageRepository;
|
|
|
_mapper = mapper;
|
|
@@ -48,6 +51,7 @@ namespace Hotline.Api.Controllers
|
|
|
_messageCodeDomainService = messageCodeDomainService;
|
|
|
_batchSmsTaskRepository = batchSmsTaskRepository;
|
|
|
_batchSmsTaskDetailRepository = batchSmsTaskDetailRepository;
|
|
|
+ _capPublisher = capPublisher;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -182,15 +186,17 @@ namespace Hotline.Api.Controllers
|
|
|
var task = _mapper.Map<BatchSmsTask>(dto);
|
|
|
task.SmsCount = dto.BatchSmsTaskDetail.Count;
|
|
|
task.SmsTaskState = ESmsTaskState.WaitDo;
|
|
|
- task.InitId();
|
|
|
+ await _batchSmsTaskRepository.AddAsync(task, HttpContext.RequestAborted);
|
|
|
|
|
|
var detail = _mapper.Map<List<BatchSmsTaskDetail>>(dto.BatchSmsTaskDetail);
|
|
|
detail.ForEach(x =>
|
|
|
{
|
|
|
x.TaskId = task.Id;
|
|
|
});
|
|
|
- await _batchSmsTaskRepository.AddAsync(task,HttpContext.RequestAborted);
|
|
|
await _batchSmsTaskDetailRepository.AddRangeAsync(detail,HttpContext.RequestAborted);
|
|
|
+ //推送任务延迟消息
|
|
|
+ //_capPublisher.PublishDelay(expiredTimeConfig.NearlyExpiredTime - DateTime.Now, EventNames.HotlineOrderNearlyExpiredTimeSms, new PublishNearlyExpiredTimeSmsDto() { OrderId = order.Id });
|
|
|
+ _capPublisher.PublishDelay(task.PlanSendTime - DateTime.Now, EventNames.HotlineBatchSmsTask, new PublishBatchSmsTaskDto() { TaskId = task.Id });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|