Files
account/modules/Account/app/Controllers/Api/StatisticsController.php
2026-01-18 20:17:59 +08:00

93 lines
2.3 KiB
PHP

<?php
namespace Modules\Account\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseController;
use Modules\Account\Services\StatisticsService;
class StatisticsController extends BaseController
{
protected $statisticsService;
public function __construct(StatisticsService $statisticsService)
{
$this->statisticsService = $statisticsService;
}
/**
* 获取统计概览
*/
public function overview(Request $request)
{
try {
$this->data['data'] = $this->statisticsService->getOverview($request);
} catch (\Throwable $th) {
$this->data['code'] = 0;
$this->data['message'] = $th->getMessage();
}
return response()->json($this->data);
}
/**
* 获取收支趋势
*/
public function trend(Request $request)
{
try {
$this->data['data'] = $this->statisticsService->getTrend($request);
} catch (\Throwable $th) {
$this->data['code'] = 0;
$this->data['message'] = $th->getMessage();
}
return response()->json($this->data);
}
/**
* 获取分类统计
*/
public function category(Request $request)
{
try {
$this->data['data'] = $this->statisticsService->getCategory($request);
} catch (\Throwable $th) {
$this->data['code'] = 0;
$this->data['message'] = $th->getMessage();
}
return response()->json($this->data);
}
/**
* 获取月度报表
*/
public function monthly(Request $request)
{
try {
$this->data['data'] = $this->statisticsService->getMonthly($request);
} catch (\Throwable $th) {
$this->data['code'] = 0;
$this->data['message'] = $th->getMessage();
}
return response()->json($this->data);
}
/**
* 获取年度报表
*/
public function yearly(Request $request)
{
try {
$this->data['data'] = $this->statisticsService->getYearly($request);
} catch (\Throwable $th) {
$this->data['code'] = 0;
$this->data['message'] = $th->getMessage();
}
return response()->json($this->data);
}
}