Files
tougao/application/api/controller/Reviewer.php
wangjinlei b4f5cd59bb 20201112
2021-09-06 14:10:10 +08:00

905 lines
40 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use TCPDF;
use think\Queue;
/**
* @title 审稿人接口
* @description 审稿人接口
*/
class Reviewer extends Controller {
protected $user_obj = '';
protected $user_reviewer_obj = '';
protected $journal_obj = '';
protected $reviewer_major_obj = '';
protected $reviewer_to_journal_obj = '';
protected $user_reviewer_info_obj = '';
protected $user_log_obj = '';
protected $article_obj = '';
protected $article_file_obj = '';
protected $article_reviewer_obj = '';
protected $article_reviewer_file_obj = '';
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) {
parent::__construct($request);
$this->user_obj = Db::name('user');
$this->user_reviewer_obj = Db::name('user_reviewer_apply');
$this->journal_obj = Db::name('journal');
$this->reviewer_major_obj = Db::name('reviewer_major');
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
$this->user_reviewer_info_obj = Db::name('user_reviewer_info');
$this->user_log_obj = Db::name('user_log');
$this->article_obj = Db::name('article');
$this->article_file_obj = Db::name('article_file');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->article_reviewer_file_obj = Db::name('article_reviewer_file');
$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');
}
/**
* 获取文章审稿实例列表(审稿人)
*/
public function getReviewerList() {
$data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$reviewer_info = $this->user_obj->where('account', $data['username'])->find();
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_journal.title journal_title,t_article.accept_sn accept_sn')
->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
->order('t_article_reviewer.state')
->limit($limit_start, $data['pageSize'])
->select();
$count = $this->article_reviewer_obj->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])->count();
return json(['code' => 0, 'data' => $res, 'total' => $count]);
}
/**
* @title 获取待审审稿实例列表
* @description 获取待审审稿实例列表
* @author wangjinlei
* @url /api/Reviewer/getReviewerListPending
* @method POST
*
* @param name:user_id type:int require:1 desc:审稿人id
*
* @return lists:数据列表#
*/
public function getReviewerListPending(){
$data = $this->request->post();
//获取审稿人基本信息
$reviewer_info = $this->user_obj->where('user_id',$data['user_id'])->find();
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_article.type,t_journal.title journal_title,t_article.accept_sn accept_sn')
->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
->where('t_article_reviewer.state',0)
->select();
foreach ($res as $k => $v){
if($v['type']){
$res[$k]['type'] = translateType($v['type']);
}
}
$re['lists'] = $res;
return jsonSuccess($re);
}
/**
* @title 获取历史审稿实例列表
* @description 获取历史审稿实例列表
* @author wangjinlei
* @url /api/Reviewer/getReviewerListHistory
* @method POST
*
* @param name:user_id type:int require:1 desc:审稿人id
* @param name:pageIndex type:int require:1 desc:当前页码
* @param name:pageSize type:int require:1 desc:每个页面的数据条数
*
* @return lists:数据列表#
*/
public function getReviewerListHistory(){
$data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$reviewer_info = $this->user_obj->where('user_id',$data['user_id'])->find();
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_article.type,t_journal.title journal_title,t_article.accept_sn accept_sn')
->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
->where('t_article_reviewer.state','>',0)
->order('t_article_reviewer.state')
->limit($limit_start, $data['pageSize'])
->select();
foreach ($res as $k => $v){
if($v['type']){
$res[$k]['type'] = translateType($v['type']);
}
}
$re['lists'] = $res;
return jsonSuccess($re);
}
/**
* 获取审稿人详情
*
*/
public function getReviewerDetail(){
$uid = $this->request->post('rid');
//获取基本信息
$base_info = $this->user_obj->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id')->where('t_user.user_id',$uid)->find();
//增加major
$major_res = $this->reviewer_major_obj->where('major_id',$base_info['major'])->column('title');
$base_info['major_title'] = $major_res?$major_res[0]:'';
$cmajor_res = $this->reviewer_major_obj->where('major_id',$base_info['cmajor'])->column('title');
$base_info['cmajor_title'] = $cmajor_res?$cmajor_res[0]:'';
return json(['data'=>$base_info]);
}
/**
* @title 获取审稿人详情
* @description 获取审稿人详情
* @author wangjinlei
* @url /api/Reviewer/getReviewerDetail1
* @method POST
*
* @param name:user_id type:int require:1 desc:审稿人id
*
*/
public function getReviewerDetail1(){
$data = $this->request->post();
//获取基本信息
$base_info = $this->user_obj->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id','left')->where('t_user.user_id',$data['user_id'])->find();
//增加major
$major_res = $this->reviewer_major_obj->where('major_id',$base_info['major'])->column('title');
$base_info['major_title'] = $major_res?$major_res[0]:'';
$cmajor_res = $this->reviewer_major_obj->where('major_id',$base_info['cmajor'])->column('title');
$base_info['cmajor_title'] = $cmajor_res?$cmajor_res[0]:'';
$journals = $this->reviewer_to_journal_obj->field('t_journal.*')->join('t_journal','t_reviewer_to_journal.journal_id = t_journal.journal_id','left')->where('t_reviewer_to_journal.reviewer_id',$data['user_id'])->where('t_reviewer_to_journal.state',0)->select();
//获取审稿人期刊与对应身份
// $frag = [];
// $revs = $this->reviewer_to_journal_obj->join('t_journal','t_reviewer_to_journal.journal_id = t_journal.journal_id','left')->where('t_reviewer_to_journal.reviewer_id',$data['user_id'])->where('t_reviewer_to_journal.state',0)->select();
// $chiefs = $this->chief_to_journal_obj->join('t_journal','t_chief_to_journal.journal_id = t_journal.journal_id','left')->where('t_chief_to_journal.user_id',$data['user_id'])->where('t_chief_to_journal.state',0)->select();
// $boards = $this->board_to_journal_obj->join('t_journal','t_board_to_journal.journal_id = t_journal.journal_id','left')->where('t_board_to_journal.user_id',$data['user_id'])->where('t_board_to_journal.state',0)->select();
// foreach ($revs as $v){
// $frag[] = array(
// 'journal'=>$v,
// 'type'=>'reviewer'
// );
// }
// foreach ($chiefs as $v){
// $frag[] = array(
// 'journal'=>$v,
// 'type'=>'chief'
// );
// }
// foreach ($boards as $v){
// $frag[] = array(
// 'journal'=>$v,
// 'type'=>'board'
// );
// }
//
// $re['journals'] = $frag;
$re['journals'] = $journals;
$re['reviewer'] = $base_info;
return jsonSuccess($re);
}
/**
* 更改审稿人信息
*/
public function editReviewer(){
$data = $this->request->post();
$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([]);
}
/**
* 上传/修改文章审核实例详情两个文件(编辑,审稿人)
*/
public function articleReviewerUpSubmit($type) {
//接受参数,查询信息
$data = $this->request->post();
$artrev_info = $this->article_reviewer_obj->where('art_rev_id', $data['artrevid'])->find();
$article_info = $this->article_obj->where('article_id',$artrev_info['article_id'])->find();
$editor_info = $this->user_obj->where('user_id',$article_info['editor_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
if ($type == 'editor') {
$up_data['editor_act'] = 1;
$user_msg_url = '/reviewerArticleDetail?id='.$data['artrevid'];
$user_info = $this->user_obj->where('account', $data['editor'])->find();
} else {
$up_data['reviewer_act'] = 1;
$user_msg_url = '/articleReviewerDetail?id='.$data['artrevid'];
$user_info = $this->user_obj->where('user_id', $artrev_info['reviewer_id'])->find();
}
//上传
self::save_article_reviewer_file($data['artrevid'], $user_info['user_id'], $user_info['account'], $data['articlefile'], 'articlefile');
if ($data['articlezip'] != '') {
self::save_article_reviewer_file($data['artrevid'], $user_info['user_id'], $user_info['account'], $data['articlezip'], 'articlezip');
}
//更新实例状态
$this->article_reviewer_obj->where('art_rev_id',$data['artrevid'])->update($up_data);
//记录userlog
$log_data['user_id'] = $user_info['user_id'];
$log_data['type'] = 3;
$log_data['content'] = $user_info['account'] . "(" . $user_info['realname'] . "),更改了一篇文章审稿实例:(" . $article_info['title'] . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//发送email提醒
if ($type != 'editor') {
$tt = 'Dear editor,<br>';
$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']);
}
//保存usermsg
add_usermsg($type == 'editor'?$artrev_info['reviewer_id']:$article_info['editor_id'], 'New status of the manuscript', $user_msg_url);
return json(['code' => 0]);
}
/**
* 获取文章审稿实例文件列表
*/
public function getFilelistByID() {
$rev_id = $this->request->post('revid');
$where['art_rev_id'] = $rev_id;
$res = $this->article_reviewer_file_obj->where($where)->select();
$frag = [];
foreach ($res as $v) {
$frag[$v['type_name']][] = $v;
}
return json($frag);
}
/**
* @title 获取文章文件manuscirpt
* @description 获取文章文件manuscirpt
* @author wangjinlei
* @url /api/Reviewer/getAFilelistByID
* @method POST
*
* @param name:revid type:int require:1 desc:art_rev_id文章审稿实例id
*
*/
public function getAFilelistByID(){
$rev_id = $this->request->post('revid');
$article_rev_info = $this->article_reviewer_obj->where('art_rev_id',$rev_id)->find();
$file_list = $this->article_file_obj->where('article_id',$article_rev_info['article_id'])->where('type_name','manuscirpt')->order('file_id desc')->limit(1)->select();
return json(['data'=>$file_list]);
}
/**
* @title 获取文章文件picturesAndTables
* @description 获取文章文件picturesAndTables
* @author wangjinlei
* @url /api/Reviewer/getBFilelistByID
* @method POST
*
* @param name:revid type:int require:1 desc:art_rev_id文章审稿实例id
*
*/
public function getBFilelistByID(){
$rev_id = $this->request->post('revid');
$article_rev_info = $this->article_reviewer_obj->where('art_rev_id',$rev_id)->find();
$file_list = $this->article_file_obj->where('article_id',$article_rev_info['article_id'])->where('type_name','picturesAndTables')->order('file_id desc')->limit(1)->select();
return json(['data'=>$file_list]);
}
/**
* @title 审稿人详情页--获取文章审稿实例详情(审稿人,编辑)
* @description 审稿人详情页--获取文章审稿实例详情(审稿人,编辑)
* @author wangjinlei
* @url /api/Reviewer/getartrevdate
* @method POST
*
* @param name:revid type:int require:1 desc:art_rev_id文章审稿实例id
* @param name:human type:string require:1 desc:(reviewer/editor)
*/
public function getartrevdate() {
//接受参数
$data = $this->request->post();
//查询实例数据
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_journal.*,t_article.title article_title,t_article.accept_sn accept_sn,t_user.account account')
->join('t_article', 't_article.article_id = t_article_reviewer.article_id', 'LEFT')
->join('t_user', 't_user.user_id = t_article_reviewer.reviewer_id', 'LEFT')
->join('t_journal','t_journal.journal_id = t_article.journal_id','left')
->where('t_article_reviewer.art_rev_id', $data['revid'])
->find();
//更改实例状态(消息提醒)
if($data['human']=='editor'){
$up_data['reviewer_act'] = 0;
}else{
$up_data['editor_act'] = 0;
}
$this->article_reviewer_obj->where('art_rev_id', $data['revid'])->update($up_data);
return json($res);
}
/**
* @title 提交问卷(审稿人)
* @description 提交问卷(审稿人)
* @author wangjinlei
* @url /api/Reviewer/questionSubmit
* @method POST
*
* @param name:art_rev_id type:int require:1 desc:art_rev_id文章审稿实例id
* @param name:qu1 type:int require:1 desc:问题1
* @param name:qu2 type:int require:1 desc:问题2
* @param name:qu3 type:int require:1 desc:问题3
* @param name:qu4 type:int require:1 desc:问题4
* @param name:qu5 type:int require:1 desc:问题5
* @param name:qu6 type:int require:1 desc:问题6
* @param name:qu7 type:int require:1 desc:问题7
* @param name:qu8 type:int require:1 desc:问题8
* @param name:qu9 type:int require:1 desc:问题9
* @param name:qu9contents type:string require:1 desc:问题9描述
* @param name:qu10 type:int require:1 desc:问题10
* @param name:qu10contents type:string require:1 desc:问题10描述
* @param name:qu11 type:int require:1 desc:问题11
* @param name:qu11contents type:string require:1 desc:问题11描述
* @param name:qu12 type:int require:1 desc:问题12
* @param name:qu12contents type:string require:1 desc:问题12描述
* @param name:qu13 type:int require:1 desc:问题13
* @param name:qu13contents type:string require:1 desc:问题13描述
* @param name:qu14 type:int require:1 desc:问题14
* @param name:qu14contents type:string require:1 desc:问题14描述
* @param name:qu15 type:int require:1 desc:问题15
* @param name:qu15contents type:string require:1 desc:问题15描述
* @param name:rated type:int require:1 desc:分数
* @param name:recommend type:int require:1 desc:最终决定
* @param name:other type:int require:1 desc:其他
* @param name:confident type:string require:1 desc:对编辑的意见
* @param name:comment type:string require:1 desc:对作者的意见
*
*/
public function questionSubmit() {
//接受参数,查询基础数据
$data = $this->request->post();
$art_rev_info = $this->article_reviewer_obj->where('art_rev_id',$data['art_rev_id'])->find();
$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();
$editor_info = $this->user_obj->where('user_id',$article_info['editor_id'])->find();
//组合insert数据,存储
$insert_data['art_rev_id'] = $data['art_rev_id'];
$insert_data['qu1'] = $data['qu1'];
$insert_data['qu2'] = $data['qu2'];
$insert_data['qu3'] = $data['qu3'];
$insert_data['qu4'] = $data['qu4'];
$insert_data['qu5'] = $data['qu5'];
$insert_data['qu6'] = $data['qu6'];
$insert_data['qu7'] = $data['qu7'];
$insert_data['qu8'] = $data['qu8'];
$insert_data['qu9'] = $data['qu9']?1:0;
$insert_data['qu9_contents'] = $data['qu9contents'];
$insert_data['qu10'] = $data['qu10']?1:0;
$insert_data['qu10_contents'] = $data['qu10contents'];
$insert_data['qu11'] = $data['qu11']?1:0;
$insert_data['qu11_contents'] = $data['qu11contents'];
$insert_data['qu12'] = $data['qu12']?1:0;
$insert_data['qu12_contents'] = $data['qu12contents'];
$insert_data['qu13'] = $data['qu13']?1:0;
$insert_data['qu13_contents'] = $data['qu13contents'];
$insert_data['qu14'] = $data['qu14']?1:0;
$insert_data['qu14_contents'] = $data['qu14contents'];
$insert_data['qu15'] = $data['qu15']?1:0;
$insert_data['qu15_contents'] = $data['qu15contents'];
$insert_data['rated'] = $data['rated'];
$insert_data['recommend'] = $data['recommend'];
$insert_data['other'] = $data['other'];
$insert_data['confidential'] = $data['confident'];
$insert_data['comments'] = $data['comment'];
if ($data['rev_qu_id'] == '') {//新增
$insert_data['ctime'] = time();
$res = $this->article_reviewer_question_obj->insert($insert_data);
} else {//更新
$res = $this->article_reviewer_question_obj->where('rev_qu_id', $data['rev_qu_id'])->update($insert_data);
}
//根据recommend问题改变此实例的状态,并且更改act消息提醒状态
if ($data['recommend'] == 1) {
$artrevstate = 3;
} else if ($data['recommend'] == 2) {
$artrevstate = 1;
} else {
$artrevstate = 2;
}
$this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->update(['state' => $artrevstate,'reviewer_act'=>1]);
//文章是从初始状态到其他状态,增加审稿人成功审核次数
if($art_rev_info['state']==0){
$this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->setInc('rs_num');
}
//记录log
//生成pdf文件
$reviewer_pdf = self::pdftest($journal_info['title']);
//发送email->编辑
$tt = 'Dear editor,<br>';
$tt .= 'Please check the new comments from the reviewer.<br>';
$tt .= 'Journal:'.$journal_info['title'].' and article title:'.$article_info['title'];
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
//发送email感谢reviewer并携带附件
$reviewer_info = $this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->find();
$tt1 = 'You have reviewed 1 submission in the journal '.$journal_info['title'].' during '.date('Y').'.Thank you for your support to our journal. This contribution is greatly appreciated.<br><br>';
$tt1 .= 'Regards<br>Editorial Office<br>'.$journal_info['title'].'<br><br>';
$tt1 .= 'Contact us<br>TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>Telephone: +64 02108293806<br>E-mail: publisher@tmrjournals.com';
sendEmail($reviewer_info['email'],'Your contribution is greatly appreciated', $journal_info['title'], $tt1,$journal_info['email'],$journal_info['epassword'],$reviewer_pdf);
//记录usermsg
add_usermsg($article_info['editor_id'], 'Feedback questionnaire be unloaded.', '/articleReviewerDetail?id='.$data['art_rev_id']);
return json(['code' => 0]);
}
/**
* 获取问卷详情
*/
public function getQuestion() {
$id = $this->request->post('artrevid');
$qu_info = $this->article_reviewer_question_obj->where('art_rev_id', $id)->find();
if ($qu_info) {
return json(['code' => 0, 'data' => $qu_info]);
} else {
return json(['code' => 1]);
}
}
/**
* 上传文章的文件
*/
public function up_file($type) {
$file = request()->file($type);
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
/**
* @title 待审文章页--获取待审文章列表
* @description 待审文章页--获取待审文章列表
* @author wangjinlei
* @url /api/Reviewer/getAllReviewerList
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:pageIndex type:int require:1 desc:当前页码
* @param name:pageSize type:int require:1 desc:每个页面的数据条数
*
* @return articles:文章列表#
* @return count:总数#
*/
public function getAllReviewerList(){
$data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$arts = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',2)->limit($limit_start,$data['pageSize'])->select();
$count = $this->article_obj->where('journal_id',$data['journal_id'])->where('state',2)->count();
$re['articles'] = $arts;
$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'] . '<br>';
$tt .= 'Dear '.$user_info['realname'].'<br><br>';
$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'].'. <br>';
$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.<br><br>';
$tt .= 'Thank you for your consideration.<br> Look forward for your reply.<br>';
$tt .= '<a href="'.$this->creatLoginUrlForreviewer($user_info,$article_info['article_id']).'">Click here to review the article</a><br>';
$tt .= 'Your username:'.$user_info['account'].'<br><br>';
$tt .= 'Your original password:123456qwe , if you have reset the password, please login with the new one or click the "<a href="https://submission.tmrjournals.com/retrieve">forgot password</a>".<br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= '<a href="https://www.tmrjournals.com/draw_up.html?issn='.$journal_info['issn'].'">Subscribe to this journal</a><br>';
$tt .= $journal_info['title'].'<br>';
$tt .= 'Email:'.$journal_info['email'].'<br>';
$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<br/>". "At present, you have passed our examination<br/>";
$content .= '<a href="https://submission.tmrjournals.com">SubmissionSystem</a><br>';
$content .= '<p>username:' . trim($data['account']) . '</p>';
$content .= '<p>Original Password: 123456qwe</p>';
$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文件历史信息
*/
private function save_article_reviewer_file($art_rev_id, $user_id, $username, $url, $type_name) {
//首先确定数据库里面是否存在此数据
$res = $this->article_reviewer_file_obj->where(['file_url' => $url])->find();
if ($res) {
return false;
}
$insert_data['art_rev_id'] = $art_rev_id;
$insert_data['up_user_id'] = $user_id;
$insert_data['up_username'] = $username;
$insert_data['file_url'] = $url;
$insert_data['type_name'] = $type_name;
$insert_data['ctime'] = time();
return $this->article_reviewer_file_obj->insert($insert_data);
}
/**
* 生成pdf感谢reviewer
*/
private function pdftest($title) {
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetHeaderData('logo.png', 25, '', '', array(0, 64, 255), array(0, 64, 128));
$pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once(dirname(__FILE__) . '/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->setFontSubsetting(true);
$pdf->SetFont('times', '', 14, '', true);
$pdf->AddPage();
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
$html ='<div style="margin-top:300px;font-size:16px;"><h3>To whom it may concern</h3>'
. 'You have reviewed 1 submission in the journal '.$title.' during '.date('Y').'
Thank you for your support to our journal. This contribution is greatly appreciated.'
.'<p>Regards<br>
Editorial Office<br>
'.$title.'</p>'
.'<p><h3>Contact us</h3>
TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>
Telephone: +64 02108293806<br>
E-mail: publisher@tmrjournals.com</p></div>';
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
// $pdf->Output('example_001.pdf', 'D');
// $pdf_wj = 'd:/example_001.pdf';
$pdf_wj = $_SERVER['DOCUMENT_ROOT'].'public/pdf/'.date('YmdHis').'thanks.pdf';
// $pdf_wj = '/public/pdf/'.date('YMD').'/'.date('His').'thanks.pdf';
$pdf->Output($pdf_wj, 'F');
return $pdf_wj;
}
}