|
@@ -40,7 +40,7 @@ final class Cron
|
|
|
|
|
|
foreach ($users as $user) {
|
|
foreach ($users as $user) {
|
|
$transfer_total = $user->transfer_total;
|
|
$transfer_total = $user->transfer_total;
|
|
- $transfer_total_last = UserHourlyUsage::where('user_id', $user->id)->orderBy('id', 'desc')->first();
|
|
|
|
|
|
+ $transfer_total_last = (new UserHourlyUsage())->where('user_id', $user->id)->orderBy('id', 'desc')->first();
|
|
|
|
|
|
if ($transfer_total_last === null) {
|
|
if ($transfer_total_last === null) {
|
|
$transfer_total_last = 0;
|
|
$transfer_total_last = 0;
|
|
@@ -61,15 +61,15 @@ final class Cron
|
|
|
|
|
|
public static function cleanDb(): void
|
|
public static function cleanDb(): void
|
|
{
|
|
{
|
|
- SubscribeLog::where(
|
|
|
|
|
|
+ (new SubscribeLog())->where(
|
|
'request_time',
|
|
'request_time',
|
|
'<',
|
|
'<',
|
|
time() - 86400 * Config::obtain('subscribe_log_retention_days')
|
|
time() - 86400 * Config::obtain('subscribe_log_retention_days')
|
|
)->delete();
|
|
)->delete();
|
|
- UserHourlyUsage::where('datetime', '<', time() - 86400 * Config::obtain('traffic_log_retention_days'))->delete();
|
|
|
|
- DetectLog::where('datetime', '<', time() - 86400 * 3)->delete();
|
|
|
|
- EmailQueue::where('time', '<', time() - 86400)->delete();
|
|
|
|
- OnlineLog::where('last_time', '<', time() - 86400)->delete();
|
|
|
|
|
|
+ (new UserHourlyUsage())->where('datetime', '<', time() - 86400 * Config::obtain('traffic_log_retention_days'))->delete();
|
|
|
|
+ (new DetectLog())->where('datetime', '<', time() - 86400 * 3)->delete();
|
|
|
|
+ (new EmailQueue())->where('time', '<', time() - 86400)->delete();
|
|
|
|
+ (new OnlineLog())->where('last_time', '<', time() - 86400)->delete();
|
|
|
|
|
|
echo Tools::toDateTime(time()) . ' 数据库清理完成' . PHP_EOL;
|
|
echo Tools::toDateTime(time()) . ' 数据库清理完成' . PHP_EOL;
|
|
}
|
|
}
|
|
@@ -80,14 +80,14 @@ final class Cron
|
|
$login_days = Config::obtain('detect_inactive_user_login_days');
|
|
$login_days = Config::obtain('detect_inactive_user_login_days');
|
|
$use_days = Config::obtain('detect_inactive_user_use_days');
|
|
$use_days = Config::obtain('detect_inactive_user_use_days');
|
|
|
|
|
|
- User::where('is_admin', 0)
|
|
|
|
|
|
+ (new User())->where('is_admin', 0)
|
|
->where('is_inactive', 0)
|
|
->where('is_inactive', 0)
|
|
->where('last_check_in_time', '<', time() - 86400 * $checkin_days)
|
|
->where('last_check_in_time', '<', time() - 86400 * $checkin_days)
|
|
->where('last_login_time', '<', time() - 86400 * $login_days)
|
|
->where('last_login_time', '<', time() - 86400 * $login_days)
|
|
->where('last_use_time', '<', time() - 86400 * $use_days)
|
|
->where('last_use_time', '<', time() - 86400 * $use_days)
|
|
->update(['is_inactive' => 1]);
|
|
->update(['is_inactive' => 1]);
|
|
|
|
|
|
- User::where('is_admin', 0)
|
|
|
|
|
|
+ (new User())->where('is_admin', 0)
|
|
->where('is_inactive', 1)
|
|
->where('is_inactive', 1)
|
|
->where('last_check_in_time', '>', time() - 86400 * $checkin_days)
|
|
->where('last_check_in_time', '>', time() - 86400 * $checkin_days)
|
|
->where('last_login_time', '>', time() - 86400 * $login_days)
|
|
->where('last_login_time', '>', time() - 86400 * $login_days)
|
|
@@ -95,12 +95,12 @@ final class Cron
|
|
->update(['is_inactive' => 0]);
|
|
->update(['is_inactive' => 0]);
|
|
|
|
|
|
echo Tools::toDateTime(time()) .
|
|
echo Tools::toDateTime(time()) .
|
|
- ' 检测到 ' . User::where('is_inactive', 1)->count() . ' 个账户处于闲置状态' . PHP_EOL;
|
|
|
|
|
|
+ ' 检测到 ' . (new User())->where('is_inactive', 1)->count() . ' 个账户处于闲置状态' . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
|
|
public static function detectNodeOffline(): void
|
|
public static function detectNodeOffline(): void
|
|
{
|
|
{
|
|
- $nodes = Node::where('type', 1)->get();
|
|
|
|
|
|
+ $nodes = (new Node())->where('type', 1)->get();
|
|
|
|
|
|
foreach ($nodes as $node) {
|
|
foreach ($nodes as $node) {
|
|
if ($node->getNodeOnlineStatus() >= 0 && $node->online === 1) {
|
|
if ($node->getNodeOnlineStatus() >= 0 && $node->online === 1) {
|
|
@@ -175,7 +175,7 @@ final class Cron
|
|
|
|
|
|
public static function expirePaidUserAccount(): void
|
|
public static function expirePaidUserAccount(): void
|
|
{
|
|
{
|
|
- $paidUsers = User::where('class', '>', 0)->get();
|
|
|
|
|
|
+ $paidUsers = (new User())->where('class', '>', 0)->get();
|
|
|
|
|
|
foreach ($paidUsers as $user) {
|
|
foreach ($paidUsers as $user) {
|
|
if (strtotime($user->class_expire) < time()) {
|
|
if (strtotime($user->class_expire) < time()) {
|
|
@@ -258,13 +258,13 @@ final class Cron
|
|
foreach ($users as $user) {
|
|
foreach ($users as $user) {
|
|
$user_id = $user->id;
|
|
$user_id = $user->id;
|
|
// 获取用户账户等待激活的TABP订单
|
|
// 获取用户账户等待激活的TABP订单
|
|
- $pending_activation_orders = Order::where('user_id', $user_id)
|
|
|
|
|
|
+ $pending_activation_orders = (new Order())->where('user_id', $user_id)
|
|
->where('status', 'pending_activation')
|
|
->where('status', 'pending_activation')
|
|
->where('product_type', 'tabp')
|
|
->where('product_type', 'tabp')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
->get();
|
|
->get();
|
|
// 获取用户账户已激活的TABP订单,一个用户同时只能有一个已激活的TABP订单
|
|
// 获取用户账户已激活的TABP订单,一个用户同时只能有一个已激活的TABP订单
|
|
- $activated_order = Order::where('user_id', $user_id)
|
|
|
|
|
|
+ $activated_order = (new Order())->where('user_id', $user_id)
|
|
->where('status', 'activated')
|
|
->where('status', 'activated')
|
|
->where('product_type', 'tabp')
|
|
->where('product_type', 'tabp')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
@@ -316,7 +316,7 @@ final class Cron
|
|
foreach ($users as $user) {
|
|
foreach ($users as $user) {
|
|
$user_id = $user->id;
|
|
$user_id = $user->id;
|
|
// 获取用户账户等待激活的流量包订单
|
|
// 获取用户账户等待激活的流量包订单
|
|
- $order = Order::where('user_id', $user_id)
|
|
|
|
|
|
+ $order = (new Order())->where('user_id', $user_id)
|
|
->where('status', 'pending_activation')
|
|
->where('status', 'pending_activation')
|
|
->where('product_type', 'bandwidth')
|
|
->where('product_type', 'bandwidth')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
@@ -348,7 +348,7 @@ final class Cron
|
|
foreach ($users as $user) {
|
|
foreach ($users as $user) {
|
|
$user_id = $user->id;
|
|
$user_id = $user->id;
|
|
// 获取用户账户等待激活的时间包订单
|
|
// 获取用户账户等待激活的时间包订单
|
|
- $order = Order::where('user_id', $user_id)
|
|
|
|
|
|
+ $order = (new Order())->where('user_id', $user_id)
|
|
->where('status', 'pending_activation')
|
|
->where('status', 'pending_activation')
|
|
->where('product_type', 'time')
|
|
->where('product_type', 'time')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
@@ -381,11 +381,11 @@ final class Cron
|
|
|
|
|
|
public static function processPendingOrder(): void
|
|
public static function processPendingOrder(): void
|
|
{
|
|
{
|
|
- $pending_payment_orders = Order::where('status', 'pending_payment')->get();
|
|
|
|
|
|
+ $pending_payment_orders = (new Order())->where('status', 'pending_payment')->get();
|
|
|
|
|
|
foreach ($pending_payment_orders as $order) {
|
|
foreach ($pending_payment_orders as $order) {
|
|
// 检查账单支付状态
|
|
// 检查账单支付状态
|
|
- $invoice = Invoice::where('order_id', $order->id)->first();
|
|
|
|
|
|
+ $invoice = (new Invoice())->where('order_id', $order->id)->first();
|
|
|
|
|
|
if ($invoice === null) {
|
|
if ($invoice === null) {
|
|
continue;
|
|
continue;
|
|
@@ -416,7 +416,7 @@ final class Cron
|
|
|
|
|
|
public static function resetNodeBandwidth(): void
|
|
public static function resetNodeBandwidth(): void
|
|
{
|
|
{
|
|
- Node::where('bandwidthlimit_resetday', date('d'))->update(['node_bandwidth' => 0]);
|
|
|
|
|
|
+ (new Node())->where('bandwidthlimit_resetday', date('d'))->update(['node_bandwidth' => 0]);
|
|
|
|
|
|
echo Tools::toDateTime(time()) . ' 重设节点流量完成' . PHP_EOL;
|
|
echo Tools::toDateTime(time()) . ' 重设节点流量完成' . PHP_EOL;
|
|
}
|
|
}
|
|
@@ -430,7 +430,7 @@ final class Cron
|
|
|
|
|
|
public static function resetFreeUserTraffic(): void
|
|
public static function resetFreeUserTraffic(): void
|
|
{
|
|
{
|
|
- $freeUsers = User::where('class', 0)->where('auto_reset_day', date('d'))->get();
|
|
|
|
|
|
+ $freeUsers = (new User())->where('class', 0)->where('auto_reset_day', date('d'))->get();
|
|
|
|
|
|
foreach ($freeUsers as $user) {
|
|
foreach ($freeUsers as $user) {
|
|
try {
|
|
try {
|
|
@@ -455,14 +455,14 @@ final class Cron
|
|
public static function sendDailyFinanceMail(): void
|
|
public static function sendDailyFinanceMail(): void
|
|
{
|
|
{
|
|
$today = strtotime('00:00:00');
|
|
$today = strtotime('00:00:00');
|
|
- $paylists = Paylist::where('status', 1)->whereBetween('datetime', [strtotime('-1 day', $today), $today])->get();
|
|
|
|
|
|
+ $paylists = (new Paylist())->where('status', 1)->whereBetween('datetime', [strtotime('-1 day', $today), $today])->get();
|
|
$text_html = '<table border=1><tr><td>金额</td><td>用户ID</td><td>用户名</td><td>充值时间</td>';
|
|
$text_html = '<table border=1><tr><td>金额</td><td>用户ID</td><td>用户名</td><td>充值时间</td>';
|
|
|
|
|
|
foreach ($paylists as $paylist) {
|
|
foreach ($paylists as $paylist) {
|
|
$text_html .= '<tr>';
|
|
$text_html .= '<tr>';
|
|
$text_html .= '<td>' . $paylist->total . '</td>';
|
|
$text_html .= '<td>' . $paylist->total . '</td>';
|
|
$text_html .= '<td>' . $paylist->userid . '</td>';
|
|
$text_html .= '<td>' . $paylist->userid . '</td>';
|
|
- $text_html .= '<td>' . User::find($paylist->userid)->user_name . '</td>';
|
|
|
|
|
|
+ $text_html .= '<td>' . (new User())->find($paylist->userid)->user_name . '</td>';
|
|
$text_html .= '<td>' . Tools::toDateTime((int) $paylist->datetime) . '</td>';
|
|
$text_html .= '<td>' . Tools::toDateTime((int) $paylist->datetime) . '</td>';
|
|
$text_html .= '</tr>';
|
|
$text_html .= '</tr>';
|
|
}
|
|
}
|
|
@@ -487,7 +487,7 @@ final class Cron
|
|
public static function sendWeeklyFinanceMail(): void
|
|
public static function sendWeeklyFinanceMail(): void
|
|
{
|
|
{
|
|
$today = strtotime('00:00:00');
|
|
$today = strtotime('00:00:00');
|
|
- $paylists = Paylist::where('status', 1)
|
|
|
|
|
|
+ $paylists = (new Paylist())->where('status', 1)
|
|
->whereBetween('datetime', [strtotime('-1 week', $today), $today])
|
|
->whereBetween('datetime', [strtotime('-1 week', $today), $today])
|
|
->get();
|
|
->get();
|
|
|
|
|
|
@@ -510,7 +510,7 @@ final class Cron
|
|
public static function sendMonthlyFinanceMail(): void
|
|
public static function sendMonthlyFinanceMail(): void
|
|
{
|
|
{
|
|
$today = strtotime('00:00:00');
|
|
$today = strtotime('00:00:00');
|
|
- $paylists = Paylist::where('status', 1)
|
|
|
|
|
|
+ $paylists = (new Paylist())->where('status', 1)
|
|
->whereBetween('datetime', [strtotime('-1 month', $today), $today])
|
|
->whereBetween('datetime', [strtotime('-1 month', $today), $today])
|
|
->get();
|
|
->get();
|
|
|
|
|
|
@@ -532,7 +532,7 @@ final class Cron
|
|
|
|
|
|
public static function sendPaidUserUsageLimitNotification(): void
|
|
public static function sendPaidUserUsageLimitNotification(): void
|
|
{
|
|
{
|
|
- $paidUsers = User::where('class', '>', 0)->get();
|
|
|
|
|
|
+ $paidUsers = (new User())->where('class', '>', 0)->get();
|
|
|
|
|
|
foreach ($paidUsers as $user) {
|
|
foreach ($paidUsers as $user) {
|
|
$user_traffic_left = $user->transfer_enable - $user->u - $user->d;
|
|
$user_traffic_left = $user->transfer_enable - $user->u - $user->d;
|
|
@@ -577,8 +577,8 @@ final class Cron
|
|
|
|
|
|
public static function sendDailyTrafficReport(): void
|
|
public static function sendDailyTrafficReport(): void
|
|
{
|
|
{
|
|
- $users = User::whereIn('daily_mail_enable', [1, 2])->get();
|
|
|
|
- $ann_latest_raw = Ann::orderBy('date', 'desc')->first();
|
|
|
|
|
|
+ $users = (new User())->whereIn('daily_mail_enable', [1, 2])->get();
|
|
|
|
+ $ann_latest_raw = (new Ann())->orderBy('date', 'desc')->first();
|
|
|
|
|
|
if ($ann_latest_raw === null) {
|
|
if ($ann_latest_raw === null) {
|
|
$ann_latest = '<br><br>';
|
|
$ann_latest = '<br><br>';
|
|
@@ -628,7 +628,7 @@ final class Cron
|
|
|
|
|
|
public static function updateNodeIp(): void
|
|
public static function updateNodeIp(): void
|
|
{
|
|
{
|
|
- $nodes = Node::where('type', 1)->get();
|
|
|
|
|
|
+ $nodes = (new Node())->where('type', 1)->get();
|
|
|
|
|
|
foreach ($nodes as $node) {
|
|
foreach ($nodes as $node) {
|
|
$node->updateNodeIp();
|
|
$node->updateNodeIp();
|