This commit is contained in:
wangjinlei
2021-01-20 17:16:12 +08:00
parent e8251d4489
commit b752036855
3 changed files with 247 additions and 2 deletions

View File

@@ -54,7 +54,7 @@ class Auto extends Controller {
public function testrev(){
$a = $this->article_obj->where('article_id',261)->find();
$this->checkrev($a);
// $this->checkrev($a);
}
/**
@@ -91,6 +91,7 @@ class Auto extends Controller {
* 审查文章审稿人状态,返回结果
*/
public function checkrev($data) {
die;
//查找审稿案例状态
$rev_list = $this->reviewer_obj->where('article_id', $data['article_id'])->where('state','<>',4)->select();
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();

View File

@@ -0,0 +1,244 @@
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
class Special extends Controller {
protected $user_obj = '';
protected $captcha_obj = '';
protected $user_act_obj = '';
protected $admin_obj = '';
protected $article_obj = '';
protected $user_reviewer_obj = '';
protected $journal_obj = '';
protected $reviewer_major_obj = '';
protected $reviewer_to_journal_obj = '';
protected $user_reviewer_info_obj = '';
protected $user_msg_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->user_obj = Db::name('user');
$this->captcha_obj = Db::name('captcha');
$this->user_act_obj = Db::name('user_act');
$this->admin_obj = Db::name('admin');
$this->article_obj = Db::name('article');
$this->user_reviewer_obj = Db::name('user_reviewer_apply');
$this->journal_obj = Db::name('journal');
$this->reviewer_major_obj = Db::name('reviewer_major');
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
$this->user_reviewer_info_obj = Db::name('user_reviewer_info');
$this->user_msg_obj = Db::name('user_msg');
}
/**
* 注册功能
*/
public function register() {
$data = $this->request->post();
// $data['username'] = '123';
// $data['password'] = '123123';
// $data['realname'] = '123';
// $data['phone'] = '12312312312';
// $data['email'] = '123@123.com';
//
//检测是否用户名和密码已经占用
$account = $data['username'];
$email = $data['email'];
$res_once = $this->user_obj->where("account='$account' or email = '$email'")->find();
if ($res_once != null) {
return json('existence');
}
//验证验证码
// if (!$this->my_checkcaptcha($data['code'], $data['random_num'])) {
// return json('errcaptcha');
// }
//存入数据
$inser_data['account'] = trim($account);
$inser_data['password'] = md5($data['password']);
$inser_data['email'] = $email;
$inser_data['phone'] = $data['phone'];
$inser_data['realname'] = $data['realname'];
$inser_data['ctime'] = time();
$this->user_obj->insert($inser_data);
//发送注册成功邮件
$tt = "Dear author,You have successfully registered<br><br>";
$content = $tt . '<p>Username:' . $account . '<br>Password:' . $data['password'] . '</p>';
sendEmail($email, 'Dear ' . $data['realname'], 'TMR', $content,);
return json($inser_data);
}
/**
* 登录功能
* @return type
*/
public function checkLogin() {
$data = $this->request->post();
//判断是否管理员登录
if ($data['username'] == 'superadmin'||$data['username'] == 'wuxiongzhi2') {
$where_admin['account'] = $data['username'];
$where_admin['password'] = md5($data['password']);
$admin_info = $this->admin_obj->where($where_admin)->find();
if($admin_info==null){
return json(['code'=>1]);
}else{
$up_admin['last_login_time'] = time();
$up_admin['last_login_ip'] = $this->request->ip();
$this->admin_obj->where('admin_id = '.$admin_info['admin_id'])->update($up_admin);
return json(['code'=>0,'userinfo'=>$admin_info]);
}
} else {//用户登录
$where['account'] = $data['username'];
$where['password'] = md5($data['password']);
$user_info = $this->user_obj->where($where)->find();
if ($user_info == null) {//登陆失败
return json(['code' => 1]);
} else {//登陆成功
$up_data['last_login_time'] = time();
$up_data['last_login_ip'] = $this->request->ip();
$this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
return json(['code' => 0, 'userinfo' => $user_info]);
}
}
}
/**
* 获取文章
*/
public function getArticles(){
$data = $this->request->post();
$list = $this->article_obj->where('special_num',$data['special_id'])->where('state',0)->select();
$re['articles'] = $list;
return json(['code'=>0,'data'=>['articles'=>$re]]);
}
/**
* 添加文章(作者)
*/
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('issn', $data['journal_issn'])->find();
Db::startTrans();
//添加文章基础信息
$inset_data['user_id'] = $user_res['user_id'];
$inset_data['journal_id'] = $journal_info['journal_id'];
$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]);
}
}
}

View File

@@ -111,7 +111,7 @@ class review {
$this->article_msg_obj->insert($insert_data);
//添加通知信息
add_usermsg($data['user_id'], 'Your manuscript has new process', '/articleDetail?id=' . $data['article_id']);
//发送邮件通知编辑
//发送邮件通知用户
$tt = $data['accept_sn'].'<br>';
$tt .= 'Dear '.($user_info['realname']==''?'Authors':$user_info['realname']).',<br>';
$tt .= 'Thank you for submitting the manuscript to '.$journal_info['title'].'. <br>';