OrderStatisticsController.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Cors;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using XYY.Authentication.Standard;
  9. using XYY.Common.Standard;
  10. using XYY.Core.Standard.ExcelHelper.MSExcelHelper;
  11. using XYY.Core.Standard.Mvc;
  12. using XYY.Model.Standard.Order;
  13. using XYY.Service.Standard.Order;
  14. namespace XYY.Api.Order.Controllers
  15. {
  16. [EnableCors("httpsAllowSpecificOrigins")]
  17. [Route("api/[controller]/[action]")]
  18. [ApiController]
  19. public class OrderStatisticsController : ApiControllerBase
  20. {
  21. private readonly ICustomerOrderStatisticsService _customerOrderStatisticsService;
  22. public OrderStatisticsController(ICustomerOrderStatisticsService customerOrderStatisticsService)
  23. {
  24. this._customerOrderStatisticsService = customerOrderStatisticsService;
  25. }
  26. [AllowAnonymous]
  27. public async Task<IActionResult> GetdeliverySignCollectList(QueryModel queryModel)
  28. {
  29. var u = User.GetUserContent();
  30. var dto = await _customerOrderStatisticsService.GetDeliverySignCollectPager(queryModel, u.CustomerId);
  31. return Ok(dto);
  32. }
  33. [AllowAnonymous]
  34. public async Task<IActionResult> GetDeliverySignDetailList(QueryModel queryModel)
  35. {
  36. var u = User.GetUserContent();
  37. var dto = await _customerOrderStatisticsService.GetDeliverySignDetailPager(queryModel, u.CustomerId);
  38. return Ok(dto);
  39. }
  40. [AllowAnonymous]
  41. public async Task<IActionResult> OutData(QueryModel queryModel)
  42. {
  43. var u = User.GetUserContent();
  44. var list = await _customerOrderStatisticsService.GetDeliverySignDetailList(queryModel, u.CustomerId);
  45. var ms = new MSExcelHelper();
  46. byte[] data = null;
  47. if (await _customerOrderStatisticsService.IsShowOnlineTime(u.CustomerId))
  48. {
  49. data = ms.OutDataAsByte<OutDeliverySignDetailInfoOnlineTime, deliverySignDetail>(list.ToList());
  50. }
  51. else { data = ms.OutDataAsByte<OutDeliverySignDetailInfo, deliverySignDetail>(list.ToList()); }
  52. var utc = DateTime.Now.ToFileTimeUtc();
  53. return File($"{utc}.xlsx", data);
  54. }
  55. [AllowAnonymous]
  56. public async Task<bool> IsShowOnlineTime()
  57. {
  58. var u = User.GetUserContent();
  59. return await _customerOrderStatisticsService.IsShowOnlineTime(u.CustomerId);
  60. }
  61. }
  62. }