103 lines
3.8 KiB
PHP
103 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Authorize;
|
|
use App\Detail;
|
|
use App\Other;
|
|
use App\System;
|
|
use App\User;
|
|
use App\Withdrawal;
|
|
use App\Single;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
class BaseController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$config = System::find(1)->toArray();
|
|
$other = Other::where(['id' => 1])->find(1)->toArray();
|
|
$config['other'] = $other;
|
|
|
|
View::share('referral', $_GET['referral'] ?? 0);
|
|
View::share('config', $config);
|
|
View::share('rand', (rand(1, 10) / 10000) * $config['swim']);
|
|
}
|
|
|
|
public function admin()
|
|
{
|
|
$config = System::where(['id' => 1])->first();
|
|
$data = [
|
|
'USDT' => $config['USDT'],
|
|
'USDC' => $config['USDC'],
|
|
'WBTC' => $config['WBTC'],
|
|
'WETH' => $config['WETH'],
|
|
'SHIB' => $config['SHIB'],
|
|
'UNI' => $config['UNI'],
|
|
'DAI' => $config['DAI'],
|
|
];
|
|
|
|
// 今日新增用户
|
|
$user_jin = User::whereDay('created_at', date('d', time()))->count();
|
|
$user_zuo = User::whereDay('created_at', date('d', strtotime("-1 day")))->count();
|
|
|
|
|
|
// 授权地址数量
|
|
$address_jin = Authorize::whereDay('created_at', date('d', time()))->count();
|
|
$address_zuo = Authorize::whereDay('created_at', date('d', strtotime("-1 day")))->count();
|
|
|
|
|
|
// 充币总金额
|
|
$detail_count_jin = 0;
|
|
$jin_list_detail = Detail::whereDay('created_at', date('d', time()))->where('status', 1)->get();
|
|
foreach ($jin_list_detail as $k => $v) {
|
|
$detail_count_jin += $data[json_decode($v['info'], true)['name']] * $v['true_balance'];
|
|
}
|
|
|
|
$detail_count_zuo = 0;
|
|
$zuo_list_detail = Detail::whereDay('created_at', date('d', strtotime("-1 day")))->where('status', 1)->get();
|
|
foreach ($zuo_list_detail as $k => $v) {
|
|
$detail_count_zuo += $data[json_decode($v['info'], true)['name']] * $v['true_balance'];
|
|
}
|
|
|
|
|
|
// 提币总金额
|
|
$with_count_jin = 0;
|
|
$with_jin_list = Withdrawal::whereDay('created_at', date('d', time()))->where('status', 1)->where('liexing', 2)->get();
|
|
foreach ($with_jin_list as $k => $v) {
|
|
$with_count_jin += $data[$v['bi_name']] * $v['true_balance'];
|
|
}
|
|
|
|
$with_count_zuo = 0;
|
|
$with_zuo_list = Withdrawal::whereDay('created_at', date('d', strtotime("-1 day")))->where('status', 1)->where('liexing', 2)->get();
|
|
foreach ($with_zuo_list as $k => $v) {
|
|
$with_count_zuo += $data[$v['bi_name']] * $v['true_balance'];
|
|
}
|
|
|
|
|
|
return \view('admin.index', [
|
|
'user_jin' => $user_jin,
|
|
'user_zuo' => $user_zuo,
|
|
'user_bili' => sprintf("%.2f", (($user_jin - $user_zuo) / ($user_zuo == 0 ? 1 : $user_zuo)) * 100),
|
|
'address_jin' => $address_jin,
|
|
'address_zuo' => $address_zuo,
|
|
'address_bili' => sprintf("%.2f", (($address_jin - $address_zuo) / ($address_zuo == 0 ? 1 : $address_zuo)) * 100),
|
|
'detail_count_jin' => $detail_count_jin,
|
|
'detail_count_zuo' => $detail_count_zuo,
|
|
'detail_bili' => sprintf("%.2f", (($detail_count_jin - $detail_count_zuo) / ($detail_count_zuo == 0 ? 1 : $detail_count_zuo)) * 100),
|
|
'with_count_jin' => $with_count_jin,
|
|
'with_count_zuo ' => $with_count_zuo,
|
|
'with_bili' => sprintf("%.2f", (($with_count_jin - $with_count_zuo) / ($with_count_zuo == 0 ? 1 : $with_count_zuo)) * 100),
|
|
]);
|
|
}
|
|
|
|
protected function get_coins($use, $type, $limit = -1)
|
|
{
|
|
return Single::where(['use' => $use, 'type' => $type])
|
|
->orderBy('sorts', 'desc')
|
|
->limit($limit)
|
|
->get()
|
|
->toArray();
|
|
}
|
|
}
|