diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index a7dc0b5..b8d26f7 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -1288,6 +1288,9 @@ class Article extends Base //增加usermsg add_usermsg($iArticleUserId, 'Your manuscript has new process: ' . $sTitle, '/articleDetail?id=' . $iId); + + //发送邮件 + $aEmailResult = $this->sendEmailForAuthor(['article' => $article_info,'user' => $user_info,'journal' => $journal_info]); return json(['code' => 0]); } //终审判断[3个审稿人审稿意见为:同意/1个审稿人审稿意见为:不同意] chengxiaoling 20250825 end @@ -4812,4 +4815,91 @@ class Article extends Base Db::commit(); return json_encode(['status' => 1, 'msg' => "The field to which the article belongs has been successfully updated"]); } + + /** + * 终审状态-通知作者 + * @param reviewer_id 审核人ID + * @param + */ + private function sendEmailForAuthor($aParam = []) + { + + //稿件信息 + $aArticle = empty($aParam['article']) ? 0 : $aParam['article']; + //作者信息 + $aUser = empty($aParam['user']) ? 0 : $aParam['user']; + //期刊信息 + $aJournal = empty($aParam['journal']) ? 0 : $aParam['journal']; + if(empty($aArticle) || empty($aUser) || empty($aJournal)){ + return ['status' => 2,'msg' => 'Missing information']; + } + + //邮件内容 + $aEmailConfig = [ + + 'email_subject' => 'Manuscript Status Update – Final Decision - {accept_sn}', + 'email_content' => ' + Dear Dr. {realname},

+ I hope this message finds you well.

+ We are writing to inform you that your manuscript entitled “[{article_title}]” (Manuscript ID: [{accept_sn}]) has progressed to the final decision stage.

+ Thank you once again for choosing to submit your valuable manuscript to our journal.

+ Sincerely,
+ Editorial Office
+ {journal_title}
+ Email: {journal_email}
+ Website: {website}' + ]; + //数据准备-邮件内容替换 + $aSearch = [ + '{accept_sn}' => empty($aArticle['accept_sn']) ? '' : $aArticle['accept_sn'],//accept_sn + '{article_title}' => empty($aArticle['title']) ? '' : $aArticle['title'],//文章标题 + '{abstrart}' => empty($aArticle['abstrart']) ? '' : $aArticle['abstrart'],//文章摘要 + '{journal_title}' => empty($aJournal['title']) ? '' : $aJournal['title'],//期刊名 + '{journal_issn}' => empty($aJournal['issn']) ? '' : $aJournal['issn'], + '{journal_email}' => empty($aJournal['email']) ? '' : $aJournal['email'], + '{website}' => empty($aJournal['website']) ? '' : $aJournal['website'], + ]; + + //邮箱 + $email = empty($aUser['email']) ? '' : $aUser['email'];//'tmr@tmrjournals.com';// + if(empty($email)){ + return ['status' => 3,'msg' => 'The author\'s email is empty']; + } + //用户名 + $realname = empty($aUser['account']) ? '' : $aUser['account']; + $realname = empty($aUser['realname']) ? $realname : $aUser['realname']; + $aSearch['{realname}'] = $realname; + //用户账号 + $aSearch['{account}'] = empty($aUser['account']) ? '' : $aUser['account']; + + //邮件标题 + $title = str_replace(array_keys($aSearch), array_values($aSearch),$aEmailConfig['email_subject']); + //邮件内容变量替换 + $content = str_replace(array_keys($aSearch), array_values($aSearch), $aEmailConfig['email_content']); + //带模版的邮件内容 + $pre = \think\Env::get('emailtemplete.pre'); + $net = \think\Env::get('emailtemplete.net'); + $net1 = str_replace("{{email}}",trim($email),$net); + $content=$pre.$content.$net1; + //发送邮件邮箱配置 + $memail = empty($aJournal['email']) ? '' : $aJournal['email']; + $mpassword = empty($aJournal['epassword']) ? '' : $aJournal['epassword']; + //期刊标题 + $from_name = empty($aJournal['title']) ? '' : $aJournal['title']; + + //发送邮件 + $aResult = sendEmail($email,$title,$from_name,$content,$memail,$mpassword); + $iStatus = empty($aResult['status']) ? 1 : $aResult['status']; + $iIsSuccess = $iStatus == 1 ? 1 : 2; + $sMsg = empty($aResult['data']) ? $iIsSuccess : $aResult['data']; + + //添加邮件发送日志 + $iArticleId = empty($aArticle['article_id']) ? 0 : $aArticle['article_id']; + $iUserId = empty($aArticle['user_id']) ? 0 : $aArticle['user_id']; + $aEmailLog = ['article_id' => $iArticleId,'art_rev_id' => $iArticleId,'reviewer_id' => $iUserId,'type' => 7,'email' => $email,'content' => $content,'create_time' => time(),'is_success' => $iIsSuccess,'msg' => $sMsg]; + $oReviewer = new \app\common\Reviewer; + $iId = $oReviewer->addLog($aEmailLog); + + return ['status' => $iIsSuccess,'msg' => $sMsg]; + } }