From a5f8f630f6775be9a5d294afc1f0593ac7b32363 Mon Sep 17 00:00:00 2001 From: chengxl Date: Wed, 23 Apr 2025 11:27:11 +0800 Subject: [PATCH] =?UTF-8?q?ai=E6=8E=A8=E8=8D=90=E5=AE=A1=E7=A8=BF=E4=BA=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Recommend.php | 41 +++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/application/api/controller/Recommend.php b/application/api/controller/Recommend.php index 05e0ad5..cca3b4c 100644 --- a/application/api/controller/Recommend.php +++ b/application/api/controller/Recommend.php @@ -32,7 +32,7 @@ class Recommend extends Base $iSize = empty($aParam['size']) ? 10 : $aParam['size']; $iPage = empty($aParam['page']) ? 1 : $aParam['page']; $limit_start = ($iPage - 1) * $iSize; -// $aParam['article_id'] = 5972; + if(empty($aParam['article_id'])){ exit(json_encode(array('status' => 2,'msg' => 'Please select an article' ))); } @@ -42,25 +42,17 @@ class Recommend extends Base if(empty($aArticle)){ exit(json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' ))); } - //查询用户信息 - $aUserInfo = Db::name('user')->field('email')->where('user_id',$aArticle['user_id'])->find(); - $sEmail = empty($aUserInfo['email']) ? '' : $aUserInfo['email']; - //查询文章作者详情 作者和审稿人的机构不一致 - $aAuthor = Db::name('article_author')->field('company')->where(['article_id'=>$aArticle['article_id'],'email' => $sEmail])->find(); - if(empty($aAuthor)){ - exit(json_encode(array('status' => 4,'msg' => 'No detailed information about the author of the article was found' ))); - } //查询文章领域 $aMajorId = Db::table('t_major_to_article')->where('article_id',$aArticle['article_id'])->column('major_id'); if(empty($aMajorId)){ - exit(json_encode(array('status' => 5,'msg' => 'No field found for the article' ))); + exit(json_encode(array('status' => 1,'msg' => 'No field found for the article','data' => []))); } //查询文章领域下的审稿人 $aMajorUser = Db::name('major_to_user')->whereIn('major_id', $aMajorId)->where('state',0)->order('major_id asc')->column('user_id'); if(empty($aMajorUser)){ - exit(json_encode(array('status' => 6,'msg' => 'No reviewers in the field of the article were found' ))); + exit(json_encode(array('status' => 1,'msg' => 'No reviewers in the field of the article were found','data' => []))); } $aMajorUser = array_unique($aMajorUser); @@ -91,25 +83,38 @@ class Recommend extends Base } //查用户信息 $aWhere['user_id'] = ['in',$aMajorUser]; - //查询作者关联的文章 + + //查询文章作者详情 作者和审稿人的机构不一致 + $aUserInfo = Db::name('user')->field('email')->where('user_id',$aArticle['user_id'])->find(); + $sEmail = empty($aUserInfo['email']) ? '' : $aUserInfo['email']; if(!empty($sEmail)){ + $aAuthor = Db::name('article_author')->field('company')->where(['article_id'=>$aArticle['article_id'],'email' => $sEmail,'state' => 0])->find(); + if(empty($aAuthor)){ + exit(json_encode(array('status' => 1,'msg' => 'No detailed information about the author of the article was found','data' => []))); + } + //查询该用户关联的文章ID $aArticleId = Db::name('article_author')->where('email', $sEmail)->column('article_id'); if(!empty($aArticleId)){ + //查询审稿人的邮箱 $aUserEmail = Db::table('t_user')->where($aWhere)->column('email'); + + //查询作者不为同一篇文章的审稿人 + $aArticleId = array_unique($aArticleId); $aAuthorEmail = Db::name('article_author')->where(['article_id'=>['not in',$aArticleId],'email' => ['in',$aUserEmail]])->column('email'); - if(empty($aAuthorEmail)){ - exit(json_encode(array('status' => 1,'msg' => '','data' => ['total' => 0,'lists' => []]))); + if(!empty($aAuthorEmail)){ + unset($aWhere['user_id']); + $aWhere['email'] = ['in',array_unique($aAuthorEmail)]; } - unset($aWhere['user_id']); - $aWhere['email'] = ['in',array_unique($aAuthorEmail)]; } } + + //根据邮箱搜索 $aEmailWhere = []; - if(!empty($aParam['email'])){//根据邮箱搜索 + if(!empty($aParam['email'])){ $aEmailWhere['email'] = ['like',"%" . $aParam["email"] . "%"]; } - //统计数量 + //统计数量 $iCount = Db::table('t_user')->where($aWhere)->where($aEmailWhere)->count(); if(empty($iCount)){ exit(json_encode(array('status' => 1,'msg' => '','data' => ['total' => 0,'lists' => []])));