接口新增
This commit is contained in:
@@ -610,4 +610,272 @@ class Workbench extends Base
|
|||||||
$aData['is_review_auth'] = 1;
|
$aData['is_review_auth'] = 1;
|
||||||
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 审稿人邮件链接失效-重新申请邮件
|
||||||
|
*/
|
||||||
|
public function applySendEmail(){
|
||||||
|
//获取参数
|
||||||
|
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||||
|
//获取审稿记录ID
|
||||||
|
$iArtRevId = empty($aParam['art_rev_id']) ? 0 : $aParam['art_rev_id'];
|
||||||
|
if(empty($iArtRevId)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please select a record']);
|
||||||
|
}
|
||||||
|
//获取账号
|
||||||
|
$sAccount = empty($aParam['account']) ? '' : $aParam['account'];
|
||||||
|
if(empty($sAccount)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please enter your account']);
|
||||||
|
}
|
||||||
|
//查询用户是否存在
|
||||||
|
$aWhere = ['account' => $sAccount,'state' => 0];
|
||||||
|
$aUser = Db::name('user')->field('user_id')->where($aWhere)->find();
|
||||||
|
if(empty($aUser)){
|
||||||
|
return json_encode(['status' => 3,'msg' => 'Account does not exist']);
|
||||||
|
}
|
||||||
|
$iUserId = $aUser['user_id'];
|
||||||
|
|
||||||
|
//查询审稿记录
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId];
|
||||||
|
$aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,reviewer_id,article_id,state')->where($aWhere)->find();
|
||||||
|
if(empty($aArticleReviewer)){
|
||||||
|
return json_encode(['status' => 4,'msg' => 'Review record does not exist']);
|
||||||
|
}
|
||||||
|
if($aArticleReviewer['state'] != 4){
|
||||||
|
return json_encode(['status' => 5,'msg' => 'The review link has not expired and no application is required']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取文章信息
|
||||||
|
$aWhere = ['article_id' => $aArticleReviewer['article_id']];
|
||||||
|
$aArticle = Db::name('article')->field('article_id,abstrart,title article_title,type,accept_sn,journal_id,state')->where($aWhere)->find();
|
||||||
|
if(empty($aArticle)){
|
||||||
|
return json_encode(['status' => 6,'msg' => 'The article does not exist']);
|
||||||
|
}
|
||||||
|
if($aArticle['state'] != 2){
|
||||||
|
return json_encode(['status' => 7,'msg' => 'The article is not in the review status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询期刊信息
|
||||||
|
$aWhere = ['journal_id' => $aArticle['article_id'],'state' => 0];
|
||||||
|
$aJournal = Db::name('journal')->field('title as journal_name,website')->find();
|
||||||
|
//查询期刊信息
|
||||||
|
if(empty($aArticle['journal_id'])){
|
||||||
|
return json_encode(array('status' => 8,'msg' => 'The article is not associated with a journal' ));
|
||||||
|
}
|
||||||
|
$aWhere = ['state' => 0,'journal_id' => $aArticle['journal_id']];
|
||||||
|
$aJournal = Db::name('journal')->where($aWhere)->find();
|
||||||
|
if(empty($aJournal)){
|
||||||
|
return json_encode(array('status' => 9,'msg' => 'No journal information found' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询编辑邮箱
|
||||||
|
$iUserId = empty($aJournal['editor_id']) ? 0 : $aJournal['editor_id'];
|
||||||
|
if(empty($iUserId)){
|
||||||
|
return json_encode(array('status' => 10,'msg' => 'The journal to which the article belongs has not designated a responsible editor' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询审稿人跟编辑的信息
|
||||||
|
$aUserId = [$aArticleReviewer['reviewer_id'],$iUserId];
|
||||||
|
$aWhere = ['user_id' => ['in',$aUserId],'state' => 0,'email' => ['<>','']];
|
||||||
|
$aUser = Db::name('user')->field('user_id,email,realname,account')->where($aWhere)->select();
|
||||||
|
if(empty($aUser)){
|
||||||
|
return json_encode(['status' => 11,'msg' => "Reviewer and editor information not found"]);
|
||||||
|
}
|
||||||
|
$aUser = array_column($aUser, null,'user_id');
|
||||||
|
|
||||||
|
//处理发邮件
|
||||||
|
//邮件模版
|
||||||
|
$aEmailConfig = [
|
||||||
|
'email_subject' => 'Request to Reopen Expired Review Link---{accept_sn}',
|
||||||
|
'email_content' => '
|
||||||
|
Dear Editor,<br><br>
|
||||||
|
The reviewer would like to reopen the expired review link for the manuscript. Below are the details:<br>
|
||||||
|
Reviewer Information:<br>
|
||||||
|
Real Name:{realname}<br>
|
||||||
|
Email:{email}<br><br>
|
||||||
|
Sincerely,<br>Editorial Office<br>
|
||||||
|
<a href="https://www.tmrjournals.com/draw_up.html?issn={journal_issn}">Subscribe to this journal</a><br>{journal_title}<br>
|
||||||
|
Email: {journal_email}<br>
|
||||||
|
Website: {website}'
|
||||||
|
];
|
||||||
|
//邮件内容
|
||||||
|
$aSearch = [
|
||||||
|
'{accept_sn}' => empty($aArticle['accept_sn']) ? '' : $aArticle['accept_sn'],//accept_sn
|
||||||
|
'{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'],
|
||||||
|
'{realname}' => empty($aUser[$aArticleReviewer['reviewer_id']]['realname']) ? '' : $aUser[$aArticleReviewer['reviewer_id']]['realname'],
|
||||||
|
'{email}' => empty($aUser[$aArticleReviewer['reviewer_id']]['email']) ? '' : $aUser[$aArticleReviewer['reviewer_id']]['email'],
|
||||||
|
];
|
||||||
|
|
||||||
|
//发邮件
|
||||||
|
//邮箱
|
||||||
|
$email = empty($aUser[$iUserId]['email']) ? '' : $aUser[$iUserId]['email'];
|
||||||
|
if(empty($email)){
|
||||||
|
return json_encode(['status' => 8,'msg' => 'Edit email as empty']);
|
||||||
|
}
|
||||||
|
$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 = 2;
|
||||||
|
$sMsg = empty($aResult['data']) ? '失败' : $aResult['data'];
|
||||||
|
if($iStatus == 1){
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success']);
|
||||||
|
}
|
||||||
|
return json_encode(['status' => 8,'msg' => 'fail']);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑审稿人邮件链接失效-重开
|
||||||
|
*/
|
||||||
|
public function updateReviewerState(){
|
||||||
|
|
||||||
|
//获取参数
|
||||||
|
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||||
|
|
||||||
|
//获取审稿记录ID
|
||||||
|
$iArtRevId = empty($aParam['art_rev_id']) ? 0 : $aParam['art_rev_id'];
|
||||||
|
if(empty($iArtRevId)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please select a record']);
|
||||||
|
}
|
||||||
|
//获取账号
|
||||||
|
$sAccount = empty($aParam['account']) ? '' : $aParam['account'];
|
||||||
|
if(empty($sAccount)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please enter your account']);
|
||||||
|
}
|
||||||
|
//查询用户是否存在
|
||||||
|
$aWhere = ['account' => $sAccount,'state' => 0];
|
||||||
|
$aUser = Db::name('user')->field('user_id,account,email')->where($aWhere)->find();
|
||||||
|
if(empty($aUser)){
|
||||||
|
return json_encode(['status' => 3,'msg' => 'Account does not exist']);
|
||||||
|
}
|
||||||
|
$iUserId = $aUser['user_id'];
|
||||||
|
|
||||||
|
//查询审稿记录
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId];
|
||||||
|
$aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,reviewer_id,article_id,state')->where($aWhere)->find();
|
||||||
|
if(empty($aArticleReviewer)){
|
||||||
|
return json_encode(['status' => 4,'msg' => 'Review record does not exist']);
|
||||||
|
}
|
||||||
|
if($aArticleReviewer['state'] != 4){
|
||||||
|
return json_encode(['status' => 5,'msg' => 'The review link has not expired and no application is required']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取文章信息
|
||||||
|
$aWhere = ['article_id' => $aArticleReviewer['article_id']];
|
||||||
|
$aArticle = Db::name('article')->field('article_id,abstrart,title,type,accept_sn,journal_id,state')->where($aWhere)->find();
|
||||||
|
if(empty($aArticle)){
|
||||||
|
return json_encode(['status' => 6,'msg' => 'The article does not exist']);
|
||||||
|
}
|
||||||
|
if($aArticle['state'] != 2){
|
||||||
|
return json_encode(['status' => 7,'msg' => 'The article is not in the review status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询期刊信息
|
||||||
|
$aWhere = ['journal_id' => $aArticle['article_id'],'state' => 0];
|
||||||
|
$aJournal = Db::name('journal')->field('title as journal_name,website')->find();
|
||||||
|
//查询期刊信息
|
||||||
|
if(empty($aArticle['journal_id'])){
|
||||||
|
return json_encode(array('status' => 8,'msg' => 'The article is not associated with a journal' ));
|
||||||
|
}
|
||||||
|
$aWhere = ['state' => 0,'journal_id' => $aArticle['journal_id']];
|
||||||
|
$aJournal = Db::name('journal')->where($aWhere)->find();
|
||||||
|
if(empty($aJournal)){
|
||||||
|
return json_encode(array('status' => 9,'msg' => 'No journal information found' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断编辑的操作权限
|
||||||
|
$iEditorId = empty($aJournal['editor_id']) ? 0 : $aJournal['editor_id'];
|
||||||
|
if($iEditorId != $iUserId){
|
||||||
|
return json_encode(array('status' => 10,'msg' => 'This article is not authorized for operation under the journal you are responsible for' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新文章状态为邀请
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId,'state' => 4];
|
||||||
|
$result = Db::name('article_reviewer')->where($aWhere)->limit(1)->update(['state' => 5,'ctime' => time(),'editor_act' => 1]);
|
||||||
|
if($result === false){
|
||||||
|
return json_encode(array('status' => 11,'msg' => 'Status update failed' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询审稿人的邮箱
|
||||||
|
$aWhere = ['user_id' => $aArticleReviewer['reviewer_id'],'state' => 0,'email' => ['<>','']];
|
||||||
|
$aUser = Db::name('user')->field('user_id,email,realname,account')->where($aWhere)->find();
|
||||||
|
if(empty($aUser)){
|
||||||
|
return json_encode(['status' => 12,'msg' => "Reviewer and editor information not found"]);
|
||||||
|
}
|
||||||
|
//处理发邮件
|
||||||
|
//邮箱
|
||||||
|
$email = empty($aUser['email']) ? '' : $aUser['email'];
|
||||||
|
if(empty($email)){
|
||||||
|
return json_encode(['status' => 13,'msg' => 'Reviewer email as empty']);
|
||||||
|
}
|
||||||
|
//邮件模版
|
||||||
|
$aEmailConfig = [
|
||||||
|
'email_subject' => 'Invitation to review a manuscript for {journal_title}-[{accept_sn}]',
|
||||||
|
'email_content' => '
|
||||||
|
Dear Dr. {realname},<br><br>
|
||||||
|
The manuscript entitled "{article_title}" has been submitted to the journal {journal_title}.The Editor-in-Chief would be most grateful if you could offer an opinion regarding its suitability for publication in the journal {journal_title}. <br><br>
|
||||||
|
<b style="font-size: 14px;">Abstract of the Manuscript:</b><br>
|
||||||
|
<b style="font-size: 12px;">{abstrart}</b><br><br>
|
||||||
|
Please let us know if there are any potential conflicts of interest and click the following link to review the manuscript.<br>
|
||||||
|
<a href="{creatLoginUrlForreviewer}">Click here to accept the invitation to review</a><br>
|
||||||
|
Your username: {account}<br>
|
||||||
|
Your original password:123456qwe, if you have reset the password, please login with the new one or click the "<a href="https://submission.tmrjournals.com/retrieve">forgot password</a>".<br>
|
||||||
|
Thank you for your continued support of our journal.<br><br>
|
||||||
|
Sincerely,<br>Editorial Office<br>
|
||||||
|
<a href="https://www.tmrjournals.com/draw_up.html?issn={journal_issn}">Subscribe to this journal</a><br>{journal_title}<br>
|
||||||
|
Email: {journal_email}<br>
|
||||||
|
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'],
|
||||||
|
];
|
||||||
|
//用户名
|
||||||
|
$realname = empty($aUser['account']) ? '' : $aUser['account'];
|
||||||
|
$realname = empty($aUser['realname']) ? $realname : $aUser['realname'];
|
||||||
|
$aSearch['{realname}'] = $realname;
|
||||||
|
//用户账号
|
||||||
|
$aSearch['{account}'] = empty($aUser['account']) ? '' : $aUser['account'];
|
||||||
|
//审稿链接
|
||||||
|
$oArticle = new \app\api\controller\Article;
|
||||||
|
$aSearch['{creatLoginUrlForreviewer}'] = $oArticle->creatLoginUrlForreviewer(['user_id' => $aArticleReviewer['reviewer_id']],$iArtRevId);
|
||||||
|
$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 = 2;
|
||||||
|
$sMsg = empty($aResult['data']) ? '失败' : $aResult['data'];
|
||||||
|
if($iStatus == 1){
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success']);
|
||||||
|
}
|
||||||
|
return json_encode(['status' => 14,'msg' => 'fail']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user