Files
tougao/application/api/controller/Article.php
wangjinlei e8251d4489 20201112
2020-12-07 14:25:07 +08:00

979 lines
46 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;
class Article extends Controller {
protected $article_obj = '';
protected $user_obj = '';
protected $user_act_obj = '';
protected $journal_obj = '';
protected $user_log_obj = '';
protected $reviewer_major_obj = '';
protected $reviewer_to_journal_obj = '';
protected $article_msg_obj = '';
protected $article_file_obj = '';
protected $article_reviewer_obj = '';
protected $article_author_obj = '';
protected $article_transfer_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->user_obj = Db::name('user');
$this->user_act_obj = Db::name('user_act');
$this->article_obj = Db::name('article');
$this->journal_obj = Db::name('journal');
$this->user_log_obj = Db::name('user_log');
$this->reviewer_major_obj = Db::name('reviewer_major');
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
$this->article_msg_obj = Db::name('article_msg');
$this->article_file_obj = Db::name('article_file');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->article_author_obj = Db::name('article_author');
$this->article_transfer_obj = Db::name('article_transfer');
}
/**
* 获取文章列表(作者)
*/
public function getArticle() {
//接收参数
$data = $this->request->post();
//构造查询条件
$userres = $this->user_obj->where(['account' => $data['username']])->column('user_id');
$where['user_id'] = $userres[0];
if ($data['journal'] != 0) {
$where['t_article.journal_id'] = $data['journal'];
}
if($data['state'] != 0){
$where['t_article.state'] = $data['state'];
}
if ($data['name'] != '') {
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
}
//分页查询数据
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$res = $this->article_obj->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where($where)
->order('article_id desc')
->limit($limit_start, $data['pageSize'])->select();
$count = $this->article_obj->where($where)->count();
//返回数据
return json(['total' => $count, 'data' => $res]);
}
/**
* 获取文章列表(编辑)
*/
public function getArticleForEditor() {
//接受参数
$data = $this->request->post();
//构造查询条件
if ($data['journal'] == 0) {//全部期刊
$userres = $this->user_obj->where(['account' => $data['username']])->column('user_id');
$journal_list = $this->journal_obj->where(['editor_id' => $userres[0]])->column('journal_id');
$where['t_article.journal_id'] = ['in', $journal_list];
} else {
$where['t_article.journal_id'] = $data['journal'];
}
if($data['state'] >= 0){
$where['t_article.state'] = $data['state'];
}else{
if($data['act']==1){
$where['t_article.state'] = array('in',[0,1,2,4]);
}else if($data['act']==2){
$where['t_article.state'] = array('in',[3,5]);
}
}
if ($data['name'] != '') {
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
}
//分页查询数据
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$res = $this->article_obj->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where($where)
->order('t_article.article_id desc')
->limit($limit_start, $data['pageSize'])
->select();
$count = $this->article_obj->where($where)->count();
return json(['total' => $count, 'data' => $res]);
}
/**
* 获取文章详情(作者,编辑)
*/
public function getArticleDetail() {
//接受参数
$data = $this->request->post();
//查询文章基础数据
$where['t_article.article_id'] = $data['articleId'];
$article_res = $this->article_obj->field('t_article.*,t_journal.title journalname,t_user.account')->join(array(['t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT'], ['t_user', 't_user.user_id = t_article.user_id', 'LEFT']))->where($where)->find();
//查询文章状态跟踪信息
$article_msg = $this->article_msg_obj->where(['article_id' => $data['articleId']])->where('state',0)->select();
$suggest = '';
//如果是退修状态,显示退休信息
// if($article_res['state']==4){
// $lastbean = end($article_msg);
// $suggest = $lastbean['content'];
// }
//查询审稿人审稿建议
if($article_res['state']==4){
$suggest = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article_reviewer_question.comments comments')
->join('t_article_reviewer_question','t_article_reviewer.art_rev_id=t_article_reviewer_question.art_rev_id','left')
->where('t_article_reviewer.state','<',4)
->where('t_article_reviewer.article_id',$article_res['article_id'])
->select();
}
//查询major信息
$major_data = [];
if($article_res['major_id']!=0){
$major_data['major'] = $this->reviewer_major_obj->where('major_id',$article_res['major_id'])->find();
}else{
$major_data['major'] = null;
}
if($article_res['cmajor_id']!=0){
$major_data['cmajor'] = $this->reviewer_major_obj->where('major_id',$article_res['cmajor_id'])->find();
}else{
$major_data['cmajor'] = null;
}
//查询文章作者信息
$author_res = $this->article_author_obj->where('article_id', $data['articleId'])->where('state', 0)->select();
//查询转投信息
$transfer_res = $this->article_transfer_obj->where('article_id',$data['articleId'])->select();
//查询建议转投详情
$transfer_info = $this->article_transfer_obj
->field('t_article_transfer.*,t_journal.title jourtitle')
->join('t_journal','t_journal.journal_id = t_article_transfer.journal_id','LEFT')
->where('t_article_transfer.article_id',$data['articleId'])
->where('t_article_transfer.state',2)
->find();
//更新文章操作记录状态
if ($data['human'] == 'editor') {
$up_data['author_act'] = 0;
} else {
$up_data['editor_act'] = 0;
}
$this->article_obj->where('article_id', $data['articleId'])->update($up_data);
return json(['article' => $article_res, 'msg' => $article_msg, 'authors' => $author_res,'suggest'=>$suggest,'transfer'=>$transfer_res,'transinfo'=>$transfer_info,'major'=>$major_data]);
}
/**
* 作者同意转投
*/
public function trans_manu(){
//接受参数
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
//更新文章状态
$this->article_obj->where('article_id',$data['article_id'])->update(['journal_id'=>$data['journal_id'],'editor_id'=>$journal_info['editor_id'],'state'=>1]);
//跟新转投表状态
$this->article_transfer_obj->where('transfer_id',$data['transfer_id'])->update(['state'=>1]);
//添加文章状态信息
$insert_data['article_id'] = $data['article_id'];
$insert_data['content'] = 'manuscript transfer to :'.$journal_info['title'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 1;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
//发送邮件提醒编辑有新的转投稿件
$tt1 = 'Dear editor';
$tt1 .= 'Please check the new transfer manuscript in the submission system.';
sendEmail($editor_info['email'],$journal_info['title'], $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword']);
//发送消息给编辑
add_usermsg($journal_info['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code'=>0]);
}
/**
* 修改文章详情(作者)
*/
public function editArticle() {
//接受参数查询信息
$data = $this->request->post();
// return json($data);
// $data['abstrart'] = "dsadsadsadsa";
// $data['accept_sn'] = "20200811001";
// $data['articleId'] = 7;
// $data['authorList'] = [
// [
// 'address'=>"dsad",
// 'art_aut_id'=>5,
// 'company'=>"sads",
// 'country'=>"China",
// 'department'=>"adsa",
// 'email'=>"dsadsadsa",
// 'firstname'=>"dsadsa",
// 'isReport'=>'true',
// 'isSuper'=>"true",
// 'lastname'=>"dsadsa",
// 'title'=>"Ph.D."
// ],
// [
// 'address'=>"",
// 'art_aut_id'=>6,
// 'company'=>"dsadsa",
// 'country'=>"Angola",
// 'department'=>"dsa",
// 'email'=>"dsadsa",
// 'firstname'=>"dsad7",
// 'isReport'=>"false",
// 'isSuper'=>"true",
// 'lastname'=>"sada",
// 'title'=>"Associate Prof."
// ]
// ];
// $data['coverLetter']='';
// $data['ctime']="1597138197";
// $data['fund']="sadsadasd";
// $data['journal']="20";
// $data['journalname']="Infectious Diseases Research";
// $data['keyWords']="dsadsad";
// $data['manuscirpt']='';
// $data['picturesAndTables']='';
// $data['state']='4';
// $data['title']="dsadsadsa";
// $data['username']="wangjinlei";
$username = $data['username'];
$user_res = $this->user_obj->where(['account' => $username])->find();
$article_old_info = $this->article_obj->where('article_id',$data['articleId'])->find();
Db::startTrans();
//更新文章信息
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = $data['fund'];
$inset_data['abstrart'] = $data['abstrart'];
$inset_data['author_act'] = 1;
$inset_data['state'] = $article_old_info['accept_sn']==''?0:1;
$where['article_id'] = $data['articleId'];
$up_res = $this->article_obj->where($where)->update($inset_data);
$article_info = $this->article_obj->where($where)->find();
//更新作者信息
$aids = [];
foreach ($data['authorList'] as $v) {
if (isset($v['art_aut_id'])) {//改
$up['art_aut_id'] = $aids[] = $v['art_aut_id'];
$up['firstname'] = $v['firstname'];
$up['lastname'] = $v['lastname'];
$up['company'] = $v['company'];
$up['department'] = $v['department'];
$up['author_title'] = $v['title'];
$up['country'] = $v['country'];
$up['email'] = $v['email'];
$up['address'] = $v['address'];
$up['is_super'] = $v['isSuper'] == 'true'?1:0;
$up['is_report'] = $v['isReport'] == 'true'?1:0;
$this->article_author_obj->update($up);
} else {//增
if ($v['firstname'] == '') {
continue;
}
$ins['article_id'] = $data['articleId'];
$ins['firstname'] = $v['firstname'];
$ins['lastname'] = $v['lastname'];
$ins['company'] = $v['company'];
$ins['department'] = $v['department'];
$ins['author_title'] = $v['title'];
$ins['country'] = $v['country'];
$ins['email'] = $v['email'];
$ins['address'] = $v['address'];
$ins['is_super'] = $v['isSuper'] == 'true'?1:0;
$ins['is_report'] = $v['isReport'] == 'true'?1:0;
$aids[] = $this->article_author_obj->insertGetId($ins);
}
}
//删
$this->article_author_obj->where('article_id', $data['articleId'])->where('art_aut_id', 'not in', $aids)->update(['state' => 1]);
//增加article_msg
$insmsg_data['article_id'] = $data['articleId'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_old_info['state'];
$insmsg_data['state_to'] = $article_old_info['accept_sn']==''?0:1;
$insmsg_data['ctime'] = time();
$msg_res = $this->article_msg_obj->insert($insmsg_data);
//发送邮件
$journal_info = $this->journal_obj->where('journal_id',$article_old_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
$tt = 'Dear editor,<br>';
$tt .= 'The author changed the manuscripts status, please check.<br><br>';
$tt .= 'TMR Publishing Group';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
//记录历史file信息
$res1 = self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
$res2 = true;
if(isset($data['picturesAndTables'])){
foreach ($data['picturesAndTables'] as $v){
$res2=$res2?self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables'):false;
}
}
// self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['picturesAndTables'], 'picturesAndTables');
$res3=self::save_article_file($data['articleId'], $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
$res4=self::save_article_file($data['articleId'],$user_res['user_id'],$user_res['account'],$data['totalpage'],'totalpage');
//增加用户操作log
$log_data['user_id'] = $article_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $data['username'] . "(" . $user_res['realname'] . "),修改了一篇文章:" . $article_info['title'] . ",时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$log_res=$this->user_log_obj->insert($log_data);
//增加usermsg
$umsg_res=add_usermsg($article_info['editor_id'], 'The manuscript has new process: ' . $article_info['title'], '/articleDetailEditor?id=' . $article_info['article_id']);
if($up_res&&$msg_res&&$res1&&$res2&&$res3&&$res4&&$log_res&&$umsg_res){
Db::commit();
return json(['code' => 0]);
}else{
Db::rollback();
return json(['code' => 1]);
}
}
/**
* 修改文章的作者(作者)
*/
public function saveAuthor() {
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id',$data['articleId'])->find();
//更新作者(增删改)
$aids = [];
foreach ($data['authorList'] as $v) {
if (isset($v['art_aut_id'])) {//改
$up['art_aut_id'] = $aids[] = $v['art_aut_id'];
$up['author'] = $v['author'];
$up['company'] = $v['company'];
$up['email'] = $v['email'];
$up['address'] = $v['address'];
$up['is_super'] = $v['is_super'] == 'true' ? 1 : 0;
$up['is_report'] = $v['is_report'] == 'true'?1:0;
$this->article_author_obj->update($up);
} else {//增
if ($v['author'] == '') {
continue;
}
$ins['author'] = $v['author'];
$ins['article_id'] = $data['articleId'];
$ins['company'] = $v['company'];
$ins['email'] = $v['email'];
$ins['address'] = $v['address'];
$ins['is_super'] = $v['is_super'] == 'true' ? 1 : 0;
$ins['is_report'] = $v['is_report'] == 'true'?1:0;
$aids[] = $this->article_author_obj->insertGetId($ins);
}
}
//删
$this->article_author_obj->where('article_id', $data['articleId'])->where('art_aut_id', 'not in', $aids)->update(['state' => 1]);
//更新文章操作状态
$this->article_obj->where('article_id',$data['articleId'])->update(['author_act'=>1]);
//发送邮件通知编辑
$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();
$tt = 'Dear editor,<br>';
$tt .= 'The author changed the manuscripts information, please check.';
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
//添加usermsg
add_usermsg($article_info['editor_id'], 'Manuscript authors be changed,please contact the author to confirm.', 'articleDetailEditor?id='.$data['articleId']);
return json(['code' => 0]);
}
/**
* 修改文章状态(编辑)
*/
public function editArticleEditor() {
//接受参数,查询信息
$data = $this->request->post();
$where_editor['account'] = $data['editname'];
$editor_info = $this->user_obj->where($where_editor)->find();
$where_article['article_id'] = $data['articleId'];
$article_info = $this->article_obj->where($where_article)->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$transfer_list = $this->article_transfer_obj->where('article_id',$data['articleId'])->where('state',0)->select();
$user_info = $this->user_obj->where(['user_id' => $article_info['user_id']])->find();
// $sn_content = '';//显示接收sn信息
//
// //接受文章时,生成流水号
// if ($article_info['state'] == 0 && $data['state'] == 1) {
// $update_data['accept_sn'] = getArticleSN($journal_info['abbr'],$article_info['type']);
// $sn_content .= 'your Manuscript ID: '.$update_data['accept_sn'].' ';
// }
if($data['state']==3 && count($transfer_list)>0){
//查询转投期刊信息
$transfer_journal = $this->journal_obj->where('journal_id',$transfer_list[0]['journal_id'])->find();
//转投
$this->article_obj->where('article_id',$data['articleId'])->update(['state'=>1,'journal_id'=>$transfer_list[0]['journal_id'],'editor_id'=>$transfer_journal['editor_id']]);
//转投信息表信息状态改变
$this->article_transfer_obj->where('transfer_id',$transfer_list[0]['transfer_id'])->update(['state'=>1]);
//查找转投journal信息
$tran_journal = $this->journal_obj->where('journal_id',$transfer_list[0]['journal_id'])->find();
//转投后的作者信息
$trans_editor_info = $this->user_obj->where('user_id',$transfer_journal['editor_id'])->find();
//添加文章状态信息
$insert_data['article_id'] = $data['articleId'];
$insert_data['content'] = 'manuscript transfer to :'.$tran_journal['title'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = 1;
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
//发送邮件提醒转投给作者
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>';
$tt .= 'Thank you for submitting your paper to '.$journal_info['title'].'. Your manuscript has undergone review.<br>';
$tt .= 'Unfortunately the editors feel that '.$journal_info['title'].' is not the appropriate venue for your manuscript. I am writing just to follow up on the suggestion from the editor of Traditional Medicine Research that you might be interested in submitting your paper to '.$tran_journal['title'].' instead.<br><br>Yours sincerely,<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= $journal_info['title'].'<br>';
$tt .= 'Email: '.$journal_info['email'].'<br>';
$tt .= 'Website: '.$tran_journal['website'];
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//发送邮件提醒编辑有新的转投稿件
$tt1 = 'Dear editor';
$tt1 .= 'Please check the new transfer manuscript in the submission system.';
sendEmail($trans_editor_info['email'],$journal_info['title'], $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword']);
//增加usermsg
add_usermsg($tran_journal['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code'=>0]);
}else{
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$insert_data['article_id'] = $data['articleId'];
$insert_data['content'] = $data['editormsg'];
$insert_data['state_from'] = $article_info['state'];
$insert_data['state_to'] = $data['state'];
$insert_data['ctime'] = time();
$this->article_msg_obj->insert($insert_data);
if ($article_info['state'] == $data['state']) {
$this->article_obj->where($where_article)->update(['editor_act'=>1]);
return json(['code' => 0]);
}
//更新文章状态
$update_data['state'] = $data['state'];
$update_data['editor_act'] = 1;
$this->article_obj->where($where_article)->update($update_data);
}
//发送文章状态更改邮件
if($data['state']==3){//拒稿
if($data['trsjournal']==0){
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>';
$tt .= 'Thank you for submitting your paper to '.$journal_info['title'].'. Your manuscript has undergone review.<br>';
$tt .= 'Unfortunately the editors feel that '.$journal_info['title'].' is not the appropriate venue for your manuscript,'
. ' and we are returning your manuscript to you so that you can submit it to another journal without delay. '
. '<br><br>Yours sincerely,<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
}else{//转投
//查找转投journal信息
$trans_journal = $this->journal_obj->where('journal_id',$data['trsjournal'])->find();
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>';
$tt .= 'Thank you for submitting your paper to '.$journal_info['title'].'. Your manuscript has undergone review.<br>';
$tt .= 'Unfortunately the editors feel that '.$journal_info['title'].' is not the appropriate venue for your manuscript. I am writing just to follow up on the suggestion from the editor of Traditional Medicine Research that you might be interested in submitting your paper to '.$trans_journal['title'].' instead.<br><br>';
$tt .= 'If you choose to pursue publication in '.$trans_journal['title'].', please submit your manuscript to ('.$trans_journal['website'].').';
$tt .= '<br><br>Yours sincerely,<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
}
}else if($data['state']==5){//录用
$tt = 'Manuscript ID: '.$article_info['accept_sn'].'<br>';
$tt .= 'Manuscript Title: '.$article_info['title'].'<br>';
$tt .= 'Authors Name: '.self::getArticleAuthors($article_info['article_id']).'<br><br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>It is a distinct pleasure to inform you that your manuscript has been accepted for publication in '.$journal_info['title'].' (ISSN '.$journal_info['issn'].').<br> The editor of TMR will contact you further by email soon.<br><br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
}else if($data['state']==4){//退修
$tt = $article_info['accept_sn'].'<br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>';
$tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'. <br>';
$tt .= 'Please find the new comments in the "<a href="http://submission.tmrjournals.com/submission?journal='.$journal_info['alias'].'">AuthorCenter</a>", Please submit your revised manuscript within two weeks.<br><br>';
$tt .= 'If you need more time to revise, you can send E-mial to tell us.<br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
}else{
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br><br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>Please check the new status of your manuscript online.<br><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']);
//转投操作
if($data['trsjournal']!=0){
$tran_data['article_id'] = $data['articleId'];
$tran_data['journal_id'] = $data['trsjournal'];
$tran_data['ctime'] = time();
$tran_data['state'] = 2;
$this->article_transfer_obj->insert($tran_data);
}
//增加用户操作log
$log_data['user_id'] = $editor_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),更改了一篇文章:(" . $article_info['title'] . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'] , '/articleDetail?id=' . $article_info['article_id']);
return json(['code' => 0]);
}
/**
* 编辑文章备注
*/
public function editArticleRemark(){
//接受参数
$data = $this->request->post();
$this->article_obj->where('article_id',$data['articleId'])->update(['remarks'=>$data['content']]);
return json(['code'=>0]);
}
/**
* 更改重复率(编辑)
*/
public function changeRepetition(){
//接受参数
$data = $this->request->post();
$this->article_obj->where('article_id',$data['articleId'])->update(['repetition'=>$data['repefen'],'repeurl'=>$data['zipurl']]);
return json(['code'=>0]);
}
/**
* 更改文章详情(编辑)
*/
public function changeArticleFileEditor() {
//接受参数查询信息
$data = $this->request->post();
$article_info = $this->article_obj->where(['article_id' => $data['articleId']])->find();
// $author_info = $this->user_obj->where('user_id',$article_info['user_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();
//存储文件入文件表
// self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['coverLetter'], 'coverLetter');
// self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['picturesAndTables'], 'picturesAndTables');
self::save_article_file($data['articleId'], $editor_info['user_id'], $editor_info['account'], $data['manuscirpt'], 'manuscirpt');
//更新文章状态(提醒用户)
$this->article_obj->where('article_id', $data['articleId'])->update(['editor_act' => 1]);
//添加article_msg信息
// $insmsg_data['article_id'] = $data['articleId'];
// $insmsg_data['content'] = '';
// $insmsg_data['state_from'] = $article_info['state'];
// $insmsg_data['state_to'] = 4;
// $insmsg_data['ctime'] = time();
// $this->article_msg_obj->insert($insmsg_data);
//发送email提醒用户
// $tt = $article_info['accept_sn'].'<br>';
// $tt .= 'Dear author,<br>';
// $tt .= 'Thanks for submitting the manuscript to '.$journal_info['title'].'. <br>';
// $tt .= 'Here are the comments in the "<a href="http://submission.tmrjournals.com/submission?journal='.$journal_info['alias'].'">AuthorCenter</a>", Please submit your revised manuscript within two weeks.<br><br>';
// $tt .= 'Sincerely,<br>Editorial Office<br>';
// $tt .= $journal_info['title'].'<br>';
// $tt .= 'Email:'.$journal_info['email'].'<br>';
// $tt .= 'Website: '.$journal_info['website'];
// sendEmail($author_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//增加用户操作log
$log_data['user_id'] = $editor_info['user_id'];
$log_data['type'] = 1;
$log_data['content'] = $editor_info['account'] . "(" . $editor_info['realname'] . "),更改了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$this->user_log_obj->insert($log_data);
//增加usermsg
add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'], '/articleDetail?id=' . $article_info['article_id']);
return json(['code' => 0]);
}
/**
* 添加文章审稿实例(编辑)
*/
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();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
//增加信息到文章审稿表
$insert_data['reviewer_id'] = $data['uid'];
$insert_data['article_id'] = $data['articleId'];
$insert_data['editor_act'] = 1;
$insert_data['ctime'] = time();
$res = $this->article_reviewer_obj->insertGetId($insert_data);
//修改文章状态->审稿中
$this->article_obj->where('article_id',$data['articleId'])->update(['state'=>2]);
//添加article_msg信息
$insmsg_data['article_id'] = $data['articleId'];
$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'] . '<br>';
$tt .= 'Dear '.$reviewer_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="http://submission.tmrjournals.com/submission?journal='.$journal_info['alias'].'">ReviewerCenter</a><br>';
$tt .= 'Your username:'.$reviewer_info['account'].'<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>';
$tt .= $journal_info['title'].'<br>';
$tt .= 'Email:'.$journal_info['email'].'<br>';
$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($data['uid'], 'You have new manuscript to be approved', '/reviewerArticleDetail?id=' . $res);
return json(['code' => 0]);
}
/**
* 添加文章(作者)
*/
public function addArticle() {
//接受参数,查询信息
$data = $this->request->post();
// return json($data);
// $data['abstrart'] = '大萨达撒多';
// $data['authorList'] = [
// [
// 'address'=>'dsadsa',
// 'company'=>'dasdsa',
// 'country'=>'china',
// 'department'=>'dsadsa',
// 'email'=>'6541654@qq.com',
// 'firstname'=>'dsadsa',
// 'isReport'=>'true',
// 'isSuper'=>'true',
// 'lastname'=>'dsadsa',
// 'title'=>'Ph.D.'
// ]
// ];
// $data['coverLetter'] = '';
// $data['fund'] = 'dsads';
// $data['journal'] = 1;
// $data['keyWords'] = 'dsads';
// $data['manuscirpt'] = "manuscirpt/20200727/cd67d8e8f944b5f1589cceb8e1aa967c.pdf";
// $data['picturesAndTables'] = [];
// $data['title'] = "大萨达撒多";
// $data['username'] = "wangjinlei";
$user_res = $this->user_obj->where('account', $data['username'])->find();
$journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
Db::startTrans();
//添加文章基础信息
$inset_data['user_id'] = $user_res['user_id'];
$inset_data['journal_id'] = $data['journal'];
$inset_data['editor_id'] = $journal_info['editor_id'];
$inset_data['title'] = $data['title'];
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = $data['fund'];
$inset_data['accept_sn'] = getArticleSN($journal_info['abbr'],$data['type']);
$inset_data['type'] = $data['type'];
$inset_data['major_id'] = $data['major'];
$inset_data['cmajor_id'] = $data['cmajor'];
$inset_data['approval'] = $data['approval']=='true'?1:0;
$inset_data['abstrart'] = $data['abstrart'];
$inset_data['author_act'] = 1;
$inset_data['ctime'] = time();
$res = $this->article_obj->insertGetId($inset_data);
//上传文章作者信息
$authors = [];
foreach ($data['authorList'] as $v) {
if ($v['firstname'] == '') {
continue;
}
$i['article_id'] = $res;
$i['firstname'] = $v['firstname'];
$i['lastname'] = $v['lastname'];
$i['company'] = $v['company'];
$i['department'] = $v['department'];
$i['author_title'] = $v['title'];
$i['country'] = $v['country'];
$i['email'] = $v['email'];
$i['address'] = $v['address'];
$i['is_super'] = $v['isSuper'] == 'true' ? 1 : 0;
$i['is_report'] = $v['isReport'] == 'true'?1:0;
$authors[] = $i;
}
$res_author = $this->article_author_obj->insertAll($authors);
//增加转投信息
$transr = true;
if($data['istransfer']=='true'){
foreach ($data['checkedjours'] as $val){
$trans_insert['article_id'] = $res;
$trans_insert['journal_id'] = $val;
$trans_insert['ctime'] = time();
$transr = $transr?$this->article_transfer_obj->insert($trans_insert):false;
}
}
//增加articlefile表的信息
$res_file1 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['coverLetter'], 'coverLetter');
$res_file2 = true;
if(isset($data['picturesAndTables'])){
foreach ($data['picturesAndTables'] as $v){
$res_file2 = $res_file2?self::save_article_file($res, $user_res['user_id'], $user_res['account'], $v, 'picturesAndTables'):false;
}
}
$res_file4 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['totalpage'], 'totalpage');
$res_file3 = self::save_article_file($res, $user_res['user_id'], $user_res['account'], $data['manuscirpt'], 'manuscirpt');
//发送邮件到编辑,提醒有待审文章
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
$tt = 'Dear editor,<br>';
$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']);
//增加用户操作log
$log_data['user_id'] = $user_res['user_id'];
$log_data['type'] = 0;
$log_data['content'] = $user_res['account'] . "(" . $user_res['realname'] . "),上传了一篇文章:" . $data['title'] . ",上传时间是:" . date('Y-m-d H:i:s', time());
$log_data['ctime'] = time();
$res_log = $this->user_log_obj->insert($log_data);
//增加usermsg
$res_msg = add_usermsg($journal_info['editor_id'], 'New manuscript', '/articleDetailEditor?id=' . $res);
if ($res && $res_author && $transr && $res_file1 && $res_file2 && $res_file3 && $res_file4 && $res_log && $res_msg) {
Db::commit();
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code' => 1]);
}
}
/**
* 作者发送消息
*/
public function authorMessage(){
$data = $this->request->post();
$insert['article_id'] = $data['articleId'];
$insert['content'] = $data['content'];
$insert['ftype'] = 1;
$insert['ctime'] = time();
$this->article_msg_obj->insert($insert);
return json(['code'=>0]);
}
/**
* 获取期刊列表
*/
public function getJournal() {
$username = $this->request->post('username');
$where = [];
if ($username) {
$uidres = $this->user_obj->where(['account' => $username])->column('user_id');
$where['editor_id'] = $uidres[0];
}
$list = $this->journal_obj->where($where)->select();
return json($list);
}
/**
* 获取文章历史上传file列表
*/
public function getFilelistByArticleID() {
$article_id = $this->request->post('articleId');
$where['article_id'] = $article_id;
$res = $this->article_file_obj->where($where)->select();
$frag = [];
foreach ($res as $v) {
$frag[$v['type_name']][] = $v;
}
return json($frag);
}
/**
* 上传文章的文件
*/
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()]);
}
}
}
/**
* 获取文章审稿实例列表
*/
public function getReviewerList() {
$data = $this->request->post();
$limit_start = $data['pageIndex'] == 1 ? 0 : ($data['pageIndex'] - 1) * $data['pageSize'] - 1;
$where['t_article_reviewer.article_id'] = $data['articleId'];
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_user.account reviewer,t_user_reviewer_info.country country,t_user_reviewer_info.field,t_user_reviewer_info.company,t_reviewer_major.title major_title,t_reviewer_major.ctitle major_ctitle')->join('t_user', 't_article_reviewer.reviewer_id = t_user.user_id', 'LEFT')->join('t_user_reviewer_info', 't_article_reviewer.reviewer_id = t_user_reviewer_info.reviewer_id', 'LEFT')->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT')->where($where)->limit($limit_start, $data['pageSize'])->select();
$count = $this->article_reviewer_obj->where($where)->count();
if ($res) {
return json(['code' => 0, 'data' => $res, 'totle' => $count]);
} else {
return json(['code' => 1]);
}
}
/**
* 根据期刊别名获取期刊信息
*/
public function getJournalByAlias(){
//接收参数
$data = $this->request->post();
$res = $this->journal_obj->where('alias',$data['alias'])->find();
return json($res);
}
/**
* 获取审核人详情
*/
public function getReviewerdetail() {
$uid = $this->request->post('uid');
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*,t_reviewer_major.title major_title')->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')->join('t_reviewer_major', 't_reviewer_major.major_id = t_user_reviewer_info.major', 'LEFT')->where('t_user.user_id', $uid)->find();
return json(['code' => 0, 'data' => $res]);
}
/**
* 获取文章审核员list
*/
public function getArticleReviewerList() {
$data = $this->request->post();
$article_info = $this->article_obj->where('article_id', $data['articleId'])->find();
$revids = $this->reviewer_to_journal_obj->where('journal_id', $article_info['journal_id'])->column('reviewer_id');
$noids = $this->article_reviewer_obj->where('article_id', $data['articleId'])->column('reviewer_id');
if ($noids != null) {
$where['t_user.user_id'] = [['in', $revids], ['not in', $noids]];
} else {
$where['t_user.user_id'] = ['in', $revids];
}
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')->where($where)->select();
if ($res) {
return json(['code' => 0, 'data' => $res]);
} else {
return json(['code' => 1]);
}
}
/**
* 存储article文件历史信息
*/
private function save_article_file($article_id, $user_id, $username, $url, $type_name) {
//首先确定数据库里面是否存在此数据
$res = $this->article_file_obj->where(['file_url' => $url])->find();
if ($res) {
return true;
}else if($type_name=='picturesAndTables' && $url == ''){
return true;
}else if($type_name=='coverLetter' && $url == ''){
return true;
}
$insert_data['article_id'] = $article_id;
$insert_data['user_id'] = $user_id;
$insert_data['username'] = $username;
$insert_data['file_url'] = $url;
$insert_data['type_name'] = $type_name;
$insert_data['ctime'] = time();
return $this->article_file_obj->insert($insert_data);
}
/**
* 获取文章作者字符串
* @param type $article_id
*/
private function getArticleAuthors($article_id){
$res = $this->article_author_obj->where('article_id',$article_id)->where('state',0)->select();
$frag = '';
foreach ($res as $v){
$frag .= $v['firstname'].$v['lastname'].',';
}
return substr($frag, 0,-1);
}
}