diff --git a/app/Controllers/Admin/AnnController.php b/app/Controllers/Admin/AnnController.php index df909e21..d087e1d7 100644 --- a/app/Controllers/Admin/AnnController.php +++ b/app/Controllers/Admin/AnnController.php @@ -30,43 +30,50 @@ class AnnController extends AdminController public function add($request, $response, $args) { - $ann = new Ann(); - $ann->date = date("Y-m-d H:i:s"); - $ann->content = $request->getParam('content'); - $ann->markdown = $request->getParam('markdown'); $issend = $request->getParam('issend'); $vip = $request->getParam('vip'); - $users = User::all(); - if (!$ann->save()) { - $rs['ret'] = 0; - $rs['msg'] = "添加失败"; - return $response->getBody()->write(json_encode($rs)); + $beginSend = $request->getParam('page') * Config::get('sendPageLimit'); + $users = User::where('class', ">=", $vip)->skip($beginSend)->limit(Config::get('sendPageLimit'))->get(); + if($request->getParam('page') == 1){ + $ann = new Ann(); + $ann->date = date("Y-m-d H:i:s"); + $ann->content = $request->getParam('content'); + $ann->markdown = $request->getParam('markdown'); + + if (!$ann->save()) { + $rs['ret'] = 0; + $rs['msg'] = "添加失败"; + return $response->getBody()->write(json_encode($rs)); + } } if ($issend == 1){ foreach($users as $user){ - if ($user->class >= $vip){ - $subject = Config::get('appName')."-公告"; - $to = $user->email; - if (!filter_var($to, FILTER_VALIDATE_EMAIL)) { - continue; - } - $text = $ann->content; - try { - Mail::send($to, $subject, 'news/warn.tpl', [ - "user" => $user,"text" => $text - ], [ - ]); - } catch (\Exception $e) { - continue; - } + $subject = Config::get('appName')."-公告"; + $to = $user->email; + if (!filter_var($to, FILTER_VALIDATE_EMAIL)) { + continue; + } + $text = $ann->content; + try { + Mail::send($to, $subject, 'news/warn.tpl', [ + "user" => $user,"text" => $text + ], [ + ]); + } catch (\Exception $e) { + continue; } } } - - Telegram::SendMarkdown("新公告:".PHP_EOL.$request->getParam('markdown')); - $rs['ret'] = 1; - $rs['msg'] = "公告添加成功,邮件发送成功"; - return $response->getBody()->write(json_encode($rs)); + if(count($users) == Config::get('sendPageLimit')){ + $rs['ret'] = 2; + $rs['msg'] = $request->getParam('page') + 1; + return $response->getBody()->write(json_encode($rs)); + }else{ + Telegram::SendMarkdown("新公告:".PHP_EOL.$request->getParam('markdown')); + $rs['ret'] = 1; + $rs['msg'] = "公告添加成功,邮件发送成功"; + return $response->getBody()->write(json_encode($rs)); + } } public function edit($request, $response, $args) diff --git a/config/.config.php.example b/config/.config.php.example index a3260a36..899360c2 100755 --- a/config/.config.php.example +++ b/config/.config.php.example @@ -32,7 +32,7 @@ $System_Config['db_password'] = 'sspanel'; //用户名对应的密码 //邮件设置-------------------------------------------------------------------------------------------- $System_Config['mailDriver'] = 'mailgun'; // mailgun or smtp or sendgrid 选择发送邮件的方式 - +$System_Config['sendPageLimit']= 50; //发信分页 解决大站发公告超时问题 # mailgun $System_Config['mailgun_key'] = ''; $System_Config['mailgun_domain'] = ''; @@ -157,7 +157,7 @@ $System_Config['number_viplevel'] = '1'; //节点自动化显示,输入要显 //支付系统设置---------------------------------------------------------------------------------------- -#取值 none | codepay | doiampay | trimepay | f2fpay | yftpay | chenAlipay | paymentwall | spay | f2fpay_codepay +#取值 none | codepay | doiampay | trimepay | f2fpay | yftpay | chenAlipay | paymentwall | spay | f2fpay_codepay $System_Config['payment_system']='none'; #codepay码支付 diff --git a/resources/views/material/admin/announcement/create.tpl b/resources/views/material/admin/announcement/create.tpl index 17c67aa7..ff234eb0 100644 --- a/resources/views/material/admin/announcement/create.tpl +++ b/resources/views/material/admin/announcement/create.tpl @@ -18,7 +18,7 @@
- +
@@ -29,33 +29,34 @@
- - - - + + + +
- - - + + +
- +
+
- +
@@ -63,20 +64,20 @@
- - + + {include file='dialog.tpl'}
- - - + + + - - - - + + + + @@ -88,8 +89,8 @@ \ No newline at end of file +