From b4f5cd59bb438b2835b410e6acfcd092b35ecb5a Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Mon, 6 Sep 2021 14:10:10 +0800 Subject: [PATCH] 20201112 --- application/api/controller/Admin.php | 4 +- application/api/controller/Article.php | 6 +- application/api/controller/Board.php | 2 + application/api/controller/Chief.php | 9 +- application/api/controller/Reviewer.php | 330 +++++++++++++++++++++++- 5 files changed, 344 insertions(+), 7 deletions(-) diff --git a/application/api/controller/Admin.php b/application/api/controller/Admin.php index 50f38bd..7a3e9ec 100644 --- a/application/api/controller/Admin.php +++ b/application/api/controller/Admin.php @@ -332,8 +332,8 @@ class Admin extends Controller { //接收信息 $data = $this->request->post(); - $data['journal'] = 5; - $data['url'] = 'reviewer/import/20210819/beb6de5c69e4878d995fd8de192d17af.xlsx'; +// $data['journal'] = 5; +// $data['url'] = 'reviewer/import/20210819/beb6de5c69e4878d995fd8de192d17af.xlsx'; $journal = $data['journal']; $journal_info = $this->journal_obj->where('journal_id', $journal)->find(); diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 82279c0..af153fd 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -39,6 +39,7 @@ class Article extends Controller { $this->article_author_obj = Db::name('article_author'); $this->article_transfer_obj = Db::name('article_transfer'); $this->chief_to_journal_obj = Db::name('chief_to_journal'); + $this->login_auto_obj = Db::name('login_auto'); } /** @@ -658,6 +659,8 @@ class Article extends Controller { return json(['code' => 0]); } + + /** * 添加文章审稿实例(编辑) @@ -665,6 +668,7 @@ class Article extends Controller { public function addArticleReviewer() { //接收参数,查询数据 $data = $this->request->post(); + $article_info = $this->article_obj->where('article_id', $data['articleId'])->find(); $editor_info = $this->user_obj->where('user_id', $article_info['editor_id'])->find(); $reviewer_info = $this->user_obj->where('user_id', $data['uid'])->find(); @@ -697,7 +701,7 @@ class Article extends Controller { . ' in the journal '.$journal_info['title'].'.
'; $tt .= 'Please bring into our knowledge if there is any potential Conflict of Interest. If you agree to review this manuscript, we ask you to complete your review and submit it by submission system within 10 days of receipt of the manuscript.

'; $tt .= 'Thank you for your consideration.
Look forward for your reply.
'; - $tt .= 'Click here to review the article
'; + $tt .= 'Click here to review the article
'; $tt .= 'Your username:'.$reviewer_info['account'].'

'; $tt .= 'Your original password:123456qwe , if you have reset the password, please login with the new one or click the "forgot password".
'; $tt .= 'Sincerely,
Editorial Office
'; diff --git a/application/api/controller/Board.php b/application/api/controller/Board.php index d3d76cc..974cb00 100644 --- a/application/api/controller/Board.php +++ b/application/api/controller/Board.php @@ -186,6 +186,7 @@ class Board extends Controller { * * @param name:user_id type:int require:1 desc:用户id * @param name:journal_id type:int require:1 desc:期刊id + * @param name:email type:string require:1 desc:邮箱 * @param name:jboard_id type:int require:1 desc:官网boardid * * @return boards:编委list# @@ -195,6 +196,7 @@ class Board extends Controller { $url = 'http://journalapi.tmrjournals.com/public/index.php/api/Main/bindBoard'; $cs['user_id'] = $data['user_id']; $cs['board_id'] = $data['jboard_id']; + $cs['email'] = $data['email']; $list = myPost($url, $cs); $insert['user_id'] = $data['user_id']; $insert['journal_id'] = $data['journal_id']; diff --git a/application/api/controller/Chief.php b/application/api/controller/Chief.php index 2225235..0880900 100644 --- a/application/api/controller/Chief.php +++ b/application/api/controller/Chief.php @@ -299,7 +299,10 @@ class Chief extends Controller { */ public function addChiefHas(){ $data = $this->request->post(); - $check = $this->chief_to_journal_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find(); + $check = $this->chief_to_journal_obj + ->where('user_id',$data['user_id']) + ->where('journal_id',$data['journal_id']) + ->where('state',0)->find(); if($check!=null){ return jsonError('has register!'); } @@ -731,10 +734,12 @@ class Chief extends Controller { * @method POST * * @param name:article_id type:int require:1 desc:文章id + * + * @return boards:编委列表# */ public function getArticleBoard(){ $data = $this->request->post(); - $list = $this->article_to_board_obj->where('article_id',$data['article_id'])->where('state',0)->select(); + $list = $this->article_to_board_obj->join('t_user','t_user.user_id = t_article_to_board.board_id','left')->where('t_article_to_board.article_id',$data['article_id'])->where('t_article_to_board.state',0)->select(); $re['boards'] = $list; return jsonSuccess($re); diff --git a/application/api/controller/Reviewer.php b/application/api/controller/Reviewer.php index 141cf8f..0b9f49d 100644 --- a/application/api/controller/Reviewer.php +++ b/application/api/controller/Reviewer.php @@ -5,6 +5,7 @@ namespace app\api\controller; use think\Controller; use think\Db; use TCPDF; +use think\Queue; /** * @title 审稿人接口 @@ -26,6 +27,8 @@ class Reviewer extends Controller { protected $article_reviewer_question_obj = ''; protected $chief_to_journal_obj = ''; protected $board_to_journal_obj = ''; + protected $login_auto_obj = ''; + protected $country_obj = ''; //put your code here public function __construct(\think\Request $request = null) { @@ -44,6 +47,8 @@ class Reviewer extends Controller { $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); $this->chief_to_journal_obj = Db::name('chief_to_journal'); $this->board_to_journal_obj = Db::name('board_to_journal'); + $this->login_auto_obj = Db::name('login_auto'); + $this->country_obj = Db::name('country'); } /** @@ -207,7 +212,46 @@ class Reviewer extends Controller { $this->user_reviewer_info_obj->where('reviewer_info_id',$data['reviewer_info_id'])->update(['major'=>$data['major'],'cmajor'=>$data['cmajor']]); return json(['code'=>0]); } - + + /** + * @title 发起审稿 + * @description 发起审稿 + * @author wangjinlei + * @url /api/Reviewer/editUserReviewer + * @method POST + * + * @param name:user_id type:int require:1 desc:审稿人userid + * @param name:email type:string require:1 desc:邮箱 + * @param name:gender type:int require:1 desc:性别 + * @param name:title type:string require:1 desc:用户title + * @param name:country type:string require:1 desc:国家 + * @param name:major type:int require:1 desc:领域 + * @param name:cmajor type:int require:1 desc:子领域 + * @param name:field type:string require:1 desc:领域 + * @param name:realname type:string require:0 desc:真实姓名 + * @param name:orcid type:string require:0 desc:orcid + * @param name:introduction type:string require:0 desc:简介 + * @param name:company type:string require:0 desc:单位 + */ + public function editUserReviewer(){ + $data = $this->request->post(); + $update['email'] = trim($data['email']); + $update['realname'] = isset($data['realname'])?trim($data['realname']):''; + $update['orcid'] = isset($data['orcid'])?trim($data['orcid']):''; + $this->user_obj->where('user_id',$data['user_id'])->update($update); + + $info_update['gender'] = $data['gender']; + $info_update['technical'] = $data['title']; + $info_update['country'] = $data['country']; + $info_update['introduction'] = isset($data['introduction'])?trim($data['introduction']):''; + $info_update['company'] = isset($data['company'])?trim($data['company']):''; + $info_update['major'] = $data['major']; + $info_update['cmajor'] = $data['cmajor']; + $info_update['field'] = trim($data['field']); + $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->update($info_update); + + return jsonSuccess([]); + } /** * 上传/修改文章审核实例详情两个文件(编辑,审稿人) @@ -513,7 +557,289 @@ class Reviewer extends Controller { $re['count'] = $count; return jsonSuccess($re); } - + + /** + * @title 发起审稿 + * @description 发起审稿 + * @author wangjinlei + * @url /api/Reviewer/launchReviewer + * @method POST + * + * @param name:article_id type:int require:1 desc:文章id + * @param name:user_id type:int require:1 desc:发起者userid + * + */ + public function launchReviewer(){ + $data = $this->request->post(); + //审查发起者是否具有审稿的权限 + $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + $user_info = $this->user_obj->where('user_id',$data['user_id'])->find(); + $re_res = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->find(); + $bo_res = $this->board_to_journal_obj->where('user_id',$data['user_id'])->find(); + if($re_res==null&&$bo_res==null){ + return jsonError('No permission'); + } + //增加信息到文章审稿表 + $insert_data['reviewer_id'] = $data['user_id']; + $insert_data['article_id'] = $data['article_id']; + $insert_data['editor_act'] = 1; + $insert_data['ctime'] = time(); + $res = $this->article_reviewer_obj->insertGetId($insert_data); + //发送email提醒审稿员 + $tt = $article_info['accept_sn'] . '
'; + $tt .= 'Dear '.$user_info['realname'].'

'; + $tt .= 'The manuscript entitled “'.$article_info['title'].'” has' + . ' been submitted to the journal '.$journal_info['title'].'. The Editor-in-Chief would' + . ' be most grateful if you could offer an opinion regarding its suitability for publication' + . ' in the journal '.$journal_info['title'].'.
'; + $tt .= 'Please bring into our knowledge if there is any potential Conflict of Interest. If you agree to review this manuscript, we ask you to complete your review and submit it by submission system within 10 days of receipt of the manuscript.

'; + $tt .= 'Thank you for your consideration.
Look forward for your reply.
'; + $tt .= 'Click here to review the article
'; + $tt .= 'Your username:'.$user_info['account'].'

'; + $tt .= 'Your original password:123456qwe , if you have reset the password, please login with the new one or click the "forgot password".
'; + $tt .= 'Sincerely,
Editorial Office
'; + $tt .= 'Subscribe to this journal
'; + $tt .= $journal_info['title'].'
'; + $tt .= 'Email:'.$journal_info['email'].'
'; + $tt .= 'Website:'.$journal_info['website']; + sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); + + return jsonSuccess([]); + } + + private function creatLoginUrlForreviewer($user,$article_id){ + $code = md5(time().rand(1000,9999).'thinkphp'); + $insert['user_id'] = $user['user_id']; + $insert['code'] = $code; + $insert['ctime'] = time(); + $this->login_auto_obj->insert($insert); + $url = 'https://submission.tmrjournals.com/per_text?Art_id='.$article_id.'&act='.$code; + return $url; + } + + /** + * @title 审查用户是否有审稿的权限 + * @description 审查用户是否有审稿的权限 + * @author wangjinlei + * @url /api/Reviewer/checkUserForReviewer + * @method POST + * + * @param name:article_id type:int require:1 desc:文章id + * @param name:user_id type:int require:1 desc:发起者userid + */ + public function checkUserForReviewer(){ + $data = $this->request->post(); + $re_res = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->find(); + $bo_res = $this->board_to_journal_obj->where('user_id',$data['user_id'])->find(); + if($re_res != null || $bo_res!=null){ + return jsonSuccess([]); + }else{ + return jsonError('No permission'); + } + } + + /** + * @title 检测用户 + * @description 检测用户 + * @author wangjinlei + * @url /api/Reviewer/checkUser + * @method POST + * + * @param name:account type:string require:1 desc:用户名/邮箱 + * + * @return has:no-has(无-有)# + */ + public function checkUser(){ + $data = $this->request->post(); + $user_info = $this->user_obj->where('account|email',$data['account'])->find(); + $has = ''; + if($user_info==null){ + $has = 'no'; + }else{ + $has = 'has'; + } + $re['has'] = $has; + return jsonSuccess($re); + } + + /** + * @title 获取专业领域 + * @description 获取专业领域 + * @author wangjinlei + * @url /api/Reviewer/getMajor + * @method POST + * + * @param name:pid type:int require:1 desc:0为顶级栏目 + * + * @return majors:专业列表# + */ + public function getMajor(){ + $data = $this->request->post(); + $majors = $this->reviewer_major_obj->where('pid',$data['pid'])->where('state',0)->select(); + $re['majors'] = $majors; + return jsonSuccess($re); + } + + /** + * @title 获取全部专业领域 + * @description 获取全部专业领域 + * @author wangjinlei + * @url /api/Reviewer/getAllMajor + * @method POST + * + * @return majors:专业列表# + */ + public function getAllMajor(){ + $majors = $this->reviewer_major_obj->where('pid',0)->where('state',0)->select(); + foreach ($majors as $k => $v){ + $cmajors = $this->reviewer_major_obj->where('pid',$v['major_id'])->where('state',0)->select(); + $majors[$k]['children'] = $cmajors; + } + $re['majors'] = $majors; + return jsonSuccess($re); + } + + /** + * @title 添加reviewer + * @description 添加reviewer + * @author wangjinlei + * @url /api/Reviewer/addReviewer + * @method POST + * + * @param name:journal_id type:int require:1 desc:期刊id + * @param name:account type:string require:1 desc:账户 + * @param name:email type:string require:1 desc:邮箱 + * @param name:gender type:int require:1 desc:性别 + * @param name:title type:string require:1 desc:用户title + * @param name:country type:string require:1 desc:国家 + * @param name:major type:int require:1 desc:领域 + * @param name:cmajor type:int require:1 desc:子领域 + * @param name:field type:string require:1 desc:领域 + * @param name:realname type:string require:0 desc:真实姓名 + * @param name:orcid type:string require:0 desc:orcid + * @param name:introduction type:string require:0 desc:简介 + * @param name:company type:string require:0 desc:单位 + */ + public function addReviewer(){ + $data = $this->request->post(); + +// $data['account'] = "wjl"; +// $data['cmajor'] = "36"; +// $data['country'] = "China"; +// $data['email'] = "wjl@126.com"; +// $data['gender'] = "2"; +// $data['journal_id'] = "1"; +// $data['major'] = "3"; +// $data['title'] = "Ph.D."; +// $data['field'] = "123454"; + + $check = $this->user_obj->where('account',trim($data['account']))->whereOr('email',$data['email'])->find(); + if($check!=null){ + return jsonError($data['account'].' has register'); + } + $journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find(); + Db::startTrans(); + //筛选数据,添加数据 + $insert['account'] = trim($data['account']); + $insert['password'] = md5('123456qwe'); + $insert['email'] = trim($data['email']); + $insert['realname'] = isset($data['realname'])?trim($data['realname']):''; + $insert['orcid'] = isset($data['orcid'])?trim($data['orcid']):''; + $insert['ctime'] = time(); + $insert['type'] = 1; + $insert['is_reviewer'] = 1; + $uid = $this->user_obj->insertGetId($insert); + $info_insert['reviewer_id'] = $uid; + $info_insert['gender'] = $data['gender']; + $info_insert['technical'] = $data['title']; + $info_insert['country'] = $data['country']; + $info_insert['introduction'] = isset($data['introduction'])?trim($data['introduction']):''; + $info_insert['company'] = isset($data['company'])?trim($data['company']):''; + $info_insert['major'] = $data['major']; + $info_insert['cmajor'] = $data['cmajor']; + $info_insert['field'] = trim($data['field']); + $res1 = $this->user_reviewer_info_obj->insertGetId($info_insert); + $to_insert['reviewer_id'] = $uid; + $to_insert['journal_id'] = $data['journal_id']; + $to_insert['account'] = trim($data['account']); + $to_insert['journal_title'] = $journal_info['title']; + $to_insert['ctime'] = time(); + $res2 = $this->reviewer_to_journal_obj->insertGetId($to_insert); + + if($uid && $res1&&$res2){ + Db::commit(); + //发送邮件通知审稿人 + $content = "Thank you for registering as a " . $journal_info['title'] . " reviewer
". "At present, you have passed our examination
"; + $content .= 'Submission System
'; + $content .= '

username:' . trim($data['account']) . '

'; + $content .= '

Original Password: 123456qwe

'; + $maidata['email'] = trim($data['email']); + $maidata['title'] = $journal_info['title']; + $maidata['content'] = $content; + $maidata['tmail'] = $journal_info['email']; + $maidata['tpassword'] = $journal_info['epassword']; + Queue::push( 'app\api\job\mail@fire' , $maidata , "tmail" ); + return jsonSuccess([]); + }else{ + Db::rollback(); + return jsonError('add error!'); + } + + } + + + /** + * @title 获取审稿人列表 + * @description 获取审稿人列表 + * @author wangjinlei + * @url /api/Reviewer/getReviewerListByJournal + * @method POST + * + * @param name:username type:string require:1 desc:用户名 + * @param name:journalId type:int require:1 desc:期刊id当全选时为0 + * @param name:pageIndex type:int require:1 desc:开始页码 + * @param name:pageSize type:int require:1 desc:每页是数据条数 + * + */ + public function getReviewerListByJournal() { + $data = $this->request->post(); + $editor_info = $this->user_obj->where('account',$data['username'])->where('state',0)->find(); + $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; + $jous = []; + if($data['journalId'] == 0){ + $jous = $this->journal_obj->where('editor_id',$editor_info['user_id'])->where('state',0)->column('journal_id'); + }else{ + $jous[] = $data['journalId']; + } + $res = $this->reviewer_to_journal_obj + ->field('t_reviewer_to_journal.is_yboard,t_user.*,t_user_reviewer_info.*,t_journal.title journal_title') + ->join('t_journal','t_journal.journal_id = t_reviewer_to_journal.journal_id','left') + ->join('t_user','t_user.user_id = t_reviewer_to_journal.reviewer_id','left') + ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_reviewer_to_journal.reviewer_id', 'LEFT') + ->where('t_reviewer_to_journal.journal_id','in',$jous) + ->where('t_reviewer_to_journal.state',0) + ->limit($limit_start,$data['pageSize']) + ->select(); + $count = $this->reviewer_to_journal_obj->where('t_reviewer_to_journal.journal_id','in',$jous)->where('t_reviewer_to_journal.state',0)->count(); + return json(['code' => 0, 'data' => $res, 'total' => $count]); + } + + /** + * @title 获取国家 + * @description 获取国家 + * @author wangjinlei + * @url /api/Reviewer/getCountrys + * @method POST + * + * @return countrys:国家列表# + */ + public function getCountrys() { + $res = $this->country_obj->order('en_name')->select(); + $re['countrys'] = $res; + return json($re); + } + /** * 存储reviewer文件历史信息 */