no message
This commit is contained in:
parent
74f61921b3
commit
5bbf50e8b2
@ -35,7 +35,7 @@ $oHttp->aData = [
|
||||
'type' => 'private'
|
||||
],
|
||||
'date' => 1610000000,
|
||||
'text' => 'reply 2'
|
||||
'text' => '/nodeOption_server_112 sssasasd'
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
@ -63,6 +63,9 @@ EOL;
|
||||
|
||||
// 每日清除前一天残留TgStep
|
||||
$jobs->clearTgStep();
|
||||
|
||||
// 每日统计报表
|
||||
$jobs->visitorCount();
|
||||
|
||||
if (Config::obtain('enable_detect_inactive_user')) {
|
||||
$jobs->detectInactiveUser();
|
||||
|
||||
@ -13,6 +13,7 @@ use App\Services\Auth as AuthService;
|
||||
use App\Models\Product;
|
||||
use App\Models\Config;
|
||||
use App\Models\UserCoupon;
|
||||
use App\Services\TomTool\VisitorCount;
|
||||
|
||||
final class FrontController extends BaseController
|
||||
{
|
||||
@ -22,12 +23,13 @@ final class FrontController extends BaseController
|
||||
public function index(ServerRequest $request, Response $response, array $args): ResponseInterface
|
||||
{
|
||||
|
||||
$sAffCode = $this->antiXss->xss_clean($args['code']);
|
||||
|
||||
if ($sAffCode) {
|
||||
if (@$args['code']) {
|
||||
$sAffCode = $this->antiXss->xss_clean($args['code']);
|
||||
setcookie('affCode', $sAffCode, (time() + (86400 * 1)), "/");
|
||||
}
|
||||
|
||||
VisitorCount::From();
|
||||
|
||||
$user = AuthService::getUser();
|
||||
|
||||
$taocan = (new Product())->where('status', '1')
|
||||
|
||||
@ -28,7 +28,7 @@ final class TestController extends BaseController
|
||||
{
|
||||
$jobs = new CronService();
|
||||
|
||||
$jobs->clearTgStep();
|
||||
$jobs->visitorCount();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
15
src/Models/CountVisitor.php
Executable file
15
src/Models/CountVisitor.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
final class CountVisitor extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'Count_visitor';
|
||||
|
||||
|
||||
}
|
||||
15
src/Models/Visitor.php
Executable file
15
src/Models/Visitor.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
final class Visitor extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'visitor';
|
||||
|
||||
|
||||
}
|
||||
@ -19,6 +19,8 @@ use App\Models\User;
|
||||
use App\Models\TgStep;
|
||||
use App\Models\Zhuanfas;
|
||||
use App\Models\Ducks;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\CountVisitor;
|
||||
use App\Services\TomTool\TgSendFormat;
|
||||
use App\Services\IM\Telegram;
|
||||
use App\Utils\Tools;
|
||||
@ -61,6 +63,38 @@ final class Cron
|
||||
{
|
||||
TgStep::where("date", "<=", date('Y-m-d', strtotime('-1 day')))->delete();
|
||||
}
|
||||
|
||||
public static function visitorCount(): void
|
||||
{
|
||||
$oVisitor = Visitor::select('from', DB::raw('count(*) as count'))
|
||||
->groupBy('from')
|
||||
->get();
|
||||
|
||||
foreach ($oVisitor as $row) {
|
||||
|
||||
$oCountVisitor = new CountVisitor();
|
||||
$oCountVisitor->from = $row->from;
|
||||
$oCountVisitor->count = $row->count;
|
||||
$oCountVisitor->date = date('Y-m-d', strtotime('-1 day'));
|
||||
$oCountVisitor->save();
|
||||
|
||||
}
|
||||
|
||||
Visitor::truncate();
|
||||
|
||||
// tg报表
|
||||
$aCountVisitor = CountVisitor::where('date', date('Y-m-d', strtotime('-1 day')))->get()->toArray();
|
||||
|
||||
$sTgReport = '';
|
||||
foreach ($aCountVisitor as $row) {
|
||||
|
||||
$sTgReport .= $row["from"].":".$row["count"]."\n";
|
||||
|
||||
}
|
||||
|
||||
(new Telegram())->send(0, $sTgReport);
|
||||
|
||||
}
|
||||
|
||||
public static function detectInactiveUser(): void
|
||||
{
|
||||
|
||||
37
src/Services/TomTool/VisitorCount.php
Executable file
37
src/Services/TomTool/VisitorCount.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\TomTool;
|
||||
|
||||
//use Psr\Http\Message\ResponseInterface;
|
||||
//use Slim\Http\Response;
|
||||
//use Slim\Http\ServerRequest;
|
||||
//use Smarty\Exception as SmartyException;
|
||||
use App\Models\Visitor;
|
||||
|
||||
final class VisitorCount
|
||||
{
|
||||
|
||||
public static function From()
|
||||
{
|
||||
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
|
||||
$oVisitorFrom = new Visitor();
|
||||
$oVisitorFrom->date = date("Y-m-d");
|
||||
$oVisitorFrom->from = $_SERVER['HTTP_REFERER'];
|
||||
$oVisitorFrom->save();
|
||||
|
||||
} else {
|
||||
|
||||
$oVisitorFrom = new Visitor();
|
||||
$oVisitorFrom->date = date("Y-m-d");
|
||||
$oVisitorFrom->from = "直接";
|
||||
$oVisitorFrom->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user