dss 2 年 前
コミット
d313d32844

+ 14 - 1
src/CallCenter.Application/Handlers/FlowControl/AnswerExtToOuterNotificationHandler.cs

@@ -2,6 +2,8 @@
 using CallCenter.Calls;
 using CallCenter.Share.Enums;
 using MediatR;
+using CallCenter.Realtimes;
+using CallCenter.Caches;
 
 namespace CallCenter.Application.Handlers
 {
@@ -9,11 +11,15 @@ namespace CallCenter.Application.Handlers
     {
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
+        private readonly IUserCacheManager _userCacheManager;
+        private readonly IRealtimeService _realtimeService;
 
-        public AnswerExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository)
+        public AnswerExtToOuterNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
+            _userCacheManager = userCacheManager;
+            _realtimeService = realtimeService;
         }
 
         public async Task Handle(AnswerExtToOuterNotification notification, CancellationToken cancellationToken)
@@ -37,6 +43,13 @@ namespace CallCenter.Application.Handlers
                     ToNo = notification.Outer.To,
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
+
+                //调用业务通知 通知前端
+                var workModel = _userCacheManager.GetWorkByTel(notification.Outer.From);
+                if (workModel != null)
+                {
+                    await _realtimeService.AnsweredAsync(workModel.UserId, new AnseredDto() { ConversationId = notification.Outer.Id, From = notification.Outer.From, Id = model.Id, To = notification.Outer.To, CallType = ECallType.ExtToOuter }, cancellationToken);
+                }
             }
         }
     }

+ 15 - 2
src/CallCenter.Application/Handlers/FlowControl/AnswerViisitorToExtNotificationHandler.cs

@@ -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);
+                }
             }
         }
     }