feat: stats
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Concerns\PortalAware;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\DailyReportService;
|
||||
use App\Support\AgentScope;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DailyReportController extends Controller
|
||||
{
|
||||
use PortalAware;
|
||||
|
||||
public function __construct(
|
||||
private readonly DailyReportService $reports,
|
||||
) {}
|
||||
|
||||
public function index()
|
||||
{
|
||||
[$from, $to] = $this->reports->window();
|
||||
|
||||
return view('admin.reports.daily', [
|
||||
'portal' => $this->portal(),
|
||||
'defaultFrom' => $from->toDateString(),
|
||||
'defaultTo' => $to->toDateString(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function data(Request $request)
|
||||
{
|
||||
$filters = [
|
||||
'date_from' => trim((string) $request->query('date_from', '')),
|
||||
'date_to' => trim((string) $request->query('date_to', '')),
|
||||
'date_range' => trim((string) $request->query('date_range', '')),
|
||||
'agent_user_id' => $this->isAgentPortal()
|
||||
? null
|
||||
: AgentScope::parseAgentUserIdFilter($request->query('agent_user_id')),
|
||||
];
|
||||
[$from, $to] = $this->reports->resolveBounds($filters);
|
||||
|
||||
return response()->json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'data' => [
|
||||
'rows' => $this->reports->rows($this->agent(), $filters),
|
||||
'from' => $from->toDateString(),
|
||||
'to' => $to->toDateString(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -41,12 +41,15 @@ class WalletAddressController extends Controller
|
||||
{
|
||||
$q = $this->baseQuery($request);
|
||||
|
||||
$sortable = ['id', 'address', 'chain_type', 'source', 'mnemonic_id', 'usdt', 'trx', 'eth', 'btc', 'bnb', 'monitor', 'created_at', 'updated_at'];
|
||||
$sortable = ['id', 'address', 'chain_type', 'source', 'collectable', 'usdt', 'trx', 'eth', 'btc', 'bnb', 'monitor', 'created_at', 'updated_at'];
|
||||
$field = (string) $request->query('field', 'id');
|
||||
$order = strtolower((string) $request->query('order', 'desc')) === 'asc' ? 'asc' : 'desc';
|
||||
if (! in_array($field, $sortable, true)) {
|
||||
$field = 'id';
|
||||
}
|
||||
if ($field === 'collectable') {
|
||||
$field = 'mnemonic_id';
|
||||
}
|
||||
$q->orderBy('wallet_addresses.'.$field, $order);
|
||||
|
||||
$limit = max(1, min(100, (int) $request->query('limit', 20)));
|
||||
@@ -65,7 +68,7 @@ class WalletAddressController extends Controller
|
||||
'source' => $row->source ?: '',
|
||||
'chain_type' => $row->chain_type ?: '',
|
||||
'address' => $row->address,
|
||||
'mnemonic_id' => $row->mnemonic_id,
|
||||
'collectable' => $row->mnemonic_id !== null,
|
||||
'usdt' => $coins['usdt'],
|
||||
'trx' => $coins['trx'],
|
||||
'eth' => $coins['eth'],
|
||||
|
||||
Reference in New Issue
Block a user