|
@@ -48,8 +48,11 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly ITrunkIvrManagerRepository _trunkIvrManagerRepository;
|
|
|
private readonly IIvrCategoryRepository _ivrCategoryRepository;
|
|
|
private readonly IWorkflowApplication _workflowApplication;
|
|
|
- private readonly IDefinitionDomainService _definitionDomainService;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly IIvrDomainService _ivrDomainService;
|
|
|
+ private readonly IIvrCacheManager _ivrCacheManager;
|
|
|
+ private readonly ILogger<TelController> _logger;
|
|
|
+ private readonly ICallDetailRepository _callDetailRepository;
|
|
|
|
|
|
public PbxController(
|
|
|
ITelRepository telRepository,
|
|
@@ -67,8 +70,11 @@ namespace Hotline.Api.Controllers
|
|
|
ITrunkIvrManagerRepository trunkIvrManagerRepository,
|
|
|
IIvrCategoryRepository ivrCategoryRepository,
|
|
|
IWorkflowApplication workflowApplication,
|
|
|
- IDefinitionDomainService definitionDomainService,
|
|
|
- ISystemSettingCacheManager systemSettingCacheManager)
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
+ IIvrDomainService ivrDomainService,
|
|
|
+ IIvrCacheManager ivrCacheManager,
|
|
|
+ ILogger<TelController> logger,
|
|
|
+ ICallDetailRepository callDetailRepository)
|
|
|
{
|
|
|
_telRepository = telRepository;
|
|
|
_telRestRepository = telRestRepository;
|
|
@@ -85,8 +91,11 @@ namespace Hotline.Api.Controllers
|
|
|
_trunkIvrManagerRepository = trunkIvrManagerRepository;
|
|
|
_ivrCategoryRepository = ivrCategoryRepository;
|
|
|
_workflowApplication = workflowApplication;
|
|
|
- _definitionDomainService = definitionDomainService;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _ivrDomainService = ivrDomainService;
|
|
|
+ _ivrCacheManager = ivrCacheManager;
|
|
|
+ _logger = logger;
|
|
|
+ _callDetailRepository = callDetailRepository;
|
|
|
}
|
|
|
|
|
|
#region 话机
|
|
@@ -314,7 +323,9 @@ namespace Hotline.Api.Controllers
|
|
|
var toWork = _userCacheManager.GetWorkByTel(dto.TelNo);
|
|
|
if (toWork is null)
|
|
|
throw UserFriendlyException.SameMessage("转接分机未进行工作");
|
|
|
-
|
|
|
+ var tel =await _deviceManager.QueryTelAsync(dto.TelNo,HttpContext.RequestAborted);
|
|
|
+ if (tel.TelStatus != ETelStatus.Ready)
|
|
|
+ throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
|
|
|
await _deviceManager.ExtToExtAsync(work.TelNo, dto.TelNo, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
@@ -366,6 +377,10 @@ namespace Hotline.Api.Controllers
|
|
|
if (toWork is null)
|
|
|
throw UserFriendlyException.SameMessage("转接分机未进行工作");
|
|
|
|
|
|
+ var totel = await _deviceManager.QueryTelAsync(dto.TelNo, HttpContext.RequestAborted);
|
|
|
+ if (totel.TelStatus != ETelStatus.Ready)
|
|
|
+ throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
|
|
|
+
|
|
|
var tel = await _deviceManager.QueryTelAsync(work.TelNo, HttpContext.RequestAborted);
|
|
|
if (!string.IsNullOrEmpty(tel.ConversationId))
|
|
|
await _deviceManager.VisitorToExtAsync(tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
|
|
@@ -449,6 +464,10 @@ namespace Hotline.Api.Controllers
|
|
|
if (toWork is null)
|
|
|
throw UserFriendlyException.SameMessage("转接分机未进行工作");
|
|
|
|
|
|
+ var totel = await _deviceManager.QueryTelAsync(dto.TelNo, HttpContext.RequestAborted);
|
|
|
+ if (totel.TelStatus != ETelStatus.Ready)
|
|
|
+ throw UserFriendlyException.SameMessage("被叫分机不在线或正在通话中");
|
|
|
+
|
|
|
var tel = await _deviceManager.QueryTelAsync(work.TelNo, HttpContext.RequestAborted);
|
|
|
if (!string.IsNullOrEmpty(tel.ConversationId))
|
|
|
await _deviceManager.OuterToExtAsync(tel.ConversationId, dto.TelNo, HttpContext.RequestAborted);
|
|
@@ -743,6 +762,62 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 话机业务
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 语音评价
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="callId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("evaluate/{callId}")]
|
|
|
+ public async Task Evaluate(string callId)
|
|
|
+ {
|
|
|
+ //检查通话是否存在
|
|
|
+ var call = await _callRepository.GetAsync(callId, HttpContext.RequestAborted);
|
|
|
+ if (call is null)
|
|
|
+ {
|
|
|
+ throw new UserFriendlyException("未找到当前通话");
|
|
|
+ }
|
|
|
+ if (call.CallDirection!= ECallDirection.In)
|
|
|
+ {
|
|
|
+ throw new UserFriendlyException("当前通话不是来电,不能发送评价邀请");
|
|
|
+ }
|
|
|
+ if (call.CallStatus == ECallStatus.Bye)
|
|
|
+ {
|
|
|
+ throw new UserFriendlyException("当前通话已结束");
|
|
|
+ }
|
|
|
+ if (call.CallStatus != ECallStatus.Answered && call.CallStatus != ECallStatus.Answer)
|
|
|
+ {
|
|
|
+ throw new UserFriendlyException("当前未进行通话,不能发送评价邀请");
|
|
|
+ }
|
|
|
+ //获取配置
|
|
|
+ var correct = _ivrDomainService.GetCorrectIvr(call.ToNo, true);
|
|
|
+ if (correct is null)
|
|
|
+ throw new UserFriendlyException("系统未配置评价,请联系管理员");
|
|
|
+ //检查是否有评价录音配置
|
|
|
+ var ivrList = _ivrCacheManager.GetIvrs();
|
|
|
+ var ivr = ivrList.First(x => x.IvrCategoryId == correct.ReturnValue && x.IsRoot);
|
|
|
+
|
|
|
+ _logger.LogInformation("transfer to ivr.no:{ivrNo}", ivr.No);
|
|
|
+
|
|
|
+ //写入子表
|
|
|
+ var detail = new CallDetail()
|
|
|
+ {
|
|
|
+ CallId = call.Id,
|
|
|
+ CallStatus = ECallStatus.Evaluate,
|
|
|
+ ConversationId = call.ConversationId,
|
|
|
+ EventName = "EVALUATE",
|
|
|
+ FromNo = call.FromNo,
|
|
|
+ ToNo = call.ToNo,
|
|
|
+ };
|
|
|
+
|
|
|
+ await _callDetailRepository.AddAsync(detail, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ await _deviceManager.VisitorToMenuAsync(call.ConversationId, ivr.No, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|