Files
ProxyPanel/app/Console/Commands/AutoReportNode.php
兔姬桑 66c3c53038 2.4.0 phase 1: 大量代码优化与改写
1. models 关系规范化;
2. 本地-在线 订单处理改写;
3. 优化用户界面节点的查表操作;
4. 半修复 VNet SSR版需要面板主动提交用户信息变动的问题;(节点等级,用户分组,Node信息修改 主动通知节点尚未添加);
5. 简化并提取出了 返利佣金相关处理逻辑;
2020-08-16 12:55:18 +08:00

44 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Components\PushNotification;
use App\Models\Node;
use App\Models\NodeDailyDataFlow;
use Illuminate\Console\Command;
use Log;
class AutoReportNode extends Command {
protected $signature = 'autoReportNode';
protected $description = '自动报告节点昨日使用情况';
public function handle(): void {
$jobStartTime = microtime(true);
if(sysConfig('node_daily_report')){
$nodeList = Node::whereStatus(1)->get();
if($nodeList->isNotEmpty()){
$msg = "|节点|上行流量|下行流量|合计|\r\n| :------ | :------ | :------ |\r\n";
foreach($nodeList as $node){
$log = NodeDailyDataFlow::whereNodeId($node->id)
->whereDate('created_at', date("Y-m-d", strtotime('-1 days')))
->first();
if($log){
$msg .= '|'.$node->name.'|'.flowAutoShow($log->u).'|'.flowAutoShow($log->d).'|'.$log->traffic."\r\n";
}else{
$msg .= '|'.$node->name.'|'.flowAutoShow(0).'|'.flowAutoShow(0)."|0B\r\n";
}
}
PushNotification::send('节点昨日使用情况', $msg);
}
}
$jobEndTime = microtime(true);
$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
}