From d9bcb95aa78d5d857c3bdf3b688618006c4af328 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Sat, 14 Jun 2025 14:18:06 +0800 Subject: [PATCH] no message --- resources/views/tabler/user/index.tpl | 3 ++- src/Command/Cron.php | 10 +++---- src/Controllers/TestController.php | 4 +-- src/Services/Cron.php | 38 ++++++++++++++++++++++++--- src/Services/Maps.php | 14 +++++++--- src/Services/Reward.php | 6 +++++ src/Services/Tg/Hook/Mod/User.php | 13 ++++----- 7 files changed, 64 insertions(+), 24 deletions(-) diff --git a/resources/views/tabler/user/index.tpl b/resources/views/tabler/user/index.tpl index 4e78176a..c68ce9a9 100755 --- a/resources/views/tabler/user/index.tpl +++ b/resources/views/tabler/user/index.tpl @@ -554,9 +554,10 @@ {else} {$public_setting['checkin_min']} MB {/if} + ,未购买套餐用户获得一天试用时长。

- (免费体验用户可依靠签到持续体验) + (免费用户可依靠签到持续体验)

上次签到时间:{$user->lastCheckInTime()} diff --git a/src/Command/Cron.php b/src/Command/Cron.php index 9eaac085..566fdae8 100755 --- a/src/Command/Cron.php +++ b/src/Command/Cron.php @@ -56,11 +56,11 @@ EOL; ) { $jobs->cleanDb(); // $jobs->resetNodeBandwidth(); - $jobs->resetDuckBandwidth(); - $jobs->reportBandWidth(); - $jobs->resetFreeUserBandwidth(); - $jobs->sendDailyTrafficReport(); - $jobs->clearTodayWidth(); + $jobs->resetDuckBandwidth(); // 重置每日的duck流量 + $jobs->reportBandWidth(); // 报告流量给tg + $jobs->resetFreeUserBandwidth(); // 重置免费用户的流量 + $jobs->sendDailyTrafficReport(); // 流量报告?不重要 + $jobs->clearTodayWidth(); // 重置每日的用户使用流量 // 每日清除前一天残留TgStep $jobs->clearTgStep(); diff --git a/src/Controllers/TestController.php b/src/Controllers/TestController.php index 23d893c8..fd90799f 100755 --- a/src/Controllers/TestController.php +++ b/src/Controllers/TestController.php @@ -81,9 +81,9 @@ final class TestController extends BaseController public function test2() { - echo 1; $oCron = new CronService(); - $oCron->resetFreeUserBandwidth(); +// $oCron->expirePaidUserAccount(); + $oCron->expireFreeUserAccount(); } diff --git a/src/Services/Cron.php b/src/Services/Cron.php index fb3aeb9a..406a6d4b 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -312,21 +312,42 @@ final class Cron echo Tools::toDateTime(time()) . ' 节点离线检测完成' . PHP_EOL; } + + // 新增,专门检测处理体验用户 + // class=1为免费体验用户,免费体验到期转为0彻底不能用 + public static function expireFreeUserAccount(): void + { + $paidUsers = (new User())->where('class', 1)->get(); + + foreach ($paidUsers as $user) { + if (strtotime($user->class_expire) < time()) { + $user->u = 0; + $user->d = 0; + $user->transfer_today = 0; + $user->class = 0; + $user->save(); + } + } + + echo Tools::toDateTime(time()) . ' 体验用户过期检测完成' . PHP_EOL; + } // 付费用户过期检测 - // class > 0,所以不包含注册试用帐户 + // 现在,付费用户是2+,体验用户是1。付费到期转为体验。 public static function expirePaidUserAccount(): void { - $paidUsers = (new User())->where('class', '>', 0)->get(); + $paidUsers = (new User())->where('class', '>=', 2)->get(); foreach ($paidUsers as $user) { if (strtotime($user->class_expire) < time()) { $text = '您好,系统发现您的套餐已经过期了。'; $reset_traffic = $_ENV['class_expire_reset_traffic']; + $reset_day = $_ENV['class_expire_reset_day']; if ($reset_traffic >= 0) { $user->transfer_enable = Tools::toGB($reset_traffic); - $text .= '已转为免费体验帐户,赠送' . $reset_traffic . 'GB体验流量。'; + $user->class_expire = date('Y-m-d H:i:s', strtotime("+$reset_day days")); + $text .= '已转为免费体验帐户,赠送' . $reset_traffic . 'GB体验流量,'.$reset_day.'天体验时长。'; } // todo 反水 @@ -341,7 +362,7 @@ final class Cron $user->u = 0; $user->d = 0; $user->transfer_today = 0; - $user->class = 0; + $user->class = 1; $user->save(); } @@ -1024,6 +1045,9 @@ final class Cron echo Tools::toDateTime(time()) . ' 重设用户每日流量完成' . PHP_EOL; } + // 这是那个每月几日重置 + // 是重置免费用户 + // 现在没用了,傻逼功能。用户光有流量没有等级照样用不了,取消等级限制则变成所有用户都运作,根本不合理 public static function resetFreeUserBandwidth(): void { $freeUsers = (new User())->where('class', 0) @@ -1048,6 +1072,11 @@ final class Cron echo Tools::toDateTime(time()) . ' 免费用户流量重置完成' . PHP_EOL; } + + public static function resetFreeUserBandwidth_new(): void + { + echo 1111; + } // 财务日报,好像没用 public static function sendDailyFinanceMail(): void @@ -1131,6 +1160,7 @@ final class Cron echo Tools::toDateTime(time()) . ' 成功发送财务月报' . PHP_EOL; } + // 流量提醒 public static function sendPaidUserUsageLimitNotification(): void { $paidUsers = (new User())->where('class', '>', 0)->get(); diff --git a/src/Services/Maps.php b/src/Services/Maps.php index fa707b64..ab8f34b0 100755 --- a/src/Services/Maps.php +++ b/src/Services/Maps.php @@ -10,20 +10,26 @@ final class Maps public static function levelToClass($level): string { switch ($level) { + case 0: + $sClass = '无套餐'; + break; case 1: - $sClass = '轻量套餐'; + $sClass = '试用套餐'; break; case 2: - $sClass = '普通套餐'; + $sClass = '轻量套餐'; break; case 3: - $sClass = '旗舰套餐'; + $sClass = '普通套餐'; break; case 4: + $sClass = '旗舰套餐'; + break; + case 5: $sClass = '专业套餐'; break; default: - $sClass = '免费体验'; + $sClass = '无套餐'; } return $sClass; } diff --git a/src/Services/Reward.php b/src/Services/Reward.php index c81e5cb1..9f0c4e18 100755 --- a/src/Services/Reward.php +++ b/src/Services/Reward.php @@ -155,6 +155,12 @@ final class Reward if ($traffic !== 0) { $user->transfer_enable += Tools::toMB($traffic); $user->last_check_in_time = time(); + + if ($user->class == 0) { + $user->class = 1; + $user->class_expire = date("Y-m-d H:i:s", strtotime("+1 day")); + } + $user->save(); } diff --git a/src/Services/Tg/Hook/Mod/User.php b/src/Services/Tg/Hook/Mod/User.php index f3c96cb4..e18e3284 100644 --- a/src/Services/Tg/Hook/Mod/User.php +++ b/src/Services/Tg/Hook/Mod/User.php @@ -42,16 +42,13 @@ final class User extends Base $iLimit = $aParam['aArg'][1] ?? 1; // 默认五条 $sType = $aParam['aOption'][1] ?? "class0"; - if ($sType) { - if ($sType == "class1") { - $aa = ">"; - } else if ($sType == "class0") { - $sType = ">="; - } + if ($sType == "class1") { + $sTypePre = ">"; + } else if ($sType == "class0") { + $sTypePre = ">="; } - - $aUser = ModelUser::where("class", $sType, 0)->orderBy("id", "desc")->limit($iLimit)->get()->toArray(); + $aUser = ModelUser::where("class", $sTypePre, 0)->orderBy("id", "desc")->limit($iLimit)->get()->toArray(); foreach ($aUser as $row) { $sMsg = json_encode($this->format($row), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);