32 lines
989 B
C#
32 lines
989 B
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using Meezi.API.Services.Delivery;
|
||
|
|
using Meezi.Core.Interfaces;
|
||
|
|
using Meezi.Shared;
|
||
|
|
|
||
|
|
namespace Meezi.API.Controllers;
|
||
|
|
|
||
|
|
[Route("api/cafes/{cafeId}/reports/delivery")]
|
||
|
|
public class DeliveryReportsController : CafeApiControllerBase
|
||
|
|
{
|
||
|
|
private readonly IDeliveryFinanceReportService _reports;
|
||
|
|
|
||
|
|
public DeliveryReportsController(IDeliveryFinanceReportService reports) => _reports = reports;
|
||
|
|
|
||
|
|
[HttpGet("revenue")]
|
||
|
|
public async Task<IActionResult> RevenueByPlatform(
|
||
|
|
string cafeId,
|
||
|
|
ITenantContext tenant,
|
||
|
|
[FromQuery] DateTime? from,
|
||
|
|
[FromQuery] DateTime? to,
|
||
|
|
CancellationToken ct)
|
||
|
|
{
|
||
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
||
|
|
|
||
|
|
var utcTo = to ?? DateTime.UtcNow;
|
||
|
|
var utcFrom = from ?? utcTo.AddDays(-30);
|
||
|
|
|
||
|
|
var data = await _reports.GetRevenueByPlatformAsync(cafeId, utcFrom, utcTo, ct);
|
||
|
|
return Ok(new ApiResponse<object>(true, data));
|
||
|
|
}
|
||
|
|
}
|