|
@@ -18,6 +18,8 @@ using Microsoft.AspNetCore.Mvc;
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
using SqlSugar;
|
|
using SqlSugar;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
|
|
+using Wex.Sdk;
|
|
|
|
+using Wex.Sdk.Tel;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Cache;
|
|
using XF.Domain.Cache;
|
|
using XF.Domain.Constants;
|
|
using XF.Domain.Constants;
|
|
@@ -52,6 +54,7 @@ namespace Hotline.Api.Controllers
|
|
private readonly ILogger<TelController> _logger;
|
|
private readonly ILogger<TelController> _logger;
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
+ private readonly IWexClient _wexClient;
|
|
|
|
|
|
public PbxController(
|
|
public PbxController(
|
|
ITelRepository telRepository,
|
|
ITelRepository telRepository,
|
|
@@ -74,7 +77,8 @@ namespace Hotline.Api.Controllers
|
|
IIvrCacheManager ivrCacheManager,
|
|
IIvrCacheManager ivrCacheManager,
|
|
ILogger<TelController> logger,
|
|
ILogger<TelController> logger,
|
|
ICallDetailRepository callDetailRepository,
|
|
ICallDetailRepository callDetailRepository,
|
|
- IUserRepository userRepository)
|
|
|
|
|
|
+ IUserRepository userRepository,
|
|
|
|
+ IWexClient wexClient)
|
|
{
|
|
{
|
|
_telRepository = telRepository;
|
|
_telRepository = telRepository;
|
|
_telRestRepository = telRestRepository;
|
|
_telRestRepository = telRestRepository;
|
|
@@ -97,6 +101,7 @@ namespace Hotline.Api.Controllers
|
|
_logger = logger;
|
|
_logger = logger;
|
|
_callDetailRepository = callDetailRepository;
|
|
_callDetailRepository = callDetailRepository;
|
|
_userRepository = userRepository;
|
|
_userRepository = userRepository;
|
|
|
|
+ _wexClient = wexClient;
|
|
}
|
|
}
|
|
|
|
|
|
#region 话机
|
|
#region 话机
|
|
@@ -278,6 +283,8 @@ namespace Hotline.Api.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #region 威尔信
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 分机休息流程开始
|
|
/// 分机休息流程开始
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -287,20 +294,22 @@ namespace Hotline.Api.Controllers
|
|
[HttpPost("rest-flow")]
|
|
[HttpPost("rest-flow")]
|
|
public async Task RestFlow([FromBody] StartRestDto dto)
|
|
public async Task RestFlow([FromBody] StartRestDto dto)
|
|
{
|
|
{
|
|
- //TODO
|
|
|
|
-
|
|
|
|
- var isApply = await _telRepository.IsApplyingAsync("8029", HttpContext.RequestAborted);
|
|
|
|
|
|
+ var tel = await _wexClient.QueryTelsAsync(new QueryTelRequest() { StaffNo = _sessionContext.StaffNo },HttpContext.RequestAborted);
|
|
|
|
+ if (tel.Data == null || tel.Data.Count == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未找到分机信息");
|
|
|
|
+
|
|
|
|
+ if (tel.Data[0].Sigin == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机未签入,不能休息");
|
|
|
|
+
|
|
|
|
+ var isApply = await _telRepository.IsApplyingAsync(tel.Data[0].TelNo, HttpContext.RequestAborted);
|
|
if (isApply)
|
|
if (isApply)
|
|
- throw UserFriendlyException.SameMessage("分机休息申请正在审核阶段");
|
|
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机休息申请正在审核阶段");
|
|
|
|
|
|
- //TODO
|
|
|
|
- var isResting = await _telRepository.IsRestingAsync("8029", HttpContext.RequestAborted);
|
|
|
|
|
|
+ var isResting = await _telRepository.IsRestingAsync(tel.Data[0].TelNo, HttpContext.RequestAborted);
|
|
if (isResting)
|
|
if (isResting)
|
|
throw new UserFriendlyException("当前坐席正在休息");
|
|
throw new UserFriendlyException("当前坐席正在休息");
|
|
|
|
|
|
- var user = _userRepository.Get(_sessionContext.RequiredUserId);
|
|
|
|
- //TODO
|
|
|
|
- var telRest = new TelRest("5f7099aa-ef27-48bd-959f-13ccc5a1dc1b", "8029", _sessionContext.RequiredUserId, _sessionContext.UserName, dto.Reason, true, user.StaffNo);
|
|
|
|
|
|
+ var telRest = new TelRest(tel.Data[0].TelNo, tel.Data[0].TelNo, _sessionContext.RequiredUserId, _sessionContext.UserName, dto.Reason, true, _sessionContext.StaffNo);
|
|
await _telRestRepository.AddAsync(telRest, HttpContext.RequestAborted);
|
|
await _telRestRepository.AddAsync(telRest, HttpContext.RequestAborted);
|
|
|
|
|
|
var startWorkflowDto = _mapper.Map<StartWorkflowDto>(dto);
|
|
var startWorkflowDto = _mapper.Map<StartWorkflowDto>(dto);
|
|
@@ -319,8 +328,15 @@ namespace Hotline.Api.Controllers
|
|
[HttpGet("begin-rest")]
|
|
[HttpGet("begin-rest")]
|
|
public async Task BeginRest()
|
|
public async Task BeginRest()
|
|
{
|
|
{
|
|
- //TODO
|
|
|
|
- var telRest = await _telRestRepository.GetAsync(x => !x.EndTime.HasValue && !x.StartTime.HasValue && x.TelNo == "8029",HttpContext.RequestAborted);
|
|
|
|
|
|
+ var tel = await _wexClient.QueryTelsAsync(new QueryTelRequest() { StaffNo = _sessionContext.StaffNo }, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ if (tel.Data == null || tel.Data.Count == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未找到分机信息");
|
|
|
|
+
|
|
|
|
+ if (tel.Data[0].Sigin == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机未签入,不能休息");
|
|
|
|
+
|
|
|
|
+ var telRest = await _telRestRepository.GetAsync(x => !x.EndTime.HasValue && !x.StartTime.HasValue && x.TelNo == tel.Data[0].TelNo, HttpContext.RequestAborted);
|
|
|
|
|
|
if (telRest == null)
|
|
if (telRest == null)
|
|
throw new UserFriendlyException($"错误");
|
|
throw new UserFriendlyException($"错误");
|
|
@@ -346,9 +362,15 @@ namespace Hotline.Api.Controllers
|
|
[HttpPost("rest-add")]
|
|
[HttpPost("rest-add")]
|
|
public async Task Rest([FromBody] ResstDto dto)
|
|
public async Task Rest([FromBody] ResstDto dto)
|
|
{
|
|
{
|
|
- var user = _userRepository.Get(_sessionContext.RequiredUserId);
|
|
|
|
- //TODO
|
|
|
|
- var telRest = new TelRest("5f7099aa-ef27-48bd-959f-13ccc5a1dc1b", "8029", _sessionContext.RequiredUserId, _sessionContext.UserName, dto.Reason, false, user.StaffNo);
|
|
|
|
|
|
+ var tel = await _wexClient.QueryTelsAsync(new QueryTelRequest() { StaffNo = _sessionContext.StaffNo }, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ if (tel.Data == null || tel.Data.Count == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未找到分机信息");
|
|
|
|
+
|
|
|
|
+ if (tel.Data[0].Sigin == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机未签入,不能休息");
|
|
|
|
+
|
|
|
|
+ var telRest = new TelRest("5f7099aa-ef27-48bd-959f-13ccc5a1dc1b", "8029", _sessionContext.RequiredUserId, _sessionContext.UserName, dto.Reason, false, _sessionContext.StaffNo);
|
|
await _telRestRepository.AddAsync(telRest, HttpContext.RequestAborted);
|
|
await _telRestRepository.AddAsync(telRest, HttpContext.RequestAborted);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,25 +383,42 @@ namespace Hotline.Api.Controllers
|
|
[HttpGet("rest-del")]
|
|
[HttpGet("rest-del")]
|
|
public async Task DelRest()
|
|
public async Task DelRest()
|
|
{
|
|
{
|
|
- //TODO
|
|
|
|
- var restingTel = await _telRestRepository.GetAsync(d => d.TelId == "5f7099aa-ef27-48bd-959f-13ccc5a1dc1b" && !d.EndTime.HasValue, HttpContext.RequestAborted);
|
|
|
|
|
|
+ var tel = await _wexClient.QueryTelsAsync(new QueryTelRequest() { StaffNo = _sessionContext.StaffNo }, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ if (tel.Data == null || tel.Data.Count == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未找到分机信息");
|
|
|
|
+
|
|
|
|
+ if (tel.Data[0].Sigin == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机未签入,不能休息");
|
|
|
|
+
|
|
|
|
+ var restingTel = await _telRestRepository.GetAsync(d => d.TelId == tel.Data[0].TelNo && !d.EndTime.HasValue, HttpContext.RequestAborted);
|
|
if (restingTel is null)
|
|
if (restingTel is null)
|
|
throw new UserFriendlyException("未查询到分机休息信息");
|
|
throw new UserFriendlyException("未查询到分机休息信息");
|
|
- await _telRestRepository.RemoveAsync(restingTel.Id,false,HttpContext.RequestAborted);
|
|
|
|
|
|
+ await _telRestRepository.RemoveAsync(restingTel.Id, false, HttpContext.RequestAborted);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 分机结束休息
|
|
|
|
|
|
+ /// 分机结束休息(威尔信)
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[Permission(EPermission.UnRest)]
|
|
[Permission(EPermission.UnRest)]
|
|
[HttpGet("un-rest-wex")]
|
|
[HttpGet("un-rest-wex")]
|
|
public async Task<TelRestDto> UnRestWEX()
|
|
public async Task<TelRestDto> UnRestWEX()
|
|
{
|
|
{
|
|
- var telRest = await _telDomainService.UnRestAsync("5f7099aa-ef27-48bd-959f-13ccc5a1dc1b", HttpContext.RequestAborted);
|
|
|
|
|
|
+ var tel = await _wexClient.QueryTelsAsync(new QueryTelRequest() { StaffNo = _sessionContext.StaffNo }, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ if (tel.Data == null || tel.Data.Count == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未找到分机信息");
|
|
|
|
+
|
|
|
|
+ if (tel.Data[0].Sigin == 0)
|
|
|
|
+ throw UserFriendlyException.SameMessage("分机未签入,不能休息");
|
|
|
|
+
|
|
|
|
+ var telRest = await _telDomainService.UnRestWexAsync(tel.Data[0].TelNo, HttpContext.RequestAborted);
|
|
return _mapper.Map<TelRestDto>(telRest);
|
|
return _mapper.Map<TelRestDto>(telRest);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|