Commit 54be437d by Joneq

新增消息系统-完成脚本开发

parent 91e27849
<?php
namespace App\Console\Commands;
use App\Model\SystemBulletinModel;
use App\Model\SystemUpdateModel;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
//TODO 上线之后去除注释这个notice ,5。0版本的缺陷 https://blog.csdn.net/weixin_44251615/article/details/93710829
ini_set("error_reporting","E_ALL & ~E_NOTICE");
class CreateNotice extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'notice:create_notice';
/**
* The console command description.
*
* @var string
*/
protected $description = '生成每日六点的公告';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//查找出今日的所有更新
$date = date('Y-m-d');
$time = strtotime($date);
$where['begin_time'] = $time - (6*3600);
$where['end_time'] = $time + (18*3600);
$allUpdate = (new SystemUpdateModel())->select('update_title','update_content')->get()->toArray();
$saveData['title'] = $date.'系统不停机维护公告';
$saveData['content'] = '';
$saveData['is_send'] = '未发送';
$saveData['create_time'] = time();
foreach ($allUpdate as $value){
$saveData['content'] .= '<h2 style="text-align: center;">'.$value['update_title'].'</h2>';
$saveData['content'] .= $value['update_content'];
}
(new SystemBulletinModel())->insertGetId($saveData);
}
}
...@@ -21,6 +21,7 @@ class Kernel extends ConsoleKernel ...@@ -21,6 +21,7 @@ class Kernel extends ConsoleKernel
Commands\qj_sf::class, Commands\qj_sf::class,
Commands\Initialization::class, Commands\Initialization::class,
Commands\Add_field::class, Commands\Add_field::class,
Commands\CreateNotice::class,
]; ];
/** /**
......
...@@ -34,7 +34,7 @@ class SystemUpdateModel extends Model ...@@ -34,7 +34,7 @@ class SystemUpdateModel extends Model
case 'update_content': case 'update_content':
$obj = $obj->where($key,'like','%'.$val.'%');break; $obj = $obj->where($key,'like','%'.$val.'%');break;
case 'begin_time': case 'begin_time':
$obj = $obj->where('create_time','>=',strtotime($val));break; $obj = $obj->where('create_time','>',strtotime($val));break;
case 'end_time': case 'end_time':
$obj = $obj->where('create_time','<=',strtotime($val));break; $obj = $obj->where('create_time','<=',strtotime($val));break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment