|
@@ -1,6 +1,6 @@
|
|
|
-using Hotline.Application.CallCenter.Calls;
|
|
|
+using DotNetCore.CAP;
|
|
|
+using Hotline.Application.CallCenter.Calls;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
-using Hotline.Caching.Services;
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Permissions;
|
|
@@ -10,12 +10,10 @@ using Hotline.Share.Dtos;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
-using Hotline.Share.Enums.KnowledgeBase;
|
|
|
using Hotline.Users;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
-using System.Text.Json;
|
|
|
using Tr.Sdk;
|
|
|
using Tr.Sdk.Blacklist;
|
|
|
using Tr.Sdk.Tels;
|
|
@@ -40,8 +38,9 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly IRepository<OrderVisit> _orderVisitRepository;
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
+ private readonly ICapPublisher _capPublisher;
|
|
|
|
|
|
- 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, IUserCacheManager userCacheManager)
|
|
|
+ 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, IUserCacheManager userCacheManager,ICapPublisher capPublisher)
|
|
|
{
|
|
|
_trClient = trClient;
|
|
|
_mapper = mapper;
|
|
@@ -55,6 +54,7 @@ namespace Hotline.Api.Controllers
|
|
|
_orderRepository = orderRepository;
|
|
|
_orderVisitRepository = orderVisitRepository;
|
|
|
_userCacheManager = userCacheManager;
|
|
|
+ _capPublisher = capPublisher;
|
|
|
}
|
|
|
|
|
|
#region 添添呼
|
|
@@ -226,6 +226,24 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
model.TelNo = model.CPN;
|
|
|
}
|
|
|
+
|
|
|
+ //获取关联 工单或是回访
|
|
|
+ var order = await _orderRepository.GetAsync(x => x.CallId == model.CallAccept, HttpContext.RequestAborted);
|
|
|
+ if (order!=null)
|
|
|
+ {
|
|
|
+ model.CallOrderType = ECallOrderType.Order;
|
|
|
+ model.ExternalId = order.Id;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var orderVisit = await _orderVisitRepository.GetAsync(x => x.CallId == model.CallAccept, HttpContext.RequestAborted);
|
|
|
+ if (orderVisit!=null)
|
|
|
+ {
|
|
|
+ model.CallOrderType = ECallOrderType.Visit;
|
|
|
+ model.ExternalId = orderVisit.Id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//获取用户
|
|
|
var work = await _userCacheManager.GetWorkByTelNoLast(model.TelNo);
|
|
|
if (work!=null)
|
|
@@ -235,6 +253,21 @@ namespace Hotline.Api.Controllers
|
|
|
model.StaffNo = work.StaffNo;
|
|
|
}
|
|
|
await _trCallRecordRepository.AddAsync(model, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ if (model.CallDirection == ECallDirection.In)
|
|
|
+ {
|
|
|
+ var publishCallRecordDto = new PublishCallRecrodDto() { };
|
|
|
+ if (order!=null)
|
|
|
+ {
|
|
|
+ var orderDto = _mapper.Map<OrderDto>(order);
|
|
|
+ publishCallRecordDto.Order = orderDto;
|
|
|
+ }
|
|
|
+ var trCallDto = _mapper.Map<TrCallDto>(model);
|
|
|
+ publishCallRecordDto.TrCallRecordDto = trCallDto;
|
|
|
+ //推省上
|
|
|
+ await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineCallBye, publishCallRecordDto);
|
|
|
+ }
|
|
|
+
|
|
|
return OpenResponse.Ok("success");
|
|
|
}
|
|
|
|
|
@@ -337,21 +370,27 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("link-callrecord")]
|
|
|
public async Task LinkCallRecord([FromBody]LinkCallRecordDto dto)
|
|
|
{
|
|
|
-
|
|
|
+ var trRecord = await _trCallRecordRepository.GetAsync(x => x.CallAccept == dto.CallId, HttpContext.RequestAborted);
|
|
|
if (dto.IsOrder)
|
|
|
{
|
|
|
//工单
|
|
|
var order = await _orderRepository.GetAsync(x => x.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
order.CallId = dto.CallId;
|
|
|
- await _orderRepository.UpdateAsync(order);
|
|
|
+ await _orderRepository.UpdateAsync(order,HttpContext.RequestAborted);
|
|
|
+ trRecord.CallOrderType = ECallOrderType.Order;
|
|
|
+ trRecord.ExternalId = order.Id;
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//回访
|
|
|
var visit = await _orderVisitRepository.GetAsync(x => x.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
visit.CallId = dto.CallId;
|
|
|
- await _orderVisitRepository.UpdateAsync(visit);
|
|
|
+ await _orderVisitRepository.UpdateAsync(visit,HttpContext.RequestAborted);
|
|
|
+ trRecord.CallOrderType = ECallOrderType.Visit;
|
|
|
+ trRecord.ExternalId = visit.Id;
|
|
|
}
|
|
|
+ await _trCallRecordRepository.UpdateAsync(trRecord, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
|