CorsJobController.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Hotline.Api.Realtimes;
  2. using Hotline.Application.Jobs;
  3. using Hotline.CallCenter.Calls;
  4. using Hotline.Orders;
  5. using Hotline.Realtimes;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Mvc;
  8. using XF.Domain.Repository;
  9. namespace Hotline.Api.Controllers
  10. {
  11. public class CorsJobController: BaseController
  12. {
  13. private readonly IOrderDomainService _orderDomainService;
  14. private readonly IRepository<TrCallRecord> _trcallrecordRepoository;
  15. private readonly IRealtimeService _realtimeService;
  16. public CorsJobController(IOrderDomainService orderDomainService)
  17. {
  18. _orderDomainService = orderDomainService;
  19. }
  20. /// <summary>
  21. /// 定时发送超期短信
  22. /// 0 30 09,14 * * ?
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet("send-overtime-sms")]
  26. [AllowAnonymous]
  27. public async Task SendOverTimeSms()
  28. {
  29. await _orderDomainService.SendOverTimeSms(HttpContext.RequestAborted);
  30. }
  31. /// <summary>
  32. /// 推送当天等待(1分钟一次)
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet("send-todaywaitnum")]
  36. [AllowAnonymous]
  37. public async Task SendToDayWaitNum()
  38. {
  39. try
  40. {
  41. int count = await _trcallrecordRepoository.Queryable()
  42. .Where(x => x.CreatedTime.Date == DateTime.Now.Date)
  43. .Where(x => x.QueueTims > 0 && x.Duration == 0)
  44. .CountAsync();
  45. await _realtimeService.TodayWaitNumAsync(count, HttpContext.RequestAborted);
  46. }
  47. catch { }
  48. }
  49. }
  50. }