using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using XYY.Authentication.Standard; using XYY.Common.Standard; using XYY.Core.Standard.ExcelHelper.MSExcelHelper; using XYY.Core.Standard.Mvc; using XYY.Model.Standard.Order; using XYY.Service.Standard.Order; namespace XYY.Api.Order.Controllers { [EnableCors("httpsAllowSpecificOrigins")] [Route("api/[controller]/[action]")] [ApiController] public class OrderStatisticsController : ApiControllerBase { private readonly ICustomerOrderStatisticsService _customerOrderStatisticsService; public OrderStatisticsController(ICustomerOrderStatisticsService customerOrderStatisticsService) { this._customerOrderStatisticsService = customerOrderStatisticsService; } [AllowAnonymous] public async Task GetdeliverySignCollectList(QueryModel queryModel) { var u = User.GetUserContent(); var dto = await _customerOrderStatisticsService.GetDeliverySignCollectPager(queryModel, u.CustomerId); return Ok(dto); } [AllowAnonymous] public async Task GetDeliverySignDetailList(QueryModel queryModel) { var u = User.GetUserContent(); var dto = await _customerOrderStatisticsService.GetDeliverySignDetailPager(queryModel, u.CustomerId); return Ok(dto); } [AllowAnonymous] public async Task OutData(QueryModel queryModel) { var u = User.GetUserContent(); var list = await _customerOrderStatisticsService.GetDeliverySignDetailList(queryModel, u.CustomerId); var ms = new MSExcelHelper(); byte[] data = null; if (await _customerOrderStatisticsService.IsShowOnlineTime(u.CustomerId)) { data = ms.OutDataAsByte(list.ToList()); } else { data = ms.OutDataAsByte(list.ToList()); } var utc = DateTime.Now.ToFileTimeUtc(); return File($"{utc}.xlsx", data); } [AllowAnonymous] public async Task IsShowOnlineTime() { var u = User.GetUserContent(); return await _customerOrderStatisticsService.IsShowOnlineTime(u.CustomerId); } } }