diff --git a/src/Services/Cron.php b/src/Services/Cron.php index a6b6e2428..8ec9d0223 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -1667,7 +1667,6 @@ final class Cron $sTgReport = $oTgSendFormat->typeA(); (new Telegram())->send(0, $sTgReport); - } // public static function mergeBandWidth__old(): void diff --git a/src/Services/Tg/Hook/Mod/Node.php b/src/Services/Tg/Hook/Mod/Node.php index 820bad2b6..b3fc98b66 100644 --- a/src/Services/Tg/Hook/Mod/Node.php +++ b/src/Services/Tg/Hook/Mod/Node.php @@ -36,6 +36,63 @@ class Node extends Base { } + public function portModifyDone($aParam) + { + $aParam["bDone"] = true; + + return $this->portModify($aParam); + } + + public function portModify($aParam) + { + $sPortType = $aParam["aOption"][1] ?? 'node'; + $sPortLike = $aParam["aOption"][2] ?? 0; + $sPortSet = $aParam["aArg"][1] ?? 0; + $bDone = $aParam["bDone"] ?? false; + + if (!$sPortLike || !$sPortSet) { + return "缺少参数"; + } + + if ($sPortSet == "?") { + return "__[portType:node]__[portLike] [portSet]"; + } + + if ($sPortType == 'node') { + $sPortName = "offset_port_node"; + } else if ($sPortType = 'user') { + $sPortName = "offset_port_user"; + } else { + return "protyType非法"; + } + + $oNodes = ModelNode::where("custom_config", "like", "%{$sPortLike}%") + ->get() + ->filter(function ($oNode) use ($sPortName) { + $aCustomConfig = json_decode($oNode->custom_config, true); + return isset($aCustomConfig[$sPortName]); + }); + $iCount = $oNodes->count(); + + if (!$bDone) { + $s = "匹配一下数据,{$iCount}条。确认加done。 \n\n"; + $s .= $this->toJson($oNodes->toArray()); + return $s; + } + + $i = 0; + foreach ($oNodes as $oNode) { + $aCustomConfig = json_decode($oNode->custom_config, true); + $aCustomConfig[$sPortName] = $sPortSet; + $jCustomConfig = json_encode($aCustomConfig); + + $oNode->custom_config = $jCustomConfig; + $i += $oNode->save(); + } + + return "完成,处理{$i}条。"; + } + public function fly($aParam) { // $sCmd = $aParam["cmd"] ?? "";