|
@@ -1,10 +1,12 @@
|
|
|
using Hotline.Application.CallCenter.Calls;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Permissions;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos;
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.KnowledgeBase;
|
|
@@ -34,8 +36,10 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IRepository<TrCallEvaluate> _trCallEvaluate;
|
|
|
private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
|
|
|
private readonly ILogger<IPPbxController> _logger;
|
|
|
+ private readonly IOrderRepository _orderRepository;
|
|
|
+ private readonly IRepository<OrderVisit> _orderVisitRepository;
|
|
|
|
|
|
- public IPPbxController(ITrClient trClient,IMapper mapper,IUserDomainService userDomainService,ISessionContext sessionContext,IRepository<TrCallRecord> trCallRecordRepository,ITrApplication trApplication,IRepository<TrCallEvaluate> trCallRecord,ISystemDicDataCacheManager systemDicDataCacheManager,ILogger<IPPbxController> logger)
|
|
|
+ public IPPbxController(ITrClient trClient,IMapper mapper,IUserDomainService userDomainService,ISessionContext sessionContext,IRepository<TrCallRecord> trCallRecordRepository,ITrApplication trApplication,IRepository<TrCallEvaluate> trCallRecord,ISystemDicDataCacheManager systemDicDataCacheManager,ILogger<IPPbxController> logger,IOrderRepository orderRepository,IRepository<OrderVisit> orderVisitRepository)
|
|
|
{
|
|
|
_trClient = trClient;
|
|
|
_mapper = mapper;
|
|
@@ -46,6 +50,8 @@ namespace Hotline.Api.Controllers
|
|
|
_trCallEvaluate = trCallRecord;
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
|
_logger = logger;
|
|
|
+ _orderRepository = orderRepository;
|
|
|
+ _orderVisitRepository = orderVisitRepository;
|
|
|
}
|
|
|
|
|
|
#region 添添呼
|
|
@@ -258,8 +264,64 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#region 关联
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 可关联工单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("canlink-order")]
|
|
|
+ public async Task<PagedDto<OrderDto>> CanLinkCallRecordOrder([FromQuery]CanLinkCallRecordOrderDto dto)
|
|
|
+ {
|
|
|
+ var (total,items) = await _orderRepository.Queryable()
|
|
|
+ .Where(x=> string.IsNullOrEmpty(x.CallId) && x.Source == Share.Enums.Order.ESource.Hotline)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword),x=>x.No.Contains(dto.Keyword))
|
|
|
+ .OrderByDescending(x=>x.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex,dto.PageSize,HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 可关联回访
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("canlink-ordervisit")]
|
|
|
+ public async Task<PagedDto<OrderVisitDto>> CanLinkCallRecordOrderVisit([FromQuery]CanLinkCallRecordOrderVisitDto dto)
|
|
|
+ {
|
|
|
+ var (total, items) = await _orderVisitRepository.Queryable()
|
|
|
+ .Includes(x=>x.Order)
|
|
|
+ .Where(x => string.IsNullOrEmpty(x.CallId) && x.VisitType == Share.Enums.Order.EVisitType.ArtificialVisit)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.No.Contains(dto.Keyword))
|
|
|
+ .OrderByDescending(x => x.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
+ return new PagedDto<OrderVisitDto>(total, _mapper.Map<IReadOnlyList<OrderVisitDto>>(items));
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 关联工单或者回访
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("link-callrecord")]
|
|
|
+ public async Task LinkCallRecord([FromBody]LinkCallRecordDto dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (dto.IsOrder)
|
|
|
+ {
|
|
|
+ //工单
|
|
|
+ var order = await _orderRepository.GetAsync(x => x.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
+ order.CallId = dto.CallId;
|
|
|
+ await _orderRepository.UpdateAsync(order);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //回访
|
|
|
+ var visit = await _orderVisitRepository.GetAsync(x => x.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
+ visit.CallId = dto.CallId;
|
|
|
+ await _orderVisitRepository.UpdateAsync(visit);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|