diff --git a/application/common/Messages.php b/application/common/Messages.php new file mode 100644 index 0000000..dcf3802 --- /dev/null +++ b/application/common/Messages.php @@ -0,0 +1,184 @@ + [ + 'title' => 'Submission Received', + 'content' => 'Your manuscript(ID: {#accept_sn#}) has been successfully submitted.
+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.
+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' => 'Editorial decision issued.
+After evaluation, your manuscript(ID: {#accept_sn#}) has not been accepted for publication. Please refer to the decision letter for details and reviewer comments.' + ],//'退稿通知', + 4 => [ + 'title' => 'Revision Requested', + 'content' => 'Revision requested.
+Editors/reviewers have requested revisions to your manuscript(ID: {#accept_sn#}). Please review the comments and submit your revised version within the required timeframe.' + ],//'退修通知', + 5 => [ + 'title' => 'Accepted for Publication', + 'content' => 'Revision requested.
+Editors/reviewers have requested revisions to your manuscript(ID: {#accept_sn#}). Please review the comments and submit your revised version within the required timeframe.' + ],//'录用通知', + 6 => [ + 'title' => 'APC Payment Required', + 'content' => 'APC payment required.
+Your manuscript(ID: {#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' => 'Proofs ready for review.
+Your manuscript(ID: {#accept_sn#}) proof is available. Please check and confirm carefully within 48 hours.' + ],//'校对通知', + 8 => [ + 'title' => 'Manuscript Published Online', + 'content' => 'Your article is now published online!
+The final version of your manuscript(ID: {#accept_sn#}) is available on the journal website. Thank you for publishing with us.' + ],//'发表通知', + 9 => [ + 'title' => 'APC Update', + 'content' => 'APC update applied.
+The Article Processing Charge for your manuscript(ID: {#accept_sn#}) has been adjusted. Please check the updated payment details in your submission dashboard.' + ],//'稿费修改', + 10 => [ + 'title' => 'Review Invitation(ID: {#accept_sn#})', + 'content' => 'Review invitation received.
+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' => 'Reminder: Review invitation pending.
+You have a pending review invitation (ID: {#accept_sn#}). Kindly respond at your earliest convenience.' + ],//'审稿提醒', + 12 => [ + 'title' => 'Review Report Reminder', + 'content' => 'Reminder: Review report due.
+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' => 'Re-review request received.
+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' => 'Reminder: Re-review pending.
+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' => 'Review assignment closed.
+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]; + } +}