admin 2 anni fa
parent
commit
14f97dae93

+ 25 - 0
src/CallCenter.Api/Controllers/TelController.cs

@@ -318,6 +318,13 @@ namespace CallCenter.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw new UserFriendlyException("当前坐席暂未进行工作");
+            //获取对方是否在工作
+            var toWork = _userCacheManager.GetWorkByTel(dto.TelNo);
+            if (toWork is null)
+                throw new UserFriendlyException("转接分机未进行工作");
+            var tel = await _deviceManager.QueryTelAsync(dto.TelNo, HttpContext.RequestAborted);
+            if (tel.TelStatus != Share.Enums.ETelStatus.Ready)
+                throw new UserFriendlyException("被叫分机不在线或正在通话中");
             await _deviceManager.ExtToExtAsync(work.TelNo, dto.TelNo, HttpContext.RequestAborted);
         }
 
@@ -346,6 +353,15 @@ namespace CallCenter.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw new UserFriendlyException("当前坐席暂未进行工作");
+
+            var toWork = _userCacheManager.GetWorkByTel(dto.TelNo);
+            if (toWork is null)
+                throw new UserFriendlyException("转接分机未进行工作");
+
+            var totel = await _deviceManager.QueryTelAsync(dto.TelNo, HttpContext.RequestAborted);
+            if (totel.TelStatus != Share.Enums.ETelStatus.Ready)
+                throw new UserFriendlyException("被叫分机不在线或正在通话中");
+
             var tel = await _deviceManager.QueryTelAsync(work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
                 await _deviceManager.VisitorToExtAsync(tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
@@ -421,6 +437,15 @@ namespace CallCenter.Api.Controllers
             var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
             if (work is null)
                 throw new UserFriendlyException("当前坐席暂未进行工作");
+
+            var toWork = _userCacheManager.GetWorkByTel(dto.TelNo);
+            if (toWork is null)
+                throw new UserFriendlyException("转接分机未进行工作");
+
+            var totel = await _deviceManager.QueryTelAsync(dto.TelNo, HttpContext.RequestAborted);
+            if (totel.TelStatus != Share.Enums.ETelStatus.Ready)
+                throw new UserFriendlyException("被叫分机不在线或正在通话中");
+
             var tel = await _deviceManager.QueryTelAsync(work.TelNo, HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(tel.ConversationId))
                 await _deviceManager.OuterToExtAsync(tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);

+ 30 - 0
src/CallCenter.Application/Handlers/CallState/RingExtToOuterNotificationHandler.cs

@@ -2,6 +2,7 @@
 using CallCenter.Calls;
 using CallCenter.Share.Enums;
 using MediatR;
+using CallCenter.Tools;
 
 namespace CallCenter.Application.Handlers
 {
@@ -47,6 +48,35 @@ namespace CallCenter.Application.Handlers
 
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
             }
+            else
+            {
+                var isp = PhoneIspTool.GetPhoneIsp(notification.Outer.To);
+                var callModel = new Call()
+                {
+                    CallStatus = ECallStatus.Alert,
+                    CallDirection = ECallDirection.Out,
+                    CallType = ECallType.ExtToOuter,
+                    ConversationId = notification.Outer.Id,
+                    FromNo = notification.Outer.From,
+                    ToNo = notification.Outer.To,
+                    Trunk = notification.Outer.Trunk,
+                    PhoneIsp = isp
+                };
+                callModel.Modified();
+                var callId = await _callRepository.AddAsync(callModel, cancellationToken);
+                //写入明细
+                var detail = new CallDetail()
+                {
+                    CallId = callId,
+                    CallStatus = ECallStatus.Alert,
+                    ConversationId = notification.Outer.Id,
+                    OMCallId = notification.Outer.CallId,
+                    EventName = notification.Attribute,
+                    FromNo = notification.Outer.From,
+                    ToNo = notification.Outer.To,
+                };
+                await _callDetailRepository.AddAsync(detail, cancellationToken);
+            }
         }
     }
 }