Files
tougao/application/common/Messages.php
2026-03-10 14:50:33 +08:00

185 lines
8.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\common;
use think\Db;
class Messages
{
//消息类型
private $aMessagesType = [
1 => [
'title' => 'Submission Received',
'content' => '<b>Your manuscriptID: {#accept_sn#}) has been successfully submitted.</b><br/>
The editorial office is conducting an initial assessment. You will be notified once the review process begins.'
],//'投稿成功',
2 => [
'title' => 'Manuscript Under Review',
'content' => 'Your manuscript is now under review.<br>
Manuscript (ID: {#accept_sn#}) has been sent to peer reviewers for evaluation. You will be notified once a review decision becomes available.'
],//'稿件进入审稿',
3 => [
'title' => 'Declined for Publication',
'content' => '<b>Editorial decision issued.</b><br/>
After evaluation, your manuscriptID: {#accept_sn#}) has not been accepted for publication. Please refer to the decision letter for details and reviewer comments.'
],//'退稿通知',
4 => [
'title' => 'Revision Requested',
'content' => '<b>Revision requested.</b><br/>
Editors/reviewers have requested revisions to your manuscriptID: {#accept_sn#}). Please review the comments and submit your revised version within the required timeframe.'
],//'退修通知',
5 => [
'title' => 'Accepted for Publication',
'content' => '<b>Revision requested.</b><br/>
Editors/reviewers have requested revisions to your manuscriptID: {#accept_sn#}). Please review the comments and submit your revised version within the required timeframe.'
],//'录用通知',
6 => [
'title' => 'APC Payment Required',
'content' => '<b>APC payment required.</b><br/>
Your manuscriptID: {#accept_sn#}) has reached the payment stage. Please complete the Article Processing Charge (APC) to proceed with publication processing.'
],//'缴费提醒',
7 => [
'title' => 'Proofreading Confirmation Required',
'content' => '<b>Proofs ready for review.</b><br/>
Your manuscriptID: {#accept_sn#}) proof is available. Please check and confirm carefully within 48 hours.'
],//'校对通知',
8 => [
'title' => 'Manuscript Published Online',
'content' => '<b>Your article is now published online!</b><br/>
The final version of your manuscriptID: {#accept_sn#}) is available on the journal website. Thank you for publishing with us.'
],//'发表通知',
9 => [
'title' => 'APC Update',
'content' => '<b>APC update applied.</b><br/>
The Article Processing Charge for your manuscriptID: {#accept_sn#}) has been adjusted. Please check the updated payment details in your submission dashboard.'
],//'稿费修改',
10 => [
'title' => 'Review Invitation(ID: {#accept_sn#})',
'content' => '<b>Review invitation received.</b><br/>
You are invited to review a manuscript (ID: {#accept_sn#}). Please accept or decline the invitation via your reviewer dashboard.'
],//'审稿通知',
11 => [
'title' => 'Review Invitation Reminder',
'content' => '<b>Reminder: Review invitation pending.</b><br/>
You have a pending review invitation (ID: {#accept_sn#}). Kindly respond at your earliest convenience.'
],//'审稿提醒',
12 => [
'title' => 'Review Report Reminder',
'content' => '<b>Reminder: Review report due.</b><br/>
Thank you for accepting the review (ID: {#accept_sn#}). Please submit your review report to help us proceed with the editorial decision.'
],//'审稿报告提交',
13 => [
'title' => 'Re-review Invitation',
'content' => '<b>Re-review request received.</b><br/>
A revised version of manuscript (ID: {#accept_sn#}) is available for your follow-up assessment. Please access the reviewer dashboard to proceed.'
],//'复审邀请',
14 => [
'title' => 'Re-review Reminder',
'content' => '<b>Reminder: Re-review pending.</b><br/>
Your follow-up review for manuscript (ID: {#accept_sn#}) is still pending. We would appreciate your evaluation at your earliest convenience.'
],//'复审提醒',
15 => [
'title' => 'Review Closed',
'content' => '<b>Review assignment closed.</b><br/>
Your review for manuscript (ID: {#accept_sn#}) is no longer required. Thank you for your support and contribution to the journal.'
],//审稿关闭提醒
];
private $aField = ['article_id','user_id','type','title','content','is_read','create_time','update_user_id','update_time'];
/**
* 站内信息添加
*/
public function add($aParam = []){
//获取参数
$aParam = empty($aParam) ? [] : $aParam;
//必填参数验证
$iType = empty($aParam['type']) ? 0 : $aParam['type'];
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
if(empty($iArticleId) || empty($iType) || empty($aParam['user_id'])){
return ['status' => 2, 'msg' => 'Parameter is empty article title/message type/user_id'];
}
if($iType == 2){//验证是否插入
$aMessages = $this->get($aParam);
if(!empty($aMessages['data'])){
return ['status' => 3, 'msg' => 'The review reminder has been sent'];
}
}
//根据类型获取消息内容
$aMessagesType = $this->aMessagesType;
$aMessagesTypeInfo = empty($aMessagesType[$iType]) ? [] : $aMessagesType[$iType];
if(empty($aMessagesTypeInfo)){
return ['status' => 4, 'msg' => 'Message content not found'];
}
//获取表字段 进行字段赋值
$aField = $this->aField;
$aInsert = [];
foreach ($aField as $key => $value) {
if(empty($aParam[$value])){
continue;
}
$aInsert[$value] = $aParam[$value];
}
//获取稿件号
$sAcceptSn = empty($aParam['accept_sn']) ? '' : $aParam['accept_sn'];
$aInsert['title'] = str_replace('{#accept_sn#}', $sAcceptSn, $aMessagesTypeInfo['title']);
$aInsert['content'] = str_replace('{#accept_sn#}', $sAcceptSn, $aMessagesTypeInfo['content']);
$aInsert['create_time'] = time();
//拒稿和退修 查询是否有同意审稿但未审稿的审稿人
if(in_array($iType, [3,4])){
$aWhere = ['article_id' => $iArticleId,'state' => 0];
$aReviewer = Db::name('article_reviewer')->where($aWhere)->column('reviewer_id');
$aBatchInsert = [];
if(!empty($aReviewer)){
$aMessagesTypeInfo = $aMessagesType[15];
$sTitle = str_replace('{#accept_sn#}', $sAcceptSn, $aMessagesTypeInfo['title']);
$sContent = str_replace('{#accept_sn#}', $sAcceptSn, $aMessagesTypeInfo['content']);
$aReviewer =array_unique($aReviewer);
foreach ($aReviewer as $key => $value) {
if(empty($value)){
continue;
}
$aBatchInsert[] = ['title' => $sTitle,'content' => $sContent,'type' => 15,'create_time' => time(),'article_id' => $iArticleId,'user_id' => $value];
}
}
$aBatchInsert[] = ['title' => $aInsert['title'],'content' => $aInsert['content'],'type' => $aInsert['type'],'create_time' => time(),'article_id' => $iArticleId,'user_id' => $aInsert['user_id']];
$result = Db::name('messages')->insertAll($aBatchInsert);
if(empty($result)){
return ['status' => 6, 'msg' => '数据插入失败'.Db::getLastSql()."\n数据内容:",'data' => $aParam];
}
}else{
$result = Db::name('messages')->insertGetId($aInsert);
if(empty($result)){
return ['status' => 5, 'msg' => '数据插入失败'.Db::getLastSql()."\n数据内容:",'data' => $aParam];
}
}
return ['status' => 1, 'msg' => '数据插入成功'];
}
/**
* 获取信息
*/
public function get($aParam = []){
//获取参数
$aParam = empty($aParam) ? [] : $aParam;
//必填参数验证
if(empty($aParam['article_id']) || empty($aParam['type']) || empty($aParam['user_id'])){
return ['status' => 2, 'msg' => '非法操作'];
}
//获取表字段 进行字段赋值
$aField = $this->aField;
$aWhere = [];
foreach ($aField as $key => $value) {
if(empty($aParam[$value])){
continue;
}
$aWhere[$value] = $aParam[$value];
}
$aMessages = Db::name('messages')->where($aWhere)->find();
return ['status' => 1, 'msg' => '获取数据成功','data' => $aMessages];
}
}