Browse Source

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

xf 4 months ago
parent
commit
45d8e14715

+ 8 - 0
src/Hotline.Api/Controllers/OrderController.cs

@@ -146,6 +146,7 @@ public class OrderController : BaseController
     private readonly IRepository<OrderPushType> _orderPushTypeRepository;
     private readonly IRepository<OrderRevoke> _orderRevokeRepository;
     private readonly IOrderTerminateRepository _orderTerminateRepository;
+    private readonly ISystemLogApplication _systemLogApplication;
 
     public OrderController(
         IOrderDomainService orderDomainService,
@@ -3495,6 +3496,13 @@ public class OrderController : BaseController
             var exists = await _orderRepository.AnyAsync(d => d.CallId == dto.CallId, HttpContext.RequestAborted);
             if (exists)
                 throw new UserFriendlyException($"来电已保存工单, phone:{dto.FromPhone}, callId: {dto.CallId}", "来电已保存工单");
+            exists = await _systemLogApplication.HasByIpUrlAsync(dto.CallId);
+            if (exists)
+            {
+                // IpUrl 里面存的是 callId, 用来判断是工单的 CallId 是否已经被修复过了.
+                // 存入的地方是 Hotline.Application.CallCenter.OrderRelateCallHandlerAsync
+                throw new UserFriendlyException($"来电已保存工单, phone:{dto.FromPhone}, callId: {dto.CallId} !", "来电已保存工单!");
+            }
         }
 
         var order = _mapper.Map<Orders.Order>(dto);

+ 2 - 2
src/Hotline.Application/CallCenter/DefaultCallApplication.cs

@@ -405,7 +405,7 @@ public abstract class DefaultCallApplication : ICallApplication
     /// </summary>
     public virtual async Task<CallNative> GetCallByCallNoAsync(string callNo, CancellationToken cancellationToken)
     {
-        return  await _callNativeRepository.Queryable()
+        return await _callNativeRepository.Queryable()
             .Where(m => m.CallNo == callNo && !string.IsNullOrEmpty(m.AudioFile))
             .FirstAsync(cancellationToken);
     }
@@ -580,7 +580,7 @@ public abstract class DefaultCallApplication : ICallApplication
             TrCallRecordDto = call.Adapt<TrCallDto>()
         }, cancellationToken: cancellationToken);
         var msg = $"原CallId: {orderCall.CallId}, 更新CallId: {call.Id}";
-        _systemLogRepository.Add("延迟更新工单通话", orderId, msg, status: 1);
+        _systemLogRepository.Add("延迟更新工单通话", orderId, msg,status:1, ipUrl: orderCall.CallId);
         return msg + "(完成推省上)";
     }
 

+ 4 - 1
src/Hotline.Application/Systems/ISystemLogApplication.cs

@@ -10,5 +10,8 @@ namespace Hotline.Application.Systems
 	public interface ISystemLogApplication
 	{
 		Task AddLog<T>(string name, string res, T entity, HttpContext context,string crName ="");
-	}
+
+		Task<bool> HasByIpUrlAsync(string ipUrl);
+
+    }
 }

+ 7 - 2
src/Hotline.Application/Systems/SystemLogApplication.cs

@@ -11,7 +11,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.Systems
 {
-	public class SystemLogApplication: ISystemLogApplication, IScopeDependency
+    public class SystemLogApplication : ISystemLogApplication, IScopeDependency
 	{
 		private readonly IMapper _mapper;
 		private readonly IRepository<SystemLog> _systemLogRepository;
@@ -43,5 +43,10 @@ namespace Hotline.Application.Systems
 			if (!string.IsNullOrEmpty(crName))
 				await _systemLogRepository.Updateable().SetColumns(l => new SystemLog() { CreatorName = crName }).Where(l => l.Id == log.Id).ExecuteCommandAsync();
 		}
-	}
+
+        public async Task<bool> HasByIpUrlAsync(string ipUrl)
+        {
+			return await _systemLogRepository.Queryable().Where(x => x.IpUrl == ipUrl).AnyAsync();
+        }
+    }
 }

+ 3 - 2
src/Hotline.Repository.SqlSugar/System/SystemLogRepository.cs

@@ -18,7 +18,7 @@ public class SystemLogRepository : BaseRepository<SystemLog>, ISystemLogReposito
     {
     }
 
-    public void Add(string name, string executeParam = "", string remark = "", [CallerMemberName]string executeUrl = "", int status = 0)
+    public void Add(string name, string executeParam = "", string remark = "", [CallerMemberName]string executeUrl = "", int status = 0, string ipUrl = "")
     {
         try
         {
@@ -28,7 +28,8 @@ public class SystemLogRepository : BaseRepository<SystemLog>, ISystemLogReposito
                 ExecuteParam = executeParam,
                 ExecuteUrl = executeUrl,
                 Remark = remark,
-                Status = status
+                Status = status,
+                IpUrl = ipUrl
             };
             if (executeUrl.IsNullOrEmpty())
             {

+ 1 - 1
src/Hotline/Settings/ISystemLogRepository.cs

@@ -18,5 +18,5 @@ public interface ISystemLogRepository : IRepository<SystemLog>
     /// <param name="remark">备注</param>
     /// <param name="status">状态(0失败 1成功)</param>
     /// <returns></returns>
-    void Add(string name, string executeParam = "", string remark = "", [CallerMemberName]string executeUrl = "", int status = 0);
+    void Add(string name, string executeParam = "", string remark = "", [CallerMemberName]string executeUrl = "", int status = 0, string ipUrl = "");
 }