108 lines
2.6 KiB
PHP
108 lines
2.6 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);
|
|
}
|
|
|
|
/**
|
|
* 获取个人中心统计数据
|
|
*/
|
|
public function dashboard(Request $request)
|
|
{
|
|
try {
|
|
$this->data['data'] = $this->statisticsService->getDashboardStats($request);
|
|
} catch (\Throwable $th) {
|
|
$this->data['code'] = 0;
|
|
$this->data['message'] = $th->getMessage();
|
|
}
|
|
|
|
return response()->json($this->data);
|
|
}
|
|
}
|