新增接口
This commit is contained in:
@@ -463,4 +463,151 @@ class Workbench extends Base
|
|||||||
}
|
}
|
||||||
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取审稿权限
|
||||||
|
* @param art_rev_id 审稿记录ID
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public function getReviewerAuth(){
|
||||||
|
|
||||||
|
//获取参数
|
||||||
|
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||||
|
$aData = ['is_review_auth' => 2];//审稿权限1是2否
|
||||||
|
//获取审稿记录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','data' => $aData]);
|
||||||
|
}
|
||||||
|
//获取账号
|
||||||
|
$sAccount = empty($aParam['account']) ? '' : $aParam['account'];
|
||||||
|
if(empty($sAccount)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please enter your account','data' => $aData]);
|
||||||
|
}
|
||||||
|
//查询用户是否存在
|
||||||
|
$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','data' => $aData]);
|
||||||
|
}
|
||||||
|
$iUserId = $aUser['user_id'];
|
||||||
|
|
||||||
|
//查询审稿记录
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId];
|
||||||
|
$aArticleReviewer = Db::name('article_reviewer')->where($aWhere)->find();
|
||||||
|
if(empty($aArticleReviewer)){
|
||||||
|
return json_encode(['status' => 4,'msg' => 'Review record does not exist','data' => $aData]);
|
||||||
|
}
|
||||||
|
$aData['review'] = $aArticleReviewer;
|
||||||
|
//获取文章信息
|
||||||
|
$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' => 5,'msg' => 'The article does not exist','data' => $aData]);
|
||||||
|
}
|
||||||
|
$aArticle['type_name'] = translateType($aArticle['type']);//文章类型
|
||||||
|
//查询期刊信息
|
||||||
|
$aWhere = ['journal_id' => $aArticle['article_id'],'state' => 0];
|
||||||
|
$aJournal = Db::name('journal')->field('title as journal_name,website')->find();
|
||||||
|
if(!empty($aJournal)){
|
||||||
|
$aArticle += $aJournal;
|
||||||
|
}
|
||||||
|
//判断是否有权限审稿
|
||||||
|
$aData['article'] = $aArticle;
|
||||||
|
if($aArticleReviewer['reviewer_id'] != $iUserId){
|
||||||
|
return json_encode(['status' => 6,'msg' => 'No review permission','data' => $aData]);
|
||||||
|
}
|
||||||
|
//判断审稿权限
|
||||||
|
if($aArticle['state'] != 2){
|
||||||
|
return json_encode(['status' => 7,'msg' => 'The article has not entered the review status','data' => $aData]);
|
||||||
|
}
|
||||||
|
//审稿拒绝
|
||||||
|
if($aArticleReviewer['state'] == 2){
|
||||||
|
//获取审稿答卷
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId,'state' => 0];
|
||||||
|
$aQuestion = Db::name('article_reviewer_question')->field('art_rev_id,recommend')->where($aWhere)->find();
|
||||||
|
if(empty($aQuestion)){
|
||||||
|
return json_encode(['status' => 8,'msg' => 'You have declined the review','data' => $aData]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//审稿已过期
|
||||||
|
if($aArticleReviewer['state'] == 4){
|
||||||
|
return json_encode(['status' => 9,'msg' => 'The review has expired','data' => $aData]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//同意/1小改后接收/接收
|
||||||
|
//判断是否为邮件
|
||||||
|
$iIsCode = 2;//是否邮件进入
|
||||||
|
$sAct = empty($aParam['act']) ? '' : $aParam['act'];
|
||||||
|
$aWhere = ['code' => $sAct,'state' => 0];
|
||||||
|
if(!empty($sAct)){
|
||||||
|
//查询绑定的用户ID
|
||||||
|
$aCode = Db::name('login_auto')->field('user_id')->where($aWhere)->find();
|
||||||
|
if(empty($aCode)){
|
||||||
|
return json_encode(['status' => 10,'msg' => 'Code is illegal','data' => $aData]);
|
||||||
|
}
|
||||||
|
if($aCode['user_id'] != $iUserId){
|
||||||
|
return json_encode(['status' => 10,'msg' => 'Illegal code operation','data' => $aData]);
|
||||||
|
}
|
||||||
|
$iIsCode = 1;
|
||||||
|
}
|
||||||
|
//当前时间
|
||||||
|
$iNowTime = time();
|
||||||
|
// 14天 = 14*24*3600 秒 = 1209600 秒
|
||||||
|
$iFourteenDays = 14 * 24 * 3600;
|
||||||
|
//五天
|
||||||
|
$iFiveDays = 5 * 24 * 3600;
|
||||||
|
//审稿邀请
|
||||||
|
if($aArticleReviewer['state'] == 5){
|
||||||
|
if($iIsCode == 1){//邮件进入未同意审稿直接同意
|
||||||
|
//添加时间
|
||||||
|
$iTime = empty($aArticleReviewer['ctime']) ? 0 : $aArticleReviewer['ctime'];
|
||||||
|
if (!is_numeric($iTime) || (int)$iTime <= 0) {
|
||||||
|
return json_encode([
|
||||||
|
'status' => 11,
|
||||||
|
'msg' => 'Invalid record time, the review period has expired',
|
||||||
|
'data' => $aData
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
//判断是否超过5天
|
||||||
|
$timeDiff = $iTime+$iFiveDays;
|
||||||
|
if($timeDiff < $iNowTime){
|
||||||
|
//执行审稿过期
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId,'state' => 5];
|
||||||
|
$result = Db::name('article_reviewer')->where($aWhere)->limit(1)->update(['state' => 4]);
|
||||||
|
return json_encode(['status' => 11,'msg' => 'The number of days for agreeing to review has exceeded 5','data' => $aData]);
|
||||||
|
}
|
||||||
|
// var_dump(date('Y-m-d H:i:s',$timeDiff),date('Y-m-d H:i:s',$iTime),date('Y-m-d H:i:s',$iNowTime));
|
||||||
|
//执行同意审稿
|
||||||
|
$aWhere = ['art_rev_id' => $iArtRevId,'state' => 5];
|
||||||
|
$result = Db::name('article_reviewer')->where($aWhere)->limit(1)->update(['state' => 0,'agree_review_time' => time()]);
|
||||||
|
}
|
||||||
|
if($iIsCode != 1){
|
||||||
|
return json_encode(['status' => 12,'msg' => 'Reviewer did not agree to review','data' => $aData]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//同意审稿
|
||||||
|
if($aArticleReviewer['state'] == 0){
|
||||||
|
//同意审稿的时间
|
||||||
|
$iTime = empty($aArticleReviewer['agree_review_time']) ? 0 : $aArticleReviewer['agree_review_time'];
|
||||||
|
//添加时间
|
||||||
|
$iCtime = empty($aArticleReviewer['ctime']) ? 0 : $aArticleReviewer['ctime'];
|
||||||
|
$iTime = empty($iTime) ? intval($iCtime) : intval($iTime);
|
||||||
|
if (!is_numeric($iTime) || (int)$iTime <= 0) {
|
||||||
|
return json_encode([
|
||||||
|
'status' => 11,
|
||||||
|
'msg' => 'Invalid record time, the review period has expired',
|
||||||
|
'data' => $aData
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
//判断是否超过14天
|
||||||
|
$timeDiff = $iTime+$iFourteenDays;
|
||||||
|
if($timeDiff < $iNowTime){
|
||||||
|
return json_encode(['status' => 11,'msg' => 'The number of days for agreeing to review has exceeded 14','data' => $aData]);
|
||||||
|
}
|
||||||
|
$aData['is_review_auth'] = 1;
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
||||||
|
}
|
||||||
|
$aData['is_review_auth'] = 1;
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aData]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user