article_obj = Db::name('article'); $this->article_reviewer_obj = Db::name('article_reviewer'); $this->user_obj = Db::name('user'); $this->rev_to_jour_obj = Db::name('reviewer_to_journal'); $this->journal_obj = Db::name('journal'); $this->reviewer_obj = Db::name('article_reviewer'); $this->article_msg_obj = Db::name('article_msg'); $this->user_log_obj = Db::name('user_log'); $this->reviewer_info_obj = Db::name('user_reviewer_info'); } /** * 自动审稿主方法 */ public function initAutoReview() { //查找对应状态的article列表 $alist = $this->article_obj->where('state', 2)->select(); foreach ($alist as $v) { Queue::push('app\api\job\review@fire', $v, "emailtest"); } } public function testrev(){ $a = $this->article_obj->where('article_id',261)->find(); $this->checkrev($a); } /** * 处理过期审稿 */ public function overdue_reviewer() { $where['state'] = 0; $where['ctime'] = ['lt', time() - 3600 * 24 * 14]; $revs = $this->article_reviewer_obj->where($where)->select(); foreach ($revs as $v) { //审稿人失败次数+1 $this->user_obj->where('user_id', $v['reviewer_id'])->setInc('rd_num'); //此审稿案例超时 $this->article_reviewer_obj->where('art_rev_id', $v['art_rev_id'])->update(['state' => 4]); } } public function testmail() { $maidata['email'] = '751475802@qq.com'; $maidata['title'] = 'test'.date('Ymd His', time()); $maidata['content'] = 'dsadsaas'; $maidata['tmail'] = 'tmrcancer@tmrjournals.com'; $maidata['tpassword'] = 'Wu999999tmrcance'; Queue::push('app\api\job\mail@fire', $maidata, "mail"); } public function mytest(){ echo 'okokokook!!!!'; } /** * 审查文章审稿人状态,返回结果 */ public function checkrev($data) { //查找审稿案例状态 $rev_list = $this->reviewer_obj->where('article_id', $data['article_id'])->where('state','<>',4)->select(); $journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find(); $user_info = $this->user_obj->where('user_id',$data['user_id'])->find(); $editor_info = $this->user_obj->where('user_id',$data['editor_id'])->find(); //分析审稿人状况 $all = count($rev_list); $s_num = 0; //初始数量 $p_num = 0; //通过数量 $np_num = 0; //不通过数量 foreach ($rev_list as $v) { if ($v['state'] == 0) { $s_num++; } else if ($v['state'] == 1 || $v['state'] == 3) { $p_num++; } else { $np_num++; } } //分情况执行 if ($all == 0) { //分配两次审稿人 $this->add_reviewer($data); $this->add_reviewer($data); return true; } elseif ($all == 1) { //分配一次审稿人 $this->add_reviewer($data); return true; } elseif ($all == 2) { if ($s_num > 0) {//不做任何处理 return true; } if ($p_num == 2) {//通过 //更新文章状态 $this->article_obj->where('article_id', $data['article_id'])->update(['state'=>4,'editor_act'=>1]); //添加文章msg信息 $insert_data['article_id'] = $data['article_id']; $insert_data['content'] = 'Review completed'; $insert_data['state_from'] = $data['state']; $insert_data['state_to'] = 4; $insert_data['ctime'] = time(); $this->article_msg_obj->insert($insert_data); //添加通知信息 add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']); //发送邮件通知编辑 $tt = $data['accept_sn'].'
'; $tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',
'; $tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'.
'; $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.

'; $tt .= 'If you need more time to revise, you can send E-mial to tell us.
'; $tt .= 'Sincerely,
Editorial Office
'; $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']); } elseif ($np_num == 2) {//不通过 //发送邮件通知编辑 $tt = 'Reviewers final opinions on the manuscript ID'.$data['accept_sn'].' are rejection. Please login and deal with the next step of this manuscript manually.'; sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); } else {//一样一个增加一个审稿案例 $this->add_reviewer($data); return true; } } elseif ($all == 3) { if ($s_num > 0) {//不做任何处理 return true; } if ($p_num == 2) {//通过 //更新文章状态 $this->article_obj->where('article_id', $data['article_id'])->update(['state'=>4,'editor_act'=>1]); //添加文章msg信息 $insert_data['article_id'] = $data['article_id']; $insert_data['content'] = 'Review completed'; $insert_data['state_from'] = $data['state']; $insert_data['state_to'] = 4; $insert_data['ctime'] = time(); $this->article_msg_obj->insert($insert_data); //添加通知信息 add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']); //发送邮件通知编辑 $tt = $data['accept_sn'].'
'; $tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',
'; $tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'.
'; $tt .= 'Please find the new comments in the "Author Center", Please submit your revised manuscript within two weeks.

'; $tt .= 'If you need more time to revise, you can send E-mial to tell us.
'; $tt .= 'Sincerely,
Editorial Office
'; $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']); } else {//不通过 //发送邮件通知编辑 $tt = 'Reviewers final opinions on the manuscript ID'.$data['accept_sn'].' are rejection. Please login and deal with the next step of this manuscript manually.'; sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); } } } /** * 增加一个审稿人 */ public function add_reviewer($article) { $journal_info = $this->journal_obj->where('journal_id', $article['journal_id'])->find(); $editor_info = $this->user_obj->where('user_id', $article['editor_id'])->find(); //根据文章筛选候选人 $reviewer = $this->chose_reviewer($article); if ($reviewer == null) {//没有查询到审稿人,执行提醒操作 //发送邮件到编辑,提醒需要手动添加审稿案例 $tt = 'Dear editor,
'; $tt .= 'There are no enough research area related reviewers in the reviewer list for manuscript ID ' . $article['accept_sn'] . ', please add reviewers for your journal or manual deal with this problem.

'; $tt .= 'TMR Publishing Group'; sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); } else {//查询到审稿人,执行添加操作 //将审稿时间定义至现在 $this->user_obj->where('user_id', $reviewer['user_id'])->update(['rtime' => time()]); $article_info = $article; $reviewer_info = $reviewer; //增加信息到文章审稿表 $insert_data['reviewer_id'] = $reviewer['user_id']; $insert_data['article_id'] = $article_info['article_id']; $insert_data['editor_act'] = 1; $insert_data['ctime'] = time(); $res = $this->article_reviewer_obj->insertGetId($insert_data); //修改文章状态->审稿中 $this->article_obj->where('article_id', $article_info['article_id'])->update(['state' => 2]); //添加article_msg信息 $insmsg_data['article_id'] = $article_info['article_id']; $insmsg_data['content'] = ''; $insmsg_data['state_from'] = $article_info['state']; $insmsg_data['state_to'] = 2; $insmsg_data['ctime'] = time(); $this->article_msg_obj->insert($insmsg_data); //发送email提醒审稿员 $tt = $article_info['accept_sn'] . '
'; $tt .= 'Dear ' . $reviewer_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 .= 'Reviewer Center
'; $tt .= 'Your username:' . $reviewer_info['account'] . '

'; $tt .= 'Sincerely,
Editorial Office
'; $tt .= $journal_info['title'] . '
'; $tt .= 'Email:' . $journal_info['email'] . '
'; $tt .= 'Website:' . $journal_info['website']; sendEmail($reviewer_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); //记录userlog $log_data['user_id'] = $article_info['editor_id']; $log_data['type'] = 2; $log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),添加了一个文章审稿实例:(" . $article_info['title'] . "-----" . $reviewer_info['account'] . "),添加时间是:" . date('Y-m-d H:i:s', time()); $log_data['ctime'] = time(); $this->user_log_obj->insert($log_data); //添加usermsg add_usermsg($reviewer['user_id'], 'You have new manuscript to be approved', '/reviewerArticleDetail?id=' . $res); } } /** * 筛选一个审稿人 */ public function chose_reviewer($article) { //筛选符合期刊 $rev_list = $this->rev_to_jour_obj->where('journal_id', $article['journal_id'])->column('reviewer_id'); $fie_list = $this->reviewer_info_obj->where('major',$article['major_id'])->column('reviewer_id'); $u_list = $this->user_obj ->where('user_id',['in',$rev_list],['in',$fie_list])//审核人属于某期刊,并且属于某个领域 ->where('rtime','<',time() - 3600 * 24 * 15)//审核人间隔时间 ->order('rs_num desc')->select(); if ($u_list) { return $u_list[0]; } else { return null; } } }