mirror of
https://github.com/v2board/v2board.git
synced 2025-06-14 13:47:49 +08:00
update: more feature
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\ServerShadowsocks;
|
||||
use App\Models\ServerTrojan;
|
||||
use App\Services\ServerService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ServerGroup;
|
||||
@ -10,7 +13,10 @@ use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\Order;
|
||||
use App\Models\StatOrder;
|
||||
use App\Models\StatServer;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StatController extends Controller
|
||||
{
|
||||
@ -43,4 +49,73 @@ class StatController extends Controller
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function getOrder(Request $request)
|
||||
{
|
||||
$statistics = StatOrder::where('record_type', 'd')
|
||||
->limit(31)
|
||||
->orderBy('record_at', 'ASC')
|
||||
->get()
|
||||
->toArray();
|
||||
$result = [];
|
||||
foreach ($statistics as $statistic) {
|
||||
$date = date('m-d', $statistic['record_at']);
|
||||
array_push($result, [
|
||||
'type' => '收款金额',
|
||||
'date' => $date,
|
||||
'value' => $statistic['order_amount'] / 100
|
||||
]);
|
||||
array_push($result, [
|
||||
'type' => '收款笔数',
|
||||
'date' => $date,
|
||||
'value' => $statistic['order_count']
|
||||
]);
|
||||
array_push($result, [
|
||||
'type' => '佣金金额',
|
||||
'date' => $date,
|
||||
'value' => $statistic['commission_amount'] / 100
|
||||
]);
|
||||
array_push($result, [
|
||||
'type' => '佣金笔数',
|
||||
'date' => $date,
|
||||
'value' => $statistic['commission_count']
|
||||
]);
|
||||
}
|
||||
return response([
|
||||
'data' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
public function getServerLastRank()
|
||||
{
|
||||
$servers = [
|
||||
'shadowsocks' => ServerShadowsocks::where('parent_id', null)->get()->toArray(),
|
||||
'vmess' => Server::where('parent_id', null)->get()->toArray(),
|
||||
'trojan' => ServerTrojan::where('parent_id', null)->get()->toArray()
|
||||
];
|
||||
$timestamp = strtotime('-1 day', strtotime(date('Y-m-d')));
|
||||
$statistics = StatServer::select([
|
||||
'server_id',
|
||||
'server_type',
|
||||
'u',
|
||||
'd'
|
||||
])
|
||||
->where('record_at', '>=', $timestamp)
|
||||
->where('record_type', 'd')
|
||||
->limit(10)
|
||||
->get()
|
||||
->toArray();
|
||||
foreach ($statistics as $k => $v) {
|
||||
foreach ($servers[$v['server_type']] as $server) {
|
||||
if ($server['id'] === $v['server_id']) {
|
||||
$statistics[$k]['server_name'] = $server['name'];
|
||||
}
|
||||
}
|
||||
$statistics[$k]['total'] = ($v['u'] + $v['d']) / 1073741824;
|
||||
}
|
||||
array_multisort(array_column($statistics, 'total'), SORT_DESC, $statistics);
|
||||
return response([
|
||||
'data' => $statistics
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,10 @@ class AdminRoute
|
||||
$router->post('/user/dumpCSV', 'Admin\\UserController@dumpCSV');
|
||||
$router->post('/user/sendMail', 'Admin\\UserController@sendMail');
|
||||
$router->post('/user/ban', 'Admin\\UserController@ban');
|
||||
// Stat
|
||||
// StatOrder
|
||||
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
||||
$router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');
|
||||
$router->get ('/stat/getOrder', 'Admin\\StatController@getOrder');
|
||||
// Notice
|
||||
$router->get ('/notice/fetch', 'Admin\\NoticeController@fetch');
|
||||
$router->post('/notice/save', 'Admin\\NoticeController@save');
|
||||
|
Reference in New Issue
Block a user