From 4e2ba8f2be6bb5793e70d6e6aafae8533af8eeb4 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Fri, 2 May 2025 17:56:40 +0800 Subject: [PATCH] no message --- src/Controllers/TestController.php | 4 ++-- src/Services/Cron.php | 23 ++++++++++++++++++++--- src/Services/Tg/Hook/Mod/User.php | 10 ++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Controllers/TestController.php b/src/Controllers/TestController.php index a1e0d12b..39c85984 100755 --- a/src/Controllers/TestController.php +++ b/src/Controllers/TestController.php @@ -82,8 +82,8 @@ final class TestController extends BaseController public function test2() { - $oCron = new Cron(); - $oCron->boot(); + $oCron = new CronService(); + $oCron->resetFreeUserBandwidth(); } diff --git a/src/Services/Cron.php b/src/Services/Cron.php index 2efcfaad..fb3aeb9a 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -43,6 +43,7 @@ use const PHP_EOL; final class Cron { + // 数据库清理 public static function cleanDb(): void { (new SubscribeLog())->where( @@ -62,11 +63,14 @@ final class Cron echo Tools::toDateTime(time()) . ' 数据库清理完成' . PHP_EOL; } + + // 清理tg step,暂时没用 public static function clearTgStep(): void { TgStep::where("date", "<=", date('Y-m-d', strtotime('-1 day')))->delete(); } + // 统计用户数据,入库,发送tg public static function userCount(): void { $sPrevDate = date("Y-m-d", strtotime("-1 day")); @@ -208,6 +212,7 @@ final class Cron // // } + // 限制帐户检测 public static function detectInactiveUser(): void { $checkin_days = Config::obtain('detect_inactive_user_checkin_days'); @@ -232,6 +237,7 @@ final class Cron ' 检测到 ' . (new User())->where('is_inactive', 1)->count() . ' 个账户处于闲置状态' . PHP_EOL; } + // 节点掉线检测 public static function detectNodeOffline(): void { $nodes = (new Node())->where('type', 1)->get(); @@ -307,6 +313,8 @@ final class Cron echo Tools::toDateTime(time()) . ' 节点离线检测完成' . PHP_EOL; } + // 付费用户过期检测 + // class > 0,所以不包含注册试用帐户 public static function expirePaidUserAccount(): void { $paidUsers = (new User())->where('class', '>', 0)->get(); @@ -390,6 +398,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 付费用户过期检测完成' . PHP_EOL; } + // 邮件队列处理 public static function processEmailQueue(): void { if ((new EmailQueue())->count() === 0) { @@ -639,6 +648,7 @@ final class Cron echo Tools::toDateTime(time()) . ' TABP订单激活处理完成' . PHP_EOL; } + // 流量包激活,暂时没用 public static function processBandwidthOrderActivation(): void { $users = User::all(); @@ -668,9 +678,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 流量包订单激活处理完成' . PHP_EOL; } - /** - * @throws Exception - */ + // 时间包激活,暂时没用 public static function processTimeOrderActivation(): void { $users = User::all(); @@ -765,6 +773,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 重设节点流量完成' . PHP_EOL; } + // 机器到日期重置流量 public static function resetDuckBandwidth(): void { (new Ducks())->where('width_reset_day', date('d'))->update(['use_width' => 0]); @@ -779,6 +788,7 @@ final class Cron // echo Tools::toDateTime(time()) . ' 重设机器流量完成' . PHP_EOL; // } + // 每小时,统计节点流量,入库,tg警报 public static function mergeBandWidth(): void { @@ -832,6 +842,7 @@ final class Cron } + // 每日报表 public static function reportBandWidth(): void { @@ -912,6 +923,7 @@ final class Cron } + // 每日清空duck和转发的每日流量 public static function clearTodayWidth(): void { Ducks::query()->update(['today_width' => 0]); @@ -1003,6 +1015,8 @@ final class Cron } + + // 用户流量每日重置 public static function resetTodayBandwidth(): void { (new User())->query()->update(['transfer_today' => 0]); @@ -1035,6 +1049,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 免费用户流量重置完成' . PHP_EOL; } + // 财务日报,好像没用 public static function sendDailyFinanceMail(): void { $today = strtotime('00:00:00'); @@ -1068,6 +1083,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 成功发送财务日报' . PHP_EOL; } + // 财务周报,好像没用 public static function sendWeeklyFinanceMail(): void { $today = strtotime('00:00:00'); @@ -1091,6 +1107,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 成功发送财务周报' . PHP_EOL; } + // 财务越好,好像没用 public static function sendMonthlyFinanceMail(): void { $today = strtotime('00:00:00'); diff --git a/src/Services/Tg/Hook/Mod/User.php b/src/Services/Tg/Hook/Mod/User.php index de55756b..0b2933ce 100644 --- a/src/Services/Tg/Hook/Mod/User.php +++ b/src/Services/Tg/Hook/Mod/User.php @@ -40,6 +40,16 @@ final class User extends Base { // $sField = $aParam['aOption'][1]; $iLimit = $aParam['aArg'][1] ?? 1; // 默认五条 + $sType = $aParam['aOption'][1] ?? "class0"; + + if ($sType) { + if ($sType == "class1") { + $aa = ">"; + } else if ($sType == "class0") { + $sType = ">="; + } + } + $aUser = ModelUser::where("class", '>', 0)->orderBy("id", "desc")->limit($iLimit)->get()->toArray();