CallNativeApplication.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Hotline.CallCenter.Calls;
  2. using Hotline.Orders;
  3. using Hotline.Repository.SqlSugar.CallCenter;
  4. using Hotline.Share.Enums.Order;
  5. using Hotline.Share.Tools;
  6. using XF.Domain.Dependency;
  7. using XF.Domain.Exceptions;
  8. namespace Hotline.Application.CallCenter;
  9. public class CallNativeApplication : ICallNativeApplication, IScopeDependency
  10. {
  11. private readonly ICallNativeRepository _callNativeRepository;
  12. private readonly ICallDomainService _callDomainService;
  13. private readonly IOrderVisitDomainService _orderVisitDomainService;
  14. public CallNativeApplication(ICallNativeRepository callNativeRepository, IOrderVisitDomainService orderVisitDomainService, ICallDomainService callDomainService)
  15. {
  16. _callNativeRepository = callNativeRepository;
  17. _orderVisitDomainService = orderVisitDomainService;
  18. _callDomainService = callDomainService;
  19. }
  20. /// <summary>
  21. /// 根据 OrderId 返回用户电话评价枚举
  22. /// 默认返回 默认满意
  23. /// </summary>
  24. /// <param name="orderId"></param>
  25. /// <returns></returns>
  26. public async Task<EVoiceEvaluate> GetReplyVoiceOrDefaultByOrderIdAsync(string orderId)
  27. {
  28. var callNative = await _callDomainService.GetByOrderIdAsync(orderId);
  29. if (callNative is null || callNative.ReplyTxt.IsNullOrEmpty())
  30. return EVoiceEvaluate.DefaultSatisfied;
  31. try
  32. {
  33. return _orderVisitDomainService.GetVisitEvaluateByReplyTxt<EVoiceEvaluate>(callNative.ReplyTxt!.Trim());
  34. }
  35. catch (UserFriendlyException)
  36. {
  37. return EVoiceEvaluate.DefaultSatisfied;
  38. }
  39. }
  40. }