ai推荐审稿人功能修改

This commit is contained in:
chengxl
2025-04-23 11:27:11 +08:00
parent 5fb7f66c6b
commit a5f8f630f6

View File

@@ -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' => []])));