Sfoglia il codice sorgente

2分钟后重新寻找通话记录

Dun.Jason 6 mesi fa
parent
commit
e535612add

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

@@ -285,7 +285,7 @@ ICallApplication callApplication,
 
         //var r = _timeLimitDomainService.CalcExpiredTime(DateTime.Now, EFlowDirection.CenterToCenter, batchId);
         //var r = _timeLimitDomainService.CalcEndTime(DateTime.Parse("2024-09-12 14:45:47"), Share.Enums.Settings.ETimeType.WorkDay, 2, 80, 50);
-        _capPublisher.PublishDelay((DateTime.Now.AddMinutes(1) - DateTime.Now), EventNames.OrderRelateCall, "123");
+        _capPublisher.PublishDelay((DateTime.Now.AddMinutes(2) - DateTime.Now), EventNames.OrderRelateCall, "123");
         //await _capPublisher.PublishDelay(EventNames.OrderRelateCall, "123", cancellationToken: HttpContext.RequestAborted);
         return OpenResponse.Ok(DateTime.Now.ToString("F"));
     }

+ 9 - 2
src/Hotline.Application/CallCenter/TianRunCallApplication.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using DotNetCore.CAP;
 using Hotline.Application.CallCenter.Calls;
 using Hotline.Application.Tels;
 using Hotline.Caching.Interfaces;
@@ -14,6 +15,7 @@ using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Dtos.TrCallCenter;
 using Hotline.Share.Enums.CallCenter;
+using Hotline.Share.Mq;
 using MapsterMapper;
 using Microsoft.AspNetCore.Http;
 using XF.Domain.Authentications;
@@ -30,6 +32,8 @@ namespace Hotline.Application.CallCenter
         private readonly ITelApplication _telApplication;
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly IMapper _mapper;
+        private readonly ICapPublisher _capPublisher;
+
 
         public TianRunCallApplication(
             ISessionContext sessionContext,
@@ -38,7 +42,8 @@ namespace Hotline.Application.CallCenter
             ITelApplication telApplication,
             ISystemSettingCacheManager systemSettingCacheManager,
             IMapper mapper
-        )
+,
+            ICapPublisher capPublisher)
         {
             _sessionContext = sessionContext;
             _trCallRecordRepository = trCallRecordRepository;
@@ -46,6 +51,7 @@ namespace Hotline.Application.CallCenter
             _telApplication = telApplication;
             _systemSettingCacheManager = systemSettingCacheManager;
             _mapper = mapper;
+            _capPublisher = capPublisher;
         }
 
         /// <summary>
@@ -154,7 +160,8 @@ namespace Hotline.Application.CallCenter
             }
             else
             {
-                
+                //如果没查到通话记录就在2分钟后处理
+                _capPublisher.PublishDelay(DateTime.Now.AddMinutes(2)-DateTime.Now,EventNames.OrderRelateCall, orderId);
             }
         }
 

+ 20 - 5
src/Hotline.Application/Handlers/Order/OrderRelateCallHandler.cs

@@ -7,14 +7,16 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using XF.Domain.Dependency;
 using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.Order
 {
-    public class OrderRelateCallHandler: ICapSubscribe
+    public class OrderRelateCallHandler: ICapSubscribe,ITransientDependency
     {
         private readonly IOrderRepository _orderRepository;
         private readonly IRepository<TrCallRecord> _trCallRecordRepository;
+        
 
         public OrderRelateCallHandler(IOrderRepository orderRepository, IRepository<TrCallRecord> trCallRecordRepository)
         {
@@ -31,10 +33,23 @@ namespace Hotline.Application.Handlers.Order
         [CapSubscribe(EventNames.OrderRelateCall)]
         public async Task OrderRelateCallAsync(string orderId,CancellationToken cancellationToken)
         {
-            string a = "11111111111111111111111111111111111111111";
-            Console.WriteLine(a);
+            var order = await _orderRepository.GetAsync(orderId, cancellationToken);
+            if (order!=null)
+            {
+                var callRecords = await _trCallRecordRepository.Queryable().Where(p => p.OtherAccept == order.CallId && string.IsNullOrEmpty(p.OtherAccept) == false).ToListAsync(cancellationToken);
+                if (callRecords.Any())
+                {
+                    foreach (var callRecord in callRecords)
+                    {
+                        if (callRecord != null && string.IsNullOrEmpty(callRecord.ExternalId))
+                        {
+                            callRecord.ExternalId = orderId;
+                            callRecord.CallOrderType = Share.Enums.CallCenter.ECallOrderType.Order;
+                            await _trCallRecordRepository.UpdateAsync(callRecord, cancellationToken);
+                        }
+                    }
+                }
+            }
         }
-
-
     }
 }