|
@@ -1,5 +1,6 @@
|
|
|
using CallCenter.Caches;
|
|
|
using CallCenter.Calls;
|
|
|
+using CallCenter.Realtimes;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using CallCenter.Share.Notifications;
|
|
|
using MediatR;
|
|
@@ -11,12 +12,16 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
|
private readonly ICallCacheManager _callCacheManager;
|
|
|
+ private readonly IUserCacheManager _userCacheManager;
|
|
|
+ private readonly IRealtimeService _realtimeService;
|
|
|
|
|
|
- public ByeVisitorOffNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,ICallCacheManager callCacheManager)
|
|
|
+ public ByeVisitorOffNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,ICallCacheManager callCacheManager, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
|
|
|
{
|
|
|
_callRepository = callRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
_callCacheManager = callCacheManager;
|
|
|
+ _userCacheManager = userCacheManager;
|
|
|
+ _realtimeService = realtimeService;
|
|
|
}
|
|
|
|
|
|
public async Task Handle(ByeVisitorOffNotification notification, CancellationToken cancellationToken)
|
|
@@ -45,6 +50,18 @@ namespace CallCenter.Application.Handlers
|
|
|
|
|
|
//处理队列记录
|
|
|
_callCacheManager.RemoveCallCache(model.Id);
|
|
|
+
|
|
|
+ //查询应答分机分机号
|
|
|
+ var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, d => d.CreationTime);
|
|
|
+ if (callDetailAnswer != null)
|
|
|
+ {
|
|
|
+ //调用业务通知 通知前端
|
|
|
+ var workModel = _userCacheManager.GetWorkByTel(callDetailAnswer.AnswerNo);
|
|
|
+ if (workModel != null)
|
|
|
+ {
|
|
|
+ await _realtimeService.ByeAsync(workModel.UserId, new ByeDto() { Id = model.Id }, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|