mirror of
https://github.com/v2board/v2board.git
synced 2025-01-26 16:09:09 +08:00
update: more feature
This commit is contained in:
parent
b8b7033132
commit
66c547d0ac
@ -5,6 +5,8 @@ namespace App\Console\Commands;
|
|||||||
use App\Jobs\StatServerJob;
|
use App\Jobs\StatServerJob;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Models\StatOrder;
|
||||||
|
use App\Models\ServerLog;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class V2BoardStatistics extends Command
|
class V2BoardStatistics extends Command
|
||||||
@ -40,8 +42,8 @@ class V2BoardStatistics extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->statOrder();
|
$this->statOrder();
|
||||||
// $this->statServer();
|
$this->statServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function statOrder()
|
private function statOrder()
|
||||||
@ -57,12 +59,22 @@ class V2BoardStatistics extends Command
|
|||||||
->whereIn('commission_status', [1, 2]);
|
->whereIn('commission_status', [1, 2]);
|
||||||
$commissionCount = $builder->count();
|
$commissionCount = $builder->count();
|
||||||
$commissionAmount = $builder->sum('commission_balance');
|
$commissionAmount = $builder->sum('commission_balance');
|
||||||
dd([
|
$data = [
|
||||||
$orderCount,
|
'order_count' => $orderCount,
|
||||||
$orderAmount,
|
'order_amount' => $orderAmount,
|
||||||
$commissionCount,
|
'commission_count' => $commissionCount,
|
||||||
$commissionAmount
|
'commission_amount' => $commissionAmount,
|
||||||
]);
|
'record_type' => 'd',
|
||||||
|
'record_at' => $startAt
|
||||||
|
];
|
||||||
|
$statistic = StatOrder::where('record_at', $startAt)
|
||||||
|
->where('record_type', 'd')
|
||||||
|
->first();
|
||||||
|
if ($statistic) {
|
||||||
|
$statistic->update($data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StatOrder::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function statServer()
|
private function statServer()
|
||||||
@ -81,7 +93,7 @@ class V2BoardStatistics extends Command
|
|||||||
->get()
|
->get()
|
||||||
->toArray();
|
->toArray();
|
||||||
foreach ($statistics as $statistic) {
|
foreach ($statistics as $statistic) {
|
||||||
$statistic['record_type'] = 'm';
|
$statistic['record_type'] = 'd';
|
||||||
$statistic['record_at'] = $startAt;
|
$statistic['record_at'] = $startAt;
|
||||||
StatServerJob::dispatch($statistic);
|
StatServerJob::dispatch($statistic);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Models\ServerShadowsocks;
|
||||||
|
use App\Models\ServerTrojan;
|
||||||
|
use App\Services\ServerService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\ServerGroup;
|
use App\Models\ServerGroup;
|
||||||
@ -10,7 +13,10 @@ use App\Models\Plan;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Models\StatOrder;
|
||||||
|
use App\Models\StatServer;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class StatController extends Controller
|
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/dumpCSV', 'Admin\\UserController@dumpCSV');
|
||||||
$router->post('/user/sendMail', 'Admin\\UserController@sendMail');
|
$router->post('/user/sendMail', 'Admin\\UserController@sendMail');
|
||||||
$router->post('/user/ban', 'Admin\\UserController@ban');
|
$router->post('/user/ban', 'Admin\\UserController@ban');
|
||||||
// Stat
|
// StatOrder
|
||||||
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
||||||
|
$router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');
|
||||||
|
$router->get ('/stat/getOrder', 'Admin\\StatController@getOrder');
|
||||||
// Notice
|
// Notice
|
||||||
$router->get ('/notice/fetch', 'Admin\\NoticeController@fetch');
|
$router->get ('/notice/fetch', 'Admin\\NoticeController@fetch');
|
||||||
$router->post('/notice/save', 'Admin\\NoticeController@save');
|
$router->post('/notice/save', 'Admin\\NoticeController@save');
|
||||||
|
@ -236,5 +236,5 @@ return [
|
|||||||
| The only modification by laravel config
|
| The only modification by laravel config
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
'version' => '1.4.3.1608376571'
|
'version' => '1.4.3.1608824466'
|
||||||
];
|
];
|
||||||
|
@ -330,4 +330,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2020-12-22 07:19:34
|
-- 2020-12-24 14:02:39
|
||||||
|
@ -376,7 +376,7 @@ ADD INDEX `record_at` (`record_at`),
|
|||||||
ADD INDEX `server_id` (`server_id`);
|
ADD INDEX `server_id` (`server_id`);
|
||||||
|
|
||||||
CREATE TABLE `v2_stat_order` (
|
CREATE TABLE `v2_stat_order` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`order_count` int(11) NOT NULL COMMENT '订单数量',
|
`order_count` int(11) NOT NULL COMMENT '订单数量',
|
||||||
`order_amount` int(11) NOT NULL COMMENT '订单合计',
|
`order_amount` int(11) NOT NULL COMMENT '订单合计',
|
||||||
`commission_count` int(11) NOT NULL,
|
`commission_count` int(11) NOT NULL,
|
||||||
@ -384,8 +384,10 @@ CREATE TABLE `v2_stat_order` (
|
|||||||
`record_type` char(1) NOT NULL,
|
`record_type` char(1) NOT NULL,
|
||||||
`record_at` int(11) NOT NULL,
|
`record_at` int(11) NOT NULL,
|
||||||
`created_at` int(11) NOT NULL,
|
`created_at` int(11) NOT NULL,
|
||||||
`updated_at` int(11) NOT NULL
|
`updated_at` int(11) NOT NULL,
|
||||||
) COMMENT='订单统计' COLLATE 'utf8_general_ci';
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `record_at` (`record_at`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单统计';
|
||||||
|
|
||||||
ALTER TABLE `v2_stat_order`
|
ALTER TABLE `v2_user`
|
||||||
ADD UNIQUE `record_at` (`record_at`);
|
DROP `enable`;
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user