Commit f20b274c by Joneq

修改邮箱发送的规则和邮件发送的格式

parent 317c0545
......@@ -44,22 +44,82 @@ class CreateNotice extends Command
{
//查找出今日的所有更新
$date = date('Y-m-d');
$time = strtotime($date);
$where['begin_time'] = $time - (6*3600);
$where['end_time'] = $time + (18*3600);
$where['begin_time'] = $date;
$where['end_time'] = date('Y-m-d H:i:s');
$allUpdate = (new SystemUpdateModel())->select('update_title','update_content')->get()->toArray();
$systemUpdateModel = new SystemUpdateModel();
//韦伯系统是所有的,通知所有人
$allUpdate = $systemUpdateModel->getWhereObj($where)->get()->toArray();
if (!empty($allUpdate)){
// 查找所有通知用户邮箱和ID
$sendUser = DB::table('t_user_perm')->where('begDate','<=',$date)
->where('endDate','>=',$date)
->select('username','userId')->get();
$this->createNoticeSaveData($allUpdate,$date,'韦伯系统',json_encode($sendUser));
}
//查找所有需要更新的子系统,通知对应系统的人
$allGroup = $systemUpdateModel->getWhereObj($where)->groupBy('system_id')->get()->toArray();
foreach ($allGroup as $value){
// 查找所有通知ID
$sendUser = DB::table('t_user_perm')->where('begDate','<=',$date)
->where('endDate','>=',$date)
->where('bid',$value['system_id'])
->select('username','userId')->get();
$this->createNoticeSaveData($allUpdate,$date,$value['system_name'],json_encode($sendUser));
}
}
private function createNoticeSaveData($allUpdate,$date,$systemName,$sendUser)
{
$saveData['title'] = $date.'系统不停机维护公告';
$saveData['content'] = '';
$saveData['is_send'] = '未发送';
$saveData['create_time'] = time();
$saveData['send_user'] = $sendUser;
$tbodyContent = '';
foreach ($allUpdate as $value){
$saveData['content'] .= '<h2 style="text-align: center;">'.$value['update_title'].'</h2>';
$saveData['content'] .= $value['update_content'];
$tbodyContent .=
'<tr>'.
'<td>'.$date.'</td>'.
'<td>'.$value['system_name'].'</td>'.
'<td>'.$value['update_type'].'</td>'.
'<td>'.$value['update_title'].'</td>'.
'<td>'.$value['update_content'].'</td>'.
'<td>'.$value['product_user'].'</td>'.
'<td>'.$value['version_num'].'</td>'.
'</tr>';
}
$saveData['content'] = '
<h2>猎芯的同事们好</h2>
<h2>以下内容为'.$systemName.'今天全部的更新,请查收</h2>
<table border="1" cellspacing="0" style="width: 1300px;line-height: 50px;table-layout: fixed">
<thead style="background:grey;font-size: 30px;">
<tr>
<td></td>
<td>系统</td>
<td>更新类型</td>
<td>更新标题</td>
<td width="350">更新内容简介</td>
<td>产品负责人</td>
<td>版本号</td>
</tr>
</thead>
<tbody>
'.$tbodyContent.'
</tbody>
</table>
';
(new SystemBulletinModel())->insertGetId($saveData);
}
}
......@@ -124,6 +124,18 @@ class MessageApiController extends Controller
}
}
//获取系统版本号码
private function getSystemUpdateVersion($request)
{
$data = $request->all();
try{
$versionNum = (new SystemNoticeLogic())->getSystemUpdateVersion($data);
$this->Export(0, '获取成功',['version'=>$versionNum]);
}catch(\Exception $e){
$this->Export(400, $e->getMessage());
}
}
//删除消息模板
public function deletetemplate($request){
......
......@@ -140,14 +140,14 @@ class SystemNoticeLogic
//发送通知
//两种类型,邮件和生成队列信息
//两种类型,邮件和系统内通知
public function sendNotice($data)
{
if (!isset($data['notice_type']) || empty($data['notice_type'])){
throw new \Exception('请至少选择一个发送选项');
}
// notice_type 1 是邮件,2是系统内的通知,用rabbitmq推送
// notice_type 1 是邮件,2是系统内的通知,
$sendData['user'] = [];
$sendData['title'] = '';
$sendData['content'] = '';
......@@ -166,7 +166,7 @@ class SystemNoticeLogic
->where('bid',$sendInfo->system_id)
->select('username','userId')->get();
$sendData['user'] = array_column($sendData['user'],'username');
$sendData['user_email'] = array_column($sendData['user_info'],'username');
$sendData['title'] = $sendInfo->update_title;
$sendData['content'] = $sendInfo->update_content;
......@@ -183,7 +183,7 @@ class SystemNoticeLogic
->where('bid',$sendInfo->system_id)
->select('username','userId')->get();
$sendData['user'] = array_column($sendData['user'],'username');
$sendData['user_email'] = array_column($sendData['user_info'],'username');
$sendData['title'] = $sendInfo->system_name.'宣讲-'.date('Y-m-d');
$sendData['content'] = $sendInfo->preach_content;
......@@ -195,7 +195,13 @@ class SystemNoticeLogic
$sendInfo = $modelObj->where('smbn_id',$data['id'])->first();
$sendData['user'] = ['all@ichunt.com'];
$sendData['user_info'] = json_decode($sendInfo->send_user,true);
if ($sendInfo->system_name === '韦伯系统'){
$sendData['user_email'] = ['all@ichunt.com'];
}else{
$sendData['user_email'] = array_column($sendData['user'],'username');
}
$sendData['title'] = $sendInfo->title;
$sendData['content'] = $sendInfo->content;
......@@ -211,7 +217,6 @@ class SystemNoticeLogic
$this->sendEmail($sendData);
$emailSendCount++;
}else{
//rabbitmq 方法不行
$this->sendRedisNotice($sendData);
$bulletinSendCount++;
}
......@@ -239,16 +244,18 @@ class SystemNoticeLogic
{
//不是正式的域名统一只发给测试用户
if ($_SERVER['SERVER_NAME'] !== 'message.ichunt.net'){
$sendData['user'] = ['gy@ichunt.com','lxb@ichunt.com'];
$sendData['user_email'] = ['gy@ichunt.com'];
}
Mail::send('emails.default', ["sendData"=>$sendData], function ($m) use($sendData) {
$m->from(env('MAIL_USERNAME'), $sendData['title']);
$m->to($sendData['user']);
$m->to($sendData['user_email']);
$m->subject('系统通知');
});
}
//生成rabbitmq信息
public function sendRedisNotice($sendData)
{
......@@ -277,6 +284,20 @@ class SystemNoticeLogic
}
public function getSystemUpdateVersion($requestData)
{
$endTime = time();
$beginTime = strtotime(date('Y-m-d',$endTime));
$versionNum = (new SystemUpdateModel())
->where('system_id',$requestData['system_id'])
->where('create_time','>=',$beginTime)
->where('create_time','<=',$endTime)
->count('smue_id');
return '1.0.'.ltrim(date('m.'),'0').ltrim(date('d.'),'0').($versionNum+1);
}
static public function getAllSystemSelect()
{
return DB::table('t_business_config')->orderBy('bid','desc')->pluck('title','bid');
......@@ -305,4 +326,5 @@ class SystemNoticeLogic
$data['department_name'] = DB::table('user_department')->where('department_id',$data['department_id'])->value('department_name');
return $data;
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ class SystemBulletinModel extends Model
public function getWhereObj($data)
{
$obj = self::where('smbn_id','>',0);
$obj = self::orderBy('smbn_id','desc');
foreach ($data as $key=>$val){
if ($val === '')continue;
switch ($key){
......
......@@ -21,7 +21,7 @@ class SystemPreachModel extends Model
public function getWhereObj($data)
{
$obj = self::where('smph_id','>',0);
$obj = self::orderBy('smph_id','desc');
foreach ($data as $key=>$val){
if ($val === '')continue;
switch ($key){
......
......@@ -21,7 +21,7 @@ class SystemUpdateModel extends Model
public function getWhereObj($data)
{
$obj = self::where('smue_id','>',0);
$obj = self::orderBy('smue_id','desc');
foreach ($data as $key=>$val){
if ($val === '')continue;
switch ($key){
......
......@@ -17,8 +17,8 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
id:'table',
cols: [[ //表头
{field: 'smbn_id', title: '序号',align:'center',width:100},
{field: 'create_time', title: '创建时间',align:'center',width:150},
{field: 'title', title: '公告标题',align:'center',width:150},
{field: 'create_time', title: '创建时间',align:'center',width:250},
{field: 'title', title: '公告标题',align:'center',width:250},
{field: 'is_send', title: '状态',align:'center',width:150},
{field: 'active', toolbar: '#active', title: '操作',align:'center',width:150, fixed:'right'}
]]
......@@ -56,6 +56,7 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
success:function(index){
layeditIndex = layedit.build('content_text',{
height:200,
width:100
}); //建立编辑器
},
......@@ -76,7 +77,7 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
form.val("data_form", jsonData);
form.render();
layer.open({
area: ['800px', '500px'],
area: ['1000px', '500px'],
title: '保存数据',
type: 1,
content: $("#save_form_show"),
......
......@@ -67,6 +67,29 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
});
form.on('select(system_id)', function (data) {
$.ajax({
url: '/msgapi/getSystemUpdateVersion',
type: 'post',
data: {'system_id':data.value},
dataType:'json',
success: function (resp) {
if (resp.errcode == 0) {
$("#version_num").val(resp.data.version);
return false;
}
layer.msg(resp.errmsg);
},
error: function (err) {
console.log(err)
}
});
return false;
});
$("#addData").click(function () {
$("#data_form_jq")[0].reset();
......
......@@ -72,8 +72,8 @@
<div class="layui-form-item">
<div class="layui-inline ">
<label class="layui-form-label">公告标题:</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" lay-verify="required" name="title" id="title" >
<div class="layui-input-inline" style="width: 300px;">
<input type="text" class="layui-input" lay-verify="required" name="title" id="title" >
</div>
</div>
</div>
......@@ -86,7 +86,7 @@
<div class="layui-inline">
<label class="layui-form-label" >宣讲内容:</label>
<div class="layui-input-inline" style="width: 600px;">
<div class="layui-input-inline" style="width: 1300px;">
<textarea id="content_text" class="layui-textarea" style="display: none" ></textarea>
<input type="hidden" id="content" name="content">
</div>
......
......@@ -76,7 +76,7 @@
<script type="text/html" id="active">
<a class="layui-btn layui-btn-xs layui-btn-normal editData" data-json='@{{d.data_json}}' data-preach_content='@{{d.preach_content}}' ><strong>编辑</strong></a>
<a class="layui-btn layui-btn-xs layui-btn-normal " data-id='@{{d.smph_id}}' ><strong>立即发送</strong></a>
<a class="layui-btn layui-btn-xs layui-btn-normal sendNotice" data-id='@{{d.smph_id}}' ><strong>立即发送</strong></a>
</script>
{{--发送信息--}}
......
......@@ -141,7 +141,7 @@
<div class="layui-inline ">
<label class="layui-form-label">更新时间:</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" lay-filter="update_time" lay-verify="required" name="update_time" id="update_time" >
<input type="text" class="layui-input" lay-filter="update_time" value="{!! date('Y-m-d H:i:s') !!}" lay-verify="required" name="update_time" id="update_time" >
</div>
</div>
</div>
......@@ -151,7 +151,8 @@
<div class="layui-form-item">
<label class="layui-form-label">更新系统</label>
<div class="layui-input-inline">
<select name="system_id" lay-filter="system_id" lay-search lay-verify="required">
<select name="system_id" lay-filter="system_id" lay-search lay-verify="required">
<option value="">请选择</option>
@foreach(\App\Logic\SystemNoticeLogic::getAllSystemSelect() as $key=>$value)
<option value="{{$key}}">{{$value}}</option>
......@@ -177,7 +178,7 @@
<div class="layui-form-item">
<label class="layui-form-label">版本号码</label>
<div class="layui-input-inline">
<input type="text" name="version_num" placeholder="填写版本号码" autocomplete="off" class="layui-input" lay-verify="required">
<input type="text" name="version_num" id="version_num" placeholder="填写版本号码" disabled="disabled" autocomplete="off" class="layui-input" lay-verify="required">
</div>
</div>
......
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