Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李洋
/
消息系统
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f20b274c
authored
Jan 09, 2023
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改邮箱发送的规则和邮件发送的格式
parent
317c0545
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
146 additions
and
26 deletions
app/Console/Commands/CreateNotice.php
app/Http/Controllers/MessageApiController.php
app/Logic/SystemNoticeLogic.php
app/Model/SystemBulletinModel.php
app/Model/SystemPreachModel.php
app/Model/SystemUpdateModel.php
public/js/Message/systemBulletin.js
public/js/Message/systemUpdate.js
resources/views/message/systemBulletin.blade.php
resources/views/message/systemPreaching.blade.php
resources/views/message/systemUpdate.blade.php
app/Console/Commands/CreateNotice.php
View file @
f20b274c
...
...
@@ -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
);
}
}
app/Http/Controllers/MessageApiController.php
View file @
f20b274c
...
...
@@ -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
){
...
...
app/Logic/SystemNoticeLogic.php
View file @
f20b274c
...
...
@@ -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
app/Model/SystemBulletinModel.php
View file @
f20b274c
...
...
@@ -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
){
...
...
app/Model/SystemPreachModel.php
View file @
f20b274c
...
...
@@ -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
){
...
...
app/Model/SystemUpdateModel.php
View file @
f20b274c
...
...
@@ -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
){
...
...
public/js/Message/systemBulletin.js
View file @
f20b274c
...
...
@@ -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
:
1
50
},
{
field
:
'title'
,
title
:
'公告标题'
,
align
:
'center'
,
width
:
1
50
},
{
field
:
'create_time'
,
title
:
'创建时间'
,
align
:
'center'
,
width
:
2
50
},
{
field
:
'title'
,
title
:
'公告标题'
,
align
:
'center'
,
width
:
2
50
},
{
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
:
[
'
8
00px'
,
'500px'
],
area
:
[
'
10
00px'
,
'500px'
],
title
:
'保存数据'
,
type
:
1
,
content
:
$
(
"#save_form_show"
),
...
...
public/js/Message/systemUpdate.js
View file @
f20b274c
...
...
@@ -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
();
...
...
resources/views/message/systemBulletin.blade.php
View file @
f20b274c
...
...
@@ -72,7 +72,7 @@
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline "
>
<label
class=
"layui-form-label"
>
公告标题:
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
style=
"width: 300px;"
>
<input
type=
"text"
class=
"layui-input"
lay-verify=
"required"
name=
"title"
id=
"title"
>
</div>
</div>
...
...
@@ -86,7 +86,7 @@
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
宣讲内容:
</label>
<div
class=
"layui-input-inline"
style=
"width:
6
00px;"
>
<div
class=
"layui-input-inline"
style=
"width:
13
00px;"
>
<textarea
id=
"content_text"
class=
"layui-textarea"
style=
"display: none"
></textarea>
<input
type=
"hidden"
id=
"content"
name=
"content"
>
</div>
...
...
resources/views/message/systemPreaching.blade.php
View file @
f20b274c
...
...
@@ -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>
{{--发送信息--}}
...
...
resources/views/message/systemUpdate.blade.php
View file @
f20b274c
...
...
@@ -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>
...
...
@@ -152,6 +152,7 @@
<label
class=
"layui-form-label"
>
更新系统
</label>
<div
class=
"layui-input-inline"
>
<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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment