request->post() : $aParam; //获取账号 $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(); $iUserId = empty($aUser['user_id']) ? 0: $aUser['user_id']; if(empty($iUserId)){ return json_encode(['status' => 2,'msg' => 'Account does not exist']); } //获取状态 $iState = isset($aParam['state']) ? $aParam['state'] : -2; //空的查询条件 $aWhere = []; //SN $sAcceptSn = empty($aParam['accept_sn']) ? '': $aParam['accept_sn']; if(!empty($sAcceptSn)){ $aWhere = ['accept_sn' => trim($sAcceptSn)]; } //标题 $sTitle = empty($aParam['title']) ? '': $aParam['title']; if(!empty($sTitle)){ $aWhere = ['title' => ['like','%'.trim($sTitle).'%']]; } //国家 $sCountry = -1; if(empty($sAcceptSn) && empty($sTitle)){ //获取期刊ID $iJournalId = empty($aParam['journal_id']) ? 0: $aParam['journal_id']; //查询账号所管理的期刊 $aJournalWhere = ['editor_id' => $iUserId,'state' => 0]; $aJournalId = DB::name('journal')->where($aJournalWhere)->column('journal_id'); if(empty($iJournalId) && empty($aJournalId)){ return json_encode(['status' => 2,'msg' => 'No journals managed by this account were found']); } if(!empty($iJournalId) && empty($aJournalId)){ return json_encode(['status' => 2,'msg' => 'This account cannot view articles under the selected journal']); } if(!empty($iJournalId) && !empty($aJournalId)){ if(!in_array($iJournalId, $aJournalId)){ return json_encode(['status' => 2,'msg' => 'This account cannot view articles under the selected journal']); } $aWhere['journal_id'] = $iJournalId; } if(empty($iJournalId) && !empty($aJournalId)){//期刊ID $aWhere['journal_id'] = ['in',$aJournalId]; } if($iState >= 0){ $aWhere['state'] = $iState; }else{ $aWhere['state'] = ['in',[0,1,2,4,6,7,8]]; } //国家 $sCountry = empty($aParam['country']) ? 0 : $aParam['country']; } //获取分页相关参数 $iSize = empty($aParam['size']) ? 15 : $aParam['size'];//每页显示条数 $iPage = empty($aParam['page']) ? 1 : $aParam['page'];// 当前页码 //统计数量 $sAuthorQuery = ''; $aAuthorWhere = []; if($sCountry == 1){ $aAuthorWhere = ['state' => 0, 'country' => 'China']; } if($sCountry == 2){ $aAuthorWhere = ['state' => 0, 'country' => ['<>','China']]; } if(!empty($aAuthorWhere)){ $sAuthorQuery = Db::name('article_author')->field('DISTINCT article_id')->where($aAuthorWhere)->buildSql(); } if(empty($sAuthorQuery)){ $iCount = Db::name('article')->where($aWhere)->count(); } if(!empty($sAuthorQuery)){ $iCount = Db::name('article')->where($aWhere) ->join(Db::raw("({$sAuthorQuery}) article_author"),'article_author.article_id = t_article.article_id') ->count(); } if(empty($iCount)){ return json_encode(['status' => 1,'msg' => 'Article not found','data' => ['total' => 0,'lists' => []]]); } //判断页数是否超过最大分页限制 $iPageNum = ceil($iCount/$iSize); if($iPage > $iPageNum){ return json_encode(['status' => 1,'msg' => 'The number of pages has exceeded the limit, maximum page number:'.$iPageNum,'data' => ['total' => $iCount,'lists' => []]]); } $sField = 't_article.article_id,t_article.journal_id,t_article.accept_sn,t_article.title,t_article.type,t_article.scoring,t_article.h_fen,t_article.b_fen,t_article.c_fen,t_article.dw_fen,t_article.ly_fen,t_article.jj_fen,t_article.remarks,t_article.special_num,t_article.is_user_act,t_article.user_update_time,t_article.state,t_article.repetition,t_article.is_buy'; $sOrder = 't_article.is_user_act asc,t_article.user_update_time desc,t_article.article_id desc'; if(empty($sAuthorQuery)){ $aArticle = Db::name('article') ->field($sField) ->where($aWhere) ->page($iPage, $iSize) ->order($sOrder) ->select(); } if(!empty($sAuthorQuery)){ $aArticle = Db::name('article') ->field($sField) ->where($aWhere) ->join(Db::raw("({$sAuthorQuery}) article_author"),'article_author.article_id = t_article.article_id') ->page($iPage, $iSize) ->order($sOrder) ->select(); } if(empty($aArticle)){ return json_encode(['status' => 1,'msg' => 'Data is empty']); } //查询通讯作者 $aAuthorData = []; $aArticleId = array_column($aArticle, 'article_id'); $aWhere = ['article_id' => ['in',$aArticleId],'state' => 0,'is_report' => 1,'email' => ['<>','']]; if($sCountry == 1){ $aWhere['country'] = 'China'; } if($sCountry == 2){ $aWhere['country'] = ['<>','China']; } $aAuthor = Db::name('article_author')->field('art_aut_id,article_id,email,country')->where($aWhere)->select(); if(!empty($aAuthor)){ $aEmail = array_unique(array_column($aAuthor, 'email')); if(!empty($aEmail)){ $aWhere = ['email' => ['in',$aEmail],'state' => 0]; $aUser = Db::name('user')->field('user_id,realname,phone,email,wos_index,scopus_index,wos_time,scopus_time')->where($aWhere)->select(); $aUser = empty($aUser) ? [] : array_column($aUser, null,'email'); } //数据处理 foreach ($aAuthor as $key => $value) { if(!empty($value['country'])){ $aCountry[$value['article_id']][] = trim($value['country']); } if(!empty($aUser[$value['email']])){ $value += $aUser[$value['email']]; } $aAuthorData[$value['article_id']][] = $value; } } //预接收查询文章的付费状态 // if($iState == 6){ // $aWhere = ['article_id' => ['in',$aArticleId]]; // $aOrder = Db::name('order')->where($aWhere)->column('article_id,ps_id'); // $aPsId = empty($aOrder) ? [] : array_values($aOrder); // if(!empty($aPsId)){ // $aWhere = ['ps_id' => ['in',$aPsId]]; // $aPaystation = Db::name('paystation')->field('ps_id,request_time pay_time,amount pay_mount')->where($aWhere)->select(); // $aPaystation = empty($aPaystation) ? [] : array_column($aPaystation, null,'ps_id'); // } // } foreach ($aArticle as $key => $value) { $aAuthorInfo = empty($aAuthorData[$value['article_id']]) ? [] : $aAuthorData[$value['article_id']]; $aArticle[$key]['report'] = $aAuthorInfo; $aArticle[$key]['country'] = empty($aAuthorInfo) ? [] : array_unique(array_column($aAuthorInfo, 'country')); $aArticle[$key]['type_name'] = translateType($value['type']); // //付款信息 // $iPsId = empty($aOrder[$value['article_id']]) ? 0 : $aOrder[$value['article_id']]; // $aArticle[$key]['pay_time'] = empty($aPaystation[$iPsId]['pay_time']) ? '' : $aPaystation[$iPsId]['pay_time']; // $aArticle[$key]['pay_mount'] = empty($aPaystation[$iPsId]['pay_mount']) ? '' : $aPaystation[$iPsId]['pay_mount']; } return json_encode(['status' => 1,'msg' => 'success','data' => ['total' => $iCount,'lists' => $aArticle]]); } /** * 获取文章详情 */ public function get($aParam = []){ //获取参数 $aParam = empty($aParam) ? $this->request->post() : $aParam; //获取文章ID $iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id']; //SN $sAcceptSn = empty($aParam['accept_sn']) ? '': $aParam['accept_sn']; if(empty($iArticleId) && empty($sAcceptSn)){ return json_encode(['status' => 2,'msg' => 'Please select the article']); } //获取账号 $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' => 2,'msg' => 'Account does not exist']); } //查询条件 $aWhere = []; if(!empty($iArticleId)){ $aWhere['article_id'] = $iArticleId; } if(!empty($sAcceptSn)){ $aWhere['accept_sn'] = $sAcceptSn; } $aArticle = Db::name('article')->where($aWhere)->find(); if(!empty($aArticle)){ $aArticle['act_user_id'] = empty($aUser['user_id']) ? 0 : $aUser['user_id']; } return json_encode(['status' => 1,'msg' => 'success','data' => $aArticle]); } /** * 获取文章审稿记录 */ public function getArticleReviewRecord($aParam = []){ //获取参数 $aParam = empty($aParam) ? $this->request->post() : $aParam; //获取文章信息 $aArticle = json_decode($this->get($aParam),true); $iStatus = empty($aArticle['status']) ? 0 : $aArticle['status']; if($iStatus != 1){ return json_encode($aArticle); } $aArticle = empty($aArticle['data']) ? [] : $aArticle['data']; if(empty($aArticle)){ return json_encode(['status' => 3,'msg' => 'The article does not exist']); } //查询文章审稿记录 $iArticleId = empty($aArticle['article_id']) ? 0 : $aArticle['article_id']; $aWhere = ['article_id' => $iArticleId,'state' => ['between',[0,3]]]; $aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,state,ctime,reviewer_id')->where($aWhere)->select(); if(empty($aArticleReviewer)){ return json_encode(['status' => 1,'msg' => 'No review record found for the article']); } //查询初审问卷 $aArtRevId = array_column($aArticleReviewer, 'art_rev_id'); $aWhere = ['art_rev_id' => ['in',$aArtRevId],'state' => 0]; $aQuestion = Db::name('article_reviewer_question')->field('art_rev_id,ctime,score,rated,recommend')->where($aWhere)->order('ctime asc')->select(); $aQuestion = empty($aQuestion) ? [] : array_column($aQuestion, null,'art_rev_id'); //查询复审 $aReviewerRepeatLists = []; $aWhere = ['art_rev_id' => ['in',$aArtRevId],'recommend' => ['between',[1,3]]]; $aReviewerRepeat = Db::name('article_reviewer_repeat')->field('art_rev_rep_id,art_rev_id,recommend,ctime,stime')->where($aWhere)->select(); if(!empty($aReviewerRepeat)){ foreach ($aReviewerRepeat as $key => $value) { $aReviewerRepeatLists[$value['art_rev_id']][] = $value; } } //查询审稿人信息 $aUserId = array_unique(array_column($aArticleReviewer, 'reviewer_id')); $aWhere = ['user_id' => ['in',$aUserId],'state' => 0]; $aUser = Db::name('user')->where($aWhere)->column('user_id,realname'); foreach ($aArticleReviewer as $key => $value) { $aQuestionData = empty($aQuestion[$value['art_rev_id']]) ? [] : $aQuestion[$value['art_rev_id']]; $value['ctime'] = empty($aQuestionData['ctime']) ? $value['ctime'] : $aQuestionData['ctime']; $value['score'] = empty($aQuestionData['score']) ? 0 : $aQuestionData['score']; $value['repeat'] = empty($aReviewerRepeatLists[$value['art_rev_id']]) ? [] : $aReviewerRepeatLists[$value['art_rev_id']]; $value['rated'] = empty($aQuestionData['rated']) ? 0 : $aQuestionData['rated']; $value['realname'] = empty($aUser[$value['reviewer_id']]) ? '' : $aUser[$value['reviewer_id']]; $value['recommend'] = empty($aQuestionData['recommend']) ? 0 : $aQuestionData['recommend']; $aArticleReviewer[$key] = $value; } return json_encode(['status' => 1,'msg' => 'success','data' => $aArticleReviewer]); } /** * 获取用户信息 */ public function getCorrespondingInfo(){ //获取参数 $aParam = empty($aParam) ? $this->request->post() : $aParam; //获取通讯作者ID $iArtAutId = empty($aParam['art_aut_id']) ? 0 : $aParam['art_aut_id']; if(empty($iArtAutId)){ return json_encode(['status' => 2,'msg' => 'Please select the user']); } //获取文章ID $iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id']; if(empty($iArticleId)){ return json_encode(['status' => 2,'msg' => 'Please select the article']); } $aWhere = ['article_id' => $iArticleId]; $aArticle = Db::name('article')->where($aWhere)->find(); if(empty($aArticle)){ return json_encode(['status' => 3,'msg' => 'The article does not exist']); } //查询通讯作者 $aWhere = ['art_aut_id' => $iArtAutId,'article_id' => $iArticleId,'state' => 0,'is_report' => 1,'email' => ['<>','']]; $aAuthor = Db::name('article_author')->field('art_aut_id,email,author_title,firstname,lastname,company,country')->where($aWhere)->find(); if(empty($aAuthor)){ return json_encode(['status' => 4,'msg' => 'Author information not found']); } //获取主信息 $sEmail = empty($aAuthor['email']) ? '' : $aAuthor['email']; $aWhere = ['email' => $sEmail,'state' => 0]; $aUser = Db::name('user')->field('user_id,realname,phone,email,remark,wos_index,wos_time,g_author,g_website,google_index,google_time,google_editor,scopus_index,scopus_time,scopus_website,scopus_editor')->where($aWhere)->find(); if(empty($aUser)){ return json_encode(['status' => 1,'msg' => 'User does not exist']); } // //获取附属信息 // $iUserId = $aUser['user_id']; // $aWhere = ['reviewer_id' => $iUserId,'state' => 0]; // $aUserInfo = Db::name('user_reviewer_info')->field('technical,country,introduction,company,website,field')->where($aWhere)->find(); // if(!empty($aUserInfo)){ // $aUser += $aUserInfo; // } $aUser += $aAuthor; return json_encode(['status' => 1,'msg' => 'success','data' => ['article' => $aArticle,'user' => $aUser]]); } /** * 更新文章是否有新操作状态 */ public function updateArticleState(){ //获取参数 $aParam = empty($aParam) ? $this->request->post() : $aParam; //主键ID $iActId = empty($aParam['act_id']) ? 0 : $aParam['act_id']; //主键父ID $iActPId = empty($aParam['act_p_id']) ? 0 : $aParam['act_p_id']; //类型 $iType = empty($aParam['type']) ? 0 : $aParam['type']; if(empty($iType)){ return json_encode(['status' => 2,'msg' => 'Missing parameter']); } $aType = is_string($iType) ? explode(',', $iType) : [$iType]; //获取文章信息 $aArticle = json_decode($this->get($aParam),true); $iStatus = empty($aArticle['status']) ? 0 : $aArticle['status']; if($iStatus != 1){ return json_encode($aArticle); } $aArticle = empty($aArticle['data']) ? [] : $aArticle['data']; if(empty($aArticle)){ return json_encode(['status' => 3,'msg' => 'The article does not exist']); } $iIsUseAct = empty($aArticle['is_user_act']) ? -1 : $aArticle['is_user_act']; if($iIsUseAct != 1){ return json_encode(['status' => 4,'msg' => 'No action required']); } //文章ID $iArticleId = empty($aArticle['article_id']) ? 0 : $aArticle['article_id']; //查询日志 $aLogWhere = ['article_id' => $iArticleId,'type' => ['in',$aType],'is_view' => 2]; if(in_array(1, $aType) || in_array(2, $aType)){//初审/复审 $aWhere['act_p_id'] = $iActPId; } if(in_array(3, $aType)){//终审 $aWhere['act_id'] = $iActId; } $aLog = Db::name('user_act_log')->field('log_id')->where($aLogWhere)->find(); if(empty($aLog)){ return json_encode(['status' => 5,'msg' => 'log does not exist']); } //更新状态 Db::startTrans(); $aLogWhere = ['article_id' => $iArticleId,'is_view' => 2]; $aLogUpdate = ['is_view' => 1,'update_time' => time(),'update_user_id' => empty($aArticle['act_user_id']) ? 0 : $aArticle['act_user_id']]; $log_update_result = Db::name('user_act_log')->where($aLogWhere)->update($aLogUpdate); if($log_update_result === false){ return json_encode(['status' => 5,'msg' => 'Log Update failed']); } $aUpdate = ['is_user_act' => 2,'user_update_time' => 0,'update_time' => time()]; $aWhere = ['article_id' => $aArticle['article_id']]; $result = Db::name('article')->where($aWhere)->limit(1)->update($aUpdate); if($result === false){ return json_encode(['status' => 5,'msg' => 'Update failed']); } Db::commit(); return json_encode(['status' => 1,'msg' => 'Update successful']); } /** * 获取审稿记录详情 */ public function getArticleReviewDetail(){ //获取参数 $aParam = empty($aParam) ? $this->request->post() : $aParam; //获取文章ID $iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id']; if(empty($iArticleId)){ return json_encode(['status' => 2,'msg' => 'Please select the article']); } //获取审稿记录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']); } //获取复审记录ID $iArtRevRepId = empty($aParam['art_rev_rep_id']) ? 0 : $aParam['art_rev_rep_id']; if(empty($iArtRevId) && empty($iArtRevRepId)){ return json_encode(['status' => 2,'msg' => 'Please select a record']); } //查询文章 $aArticle = json_decode($this->get($aParam),true); $iStatus = empty($aArticle['status']) ? 0 : $aArticle['status']; if($iStatus != 1){ return json_encode($aArticle); } $aArticle = empty($aArticle['data']) ? [] : $aArticle['data']; //查询审稿记录 $aWhere = ['art_rev_id' => $iArtRevId,'article_id' => $iArticleId]; $aArticleReviewer = Db::name('article_reviewer')->field('art_rev_id,reviewer_id,ctime')->where($aWhere)->find(); if(empty($aArticleReviewer)){ return json_encode(['status' => 3,'msg' => 'Review record does not exist']); } if(empty($iArtRevRepId)){ //查询初审问卷 $aWhere = ['art_rev_id' => $iArtRevId]; $aQuestion = Db::name('article_reviewer_question')->field('is_anonymous')->where($aWhere)->find(); $aArticleReviewer['is_anonymous'] = empty($aQuestion['is_anonymous']) ? 0 : $aQuestion['is_anonymous']; } //查询审稿人姓名 $iUserId = empty($aArticleReviewer['reviewer_id']) ? 0 : $aArticleReviewer['reviewer_id']; if(!empty($iUserId)){ $aWhere = ['user_id' => $iUserId,'state' => 0]; $aUser = Db::name('user')->field('realname,email')->where($aWhere)->find(); $aArticleReviewer['realname'] = empty($aUser['realname']) ? '' : $aUser['realname']; $aArticleReviewer['email'] = empty($aUser['email']) ? '' : $aUser['email']; } //组装信息 $aData = ['article' => $aArticle,'article_reviewer' => $aArticleReviewer]; //查询复审信息 if(!empty($iArtRevRepId)){ //查询初审问卷 $aWhere = ['art_rev_id' => $iArtRevId,'art_rev_rep_id' => $iArtRevRepId]; $aData['article_reviewer_repeat'] = Db::name('article_reviewer_repeat')->where($aWhere)->find(); } return json_encode(['status' => 1,'msg' => 'success','data' => $aData]); } }