From a74ef3f56fbf6d043ad78b0c7df0a924a4c26e88 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Sat, 18 Oct 2025 13:55:40 +0800 Subject: [PATCH] no message --- src/Command/Cron.php | 1 + src/Controllers/User/ProductController.php | 2 +- src/Services/Cron.php | 49 ++++++++++++++++++++++ src/Services/Tg/Hook/Mod/Test.php | 6 +++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/Command/Cron.php b/src/Command/Cron.php index 0b494c082..af917ea4c 100755 --- a/src/Command/Cron.php +++ b/src/Command/Cron.php @@ -68,6 +68,7 @@ EOL; ) { $jobs->cleanDb(); // $jobs->resetNodeBandwidth(); + $jobs->reportPayUser(); // 付费用户统计 $jobs->resetDuckBandwidth(); // 重置每日的duck流量 $jobs->reportBandWidth(); // 报告流量给tg $jobs->resetFreeUserBandwidth(); // 重置免费用户的流量 diff --git a/src/Controllers/User/ProductController.php b/src/Controllers/User/ProductController.php index 2cd222009..27d860e51 100755 --- a/src/Controllers/User/ProductController.php +++ b/src/Controllers/User/ProductController.php @@ -47,7 +47,7 @@ final class ProductController extends BaseController } else if ($aProductRow["class_time"] < 180) { $aProductRow["time_group_str"] = "季付"; } else if ($aProductRow["class_time"] < 360) { - $aProductRow["time_group_str"] = "半年"; + $aProductRow["time_group_str"] = "半年付"; } else { $aProductRow["time_group_str"] = "年付"; } diff --git a/src/Services/Cron.php b/src/Services/Cron.php index eaa8bc465..1fd2fba79 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -51,6 +51,7 @@ use function time; use const PHP_EOL; use App\Models\Smtp as ModelSmtp; //use Illuminate\Support\Facades\DB; // 线上可能要开 +use Carbon\Carbon; final class Cron @@ -146,6 +147,54 @@ final class Cron TgStep::where("date", "<=", date('Y-m-d', strtotime('-1 day')))->delete(); } + // 付费用户统计 + public static function reportPayUser(): void + { + $iPayClass = $_ENV["user_payClass"]; + + $now = Carbon::now(); + + $threeMonthsAgo = $now->copy()->subMonths(3); + $sixMonthsAgo = $now->copy()->subMonths(6); + $twelveMonthsAgo = $now->copy()->subMonths(12); + + $aCount = [ + '三月' => DB::table('user') + ->where('class', '>=', $iPayClass) + ->where('reg_date', '>', $threeMonthsAgo) + ->count(), + + '半年' => DB::table('user') + ->where('class', '>=', $iPayClass) + ->whereBetween('reg_date', [$sixMonthsAgo, $threeMonthsAgo]) + ->count(), + + '一年' => DB::table('user') + ->where('class', '>=', $iPayClass) + ->whereBetween('reg_date', [$twelveMonthsAgo, $sixMonthsAgo]) + ->count(), + + '一年+' => DB::table('user') + ->where('class', '>=', $iPayClass) + ->where('reg_date', '<=', $twelveMonthsAgo) + ->count(), + + '总共' => DB::table('user') + ->where('class', '>=', $iPayClass) + ->count(), + ]; + + $str = "# 付费用户计数"; + foreach ($aCount as $k => $v) { + $str .= "\n".$k.":".$v; + } + + $oTelegramV2 = new TelegramV2("base"); + $oTelegramV2->setMsgType("html"); + $oTelegramV2->send($str, "str"); + + } + // 统计用户数据,入库,发送tg public static function userCount(): void { diff --git a/src/Services/Tg/Hook/Mod/Test.php b/src/Services/Tg/Hook/Mod/Test.php index 399f289dd..70ec6d42f 100644 --- a/src/Services/Tg/Hook/Mod/Test.php +++ b/src/Services/Tg/Hook/Mod/Test.php @@ -180,6 +180,12 @@ final class Test extends Base return 1; } + public function reportPayUser() + { + $oJob = new Cron(); + $oJob->reportPayUser(); + } + public function orderPay() { $job = new Cron();