no message
This commit is contained in:
parent
0758471cf8
commit
dfdcc4afc6
@ -84,6 +84,9 @@ EOL;
|
||||
// $jobs->visitorCount();
|
||||
// 每日统计报表 - 用户
|
||||
$jobs->userCount();
|
||||
|
||||
// mail_log清理
|
||||
$jobs->mailLog_clear();
|
||||
|
||||
if (Config::obtain('enable_detect_inactive_user')) {
|
||||
$jobs->detectInactiveUser();
|
||||
|
||||
16
src/Models/MailLog.php
Executable file
16
src/Models/MailLog.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
//declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
//use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class MailLog extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'mail_log';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@ -31,6 +31,7 @@ use App\Models\PlanActivated;
|
||||
use App\Models\PlanExpired;
|
||||
use App\Models\PlanPending;
|
||||
use App\Models\PlanQueue;
|
||||
use App\Models\MailLog;
|
||||
use App\Services\TomTool\TgSendFormat;
|
||||
use App\Services\IM\Telegram;
|
||||
use App\Services\IM\TelegramV2;
|
||||
@ -1803,9 +1804,20 @@ final class Cron
|
||||
// echo Tools::toDateTime(time()) . ' 免费用户流量重置完成' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
// mail_log 清理
|
||||
public static function mailLog_clear()
|
||||
{
|
||||
$sDateEnd = date("Y-m-d", strtotime("-7 day"));
|
||||
|
||||
$iDelCount = MailLog::whereDate("date", "<", $sDateEnd)->delete();
|
||||
|
||||
echo Tools::toDateTime(time()) . " 删除mailLog条:$iDelCount" . PHP_EOL;
|
||||
}
|
||||
|
||||
public static function resetFreeUserBandwidth_new(): void
|
||||
{
|
||||
echo 1111;
|
||||
// echo 1111;
|
||||
}
|
||||
|
||||
// 财务日报,好像没用
|
||||
|
||||
@ -7,6 +7,7 @@ namespace App\Services\Mail;
|
||||
use App\Models\Config;
|
||||
use Exception;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use App\Models\MailLog as ModelMailLog;
|
||||
|
||||
final class Smtp extends Base
|
||||
{
|
||||
@ -54,23 +55,18 @@ final class Smtp extends Base
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
|
||||
// $mail->send();
|
||||
|
||||
$sMsg = "";
|
||||
$sError = "";
|
||||
|
||||
if (!$mail->send()) {
|
||||
$sMsg = '发送失败: ' . $mail->ErrorInfo;
|
||||
// file_put_contents('mail_log.txt', date('Y-m-d H:i:s') . " - $sMsg" . $to . PHP_EOL, FILE_APPEND);
|
||||
// echo '发送失败: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
// 每次成功后,将记录写入 log.txt
|
||||
$sMsg = date('Y-m-d H:i:s') . " - Sent to: " . $to . PHP_EOL;
|
||||
// file_put_contents('mail_log.txt', , FILE_APPEND);
|
||||
// echo '发送成功';
|
||||
$sError = $mail->ErrorInfo;
|
||||
}
|
||||
|
||||
// echo $sMsg;
|
||||
// file_put_contents('mail_log/'.date('Y-m-d').'.txt', date('Y-m-d H:i:s') . " - $sMsg" . $to . PHP_EOL, FILE_APPEND);
|
||||
|
||||
$oMailLog = new ModelMailLog();
|
||||
$oMailLog->to = $to;
|
||||
$oMailLog->title = $subject;
|
||||
$oMailLog->date = date("Y-m-d");
|
||||
$oMailLog->error = $sError;
|
||||
$oMailLog->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
44
src/Services/Tg/Hook/Mod/MailLog.php
Normal file
44
src/Services/Tg/Hook/Mod/MailLog.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Tg\Hook\Mod;
|
||||
|
||||
use App\Models\MailLog as ModelMailLog;
|
||||
use App\Services\Tg\Hook\Dog;
|
||||
|
||||
class MailLog extends Base {
|
||||
|
||||
private $oDog;
|
||||
|
||||
public function __construct($aUpdate)
|
||||
{
|
||||
|
||||
$this->oDog = new Dog(new ModelMailLog());
|
||||
$this->oDog->_setDogName("mailLog"); // 必须,me用,正常就是类名,只不过后期没准改名,所以就这里写死
|
||||
// $this->oDog->_setPrimaryKey("code"); // 可选,默认id
|
||||
// $this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
|
||||
}
|
||||
|
||||
public function __call($sName, $aArg)
|
||||
{
|
||||
return $this->oDog->$sName($aArg[0]);
|
||||
}
|
||||
|
||||
public function show($aParam)
|
||||
{
|
||||
$sDate = $aParam["aArg"][1] ?? date("Y-m-d");
|
||||
|
||||
$aMailLog = ModelMailLog::whereDate("date", $sDate)->get()->toArray();
|
||||
|
||||
return $this->toJson($aMailLog);
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$aCount = ModelMailLog::selectRaw('date, count(*) as total')
|
||||
->groupBy('date')
|
||||
->get();
|
||||
|
||||
return $this->toJson($aCount);
|
||||
}
|
||||
|
||||
}
|
||||
@ -171,8 +171,9 @@ final class Test extends Base
|
||||
public function badian()
|
||||
{
|
||||
$jobs = new Cron();
|
||||
$jobs->userCount();
|
||||
// $jobs->userCount();
|
||||
// $jobs->resetTodayBandwidth();
|
||||
$jobs->mailLog_clear();
|
||||
}
|
||||
|
||||
public function orderCombo()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user