|
@@ -1,5 +1,7 @@
|
|
|
-using CallCenter.Calls;
|
|
|
+using CallCenter.Caches;
|
|
|
+using CallCenter.Calls;
|
|
|
using CallCenter.Notifications;
|
|
|
+using CallCenter.Realtimes;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using MediatR;
|
|
|
|
|
@@ -9,12 +11,16 @@ namespace CallCenter.Application.Handlers
|
|
|
{
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
|
+ private readonly IUserCacheManager _userCacheManager;
|
|
|
+ private readonly IRealtimeService _realtimeService;
|
|
|
|
|
|
|
|
|
- public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
|
|
|
+ public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
|
|
|
{
|
|
|
_callRepository = callRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
+ _realtimeService = realtimeService;
|
|
|
+ _userCacheManager = userCacheManager;
|
|
|
}
|
|
|
|
|
|
public async Task Handle(AnswerViisitorToExtNotification notification, CancellationToken cancellationToken)
|
|
@@ -38,6 +44,13 @@ namespace CallCenter.Application.Handlers
|
|
|
ToNo = notification.Visitor.To,
|
|
|
};
|
|
|
await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
+
|
|
|
+ //调用业务通知 通知前端
|
|
|
+ var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
|
|
|
+ if (workModel != null)
|
|
|
+ {
|
|
|
+ await _realtimeService.AnsweredAsync(workModel.UserId, new AnseredDto() { ConversationId = notification.Visitor.Id, From = notification.Visitor.From, Id = model.Id, To = notification.TelNo, CallType = ECallType.VisitorCallIn }, cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|