Jason 1 年間 前
コミット
f511226231

+ 8 - 3
src/Hotline.Api/Controllers/IPPbxController.cs

@@ -1,4 +1,5 @@
-using Hotline.Permissions;
+using Hotline.CallCenter.Calls;
+using Hotline.Permissions;
 using Hotline.Share.Dtos.TrCallCenter;
 using Hotline.Users;
 using MapsterMapper;
@@ -8,6 +9,7 @@ using Tr.Sdk;
 using Tr.Sdk.Blacklist;
 using Tr.Sdk.Tels;
 using XF.Domain.Authentications;
+using XF.Domain.Repository;
 
 namespace Hotline.Api.Controllers
 {
@@ -17,13 +19,15 @@ namespace Hotline.Api.Controllers
         private readonly IMapper _mapper;
         private readonly IUserDomainService _userDomainService;
         private readonly ISessionContext _sessionContext;
+        private readonly IRepository<TrCallRecord> _trCallRecordRepository;
 
-        public IPPbxController(ITrClient trClient,IMapper mapper,IUserDomainService userDomainService,ISessionContext sessionContext)
+        public IPPbxController(ITrClient trClient,IMapper mapper,IUserDomainService userDomainService,ISessionContext sessionContext,IRepository<TrCallRecord> trCallRecordRepository)
         {
             _trClient = trClient;
             _mapper = mapper;
             _userDomainService = userDomainService;
             _sessionContext = sessionContext;
+            _trCallRecordRepository = trCallRecordRepository;
         }
 
         #region 添添呼
@@ -121,7 +125,8 @@ namespace Hotline.Api.Controllers
         [HttpPost("receiveCallRecord")]
         public async Task ReceiveCallRecord([FromBody]ReceiveCallRecordDto dto)
         {
-
+            var model = _mapper.Map<TrCallRecord>(dto);
+            await _trCallRecordRepository.AddAsync(model, HttpContext.RequestAborted);
         }
 
         #endregion

+ 1 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -785,7 +785,7 @@ public class OrderController : BaseController
             .OrderByDescending(x => x.CreationTime)
             .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
 
-        return new PagedDto<OrderDelay>(total, _mapper.Map<IReadOnlyList<OrderDelay>>(items));
+        return new PagedDto<OrderDelay>(total, items);
     }
 
     /// <summary>

+ 30 - 2
src/Hotline.Application/Mappers/CallMapperConfigs.cs

@@ -1,4 +1,7 @@
-using Mapster;
+using Hotline.CallCenter.Calls;
+using Hotline.Share.Dtos.TrCallCenter;
+using Hotline.Share.Enums.CallCenter;
+using Mapster;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -11,7 +14,32 @@ namespace Hotline.Application.Mappers
     {
         public void Register(TypeAdapterConfig config)
         {
-            //config
+            config.ForType<ReceiveCallRecordDto, TrCallRecord>()
+                .Map(d => d.User, x => x.user)
+                .Map(d => d.RecordingFileName, x => x.recording_file_name)
+                .Map(d => d.CallDirection, x => x.call_direction == "in" ? ECallDirection.In : ECallDirection.Out)
+                .Map(d => d.EndBy, x => x.hangup_side == "caller" ? EEndBy.From : (x.hangup_side == "callee" ? EEndBy.To : EEndBy.None))
+                .Map(d => d.CallAccept, x => x.call_accept)
+                .Map(d => d.CPN, x => x.caller_id_number)
+                .Map(d => d.CPNName, x => x.caller_id_name)
+                .Map(d => d.RecordingFileUrl, x => x.recording_file_url)
+                .Map(d => d.CreatedTime, x => x.created_time)
+                .IgnoreIf((s, d) => s.answered_time == null, d => d.AnsweredTime)
+                .Map(d => d.OverTime, x => x.over_time)
+                .Map(d => d.Gateway, x => x.gateway)
+                .Map(d => d.OtherStr, x => x.other_str)
+                .Map(d => d.OtherAccept, x => x.other_accept)
+                .Map(d => d.Status, x => x.status)
+                .IgnoreIf((s, d) => s.beginIvrTime == null, d => d.BeginIvrTime)
+                .IgnoreIf((s, d) => s.endIvrTime == null, d => d.EndIvrTime)
+                .IgnoreIf((s, d) => s.beginQueueTime == null, d => d.BeginQueueTime)
+                .IgnoreIf((s, d) => s.endQueueTime == null, d => d.EndQueueTime)
+                .IgnoreIf((s, d) => s.beginRingTime == null, d => d.BeginRingTime)
+                .IgnoreIf((s, d) => s.endRingTime == null, d => d.EndRingTimg)
+                .Map(d => d.OlaQueue, x => x.ola_queue)
+                .Map(d => d.BatchAccept, x => x.batch_accept)
+                .Map(d => d.IvrDtmf, x => x.ivr_dtmf)
+                .Map(d => d.DtmfType, x => x.dtmf_type);
         }
     }
 }

+ 6 - 0
src/Hotline.Share/Enums/CallCenter/EEndBy.cs

@@ -18,4 +18,10 @@ public enum EEndBy
     /// </summary>
     [Description("被叫方结束")]
     To = 1,
+
+    /// <summary>
+    /// 其他位置情况
+    /// </summary>
+    [Description("其他未知情况")]
+    None = 2,
 }

+ 1 - 1
src/Hotline/CallCenter/Calls/TrCallRecord.cs

@@ -57,7 +57,7 @@ namespace Hotline.CallCenter.Calls
         /// <summary>
         /// 线路号
         /// </summary>
-        public string gateway { get; set; }
+        public string Gateway { get; set; }
         /// <summary>
         /// 呼出时自定义的内容
         /// </summary>