1
This commit is contained in:
parent
8bc8b16ed2
commit
845e18ced6
@ -154,11 +154,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group mb-3 row">
|
<div class="form-group mb-3 row">
|
||||||
<label class="form-label col-3 col-form-label">排序组</label>
|
<label class="form-label col-3 col-form-label required">排序组</label>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input id="order_group" type="text" class="form-control" value="">
|
<input id="order_group" type="text" class="form-control" value="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label required">转发 code</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="zhuanfa_code" type="text" class="form-control" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label required">duck code</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="duck_code" type="text" class="form-control" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label">备注</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="memo" type="text" class="form-control" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="hr-text">
|
<div class="hr-text">
|
||||||
<span>流量设置</span>
|
<span>流量设置</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -171,6 +171,24 @@
|
|||||||
<input id="order_group" type="text" class="form-control" value="{$node->order_group}">
|
<input id="order_group" type="text" class="form-control" value="{$node->order_group}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="zhuanfa-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label">转发 code</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="zhuanfa_code" type="text" class="form-control" value="{$node->zhuanfa_code}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="duck-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label">duck code</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="duck_code" type="text" class="form-control" value="{$node->duck_code}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="duck-group mb-3 row">
|
||||||
|
<label class="form-label col-3 col-form-label">备注</label>
|
||||||
|
<div class="col">
|
||||||
|
<input id="memo" type="text" class="form-control" value="{$node->memo}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="hr-text">
|
<div class="hr-text">
|
||||||
<span>流量设置</span>
|
<span>流量设置</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -55,7 +55,9 @@ EOL;
|
|||||||
time() - Config::obtain('last_daily_job_time') > 86399
|
time() - Config::obtain('last_daily_job_time') > 86399
|
||||||
) {
|
) {
|
||||||
$jobs->cleanDb();
|
$jobs->cleanDb();
|
||||||
$jobs->resetNodeBandwidth();
|
// $jobs->resetNodeBandwidth();
|
||||||
|
$jobs->resetDuckBandwidth();
|
||||||
|
$jobs->bandwidthMerge();
|
||||||
$jobs->resetFreeUserBandwidth();
|
$jobs->resetFreeUserBandwidth();
|
||||||
$jobs->sendDailyTrafficReport();
|
$jobs->sendDailyTrafficReport();
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,9 @@ final class NodeController extends BaseController
|
|||||||
'node_bandwidth' => '已用流量/GB',
|
'node_bandwidth' => '已用流量/GB',
|
||||||
'bandwidthlimit_resetday' => '重置日',
|
'bandwidthlimit_resetday' => '重置日',
|
||||||
'order_group' => '排序组',
|
'order_group' => '排序组',
|
||||||
|
'zhuanfa_code' => '转发 code',
|
||||||
|
'duck_code' => 'duck code',
|
||||||
|
'memo' => 'memo',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -59,6 +62,9 @@ final class NodeController extends BaseController
|
|||||||
'node_bandwidth_limit',
|
'node_bandwidth_limit',
|
||||||
'bandwidthlimit_resetday',
|
'bandwidthlimit_resetday',
|
||||||
'order_group',
|
'order_group',
|
||||||
|
'zhuanfa_code',
|
||||||
|
'duck_code',
|
||||||
|
'memo',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,6 +109,9 @@ final class NodeController extends BaseController
|
|||||||
$node->is_dynamic_rate = $request->getParam('is_dynamic_rate') === 'true' ? 1 : 0;
|
$node->is_dynamic_rate = $request->getParam('is_dynamic_rate') === 'true' ? 1 : 0;
|
||||||
$node->dynamic_rate_type = $request->getParam('dynamic_rate_type') ?? 0;
|
$node->dynamic_rate_type = $request->getParam('dynamic_rate_type') ?? 0;
|
||||||
$node->order_group = $request->getParam('order_group') ?? 0;
|
$node->order_group = $request->getParam('order_group') ?? 0;
|
||||||
|
$node->duck_code = trim($request->getParam('duck_code'));
|
||||||
|
$node->zhuanfa_code = trim($request->getParam('zhuanfa_code'));
|
||||||
|
$node->memo = $request->getParam('memo');
|
||||||
$node->dynamic_rate_config = json_encode([
|
$node->dynamic_rate_config = json_encode([
|
||||||
'max_rate' => $request->getParam('max_rate') ?? 1,
|
'max_rate' => $request->getParam('max_rate') ?? 1,
|
||||||
'max_rate_time' => $request->getParam('max_rate_time') ?? 22,
|
'max_rate_time' => $request->getParam('max_rate_time') ?? 22,
|
||||||
@ -195,6 +204,9 @@ final class NodeController extends BaseController
|
|||||||
$node->name = $request->getParam('name');
|
$node->name = $request->getParam('name');
|
||||||
$node->node_group = $request->getParam('node_group') ?? 0;
|
$node->node_group = $request->getParam('node_group') ?? 0;
|
||||||
$node->order_group = $request->getParam('order_group') ?? 0;
|
$node->order_group = $request->getParam('order_group') ?? 0;
|
||||||
|
$node->zhuanfa_code = $request->getParam('zhuanfa_code');
|
||||||
|
$node->duck_code = $request->getParam('duck_code');
|
||||||
|
$node->memo = $request->getParam('memo');
|
||||||
$node->server = trim($request->getParam('server'));
|
$node->server = trim($request->getParam('server'));
|
||||||
$node->traffic_rate = $request->getParam('traffic_rate') ?? 1;
|
$node->traffic_rate = $request->getParam('traffic_rate') ?? 1;
|
||||||
$node->is_dynamic_rate = $request->getParam('is_dynamic_rate') === 'true' ? 1 : 0;
|
$node->is_dynamic_rate = $request->getParam('is_dynamic_rate') === 'true' ? 1 : 0;
|
||||||
|
|||||||
@ -13,12 +13,18 @@ use App\Services\Auth as AuthService;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Config;
|
use App\Models\Config;
|
||||||
use App\Models\UserCoupon;
|
use App\Models\UserCoupon;
|
||||||
|
use App\Services\Cron as CronService;
|
||||||
use App\Services\Reward;
|
use App\Services\Reward;
|
||||||
|
|
||||||
final class TestController extends BaseController
|
final class TestController extends BaseController
|
||||||
{
|
{
|
||||||
public function index(ServerRequest $request, Response $response, array $args): ResponseInterface
|
public function index(ServerRequest $request, Response $response, array $args): ResponseInterface
|
||||||
{
|
{
|
||||||
|
$jobs = new CronService();
|
||||||
|
|
||||||
|
$jobs->bandwidthMerge();
|
||||||
|
|
||||||
|
exit;
|
||||||
if ($_ENV['is_loc'] !== true) {
|
if ($_ENV['is_loc'] !== true) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,7 +100,7 @@ final class TicketController extends BaseController
|
|||||||
'管理员,有人开启了新的工单,请你及时处理。'
|
'管理员,有人开启了新的工单,请你及时处理。'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sTgContent = "📮📮📮有新工单📮📮📮\n\n工单号:".$ticket->id."\n\n用户ID:".$this->user->id."\n\n用户名:".$this->user->user_name."\n\n标题:".$title."\n\n内容:".$comment."
|
$sTgContent = "📮📮📮📮📮📮\n\n新工单\n\n工单号:".$ticket->id."\n\n用户ID:".$this->user->id."\n\n用户名:".$this->user->user_name."\n\n标题:".$title."\n\n内容:".$comment."
|
||||||
";
|
";
|
||||||
|
|
||||||
(new Telegram())->send(0, $sTgContent);
|
(new Telegram())->send(0, $sTgContent);
|
||||||
@ -164,7 +164,7 @@ final class TicketController extends BaseController
|
|||||||
'</a> 工单,请你及时处理。'
|
'</a> 工单,请你及时处理。'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sTgContent = "📮📮📮工单后续📮📮📮\n\n工单号:".$ticket->id."\n\n用户ID:".$this->user->id."\n\n用户名:".$this->user->user_name."\n\n标题:".$ticket->title."\n\n内容:".$comment."
|
$sTgContent = "📮📮📮📮📮📮\n\n工单后续\n\n工单号:".$ticket->id."\n\n用户ID:".$this->user->id."\n\n用户名:".$this->user->user_name."\n\n标题:".$ticket->title."\n\n内容:".$comment."
|
||||||
";
|
";
|
||||||
|
|
||||||
(new Telegram())->send(0, $sTgContent);
|
(new Telegram())->send(0, $sTgContent);
|
||||||
|
|||||||
16
src/Models/Ducks.php
Executable file
16
src/Models/Ducks.php
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Query\Builder;
|
||||||
|
use function time;
|
||||||
|
|
||||||
|
final class Ducks extends Model
|
||||||
|
{
|
||||||
|
protected $connection = 'default';
|
||||||
|
protected $table = 'ducks';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
16
src/Models/Zhuanfas.php
Executable file
16
src/Models/Zhuanfas.php
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Query\Builder;
|
||||||
|
use function time;
|
||||||
|
|
||||||
|
final class Zhuanfas extends Model
|
||||||
|
{
|
||||||
|
protected $connection = 'default';
|
||||||
|
protected $table = 'zhuanfas';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -16,6 +16,9 @@ use App\Models\Order;
|
|||||||
use App\Models\Paylist;
|
use App\Models\Paylist;
|
||||||
use App\Models\SubscribeLog;
|
use App\Models\SubscribeLog;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Models\Zhuanfas;
|
||||||
|
use App\Models\Ducks;
|
||||||
|
use App\Services\TomTool\TgSendFormat;
|
||||||
use App\Services\IM\Telegram;
|
use App\Services\IM\Telegram;
|
||||||
use App\Utils\Tools;
|
use App\Utils\Tools;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@ -409,13 +412,102 @@ final class Cron
|
|||||||
echo Tools::toDateTime(time()) . ' Successfully removed inactive user\'s Link and Invite' . PHP_EOL;
|
echo Tools::toDateTime(time()) . ' Successfully removed inactive user\'s Link and Invite' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 废弃
|
||||||
public static function resetNodeBandwidth(): void
|
public static function resetNodeBandwidth(): void
|
||||||
{
|
{
|
||||||
(new Node())->where('bandwidthlimit_resetday', date('d'))->update(['node_bandwidth' => 0]);
|
(new Node())->where('bandwidthlimit_resetday', date('d'))->update(['node_bandwidth' => 0]);
|
||||||
|
|
||||||
echo Tools::toDateTime(time()) . ' 重设节点流量完成' . PHP_EOL;
|
echo Tools::toDateTime(time()) . ' 重设节点流量完成' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function resetDuckBandwidth(): void
|
||||||
|
{
|
||||||
|
(new Ducks())->where('width_reset_day', date('d'))->update(['use_width' => 0]);
|
||||||
|
|
||||||
|
echo Tools::toDateTime(time()) . ' 重设机器流量完成' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static function resetZhuanfaBandwidth(): void
|
||||||
|
// {
|
||||||
|
// (new Ducks())->where('end_date', date('Y-m-d'))->update(['use_width' => 0]);
|
||||||
|
//
|
||||||
|
// echo Tools::toDateTime(time()) . ' 重设机器流量完成' . PHP_EOL;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static function bandwidthMerge(): void
|
||||||
|
{
|
||||||
|
$oNode = new Node();
|
||||||
|
$oZhuanfas = new Zhuanfas();
|
||||||
|
$oDucks = new Ducks();
|
||||||
|
|
||||||
|
$oNodeAll = $oNode->all();
|
||||||
|
|
||||||
|
foreach ($oNodeAll as $oNodeRow) {
|
||||||
|
|
||||||
|
@ $iZhuanfaFlowToday[$oNodeRow->zhuanfa_code] += $oNodeRow->node_bandwidth;
|
||||||
|
@ $iDuckFlowToday[$oNodeRow->duck_code] += $oNodeRow->node_bandwidth;
|
||||||
|
|
||||||
|
$oZhuanfas->where('code', $oNodeRow->zhuanfa_code)->increment('use_width', $oNodeRow->node_bandwidth);
|
||||||
|
$oDucks->where('code', $oNodeRow->duck_code)->increment('use_width', $oNodeRow->node_bandwidth);
|
||||||
|
$oNode->where('id', $oNodeRow->id)->update(['node_bandwidth' => 0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 流量报告,转发
|
||||||
|
$oTgSendFormat = new TgSendFormat();
|
||||||
|
$oTgSendFormat->sTitleEmoji = "⚡️⚡️⚡️⚡️⚡️⚡️";
|
||||||
|
$oTgSendFormat->sTitle = "流量报告 - 转发";
|
||||||
|
$today = new DateTime();
|
||||||
|
|
||||||
|
$oZhuanfasAll = $oZhuanfas->all();
|
||||||
|
foreach ($oZhuanfasAll as $oZhuanfasRow) {
|
||||||
|
|
||||||
|
$targetDate = new DateTime($oZhuanfasRow->end_date);
|
||||||
|
$interval = $today->diff($targetDate);
|
||||||
|
|
||||||
|
$oTgSendFormat->rowAdd(
|
||||||
|
$oZhuanfasRow->name,
|
||||||
|
$iZhuanfaFlowToday[$oZhuanfasRow->code],
|
||||||
|
$oZhuanfasRow->use_width,
|
||||||
|
$oZhuanfasRow->max_width,
|
||||||
|
$interval->days
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$sTgReport = $oTgSendFormat->typeA();
|
||||||
|
|
||||||
|
// var_dump($sTgReport);
|
||||||
|
(new Telegram())->send(0, $sTgReport);
|
||||||
|
|
||||||
|
// 流量报告,机器
|
||||||
|
$oTgSendFormat = new TgSendFormat();
|
||||||
|
$oTgSendFormat->sTitleEmoji = "⚡️⚡️⚡️⚡️⚡️⚡️";
|
||||||
|
$oTgSendFormat->sTitle = "流量报告 - 机器";
|
||||||
|
|
||||||
|
$oDucksAll = $oDucks->all();
|
||||||
|
foreach ($oDucksAll as $oDucksRow) {
|
||||||
|
|
||||||
|
$targetDate = new DateTime($oZhuanfasRow->end_date);
|
||||||
|
|
||||||
|
$oTgSendFormat->rowAdd(
|
||||||
|
$oDucksRow->code,
|
||||||
|
$iDuckFlowToday[$oDucksRow->code] ?? 0,
|
||||||
|
$oDucksRow->use_width,
|
||||||
|
$oDucksRow->max_width,
|
||||||
|
$oDucksRow->width_reset_day - date('d')
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$sTgReport = $oTgSendFormat->typeA();
|
||||||
|
|
||||||
|
// var_dump($sTgReport);
|
||||||
|
(new Telegram())->send(0, $sTgReport);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static function resetTodayBandwidth(): void
|
public static function resetTodayBandwidth(): void
|
||||||
{
|
{
|
||||||
(new User())->query()->update(['transfer_today' => 0]);
|
(new User())->query()->update(['transfer_today' => 0]);
|
||||||
|
|||||||
63
src/Services/TomTool/TgSendFormat.php
Executable file
63
src/Services/TomTool/TgSendFormat.php
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services\TomTool;
|
||||||
|
|
||||||
|
use App\Utils\Tools;
|
||||||
|
|
||||||
|
final class TgSendFormat
|
||||||
|
{
|
||||||
|
|
||||||
|
public $sTitleEmoji;
|
||||||
|
public $sTitle;
|
||||||
|
public $aContent;
|
||||||
|
|
||||||
|
public function typeA ()
|
||||||
|
{
|
||||||
|
$sStr = '';
|
||||||
|
|
||||||
|
$sStr .= "\n\n".$this->sTitleEmoji;
|
||||||
|
|
||||||
|
$sStr .= "\n\n".$this->sTitle;
|
||||||
|
|
||||||
|
foreach ($this->aContent as $v) {
|
||||||
|
// echo "失联客机";
|
||||||
|
$sStr .= "\n\n".$v[0].":".$v[1]."。";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sStr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rowAdd($sName, $iFlowToday, $iUseWidth, $iMaxWidth, $iLimitDay = false) {
|
||||||
|
|
||||||
|
$iUseWidth = number_format(Tools::flowToGB($iUseWidth) / 1024, 2);
|
||||||
|
$iMaxWidth = number_format(Tools::flowToGB($iMaxWidth) / 1024, 2);
|
||||||
|
$iFlowToday = Tools::flowToGB($iFlowToday);
|
||||||
|
|
||||||
|
if ($iMaxWidth <= 0) {
|
||||||
|
$sFlowRate = 0;
|
||||||
|
} else {
|
||||||
|
$sFlowRate = number_format($iUseWidth / $iMaxWidth * 100, 0, '.', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sFlowRate > 70) {
|
||||||
|
$sFlowEmoji = '🪫';
|
||||||
|
} else {
|
||||||
|
$sFlowEmoji = '🔋';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sFlowMix = $sFlowEmoji.' '.(100 - $sFlowRate)."%(".$iMaxWidth." - ".$iUseWidth." = ".$iMaxWidth - $iUseWidth.")【 消耗:".$iFlowToday."g";
|
||||||
|
|
||||||
|
if ($iLimitDay > 0) {
|
||||||
|
$sFlowMix .= ",距离重置:".$iLimitDay." 天";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sFlowMix .= " 】";
|
||||||
|
|
||||||
|
$this->aContent[] = [$sName, $sFlowMix];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user