|
@@ -12,6 +12,7 @@ using XF.Domain.Constants;
|
|
|
using XF.Domain.Cache;
|
|
|
using CallCenter.Settings;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
+using NewRock.Sdk.Transfer.Queue.Request;
|
|
|
|
|
|
namespace CallCenter.Application.Handlers
|
|
|
{
|
|
@@ -85,6 +86,35 @@ namespace CallCenter.Application.Handlers
|
|
|
Visitor = new VisitorToMenuVisitor() { Id = notification.Visitor.Id }
|
|
|
},
|
|
|
_options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
|
|
|
+
|
|
|
+ var correct = GetCorrectIvr(notification.Visitor.To);
|
|
|
+ switch (correct.eCorrectIvr)
|
|
|
+ {
|
|
|
+ //跳转IVR
|
|
|
+ case ECorrectIvr.Ivr:
|
|
|
+ _logger.LogInformation("transfer to ivr.no: {ivrNo}", correct.ReturnValue );
|
|
|
+ await _newRockClient.VisitorToMenu(new VisitorToMenuRequest()
|
|
|
+ {
|
|
|
+ Attribute = "Connect",
|
|
|
+ Menu = new VisitorToMenuMenu() { Id = correct.ReturnValue },
|
|
|
+ Visitor = new VisitorToMenuVisitor() { Id = notification.Visitor.Id}
|
|
|
+ },
|
|
|
+ _options.Value.ReceiveKey,_options.Value.Expired,cancellationToken);
|
|
|
+ break;
|
|
|
+ //直接转分机组
|
|
|
+ case ECorrectIvr.Group:
|
|
|
+ _logger.LogInformation("transfer to group.no:{groupNo}", correct.ReturnValue);
|
|
|
+ await _newRockClient.VisitorToGroupQueue(new VisitorToGroupQueueRequest()
|
|
|
+ {
|
|
|
+ Attribute= "Queue",
|
|
|
+ Visitor = new VisitorToGroupQueueVisitor() { Id = notification.Visitor.Id },
|
|
|
+ Group= new VisitorToGroupQueueGroup() { Id = correct.ReturnValue }
|
|
|
+ },
|
|
|
+ _options.Value.ReceiveKey,_options.Value.Expired,cancellationToken);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -101,6 +131,56 @@ namespace CallCenter.Application.Handlers
|
|
|
return ivr;
|
|
|
}
|
|
|
|
|
|
+ private CorrectIvr GetCorrectIvr(string to)
|
|
|
+ {
|
|
|
+ var worktimeSettings = _worktimeCache.GetOrAdd("worktimesettings", d => _worktimeOptions.Value, ExpireMode.Absolute, TimeSpan.FromDays(1));
|
|
|
+ var correct = GetCorrectCategory(worktimeSettings.LineSetting.First(x => x.NumNo == to));
|
|
|
+ return correct;
|
|
|
+ }
|
|
|
+
|
|
|
+ private CorrectIvr GetCorrectCategory(LineSetting settings)
|
|
|
+ {
|
|
|
+ if (!settings.WorkDay.Contains((int)DateTime.Now.DayOfWeek))
|
|
|
+ return new CorrectIvr() { eCorrectIvr = ECorrectIvr.Group, ReturnValue = settings.RestToGroup };
|
|
|
+ var time = TimeOnly.FromDateTime(DateTime.Now);
|
|
|
+ if ((time >= TimeOnly.Parse(settings.MorningBegin) && time <= TimeOnly.Parse(settings.MorningEnd))
|
|
|
+ || (time >= TimeOnly.Parse(settings.AfterBegin) && time <= TimeOnly.Parse(settings.AfterEnd)))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(settings.WorkCategory))
|
|
|
+ {
|
|
|
+ return new CorrectIvr() { eCorrectIvr = ECorrectIvr.Ivr, ReturnValue = settings.WorkCategory };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new CorrectIvr() { eCorrectIvr = ECorrectIvr.Group, ReturnValue = settings.WorkToGroup };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(settings.RestCategory))
|
|
|
+ {
|
|
|
+ return new CorrectIvr() { eCorrectIvr = ECorrectIvr.Ivr, ReturnValue = settings.RestCategory };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new CorrectIvr() { eCorrectIvr = ECorrectIvr.Group,ReturnValue = settings.RestToGroup };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class CorrectIvr
|
|
|
+ {
|
|
|
+ public string ReturnValue { get; set; }
|
|
|
+
|
|
|
+ public ECorrectIvr eCorrectIvr { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public enum ECorrectIvr
|
|
|
+ {
|
|
|
+ Ivr = 0,
|
|
|
+ Group = 1,
|
|
|
+ }
|
|
|
+
|
|
|
private string GetCorrectCategory(WorkTimeSettings settings)
|
|
|
{
|
|
|
if (!settings.WorkDay.Contains((int)DateTime.Now.DayOfWeek))
|