From 98906feb3535dc120343bbe2ace44e8a46b45d48 Mon Sep 17 00:00:00 2001 From: CGDF <17256673+CGDF-Github@users.noreply.github.com> Date: Fri, 28 Sep 2018 21:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E3=80=90=E4=BD=99=E9=87=8F?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E3=80=91BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/Job.php | 77 +++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/app/Command/Job.php b/app/Command/Job.php index a7e94793..35ff9c10 100644 --- a/app/Command/Job.php +++ b/app/Command/Job.php @@ -314,44 +314,6 @@ class Job } } } - } - - //余量不足检测 - if (Config::get('notify_limit_mode') !='false'){ - $user_traffic_left = $user->transfer_enable - $user->u - $user->d; - $under_limit='false'; - - if (Config::get('notify_limit_mode') == 'per'&& - $user_traffic_left / $user->transfer_enable * 100 < Config::get('notify_limit_value')){ - $under_limit='true'; - $unit_text='%'; - } - else if(Config::get('notify_limit_mode')=='mb'&& - $user_traffic_left / 1024 / 1024 < Config::get('notify_limit_value')){ - $under_limit='true'; - $unit_text='MB'; - } - - if($under_limit=='true' && !file_exists(BASE_PATH."/storage/traffic_notified/".$user->id.".userid")){ - $subject = Config::get('appName')." - 您的剩余流量过低"; - $to = $user->email; - $text = '您好,系统发现您剩余流量已经低于 '.Config::get('notify_limit_value').$unit_text.' 。' ; - try { - Mail::send($to, $subject, 'news/warn.tpl', [ - "user" => $user,"text" => $text - ], [ - ]); - $myfile = fopen(BASE_PATH."/storage/traffic_notified/".$user->id.".userid", "w+") or die("Unable to open file!"); - $txt = "1"; - fwrite($myfile, $txt); - fclose($myfile); - } catch (Exception $e) { - echo $e->getMessage(); - } - } - else{ - unlink(BASE_PATH."/storage/traffic_notified/".$user->id.".userid"); - } } } @@ -704,6 +666,45 @@ class Job } } + //余量不足检测 + mkdir(BASE_PATH."/storage/traffic_notified/"); + if (Config::get('notify_limit_mode') !='false'){ + $user_traffic_left = $user->transfer_enable - $user->u - $user->d; + $under_limit='false'; + + if (Config::get('notify_limit_mode') == 'per'&& + $user_traffic_left / $user->transfer_enable * 100 < Config::get('notify_limit_value')){ + $under_limit='true'; + $unit_text='%'; + } + else if(Config::get('notify_limit_mode')=='mb'&& + Tools::flowToMB($user_traffic_left) < Config::get('notify_limit_value')){ + $under_limit='true'; + $unit_text='MB'; + } + + if($under_limit=='true' && !file_exists(BASE_PATH."/storage/traffic_notified/".$user->id.".userid")){ + $subject = Config::get('appName')." - 您的剩余流量过低"; + $to = $user->email; + $text = '您好,系统发现您剩余流量已经低于 '.Config::get('notify_limit_value').$unit_text.' 。' ; + try { + Mail::send($to, $subject, 'news/warn.tpl', [ + "user" => $user,"text" => $text + ], [ + ]); + $myfile = fopen(BASE_PATH."/storage/traffic_notified/".$user->id.".userid", "w+") or die("Unable to open file!"); + $txt = "1"; + fwrite($myfile, $txt); + fclose($myfile); + } catch (Exception $e) { + echo $e->getMessage(); + } + } + else{ + unlink(BASE_PATH."/storage/traffic_notified/".$user->id.".userid"); + } + } + if (strtotime($user->expire_in)+((int)Config::get('enable_account_expire_delete_days')*86400)