Files
tougao/application/api/controller/Article.php
wangjinlei de6ccd46ab 1
2022-04-24 09:33:54 +08:00

2010 lines
98 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 think\Queue;
/**
* @title 文章接口
* @description 文章接口
*/
class Article extends Controller {
protected $article_obj = '';
protected $user_obj = '';
protected $user_act_obj = '';
protected $journal_obj = '';
protected $user_log_obj = '';
protected $user_reviewer_info_obj = '';
protected $reviewer_major_obj = '';
protected $reviewer_to_journal_obj = '';
protected $article_reviewer_question_obj = '';
protected $article_msg_obj = '';
protected $article_file_obj = '';
protected $article_reviewer_obj = '';
protected $article_author_obj = '';
protected $article_transfer_obj = '';
protected $chief_to_journal_obj = '';
protected $login_auto_obj = '';
protected $major_obj = "";
protected $major_to_journal_obj = '';
protected $reviewer_from_author_obj = '';
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);
$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->user_reviewer_info_obj = Db::name("user_reviewer_info");
$this->reviewer_major_obj = Db::name('reviewer_major');
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
$this->article_reviewer_question_obj = Db::name('article_reviewer_question');
$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');
$this->chief_to_journal_obj = Db::name('chief_to_journal');
$this->login_auto_obj = Db::name('login_auto');
$this->major_obj = Db::name("major");
$this->major_to_journal_obj = Db::name('major_to_journal');
$this->reviewer_from_author_obj = Db::name("reviewer_from_author");
$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');
}
/**
* 获取文章列表(作者)
*/
/**
* @title 获取文章列表(作者)
* @description 获取文章列表(作者)
* @author wangjinlei
* @url /api/Article/getArticle
* @method POST
*
* @param name:username type:string require:1 desc:用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:state type:int require:1 desc:状态id0全部
* @param name:name type:string require:1 desc:查询条件
* @param name:pageIndex type:int require:1 desc:页码
* @param name:pageSize type:int require:1 desc:单页条数
*
* @return article:文章信息#
* @return msg:文章跟踪信息#
* @return authors:作者信息#
* @return suggest:建议信息#
* @return transfer:转投信息#
* @return transinfo:建议转投信息#
* @return major:领域信息#
*
*/
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();
foreach ($res as $key => $val) {
//查询建议转投详情
$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', $val['article_id'])
->where('t_article_transfer.state', 2)
->find();
$res[$key]['transinfo'] = $transfer_info;
}
//返回数据
return json(['total' => $count, 'data' => $res]);
}
/**
* @title 获取文章列表(编辑)
* @description 获取文章列表(编辑)
* @author wangjinlei
* @url /api/Article/getArticleForEditor
* @method POST
*
* @param name:username type:string require:1 desc:编辑用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:state type:int require:1 desc:状态
* @param name:act type:int require:1 desc:1进行中2已完成
* @param name:sn type:string require:0 desc:流水号
* @param name:pageIndex type:int require:1 desc:当前页码
* @param name:pageSize type:int require:1 desc:每个页面的数据条数
*
* @return articles:文章列表#
* @return count:总数#
*/
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,6]);
}else if($data['act']==2){
$where['t_article.state'] = array('in',[3,5]);
}
}
if(isset($data['sn'])&& trim($data['sn'])!=""){
$where["t_article.accept_sn"] = trim($data['sn']);
}
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,t_user.email,t_user.realname,t_user.phone')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->join('t_user',"t_user.user_id = t_article.user_id",'left')
->where($where)
->order('t_article.article_id desc')
->limit($limit_start, $data['pageSize'])
->select();
//增加审稿意见信息
foreach($res as $key => $val){
$cache_review = $this->article_reviewer_obj
->where("t_article_reviewer.article_id",$val['article_id'])
->where("t_article_reviewer.state",'in',[1,2,3])
->select();
$res[$key]['review'] = $cache_review;
}
//添加国家信息
foreach($res as $k => $v){
$cache_author_list = $this->article_author_obj->where('article_id',$v['article_id'])->select();
$cache_country = [];
foreach($cache_author_list as $key => $val){
if($val['country']!=''&&!in_array($val['country'],$cache_country)){
$cache_country[] = $val['country'];
}
}
$res[$k]['countrys'] = $cache_country;
}
$count = $this->article_obj->where($where)->count();
return json(['total' => $count, 'data' => $res]);
}
/**
* @title 获取文章详情(作者,编辑)
* @description 获取文章详情(作者,编辑)
* @author wangjinlei
* @url /api/Article/getArticleDetail
* @method POST
*
* @param name:articleId type:int require:1 desc:文章id
* @param name:human type:string require:1 desc:editor/author
*
* @return article:文章信息#
* @return msg:文章跟踪信息#
* @return authors:作者信息#
* @return suggest:建议信息#
* @return transfer:转投信息#
* @return transinfo:建议转投信息#
* @return major:领域信息#
*
*/
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.qu9_contents,t_article_reviewer_question.qu10_contents,t_article_reviewer_question.qu11_contents,t_article_reviewer_question.qu12_contents,t_article_reviewer_question.qu13_contents,t_article_reviewer_question.qu14_contents,t_article_reviewer_question.qu15_contents,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.state','>',0)
->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;
// }
//新领域查询
$major = $this->getMajorStr($article_res['major_id'])==""?"":substr($this->getMajorStr($article_res['major_id']), 3);
//查询文章作者信息
$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]);
}
private function getMajorStr($major_id){
$frag = '';
$major_info = $this->major_obj->where('major_id',$major_id)->find();
if($major_info==null){
return '';
}
if($major_info['major_level']==1){
return '';
}else{
$frag = $this->getMajorStr($major_info['pid']).' > '.$major_info['major_title'];
}
return $frag;
}
/**
* 作者同意转投
*/
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'],'author_act'=>1,'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.';
$sendUser=[
'title'=> $journal_info['title'], // 邮件标题
'content'=>$tt1,//邮件内容
'user_id'=>$journal_info['editor_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',$sendUser,'domail');
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]);
}
/**
* @title 作者拒绝转投
* @description 作者拒绝转投
* @author wangjinlei
* @url /api/Article/trans_manu_no
* @method POST
*
* @param name:transfer_id type:int require:1 desc:转投id
*
*/
public function trans_manu_no(){
$data = $this->request->post();
//跟新转投表状态
$this->article_transfer_obj->where('transfer_id',$data['transfer_id'])->update(['state'=>1]);
//提醒编辑作者拒绝了转投,email
return jsonSuccess([]);
}
/**
* 修改文章详情(作者)
*/
public function editArticle() {
//接受参数查询信息
$data = $this->request->post();
$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();
$journal_info = $this->journal_obj->where("journal_id",$article_info["journal_id"])->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';
// $sendUser=[
// 'title'=> $journal_info['title'], // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$user_res['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',$sendUser,'domail');
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($journal_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]);
}
}
/**
* @title 修回文章
* @description 修回文章
* @author wangjinlei
* @url /api/Article/RepairBack
* @method POST
*
* @param name:username type:string require:1 desc:作者账号名
* @param name:articleId type:int require:1 desc:文章id
* @param name:picturesAndTables type:string require:1 desc:Figures
* @param name:manuscirpt type:string require:1 desc:文章文件
*
*/
public function RepairBack(){
$data = $this->request->post();
$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['author_act'] = 1;
$inset_data['state'] = 1;
$where['article_id'] = $data['articleId'];
$up_res = $this->article_obj->where($where)->update($inset_data);
$article_info = $this->article_obj->where($where)->find();
$journal_info = $this->journal_obj->where("journal_id",$article_info["journal_id"])->find();
//增加article_msg
$insmsg_data['article_id'] = $data['articleId'];
$insmsg_data['content'] = '';
$insmsg_data['state_from'] = $article_old_info['state'];
$insmsg_data['state_to'] = 1;
$insmsg_data['ctime'] = time();
$msg_res = $this->article_msg_obj->insert($insmsg_data);
//发送邮件
$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';
// $sendUser=[
// 'title'=> $journal_info['title'], // 邮件标题
// 'content'=>$tt,//邮件内容
// 'user_id'=>$user_res['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',$sendUser,'domail');
$res2 = 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');
//增加用户操作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($journal_info['editor_id'], 'The manuscript has new process: ' . $article_info['title'], '/articleDetailEditor?id=' . $article_info['article_id']);
if($msg_res&&$res2&&$res3&&$log_res&&$umsg_res){
Db::commit();
return json(['code' => 0]);
}else{
Db::rollback();
return jsonError("system error!");
}
}
/**
* @title 发送留言板消息
* @description 发送留言板消息
* @author wangjinlei
* @url /api/Article/pushArticleDialog
* @method POST
*
* @param name:article_id type:int require:1 desc:文章id
* @param name:username type:String require:1 desc:发送者用户名
* @param name:ad_content type:String require:1 desc:内容
*
*/
public function pushArticleDialog(){
$data = $this->request->post();
$user_info = $this->user_obj->where('account',$data['username'])->find();
$insert['article_id'] = $data['article_id'];
$insert['user_id'] = $user_info['user_id'];
$insert['ad_content'] = trim($data['ad_content']);
$insert['ad_ctime'] = time();
$this->article_dialog_obj->insert($insert);
//留言红点提示并邮件
$this->messageTips($data['article_id'],$user_info['user_id']);
return jsonSuccess([]);
}
/**
* @title 获取留言板消息列表
* @description 获取留言板消息列表
* @author wangjinlei
* @url /api/Article/getArticleDialogs
* @method POST
*
* @param name:article_id type:int require:1 desc:文章id
*
* @return dialogs:消息列表@
* @dialogs ad_id:主键 article_id:文章id user_id:用户id username:用户名 ad_content:消息 ad_time:时间 ad_state:状态
*
*/
public function getArticleDialogs(){
$data = $this->request->post();
$list = $this->article_dialog_obj
->field("t_article_dialog.*,t_user.account username")
->join("t_user","t_user.user_id = t_article_dialog.user_id","left")
->where("t_article_dialog.article_id",$data['article_id'])
->where('t_article_dialog.ad_state',0)
->select();
$re['dialogs'] = $list;
return jsonSuccess($re);
}
/**
* @title 添加修回页修回意见(编辑)
* @description 添加修回页修回意见(编辑)
* @author wangjinlei
* @url /api/Article/addArticleProposal
* @method POST
*
* @param name:article_id type:int require:1 desc:文章id
* @param name:proposal_file type:String require:1 desc:文件地址
*
*/
public function addArticleProposal(){
$data = $this->request->post();
$insert['article_id'] = $data['article_id'];
$insert['proposal_file'] = trim($data['proposal_file']);
$insert['ap_ctime'] = time();
$this->article_proposal_obj->insert($insert);
return jsonSuccess([]);
}
/**
* @title 获取修回页修回意见列表
* @description 获取修回页修回意见列表
* @author wangjinlei
* @url /api/Article/getArticleProposals
* @method POST
*
* @param name:article_id type:int require:1 desc:文章id
*
* @return proposals:意见列表@
* @proposals proposal_id:主键 proposal_file:文件地址 ap_ctime:添加时间
*/
public function getArticleProposals(){
$data = $this->request->post();
$list = $this->article_proposal_obj->where('article_id',$data['article_id'])->where('ap_state',0)->select();
$re['proposals'] = $list;
return jsonSuccess($re);
}
/**
* 修改文章的作者(作者)
*/
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]);
//发送邮件通知编辑
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_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.';
$sendUser=[
'title'=> $journal_info['title'], // 邮件标题
'content'=>$tt,//邮件内容
'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',$sendUser,'domail');
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
//添加usermsg
add_usermsg($journal_info['editor_id'], 'Manuscript authors be changed,please contact the author to confirm.', 'articleDetailEditor?id='.$data['articleId']);
return json(['code' => 0]);
}
/**
* @title 修改文章状态(编辑)
* @description 修改文章状态(编辑)
* @author wangjinlei
* @url /api/Article/editArticleEditor
* @method POST
*
* @param name:editname type:String require:1 desc:编辑名字
* @param name:articleId type:int require:1 desc:文章id
* @param name:state type:int require:1 desc:状态代码
* @param name:editormsg type:String require:1 desc:携带的消息(以后会废除)
* @param name:trsjournal type:int require:0 desc:转投期刊id(拒稿时候是必传不推荐转投的为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();
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id",$user_info['user_id'])->find();
// 发送邮件内容
$sendUser=[
'title'=> $journal_info['title'], // 邮件标题
'user_id'=>$user_info['user_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']
];
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'],'author_act'=>1,'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);
$user_rev_info = $this->user_reviewer_info_obj->where("reviewer_id",$user_info['user_id'])->find();
//发送邮件提醒转投给作者
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br>';
$tt .= 'Dear Dr. '.($user_info['realname']==''?$user_info['account']:$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. You munuscript will transfer to journal - '.$tran_journal['title'].' as you co-submitting chose order.If you have questions about the Co-submission process, please contact publisher@tmrjournals.com within 48 hours.<br><br>Yours sincerely,<br>';
$tt .= 'Editorial Office<br>';
$tt .= $journal_info['title'].'<br>';
$tt .= '<a href="https://www.tmrjournals.com/draw_up.html?issn='.$journal_info['issn'].'">Subscribe to this journal</a><br>';
$tt .= 'Email: '.$journal_info['email'].'<br>';
$tt .= 'Website: '.$tran_journal['website'];
$sendUser['user_id'] = $user_info['user_id'];
$sendUser['email'] = $user_info['email'];
$sendUser['content'] = $tt;
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
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']);
// $sendUser['user_id'] = $trans_editor_info['user_id'];
// $sendUser['email'] = $trans_editor_info['email'];
// $sendUser['content'] = 'Dear editor,Please check the new transfer manuscript in the submission system.';
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
//增加usermsg
add_usermsg($tran_journal['editor_id'], 'New transfer manuscript ', '/articleDetailEditor?id=' . $article_info['article_id']);
return json(['code'=>0]);
}else{
//接收文章必须有两个及以上的大于40个字的对作者的评论,除去news和comment类型的文章
if($data['state']==5&&$article_info['type']!="N"&&$article_info['type']!="T"&&$article_info['type']!="LTE"&&$article_info['journal_id']!=21){
//定义符合条件的数量
$rev_real_num = 0;
//获取通过的审稿意见数
$rev_list = $this->article_reviewer_obj
->field('t_article_reviewer_question.*')
->join("t_article_reviewer_question",'t_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id','left')
->where('t_article_reviewer.article_id',$article_info['article_id'])
->where('t_article_reviewer.state','in',[1,3])
->select();
foreach ($rev_list as $v){
$content = $v['qu9_contents']." ".$v['qu10_contents']." ".$v['qu11_contents']." ".$v['qu12_contents']." ".$v['qu13_contents']." ".$v['qu14_contents']." ".$v['qu15_contents']." ".$v['comments'];
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $content)>0){//含有中文
if(mb_strlen($content, 'UTF8')>=60){
$rev_real_num++;
}
}else{//不含中文
$carray = explode(" ", $content);
if(count($carray)>=40){
$rev_real_num++;
}
}
}
if($rev_real_num<2){
return json(['code'=>1,'msg'=>"More than two available reviewer-comments are necessary before going next step."]);
}
}
//添加文章状态信息(如果状态未更新可做通话用,并结束操作)
$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;
//更新文章状态
if($data['state']==4){
$update_data['ttime'] = time();
}
if($data['state']==3){
$update_data['rstime'] = time();
}
$this->article_obj->where($where_article)->update($update_data);
//拒稿或者录用 - 发送审稿意见
if( $article_info['journal_id'] == 1 && ($data['state'] == 3 || $data['state'] == 5) ){
$this->sendEmailToReviewer($data['articleId'],$data['state']);
}
}
//发送文章状态更改邮件
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 Dr. '.($user_info['realname']==''?$user_info['account']:$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 = 'Dear Dr. '.($user_info['realname']==""?$user_info['account']:$user_info['realname']).'<br><br>';
$tt .= 'Thank you very much for submitting your manuscript "'.$article_info['title'].'" ('.$article_info['accept_sn'].'). We had read your paper discussed it with our editorial team. Unfortunately, our opinion is that the paper would not be a strong candidate for '.$journal_info['title'].'. When a paper is turned down on editorial grounds, we aim to return it to the authors as quickly as possible, avoiding a time-consuming peer-review process.<br><br>';
$tt .= 'Nevertheless, thank you for giving us the opportunity to consider your work. I am sorry that we cannot be more positive on this occasion and hope you are soon able to find an alternative journal. Although we cannot offer to publish your paper in '.$journal_info['title'].', the work may be appropriate for another journal in the TMR Publishing Group. <br><br>';
$tt .= 'I have asked the editor of '.$trans_journal['title'].' ('.$trans_journal['website'].'), and there is a good chance that your manuscript will be published there. If you wish to transfer your manuscript to a journal of your choice, please click on the agree button in the <a href="https://submission.tmrjournals.com">Submission System</a>, you will not have to re-supply manuscript metadata and files.<br><br><br><br>';
$tt .= 'Yours Sincerely,<br>';
$tt .= $journal_info['title'].' | Editorial Office<br>';
$tt .= 'Email: '.$journal_info['email'].'<br>';
$tt .= 'Website:<a href="'.$journal_info['website'].'">'.$journal_info['website'].'</a>';
}
}else if($data['state']==5){//录用
//录用后更新录用时间
$this->article_obj->where('article_id',$article_info['article_id'])->update(['rtime'=> time()]);
$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 Dr. '.($user_info['realname']==''?$user_info['account']:$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 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 Dr. '.($user_info['realname']==''?$user_info['account']:$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 if($data['state']==6){//终审
$tt = 'Dear Dr. '.($user_info['realname']==''?$user_info['account']:$user_info['realname']).'<br>';
$tt .= 'Manuscript status: Your manuscript "'.$article_info['title'].'" is under reviewing by editorial member team of '.$journal_info['title'].'.';
}else{
$tt = '"'.$article_info['title'].'"<br>';
$tt .= $article_info['accept_sn'].'<br>';
$tt .= 'journal:'.$journal_info['title'].'<br><br>';
$tt .= 'Dear Dr. '.($user_info['realname']==''?$user_info['account']:$user_info['realname']).',<br>Please check the new status of your manuscript online.<br><br>';
}
$tt .= $journal_info['title'].'<br>';
$tt .= '<a href="https://www.tmrjournals.com/draw_up.html?issn='.$journal_info['issn'].'">Subscribe to this journal</a><br>';
$tt .= 'Email: '.$journal_info['email'].'<br>';
$tt .= 'Website: '.$journal_info['website'];
if($data['state']!=5||$journal_info['journal_id']!=9){
$sendUser['content'] = $tt;
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($user_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
}
if($data['state']==6){//进入终审,通知主编邮件
$chiefs = $this->chief_to_journal_obj->join('t_user','t_user.user_id = t_chief_to_journal.user_id','left')->where('t_chief_to_journal.journal_id',$journal_info['journal_id'])->where('t_chief_to_journal.state',0)->select();
foreach ($chiefs as $v){
$tts = 'Dear Dr. '.($v['realname']==''?$v['account']:$v['realname']).',<br><br>';
$tts .= 'The manuscript entitled “'.$article_info['title'].'” has been peer-reviewed, revised and about to be published in '.$journal_info['title'].'.<br><br>';
$tts .= 'If you want to review this article, you could use it Submission System (<a href="https://submission.tmrjournals.com">Plese click here</a>).<br>';
$tts .= 'Your username: '.$v['account'].'<br>';
$tts .= 'Password: 123456qwe (Original password)<br><br>';
$tts .= 'If you are unable to review it now, you may provide your comments at a later time at your convenience. Then ,there is no need to reply to this email.<br><br>';
$tts .= 'Any comments you make will be valued by the editorial board. Please bring into our knowledge if there is any potential Conflict of Interest.<br><br><br><br>';
$tts .= 'Sincerely,<br>Editorial Office<br>'.$journal_info['title'].'<br>';
$tts .= 'Email: '.$journal_info['email'].'<br>';
$tts .= 'Website:<a href="'.$journal_info['website'].'">'.$journal_info['website'].'</a>';
$sendUser['user_id'] = $v['user_id'];
$sendUser['email'] = $v['email'];
$sendUser['content'] = $tts;
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tts, $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 emailtest(){
$v = $this->user_obj->where('user_id',54)->find();
$journal_info = $this->journal_obj->where('journal_id',9)->find();
$trans_journal = $this->journal_obj->where('journal_id',5)->find();
$article_info = $this->article_obj->where('article_id',1058)->find();
$tts = 'Dear Dr. '.($v['realname']==''?$v['account']:$v['realname']).',<br><br>';
$tts .= 'The manuscript entitled “'.$article_info['title'].'” has been peer-reviewed, revised and about to be published in '.$journal_info['title'].'.<br><br>';
$tts .= 'If you want to review this article, you could use it Submission System (<a href="https://submission.tmrjournals.com">Plese click here</a>).<br>';
$tts .= 'Your username: '.$v['account'].'<br>';
$tts .= 'Password: 123456qwe (Original password)<br><br>';
$tts .= 'If you are unable to review it now, you may provide your comments at a later time at your convenience. Then ,there is no need to reply to this email.<br><br>';
$tts .= 'Any comments you make will be valued by the editorial board. Please bring into our knowledge if there is any potential Conflict of Interest.<br><br><br><br>';
$tts .= 'Sincerely,<br>Editorial Office<br>'.$journal_info['title'].'<br>';
$tts .= 'Email: '.$journal_info['email'].'<br>';
$tts .= 'Website:<a href="'.$journal_info['website'].'">'.$journal_info['website'].'</a>';
$sendReviewer=[
'title'=>'Your contribution is greatly appreciated', // 邮件标题
'content'=>$tts,//邮件内容
'user_id'=>$v['user_id'], //收件人ID
'email'=>$v['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($v['email'], $journal_info['title'], $journal_info['title'], $tts, $journal_info['email'], $journal_info['epassword']);
}
private function creatLoginUrlForChief($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/man_text?Art_id='.$article_id.'&act='.$code;
return $url;
}
public 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;
}
public function creatRejectUrlForReviewer($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_fail?Art_id='.$article_id.'&act='.$code;
return $url;
}
/**
* @title 获取期刊by领域
* @description 获取期刊by领域
* @author wangjinlei
* @url /api/Article/getJournalsByMajor
* @method POST
*
* @param name:major_id type:int require:1 desc:领域id
*
* @return journals:期刊列表#
*/
public function getJournalsByMajor(){
$data = $this->request->post();
// $data['major_id'] = 60;
$list = $this->major_to_journal_obj
->field("t_journal.*")
->join("t_journal","t_journal.issn = t_major_to_journal.journal_issn","left")
->where("t_major_to_journal.major_id",$data['major_id'])
->where('t_major_to_journal.mtj_state',0)
->select();
$re['journals'] = $list;
return jsonSuccess($re);
}
/**
* 编辑文章备注
*/
public function editArticleRemark(){
//接受参数
$data = $this->request->post();
$this->article_obj->where('article_id',$data['articleId'])->update(['remarks'=>$data['content']]);
return json(['code'=>0]);
}
/**
* @title 更改重复率(编辑)
* @description 更改重复率(编辑)
* @author wangjinlei
* @url /api/Article/changeRepetition
* @method POST
*
* @param name:articleId type:int require:1 desc:文章id
* @param name:repefen type:string require:1 desc:重复数字
* @param name:zipurl type:string require:1 desc:查重文件地址
*
*/
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();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$editor_info = $this->user_obj->where(['user_id' => $journal_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();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$reviewer_info = $this->user_obj->where('user_id', $data['uid'])->find();
$reviewer_move = $this->user_reviewer_info_obj->where("reviewer_info_id",$reviewer_info['user_id'])->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();
$insert_data['state'] = 5;
$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 Dr. '.($reviewer_info['realname']==""?$reviewer_info['account']:$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="'.$this->creatLoginUrlForreviewer($reviewer_info,$res).'">Click here to review the article</a><br>';
// $tt .= '<a href="https://submission.tmrjournals.com/">Click here to review the article</a><br>';
$tt .= '<a href="'.$this->creatRejectUrlForReviewer($reviewer_info, $res).'">Click on the link to reject the review of this manuscript</a><br>';
$tt .= 'Your username:'.$reviewer_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'];
$sendUser=[
'title'=> $journal_info['title'], // 邮件标题
'content'=>$tt,//邮件内容
'user_id'=>$reviewer_info['user_id'], //收件人ID
'email'=>$reviewer_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',$sendUser,'domail');
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 addArtRev(){
$data = $this->request->post();
//增加信息到文章审稿表
$insert['reviewer_id'] = $data['uid'];
$insert['article_id'] = $data['articleId'];
$insert['ctime'] = time();
$insert['state'] = 3;
$art_rev_id = $this->article_reviewer_obj->insertGetId($insert);
//添加问卷信息
$insert_data['art_rev_id'] = $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'];
$insert_data['ctime'] = time();
$res = $this->article_reviewer_question_obj->insert($insert_data);
$re['code'] = 0;
return json($re);
}
/**
* @title 添加文章(投稿)
* @description 添加文章(投稿)
* @author wangjinlei
* @url /api/Article/addArticle
* @method POST
*
* @param name:username type:string require:1 desc:用户名
* @param name:journal type:int require:1 desc:期刊id
* @param name:title type:int require:1 desc:标题
* @param name:keyWords type:String require:1 desc:关键字
* @param name:fund type:string require:0 desc:fund
* @param name:type type:String require:1 desc:类型缩写
* @param name:major type:int require:1 desc:领域id
* @param name:approval type:string require:1 desc:true/false
* @param name:abstrart type:string require:1 desc:简介
* @param name:authorList type:array require:1 desc:作者
*
* @return articles:文章列表#
* @return count:总数#
*/
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();
//确定用户是否属于黑名单
$black_check = $this->user_black_obj->where('user_id', $user_res['user_id'])->where('black_state', 0)->find();
if ($black_check) {
return jsonError("Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.");
}
// if($user_res['account']=='fariba'||$user_res['account']=='zc'||$user_res['account']=='Mohammad Hossein'||$user_res['account']=='xiaoyueyue'||$user_res['account']=='sethlee000'||$user_res['account']=='yuanying9908'){
// return json(['code'=>1,'msg'=>'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
// }
$journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find();
//首先查重是否重复投稿
$checkArticle = $this->article_obj->where("title",trim($data['title']))->select();
foreach ($checkArticle as $v){
if($v['state']!=3){
return json(['code'=>1,'msg'=>'Warning: you are re-submitting the article!']);
}
}
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'] = trim($data['title']);
$inset_data['keywords'] = $data['keyWords'];
$inset_data['fund'] = trim($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'] = trim($v['firstname']);
$i['lastname'] = trim($v['lastname']);
$i['orcid'] = trim($v['orcid']);
$i['company'] = trim($v['company']);
$i['department'] = trim($v['department']);
$i['author_title'] = $v['title'];
$i['country'] = $v['country'];
$i['email'] = trim($v['email']);
$i['address'] = trim($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']);
$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']).',<br><br>';
$tt1 .= 'Thank you for submitting your manuscript entitled "'.$data['title'].'". Your submission has been assigned the following tracking number:'.$inset_data['accept_sn'].'. We will be in touch again as soon as we have reached a decision. Please quote the tracking number in any communication. This e-mail simply acknowledges receipt of your submission. If the editors decide for editorial reasons that the paper is unsuitable for publication in '.$journal_info['title'].', you will be informed as soon as possible.<br><br><br>';
if($journal_info['journal_id']==9){//life research 期刊发送收到文章邮件
$tt1 .= 'Life Research applies the CC BY-NC 4.0 license. Full details of the policy can be found at https://www.tmrjournals.com/notice.html?J_num=14&footer_id=123. Authors should read Guide to Authors carefully before submitting.<br><br>';
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact liferes@tmrjournals.com.<br><br>';
$tt1 .= 'Thank you for choosing to submit your manuscript to Life Research.<br><br><br>';
$tt1 .= 'Yours sincerely,<br>Haoran Zhang<br><br>';
$tt1 .= 'Manuscript Administration, Life Research<br>https://www.tmrjournals.com/lr/';
}else{//其他期刊发送邮件
$tt1 .= 'You may check on the status of this manuscript in the Submission System. If you encounter any problems, please contact '.$journal_info['email'].'.<br><br>';
$tt1 .= 'Thank you for choosing to submit your manuscript to '.$journal_info['title'].'.<br><br><br>';
$tt1 .= 'Sincerely,<br>Editorial Office<br>';
$tt1 .= '<a href="https://www.tmrjournals.com/draw_up.html?issn='.$journal_info['issn'].'">Subscribe to this journal</a><br>';
$tt1 .= $journal_info['title'].'<br>';
$tt1 .= 'Email: '.$journal_info['email'].'<br>';
$tt1 .= 'Website: '.$journal_info['website'];
}
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;
$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);
//通讯作者转为审稿人
$this->addReviewerFromArticle($res, $journal_info['journal_id']);
//推荐审稿人
$recommend_res = true;
foreach($data['reviewers'] as $v){
$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 && $recommend_res) {
Db::commit();
return json(['code' => 0]);
} else {
Db::rollback();
return json(['code' => 1]);
}
}
/**
* 添加推荐审稿人
*/
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 获取待审文章
* @description 获取待审文章
* @author wangjinlei
* @url /api/Article/getReviewerArticles
* @method POST
*
*
* @return articles:待审稿件#
*/
public function getReviewerArticles(){
$list = $this->article_obj
->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.state',2)->where("CHAR_LENGTH(t_article.title)=LENGTH(t_article.title)")->limit(3)->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
/**
* @title 获取待审文章
* @description 获取待审文章
* @author wangjinlei
* @url /api/Article/getReviewerArticlesForJournal
* @method POST
*
* @param name:issn type:string require:1 desc:issn
*
* @return articles:待审稿件#
*/
public function getReviewerArticlesForJournal(){
$data = $this->request->post();
$journal_info = $this->journal_obj->where('issn',$data['issn'])->find();
$list = $this->article_obj
->field('t_article.*,t_journal.title journalname')
->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT')
->where('t_article.state',2)->where('t_article.journal_id',$journal_info['journal_id'])
->where("(t_journal.journal_id = 21) or (length(t_article.title) = CHARACTER_LENGTH(t_article.title))")
->limit(3)->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
// public function cfreviewer(){
// $list = $this->article_author_obj->where("is_report",1)->select();
// foreach ($list as $v){
// $ar = $this->article_obj->where("article_id",$v['article_id'])->find();
// if(!$ar){
// continue;
// }
// $this->addReviewerFromReportAuthor($v['art_aut_id'], $ar['journal_id']);
// }
// echo 'ok';
// }
private function addReviewerFromArticle($article_id,$journal_id){
$list = $this->article_author_obj->where('article_id',$article_id)->where('is_report',1)->where('state',0)->select();
foreach ($list as $v){
$this->addReviewerFromReportAuthor($v['art_aut_id'], $journal_id);
}
}
/**
* 添加审稿人来自通讯作者
*/
private function addReviewerFromReportAuthor($art_aut_id,$journal_id){
$journal_info = $this->journal_obj->where('journal_id',$journal_id)->find();
//判断通讯作者信息是否合规
$author_info = $this->article_author_obj->where('art_aut_id',$art_aut_id)->find();
if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$author_info['email'])){
return ;
}
$check = $this->reviewer_from_author_obj->where('art_aut_id',$art_aut_id)->where('journal_id',$journal_id)->find();
if($check){
return ;
}
//判断目前的状态进行下一步流程
$user_info = $this->user_obj->where('email',$author_info['email'])->where('state',0)->find();
if($user_info==null){//不存在用户
//添加用户,发送邮件
$user_insert['account'] = $author_info['email'];
$user_insert['password'] = md5("123456qwe");
$user_insert['email'] = $author_info['email'];
$user_insert['realname'] = $author_info['firstname']." ".$author_info['lastname'];
$user_insert['ctime'] = time();
$add_user_id = $this->user_obj->insertGetId($user_insert);
//发送邮件
$tt = 'Dear Dr. '.$user_insert['realname'].'<br><br>';
$tt .= 'Thank you for submitting your paper to '.$journal_info['title'].' as the corresponding author.<br>';
$tt .= 'In order to provide a better online experience for authors, we have set up your account in our submission system.<br><br>';
$tt .= 'You could log in with your account in https://submission.tmrjournals.com/login <br>';
$tt .= 'Your username:'.$author_info['email'].'<br>';
$tt .= 'Your password:123456qwe (you could change your password in the system by yourself later.)<br><br>';
$tt .= 'Thank you so much for your kindly support.<br><br>';
$tt .= 'Sincerely,<br>Editorial Office<br>'.$journal_info['title'].'<br>';
$tt .= 'Email: '.$journal_info['email'].'<br>';
$tt .= 'Website:<a href="'.$journal_info['website'].'">'.$journal_info['website'].'</a>';
sendEmail($author_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
$sendUser=[
'title'=>$journal_info['title'], // 邮件标题
'content'=>$tt,//邮件内容
'user_id'=>$add_user_id, //收件人ID
'email'=>$author_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',$sendUser,'domail');
//添加转换表数据
$art_insert['art_aut_id'] = $art_aut_id;
$art_insert['journal_id'] = $journal_id;
$art_insert['rfa_ctime'] = time();
$this->reviewer_from_author_obj->insert($art_insert);
return ;
}
$reviewer_check = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
$reviewer_this_check = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('journal_id',$journal_id)->where('state',0)->find();
if($reviewer_check == null){//存在用户但不是审稿人
//添加转换表数据
$art_insert['art_aut_id'] = $art_aut_id;
$art_insert['journal_id'] = $journal_id;
$art_insert['rfa_ctime'] = time();
$this->reviewer_from_author_obj->insert($art_insert);
return ;
}else{
if($reviewer_this_check==null){
//直接添加审稿人
$reviewer_insert['reviewer_id'] = $user_info['user_id'];
$reviewer_insert['journal_id'] = $journal_id;
$reviewer_insert['account'] = $author_info['email'];
$reviewer_insert['journal_title'] = $journal_info['title'];
$reviewer_insert['ctime'] = time();
$this->reviewer_to_journal_obj->insert($reviewer_insert);
return ;
}else{
return ;
}
}
}
/**
* 作者发送消息
*/
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()]);
}
}
}
/**
* @title 上传编辑修回意见文件
* @description 上传编辑修回意见文件
* @author wangjinlei
* @url /api/Article/up_proposal_file
* @method POST
*
* @param name:name type:string require:1 default:articleProposal desc:文件域名称
*
* @return upurl:图片地址
*/
public function up_proposal_file() {
$file = request()->file('articleProposal');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleProposal');
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) * $data['pageSize'];
$where['t_article_reviewer.article_id'] = $data['articleId'];
$res = $this->article_reviewer_obj
->field('t_article_reviewer.*,t_user.email,t_user.realname,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'])->where('state',0)->column('reviewer_id');
$noids = $this->article_reviewer_obj->where('article_id', $data['articleId'])->column('reviewer_id');
$res = $this->reviewer_to_journal_obj
->field('t_user.user_id,t_user.account')
->join('t_user','t_user.user_id = t_reviewer_to_journal.reviewer_id','left')
->join('t_user_reviewer_info', 't_user.user_id = t_user_reviewer_info.reviewer_id', 'LEFT')
->where('t_reviewer_to_journal.journal_id',$article_info['journal_id'])
->where('t_user.user_id','not in',$noids)
->where('t_user.state',0)
->select();
// if ($noids != null) {
// $where['t_user.user_id'] = [['in', $revids], ['not in', $noids]];
// } else {
// $where['t_user.user_id'] = ['in', $revids];
// }
// $where['t_user.state'] = 0;
// $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();
//
// echo $this->user_obj->getLastSql();
// die;
if ($res) {
return json(['code' => 0, 'data' => $res]);
} else {
return json(['code' => 1]);
}
}
/**
* 获取文章数通过期刊issn号
*/
public function getArticleForJournal(){
$data = $this->request->post();
$journal_info = $this->journal_obj->where('issn',$data['issn'])->find();
$list = $this->article_obj
->where('journal_id',$journal_info['journal_id'])
->where('state','in','0,1,2,4')
// ->where('ctime','>',$data['ctime'])
->select();
$re['articles'] = $list;
return jsonSuccess($re);
}
/**
* 存储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;
}else if($type_name=='totalpage' && $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
*/
public 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);
}
// 给审稿人发送邮件- 稿件的基本情况
public function sendEmailToReviewer($articleId,$state){
//articleId = 1037;
//$state = 3;
$resState = $state==3?"Reject":"Accept";
$allArticleReviewer = $this->article_reviewer_obj->field('t_user.email,t_user.realname,t_article_reviewer.reviewer_id,t_article_reviewer_question.recommend,t_article_reviewer_question.comments')
->join('t_article_reviewer_question','t_article_reviewer_question.art_rev_id = t_article_reviewer.art_rev_id','LEFT')
->join('t_user','t_user.user_id = t_article_reviewer.reviewer_id','LEFT')
->where('t_article_reviewer.article_id',$articleId)
->where('t_article_reviewer.state','in',[1,2,3])
->select();
// 根据文章ID查询journal_id
$journalInfo = $this->article_obj->field('t_journal.journal_id,t_journal.title,t_journal.email,t_journal.epassword')
->join('t_journal','t_journal.journal_id = t_article.journal_id','LEFT')
->where('t_article.article_id',$articleId)
->find();
// 文章信息
$articleInfo = $this->article_obj->where('article_id',$articleId)->find();
$pushData=[
'title'=>$journalInfo['title'], // 邮件标题
'journal_id'=>$journalInfo['journal_id'], // 期刊ID
'sendEmail'=>$journalInfo['email'], // 期刊邮箱
'sendPassword'=>$journalInfo['epassword'], // 期刊密码
'from_name'=>$journalInfo['title']
];
$difference = "Please check the final decision of the manuscript you reviewed.<br><br>Dear Reviewer,<br>";
$difference .= "The final decision of the manuscript ".'"' . $articleInfo['accept_sn']. '"' ." is ".'"'.$resState. '"' .".<br><br>";
$difference .= "We sincerely appreciate the time you spent reading and commenting on manuscripts, and we are very grateful for your willingness to serve in this role. Although final decisions are always editorial,the reviewers bring to our deliberations scientific insights, and passion.<br><br> ";
$difference .="We note that the final decision is contrary to your decision. <br> You deserve to know all peer review decisions and comments following as peer reviewer:<br>";
$recommend=[
1=>'Accept with minor changes',
2=>'Accept subject to revisions, as noted in comments',
3=>'Reject in current form, but may be resubmitted',
4=>'Reject, with no resubmission',
];
$all = "Please check the final decision of the manuscript you reviewed.<br><br>Dear Reviewer,<br>";
$all .= "The final decision of the manuscript ".'"' . $articleInfo['accept_sn']. '"' ." is ".'"'.$resState. '"' .".<br><br>";
$all .= "We sincerely appreciate the time you spent reading and commenting on manuscripts, and we are very grateful for your willingness to serve in this role. Although final decisions are always editorial,the reviewers bring to our deliberations scientific insights, and passion.<br><br> ";
$all .= "Please let us know your feedback at publisher@tmrjournals.com.";
foreach ($allArticleReviewer as $k => $value){
// 最终意见发给全部审稿人
$pushData['content'] = $all;
$pushData['user_id'] = $value['reviewer_id'];
$pushData['email'] =$value['email'];
Queue::push('app\api\job\domail@fire',$pushData,'domail');
$num = $value['recommend'];
if($value['comments']!=''){
$difference.= "<br>Reviewer ". ($k+1).' : '.$recommend[$num] ." ( ".preg_replace("/\t/","",$value['comments'])." )<br>";
}else{
$difference.= "<br>Reviewer ". ($k+1).' : '.$recommend[$num] ."<br>";
}
}
$difference .= "<br><br>Please let us know your feedback at publisher@tmrjournals.com.";
// 分歧稿件
foreach ($allArticleReviewer as $k => $value){
$pushData['content'] = $difference;
$pushData['user_id'] = $value['reviewer_id'];
$pushData['email'] =$value['email'];
if($state == 3 && ($value['recommend'] == 1 || $value['recommend'] == 2)){
Queue::push('app\api\job\domail@fire',$pushData,'domail');
}
if($state == 5 && ($value['recommend'] == 3 || $value['recommend'] == 4)){
Queue::push('app\api\job\domail@fire',$pushData,'domail');
}
}
}
/**
* 留言板留言文章显示红点并发送邮件
* @param $article_id
* @param $user_id
*/
private function messageTips($article_id,$user_id){
$article = $this->article_obj->field('t_article.user_id,t_article.editor_id,t_article.accept_sn,t_journal.journal_id,t_journal.title,t_journal.email,t_journal.epassword')
->join('t_journal','t_journal.journal_id = t_article.journal_id','LEFT')
->where('t_article.article_id',$article_id)
->find();
// 判断提交留言人的身份
$res = $this->user_obj->where('user_id',$user_id)->find();
if($res['type'] == 1 ){ // 作者 - 修改author_act,并发送给编辑发邮件
$this->article_obj->where('article_id',$article_id)->update(['author_act'=>1]);
$editor = $this->user_obj->where('user_id',$article['editor_id'])->find();
// 发邮件
$content = 'Dear editor,<br>please check the new feedback.';
sendEmail($editor['email'],$article['title'],$article['title'],$content,$article['email'],$article['epassword']);
}
if($res['type'] == 2 ){ //编辑 - 修改editor_act,并发送给作者发邮件
$this->article_obj->where('article_id',$article_id)->update(['editor_act'=>1]);
$author = $this->user_obj->where('user_id',$article['user_id'])->find();
// 发邮件
$content='Dear '.$res['realname'].',<br>';
$content.='Thank you for contacting our editor. <br>ID: '.$article['accept_sn'].'.<br><br>';
$content.= ' Your manuscript: '.$article['accept_sn'].' has received a new reply; please login https://submission.tmrjournals.com/login to check. <br>';
$content.= 'Sincerely,<br>'.$article['title'];
sendEmail($author['email'],$article['title'],$article['title'],$content,$article['email'],$article['epassword']);
}
}
}