diff --git a/resources/views/tabler/admin/node/create.tpl b/resources/views/tabler/admin/node/create.tpl
index 58473738..c5828e90 100755
--- a/resources/views/tabler/admin/node/create.tpl
+++ b/resources/views/tabler/admin/node/create.tpl
@@ -154,11 +154,29 @@
+
+
+
流量设置
diff --git a/resources/views/tabler/admin/node/edit.tpl b/resources/views/tabler/admin/node/edit.tpl
index de5fd72f..92a1abca 100755
--- a/resources/views/tabler/admin/node/edit.tpl
+++ b/resources/views/tabler/admin/node/edit.tpl
@@ -171,6 +171,24 @@
+
+
+
流量设置
diff --git a/src/Command/Cron.php b/src/Command/Cron.php
index b0f86b2a..bd755605 100755
--- a/src/Command/Cron.php
+++ b/src/Command/Cron.php
@@ -55,7 +55,9 @@ EOL;
time() - Config::obtain('last_daily_job_time') > 86399
) {
$jobs->cleanDb();
- $jobs->resetNodeBandwidth();
+// $jobs->resetNodeBandwidth();
+ $jobs->resetDuckBandwidth();
+ $jobs->bandwidthMerge();
$jobs->resetFreeUserBandwidth();
$jobs->sendDailyTrafficReport();
diff --git a/src/Controllers/Admin/NodeController.php b/src/Controllers/Admin/NodeController.php
index 0e0d7aa1..35c2e9e3 100755
--- a/src/Controllers/Admin/NodeController.php
+++ b/src/Controllers/Admin/NodeController.php
@@ -39,6 +39,9 @@ final class NodeController extends BaseController
'node_bandwidth' => '已用流量/GB',
'bandwidthlimit_resetday' => '重置日',
'order_group' => '排序组',
+ 'zhuanfa_code' => '转发 code',
+ 'duck_code' => 'duck code',
+ 'memo' => 'memo',
],
];
@@ -59,6 +62,9 @@ final class NodeController extends BaseController
'node_bandwidth_limit',
'bandwidthlimit_resetday',
'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->dynamic_rate_type = $request->getParam('dynamic_rate_type') ?? 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([
'max_rate' => $request->getParam('max_rate') ?? 1,
'max_rate_time' => $request->getParam('max_rate_time') ?? 22,
@@ -195,6 +204,9 @@ final class NodeController extends BaseController
$node->name = $request->getParam('name');
$node->node_group = $request->getParam('node_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->traffic_rate = $request->getParam('traffic_rate') ?? 1;
$node->is_dynamic_rate = $request->getParam('is_dynamic_rate') === 'true' ? 1 : 0;
diff --git a/src/Controllers/TestController.php b/src/Controllers/TestController.php
index f0dde272..9f856ff7 100755
--- a/src/Controllers/TestController.php
+++ b/src/Controllers/TestController.php
@@ -13,12 +13,18 @@ use App\Services\Auth as AuthService;
use App\Models\Product;
use App\Models\Config;
use App\Models\UserCoupon;
+use App\Services\Cron as CronService;
use App\Services\Reward;
final class TestController extends BaseController
{
public function index(ServerRequest $request, Response $response, array $args): ResponseInterface
{
+ $jobs = new CronService();
+
+ $jobs->bandwidthMerge();
+
+ exit;
if ($_ENV['is_loc'] !== true) {
exit;
}
diff --git a/src/Controllers/User/TicketController.php b/src/Controllers/User/TicketController.php
index 92fc6b36..d2c0fd26 100755
--- a/src/Controllers/User/TicketController.php
+++ b/src/Controllers/User/TicketController.php
@@ -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);
@@ -164,7 +164,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标题:".$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);
diff --git a/src/Models/Ducks.php b/src/Models/Ducks.php
new file mode 100755
index 00000000..f8cfd974
--- /dev/null
+++ b/src/Models/Ducks.php
@@ -0,0 +1,16 @@
+where('bandwidthlimit_resetday', date('d'))->update(['node_bandwidth' => 0]);
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
{
(new User())->query()->update(['transfer_today' => 0]);
diff --git a/src/Services/TomTool/TgSendFormat.php b/src/Services/TomTool/TgSendFormat.php
new file mode 100755
index 00000000..58c203a4
--- /dev/null
+++ b/src/Services/TomTool/TgSendFormat.php
@@ -0,0 +1,63 @@
+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];
+
+ }
+
+}