From 318222805dd259fab93ec9a904d805a60f7a42a5 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Wed, 20 Apr 2022 14:50:55 +0800 Subject: [PATCH 1/2] 1 --- application/api/controller/Article.php | 61 +++++++++++++++++++++++++- application/api/controller/Special.php | 21 ++++++--- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 45c7a06..af1e8db 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -1459,7 +1459,14 @@ class Article extends Controller { //通讯作者转为审稿人 $this->addReviewerFromArticle($res, $journal_info['journal_id']); - if ($res && $res_author && $transr && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg) { + + //如果存在推荐审稿人,则执行添加审稿人操作 + $res_recommend = true; + foreach($data['reviewers'] as $v){ + $res_recommend = $this->addRecommentReviewer($v,$journal_info['journal_id'],$user_res['user_id'],$res); + } + + if ($res && $res_author && $transr && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $res_recommend) { Db::commit(); return json(['code' => 0]); } else { @@ -1468,6 +1475,58 @@ class Article extends Controller { } } + + /** + * 添加推荐审稿人 + */ + public function addRecommentReviewer($reivewe,$journal_id,$user_id,$article_id){ + $journal_info = $this->journal_obj->where('journal_id',$journal_id)->find(); + //判断此用户是否存在 + $reviewer_info = $this->user_obj->where('email', $reivewe['email'])->where('state', 0)->find(); + if ($reviewer_info == null) { //添加用户 + $insert_user['account'] = $reivewe['email']; + $insert_user['password'] = md5('123456qwe'); + $insert_user['email'] = $reivewe['email']; + $insert_user['realname'] = $reivewe['realname']; + $insert_user['ctime'] = time(); + $i_id = $this->user_obj->insertGetId($insert_user); + $reviewer_info = $this->user_obj->where('user_id', $i_id)->find(); + } + //判断是否是此期刊审稿人 + $rtj = $this->reviewer_to_journal_obj->where('journal_id', $journal_id)->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find(); + // $res2 = true; + // $res3 = true; + if ($rtj == null) { + //判断是否具有审稿人身份,并具有审稿人资料 + $uri = $this->user_reviewer_info_obj->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find(); + if ($uri == null) { //添加审稿人信息 + $insert_reviewer_info['reviewer_id'] = $reviewer_info['user_id']; + $insert_reviewer_info['major'] = $reivewe['major']; + $insert_reviewer_info['cmajor'] = $reivewe['cmajor']; + $insert_reviewer_info['country'] = $reivewe['country']; + $res2 = $this->user_reviewer_info_obj->insert($insert_reviewer_info); + } + $insert_rtj['reviewer_id'] = $reviewer_info['user_id']; + $insert_rtj['journal_id'] = $journal_info['journal_id']; + $insert_rtj['account'] = $reviewer_info['account']; + $insert_rtj['journal_title'] = $journal_info['title']; + $insert_rtj['ctime'] = time(); + $res3 = $this->reviewer_to_journal_obj->insert($insert_rtj); + } + + //添加推荐审稿人信息 + $insert_recommend['reviewer_id'] = $reviewer_info['user_id']; + $insert_recommend['article_id'] = $article_id; + $insert_recommend['recommend_user_id'] = $user_id; + $insert_recommend['urr_ctime'] = time(); + $res_recommend = $this->user_reviewer_recommend_obj->insert($insert_recommend); + + if ($res2 && $res3 && $res_recommend) { + return true; + } else { + return false; + } + } /** * @title 获取待审文章 diff --git a/application/api/controller/Special.php b/application/api/controller/Special.php index d5afb5b..7697e19 100644 --- a/application/api/controller/Special.php +++ b/application/api/controller/Special.php @@ -32,6 +32,7 @@ class Special extends Controller protected $user_to_special_obj = ''; protected $chief_to_journal_obj = ''; protected $article_reviewer_obj = ''; + protected $user_reviewer_recommend_obj = ''; public function __construct(\think\Request $request = null) { @@ -56,6 +57,7 @@ class Special extends Controller $this->user_to_special_obj = Db::name('user_to_special'); $this->chief_to_journal_obj = Db::name('chief_to_journal'); $this->article_reviewer_obj = Db::name('article_reviewer'); + $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); } /** @@ -531,22 +533,20 @@ class Special extends Controller { $data = $this->request->post(); $rule = new Validate([ + 'editor_id' => 'require', 'email' => 'require|email', 'realname' => 'require', 'article_id' => 'require', 'major' => 'require', - 'cmajor' => 'require' + 'cmajor' => 'require', + 'country' => 'require' ]); if (!$rule->check($data)) { return jsonError($rule->getError()); } $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(); - - - Db::startTrans(); - //判断此用户是否存在 $reviewer_info = $this->user_obj->where('email', $data['email'])->where('state', 0)->find(); if ($reviewer_info == null) { //添加用户 @@ -558,7 +558,6 @@ class Special extends Controller $i_id = $this->user_obj->insertGetId($insert_user); $reviewer_info = $this->user_obj->where('user_id', $i_id)->find(); } - //检验审稿实例是否存在 $check_repi = $this->article_reviewer_obj->where('article_id', $data['article_id'])->where('reviewer_id', $reviewer_info['user_id'])->find(); if ($check_repi != null) { @@ -575,6 +574,7 @@ class Special extends Controller $insert_reviewer_info['reviewer_id'] = $reviewer_info['user_id']; $insert_reviewer_info['major'] = $data['major']; $insert_reviewer_info['cmajor'] = $data['cmajor']; + $insert_reviewer_info['country'] = $data['country']; $res2 = $this->user_reviewer_info_obj->insert($insert_reviewer_info); } $insert_rtj['reviewer_id'] = $reviewer_info['user_id']; @@ -592,7 +592,14 @@ class Special extends Controller $insert_article_reviewer['ctime'] = time(); $arid = $this->article_reviewer_obj->insertGetId($insert_article_reviewer); - if ($res2 && $res3 && $arid) { + //添加推荐审稿人信息 + $insert_recommend['reviewer_id'] = $reviewer_info['user_id']; + $insert_recommend['recommend_user_id'] = $data['editor_id']; + $insert_recommend['urr_type'] = 1; + $insert_recommend['urr_ctime'] = time(); + $res_recommend = $this->user_reviewer_recommend_obj->insert($insert_recommend); + + if ($res2 && $res3 && $arid && $res_recommend) { Db::commit(); $articlecontroller = new articlecontroller(); //发送email提醒审稿员 From de6ccd46ab41f370d32a5a1edba458e2601fc4f7 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sun, 24 Apr 2022 09:33:54 +0800 Subject: [PATCH 2/2] 1 --- application/api/controller/Article.php | 75 +++++++++++++----------- application/api/controller/Reviewer.php | 78 ++++++++++++++++++++----- application/api/controller/User.php | 13 +---- public/index.php | 8 +-- 4 files changed, 108 insertions(+), 66 deletions(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index af1e8db..d414c75 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -34,6 +34,7 @@ class Article extends Controller { protected $article_dialog_obj = ''; protected $article_proposal_obj = ''; protected $user_black_obj = ''; + protected $user_reviewer_recommend_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -59,6 +60,7 @@ class Article extends Controller { $this->article_dialog_obj = Db::name('article_dialog'); $this->article_proposal_obj = Db::name('article_proposal'); $this->user_black_obj = Db::name('user_black'); + $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); } /** @@ -1312,6 +1314,35 @@ class Article extends Controller { public function addArticle() { //接受参数,查询信息 $data = $this->request->post(); + // $data['journal'] = 1; + // $data['username'] = 'wangjinlei'; + // $data['title'] = 'sadfsq11adf'; + // $data['major'] = 2; + // $data['authorList'][0] = [ + // 'firstname'=>'name1', + // 'lastname'=>'name22', + // 'orcid'=>'', + // 'company'=>'dsadsa', + // 'department'=>'name1', + // 'title'=>'Assistant Prof.', + // 'country'=>'Angola', + // 'email'=>'sadf@65.com', + // 'address'=>'address', + // 'isSuper'=>'true', + // 'isReport'=>'true' + // ]; + // $data['abstrart']='dadsasd'; + // $data['type']='A'; + // $data['approval']='false'; + // $data['istransfer']='false'; + // $data['becomeRev']='false'; + // $data['keyWords']='sdfsfdf'; + // $data['fund']=''; + // $data['coverLetter']=''; + // $data['totalpage']=''; + // $data['manuscirpt']='manuscirpt/20220420/7c9ffb7ff502ec6b6b7642fcba77fa63.rar'; + + $user_res = $this->user_obj->where('account', $data['username'])->find(); //确定用户是否属于黑名单 @@ -1332,6 +1363,9 @@ class Article extends Controller { return json(['code'=>1,'msg'=>'Warning: you are re-submitting the article!']); } } + + + Db::startTrans(); //添加文章基础信息 @@ -1384,7 +1418,7 @@ class Article extends Controller { } } - + //增加articlefile表的信息 $res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter'); $res_file2 = true; @@ -1401,18 +1435,6 @@ class Article extends Controller { $tt = 'Dear editor,
'; $tt .= 'Please check the new manuscript in the submission system.'; sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']); - $sendEditor=[ - 'title'=> $journal_info['title'], // 邮件标题 - 'content'=>'Dear editor,
Please check the new manuscript in the submission system.',//邮件内容 - 'user_id'=>$editor_info['user_id'], //收件人ID - 'email'=>$editor_info['email'],// 收件人邮箱 - 'journal_id'=>$journal_info['journal_id'], // 期刊ID - 'sendEmail'=>$journal_info['email'], // 期刊邮箱 - 'sendPassword'=>$journal_info['epassword'], // 期刊密码 - 'from_name'=>$journal_info['title'] - ]; - // Queue::push('app\api\job\domail@fire',$sendEditor,'domail'); - $user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id",$user_res['user_id'])->find(); //发送邮件给作者,表示感谢 $tt1 = 'Dear Dr. '.($user_res['realname']==''?$user_res['account']:$user_res['realname']).',

'; @@ -1432,20 +1454,8 @@ class Article extends Controller { $tt1 .= 'Email: '.$journal_info['email'].'
'; $tt1 .= 'Website: '.$journal_info['website']; } - $sendUser=[ - 'title'=> $journal_info['title'], // 邮件标题 - 'content'=>$tt1,//邮件内容 - 'user_id'=>$user_res['user_id'], //收件人ID - 'email'=>$user_res['email'],// 收件人邮箱 - 'journal_id'=>$journal_info['journal_id'], // 期刊ID - 'sendEmail'=>$journal_info['email'], // 期刊邮箱 - 'sendPassword'=>$journal_info['epassword'], // 期刊密码 - 'from_name'=>$journal_info['title'] - ]; - // Queue::push('app\api\job\domail@fire',$sendUser,'domail'); sendEmail($user_res['email'],$journal_info['title'], $journal_info['title'], $tt1,$journal_info['email'],$journal_info['epassword']); - //增加用户操作log $log_data['user_id'] = $user_res['user_id']; $log_data['type'] = 0; @@ -1459,14 +1469,13 @@ class Article extends Controller { //通讯作者转为审稿人 $this->addReviewerFromArticle($res, $journal_info['journal_id']); - - //如果存在推荐审稿人,则执行添加审稿人操作 - $res_recommend = true; + //推荐审稿人 + $recommend_res = true; foreach($data['reviewers'] as $v){ - $res_recommend = $this->addRecommentReviewer($v,$journal_info['journal_id'],$user_res['user_id'],$res); + $recommend_res = $this->addRecommentReviewer($v,$journal_info['journal_id'],$user_res['user_id'],$res); } - if ($res && $res_author && $transr && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $res_recommend) { + if ($res && $res_author && $transr && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg && $recommend_res) { Db::commit(); return json(['code' => 0]); } else { @@ -1474,7 +1483,7 @@ class Article extends Controller { return json(['code' => 1]); } } - + /** * 添加推荐审稿人 @@ -1494,8 +1503,8 @@ class Article extends Controller { } //判断是否是此期刊审稿人 $rtj = $this->reviewer_to_journal_obj->where('journal_id', $journal_id)->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find(); - // $res2 = true; - // $res3 = true; + $res2 = true; + $res3 = true; if ($rtj == null) { //判断是否具有审稿人身份,并具有审稿人资料 $uri = $this->user_reviewer_info_obj->where('reviewer_id', $reviewer_info['user_id'])->where('state', 0)->find(); diff --git a/application/api/controller/Reviewer.php b/application/api/controller/Reviewer.php index 528a6f4..aa187a3 100644 --- a/application/api/controller/Reviewer.php +++ b/application/api/controller/Reviewer.php @@ -4,6 +4,7 @@ namespace app\api\controller; use think\Controller; use think\Db; +use think\Validate; use TCPDF; use think\Queue; @@ -30,6 +31,8 @@ class Reviewer extends Controller protected $board_to_journal_obj = ''; protected $login_auto_obj = ''; protected $country_obj = ''; + protected $user_reviewer_recommend_obj = ''; + protected $article_msg_obj = ''; //put your code here public function __construct(\think\Request $request = null) @@ -51,6 +54,8 @@ class Reviewer extends Controller $this->board_to_journal_obj = Db::name('board_to_journal'); $this->login_auto_obj = Db::name('login_auto'); $this->country_obj = Db::name('country'); + $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); + $this->article_msg_obj = Db::name('article_msg'); } /** @@ -387,9 +392,9 @@ class Reviewer extends Controller //发送email提醒 if ($type != 'editor') { - $tt = 'Dear editor,
'; - $tt .= 'Please check the new comments from the reviewer.'; - sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); + $tt = 'Dear editor,
'; + $tt .= 'Please check the new comments from the reviewer.'; + sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); $sendEditor = [ 'title' => $journal_info['title'], // 邮件标题 'content' => 'Dear editor,
Please check the new comments from the reviewer.', //邮件内容 @@ -712,6 +717,14 @@ class Reviewer extends Controller $this->user_obj->where('user_id', $art_rev_info['reviewer_id'])->setInc('rs_num'); } + //添加文章状态信息 + $insert_data['article_id'] = $article_info['article_id']; + $insert_data['content'] = 'Comments from the reviewer has been received'; + $insert_data['state_from'] = $article_info['state']; + $insert_data['state_to'] = $article_info['state']; + $insert_data['ctime'] = time(); + $this->article_msg_obj->insert($insert_data); + //记录log //生成pdf文件 // $reviewer_pdf = self::pdftest($journal_info['title']); @@ -928,7 +941,7 @@ class Reviewer extends Controller ->text($reviewer_info['realname'] == '' ? $reviewer_info['account'] : $reviewer_info['realname'], $ziti, 60, '#000000', [1900, 1700]) ->text('awarded ' . date('d, F, Y', $article_info['rtime'] == 0 ? $article_info['ctime'] : $article_info['rtime']) . ' to', $ziti, 60, '#000000', [1600, 1500]) ->text('In recognition of the review made for the journal', $ziti, 80, '#000000', [900, 1900]) - ->text($article_info['title'],$ziti,30,'#000000',[230,2100]) + ->text($article_info['title'], $ziti, 30, '#000000', [230, 2100]) ->text('The Editors of', $ziti, 65, '#000000', [230, 2345]) ->text($journal_info['title'], $ziti, 60, '#000000', [830, 2345]) ->text('Auckland, New Zealand, 2012', $ziti, 60, '#000000', [230, 2500]) @@ -990,20 +1003,17 @@ class Reviewer extends Controller $tt .= 'Email:' . $journal_info['email'] . '
'; $tt .= 'Website:' . $journal_info['website']; - $sendReviewer = [ - 'title' => $journal_info['title'], // 邮件标题 - 'content' => $tt, //邮件内容 - 'user_id' => $user_info['user_id'], //收件人ID - 'email' => $user_info['email'], // 收件人邮箱 - 'journal_id' => $journal_info['journal_id'], // 期刊ID - 'sendEmail' => $journal_info['email'], // 期刊邮箱 - 'sendPassword' => $journal_info['epassword'], // 期刊密码 - 'from_name' => $journal_info['title'] - ]; - // Queue::push('app\api\job\domail@fire', $sendReviewer, 'domail'); - sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); + //添加文章状态信息 + $insert_data['article_id'] = $article_info['article_id']; + $insert_data['content'] = 'The reviewer has been appointed'; + $insert_data['state_from'] = $article_info['state']; + $insert_data['state_to'] = $article_info['state']; + $insert_data['ctime'] = time(); + $this->article_msg_obj->insert($insert_data); + + $re['art_rev_id'] = $res; return jsonSuccess($re); } @@ -1033,6 +1043,17 @@ class Reviewer extends Controller $data = $this->request->post(); $art_rev_info = $this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->find(); if ($art_rev_info['state'] == 5) { + //添加找到审稿人信息的article msg + $article_info = $this->article_obj->where('article_id',$art_rev_info['article_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + //添加文章状态信息 + $insert_data['article_id'] = $article_info['article_id']; + $insert_data['content'] = 'The reviewer has been appointed'; + $insert_data['state_from'] = $article_info['state']; + $insert_data['state_to'] = $article_info['state']; + $insert_data['ctime'] = time(); + $this->article_msg_obj->insert($insert_data); + $this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->update(['state' => 0]); return jsonSuccess([]); } else { @@ -1657,6 +1678,31 @@ class Reviewer extends Controller return jsonSuccess($re); } + /** + * 获取作者推荐审稿人 + */ + public function getRecommendReviewer() + { + $data = $this->request->post(); + // 验证规则 + $rule = new Validate([ + 'article_id' => 'require|number' + ]); + if (!$rule->check($data)) { + return jsonError($rule->getError()); + } + + $list = $this->user_reviewer_recommend_obj + ->field("t_user.user_id,t_user.realname,t_reviewer_major.title cmajor,t_user.account,t_user_reviewer_info.company,t_user_reviewer_info.field,t_user.rs_num,t_user.rd_num") + ->join("t_user", "t_user.user_id = t_user_reviewer_recommend.reviewer_id", "left") + ->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user_reviewer_recommend.reviewer_id", "left") + ->join("t_reviewer_major", "t_reviewer_major.major_id = t_user_reviewer_info.cmajor", "left") + ->where('t_user_reviewer_recommend.article_id', $data['article_id']) + ->select(); + $re['reviewers'] = $list; + return jsonSuccess($re); + } + /** * @title 获取所有审稿意见 * @description 获取所有审稿意见 diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 735c958..2df1a4c 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -705,18 +705,7 @@ class User extends Controller $url = config('base_web_url') . 'retrieveact?actkey=' . $act_insert['act_key']; $title = 'Your request to reset your password [TMR Publishing Group]'; $content = "$realname, we've received your request to reset your password.Please click the link below to change your password. $url"; - //$res = sendEmail($email, $title, 'TMR', $content); - $sendUser = [ - 'title' => $title, // 邮件标题 - 'content' => $content, //邮件内容 - 'user_id' => $user['user_id'], //收件人ID - 'email' => $email, // 收件人邮箱 - 'journal_id' => 0, // 期刊ID - 'sendEmail' => Env::get('email.send_email'), // 期刊邮箱 - 'sendPassword' => Env::get('email.send_email_password'), // 期刊密码 - 'from_name' => 'TMR' - ]; - // $isUserPushed = Queue::push('app\api\job\domail@fire',$sendUser,'domail'); + $res = sendEmail($email, $title, 'TMR', $content,Env::get('email.send_email'),Env::get("email.send_email_password")); // if ($isUserPushed) {//成功 return json(['code' => 0, 'msg' => 'success']); // } else {//失败 diff --git a/public/index.php b/public/index.php index 258d72d..9043046 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,7 @@