| 12345678910111213141516171819202122 |
- <?php
- namespace App\Services\Reporting;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Schema;
- class ReportActivity
- {
- public static function telegram($user): void
- {
- if (request()->path() !== 'api/onMessage' || (int) ($user->from ?? 0) === 2) return;
- try {
- if (!Schema::hasTable('reporting_activity')) return;
- $now = now('Asia/Shanghai')->format('Y-m-d H:i:00');
- $parent = Schema::hasTable('share_members') ? DB::table('share_members')->where('user_id', $user->id)->where('bound_at', '<=', $now)->value('parent_user_id') : null;
- DB::table('reporting_activity')->insertOrIgnore(['user_id' => $user->id, 'agent_id' => $user->agent_id, 'inviter_id' => $parent,
- 'client_platform' => 'unknown', 'session_hash' => hash('sha256', 'telegram:' . $user->id), 'observed_at' => $now]);
- } catch (\Throwable $e) { Log::error('reporting_telegram_activity_failed', ['exception' => get_class($e)]); }
- }
- }
|