using HoneyBox.Admin.Business.Attributes; using HoneyBox.Admin.Business.Models.Statistics; using HoneyBox.Admin.Business.Services.Interfaces; using Microsoft.AspNetCore.Mvc; namespace HoneyBox.Admin.Business.Controllers; /// /// 统计报表控制器 /// [Route("api/admin/business/statistics")] public class StatisticsController : BusinessControllerBase { private readonly IStatisticsService _statisticsService; public StatisticsController(IStatisticsService statisticsService) { _statisticsService = statisticsService; } /// /// 获取今日订单统计数据 /// /// 今日订单统计 [HttpGet("today-order")] [BusinessPermission("statistics:view")] public async Task GetTodayOrderStats() { var result = await _statisticsService.GetTodayOrderStatsAsync(); return Ok(result); } /// /// 获取货币信息统计数据 /// /// 货币信息统计 [HttpGet("currency-info")] [BusinessPermission("statistics:view")] public async Task GetCurrencyInfoStats() { var result = await _statisticsService.GetCurrencyInfoStatsAsync(); return Ok(result); } /// /// 获取收入汇总统计数据 /// /// 收入汇总统计 [HttpGet("income-summary")] [BusinessPermission("statistics:view")] public async Task GetIncomeSummaryStats() { var result = await _statisticsService.GetIncomeSummaryStatsAsync(); return Ok(result); } /// /// 获取用户统计数据 /// /// 用户统计 [HttpGet("user-stats")] [BusinessPermission("statistics:view")] public async Task GetUserStats() { var result = await _statisticsService.GetUserStatsAsync(); return Ok(result); } /// /// 获取单个盒子的统计数据 /// /// 盒子ID /// 开始时间 /// 结束时间 /// 盒子统计数据 [HttpGet("box-statistics")] [BusinessPermission("statistics:view")] public async Task GetBoxStatistics( [FromQuery] int goodsId, [FromQuery] DateTime? startTime, [FromQuery] DateTime? endTime) { var request = new BoxStatisticsRequest { GoodsId = goodsId, StartTime = startTime, EndTime = endTime }; var result = await _statisticsService.GetBoxStatisticsAsync(request); return Ok(new { code = 0, msg = "获取成功", data = result }); } /// /// 获取盒子利润统计列表 /// /// 请求参数 /// 盒子利润统计列表 [HttpGet("box-profit-list")] [BusinessPermission("statistics:view")] public async Task GetBoxProfitList([FromQuery] BoxProfitListRequest request) { var result = await _statisticsService.GetBoxProfitListAsync(request); return Ok(new { code = 0, msg = "获取数据成功", count = result.Total, data = result.List, summary = new BoxProfitSummary { TotalIncome = 0, TotalCost = 0, TotalProfit = 0, TotalReMoney = 0, TotalFhMoney = 0 } }); } /// /// 获取所有盒子的汇总统计数据 /// /// 盒子ID /// 盒子名称 /// 状态 /// 盒子类型 /// 开始时间 /// 结束时间 /// 汇总统计数据 [HttpGet("summary-statistics")] [BusinessPermission("statistics:view")] public async Task GetSummaryStatistics( [FromQuery] int? goodsId, [FromQuery] string? title, [FromQuery] int? status, [FromQuery] int? type, [FromQuery] DateTime? startTime, [FromQuery] DateTime? endTime) { var request = new BoxSummaryStatisticsRequest { GoodsId = goodsId, Title = title, Status = status, Type = type, StartTime = startTime, EndTime = endTime }; var result = await _statisticsService.GetSummaryStatisticsAsync(request); return Ok(new { code = 0, msg = "获取成功", data = result }); } }