1076 lines
43 KiB
PHP
1076 lines
43 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use think\Controller;
|
||
use think\Db;
|
||
use think\captcha;
|
||
use think\Cache;
|
||
use think\Queue;
|
||
|
||
/**
|
||
* @title 用户相关接口
|
||
* @description 用户相关接口
|
||
*/
|
||
class User extends Controller {
|
||
|
||
protected $user_obj = '';
|
||
protected $captcha_obj = '';
|
||
protected $user_act_obj = '';
|
||
protected $admin_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 = '';
|
||
protected $chief_to_journal_obj = '';
|
||
protected $board_to_journal_obj = '';
|
||
protected $reviewer_from_author_obj = '';
|
||
protected $article_author_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->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');
|
||
$this->chief_to_journal_obj = Db::name('chief_to_journal');
|
||
$this->board_to_journal_obj = Db::name('board_to_journal');
|
||
$this->reviewer_from_author_obj = Db::name('reviewer_from_author');
|
||
$this->article_author_obj = Db::name('article_author');
|
||
}
|
||
|
||
/**
|
||
* @title 登录功能
|
||
* @description 登录功能
|
||
* @author wangjinlei
|
||
* @url /api/User/checkLogin
|
||
* @method POST
|
||
*
|
||
* @param name:username type:string require:1 desc:用户名
|
||
* @param name:password type:string require:1 desc:密码
|
||
*
|
||
* @return userinfo:用户信息#
|
||
* @return roles:角色列表#
|
||
*/
|
||
public function checkLogin() {
|
||
$data = $this->request->post();
|
||
if($data['username']=='fariba'||$data['username']=='zc'||$data['username']=='Mohammad Hossein'||$data['username']=='xiaoyueyue'||$data['username']=='sethlee000'||$data['username']=='yuanying9908'){
|
||
return json(['code'=>1,'msg'=>'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
|
||
}
|
||
|
||
//判断是否管理员登录
|
||
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 {//用户登录
|
||
$user_info = $this->user_obj
|
||
->where('account|email', $data['username'])
|
||
->where('password', md5($data['password']))
|
||
->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);
|
||
$roles = $this->getUserRoles($user_info['account']);
|
||
|
||
$re['roles'] = $roles;
|
||
$re['userinfo'] = $user_info;
|
||
return jsonSuccess($re);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 为所有用户发送邮件
|
||
*/
|
||
public function pushEmail(){
|
||
die;
|
||
$list = $this->user_obj->where('state',0)->select();
|
||
//发送邮件通知审稿人
|
||
foreach($list as $v){
|
||
$content = "Dear Researcher,<br/><br/>";
|
||
$content .= "We sincerely invite you to subscribe to our journal <b>Traditional Medicine Research</b> (TMR) (ISSN 2413-3973).<br/>";
|
||
$content .= "If you are interested in our journal,it is easy to subscribe to journals and topics on our official website. Please click here:<br/>";
|
||
$content .= "<a href='https://www.tmrjournals.com/draw_up.html?issn=2413-3973'>https://www.tmrjournals.com/draw_up.html?issn=2413-3973</a><br/><br/>";
|
||
$content .= "Updates to the topics you have subscribed to will be sent to your mailbox.<br/><br/>";
|
||
$content .= "Thank you for your attention to our invitation. If you have any questions, do not hesitate to contact us.<br/><br/>";
|
||
$content .= "<span style='font-size:6px;line-height:30px;'>TMR is a peer-reviewed open access journal managed by TMR Publishing Group. TMR is dedicated to protecting and developing all types of traditional medicines, including traditional Chinese medicine, Persian medicine, Ayurveda, Siddha, minority medicine, etc., using the latest achievements in modern science. TMR emphasizes the historical origin and developmental pipeline of the research objective and encourages authors to analyze the theoretical significance underlying a study and the application of traditional medicine in clinical practice.</span><br/><br/>";
|
||
$content .= "Best wishes,<br/>";
|
||
$content .= "TMR Publishing Group";
|
||
$maidata['email'] = $v['email'];
|
||
$maidata['title'] = "Traditional Medicine Research";
|
||
$maidata['content'] = $content;
|
||
$maidata['tmail'] = "tmrweb@tmrjournals.com";
|
||
$maidata['tpassword'] = "Wu999999tmrwe";
|
||
Queue::push( 'app\api\job\mail@fire' , $maidata , "tmail" );
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 申请期刊审稿人对于审稿人
|
||
* @description 申请期刊审稿人对于审稿人
|
||
* @author wangjinlei
|
||
* @url /api/User/applyReviewerForReviewer
|
||
* @method POST
|
||
*
|
||
* @param name:username type:string require:1 desc:用户名
|
||
* @param name:journal_id type:int require:1 desc:期刊id
|
||
*
|
||
*/
|
||
public function applyReviewerForReviewer(){
|
||
$data = $this->request->post();
|
||
$user_info = $this->user_obj->where('account', trim($data['username']))->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();
|
||
$reviewer_info_info = $this->user_reviewer_info_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
|
||
$check = $this->reviewer_to_journal_obj->where("reviewer_id",$user_info['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find();
|
||
$check1 = $this->user_reviewer_obj->where('name',trim($data['username']))->where('journal_id',$data['journal_id'])->find();
|
||
if($check||$check1){
|
||
return jsonError("You are already in the reviewer list of this journal");
|
||
}
|
||
$insert_data['journal_id'] = $data['journal_id'];
|
||
$insert_data['name'] = trim($data['username']);
|
||
$insert_data['introduction'] = $reviewer_info_info['introduction'];
|
||
$insert_data['email'] = $user_info['email'];
|
||
$insert_data['company'] = $reviewer_info_info['company'];
|
||
$insert_data['country'] = $reviewer_info_info['country'];
|
||
$insert_data['major'] = $reviewer_info_info['major'];
|
||
$insert_data['technical'] = $reviewer_info_info['technical'];
|
||
$insert_data['field'] = $reviewer_info_info['field'];
|
||
$insert_data['gender'] = $reviewer_info_info['gender'];
|
||
$insert_data['qualifications'] = $reviewer_info_info['qualifications'];
|
||
$insert_data['ctime'] = time();
|
||
$res = $this->user_reviewer_obj->insertGetId($insert_data);
|
||
//发送email-》编辑
|
||
$tt = 'Dear editor,<br>';
|
||
$tt .= 'Please check the new reviewer application.';
|
||
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
|
||
//发送消息信息--编辑
|
||
add_usermsg($journal_info['editor_id'], '新增审稿人申请,申请人(' . $data['username'] . ')', '/reviewerApplyDetail?id=' . $res);
|
||
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 审稿系统登录功能
|
||
* @description 审稿系统登录功能
|
||
* @author wangjinlei
|
||
* @url /api/User/reviewer_login
|
||
* @method POST
|
||
*
|
||
* @param name:username type:string require:1 desc:用户名
|
||
* @param name:password type:string require:1 desc:密码
|
||
*
|
||
* @return userinfo:用户信息#
|
||
*/
|
||
// public function reviewer_login() {
|
||
// $data = $this->request->post();
|
||
// $user_info = $this->user_obj
|
||
// ->where('account|email', $data['username'])
|
||
// ->where('password', md5($data['password']))
|
||
// ->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]);
|
||
// }
|
||
// }
|
||
|
||
/**
|
||
* @title 获取用户身份列表
|
||
* @description 获取用户身份列表
|
||
* @author wangjinlei
|
||
* @url /api/User/getUserRole
|
||
* @method POST
|
||
*
|
||
* @param name:account type:string require:1 desc:用户名
|
||
*
|
||
* @return roles:角色列表#
|
||
*
|
||
*/
|
||
public function getUserRole(){
|
||
$data = $this->request->post();
|
||
$roles = $this->getUserRoles($data['account']);
|
||
$re['roles'] = $roles;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
private function getUserRoles($account) {
|
||
$user_info = $this->user_obj->where('account',$account)->find();
|
||
if($user_info['type']==2){
|
||
$ros[] = 'editor';
|
||
return $ros;
|
||
}
|
||
$roles[] = 'author';
|
||
$reviewer_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
|
||
if($reviewer_res!=null){
|
||
$roles[] = 'reviewer';
|
||
}
|
||
$yboard_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('is_yboard',1)->where('state',0)->find();
|
||
if($yboard_res!=null){
|
||
$roles[] = 'yboard';
|
||
}
|
||
$chief_res = $this->chief_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
|
||
if($chief_res != null){
|
||
$roles[] = 'chief';
|
||
}
|
||
$board_res = $this->board_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
|
||
if($board_res != null){
|
||
$roles[] = 'board';
|
||
}
|
||
return $roles;
|
||
}
|
||
|
||
/**
|
||
* @title 升级审稿人至青年编委
|
||
* @description 升级审稿人至青年编委
|
||
* @author wangjinlei
|
||
* @url /api/User/upReviewerToYboard
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id type:int require:1 desc:期刊id
|
||
* @param name:user_id type:int require:1 desc:审稿人userid
|
||
*
|
||
* @return roles:角色列表#
|
||
*
|
||
*/
|
||
public function upReviewerToYboard(){
|
||
$data = $this->request->post();
|
||
$this->reviewer_to_journal_obj->where('journal_id',$data['journal_id'])->where('reviewer_id',$data['user_id'])->where('state',0)->update(['is_yboard'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 降级青年编委至审稿人
|
||
* @description 降级青年编委至审稿人
|
||
* @author wangjinlei
|
||
* @url /api/User/downReviewerToYboard
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id type:int require:1 desc:期刊id
|
||
* @param name:user_id type:int require:1 desc:审稿人userid
|
||
*
|
||
* @return roles:角色列表#
|
||
*
|
||
*/
|
||
public function downReviewerToYboard(){
|
||
$data = $this->request->post();
|
||
$this->reviewer_to_journal_obj->where('journal_id',$data['journal_id'])->where('reviewer_id',$data['user_id'])->where('state',0)->update(['is_yboard'=>0]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取orcid
|
||
*/
|
||
public function checkOrcid() {
|
||
$data = $this->request->post();
|
||
$account = $data['account'];
|
||
$user = $this->user_obj->where('account', $account)->find();
|
||
return json(['code' => 0, 'userinfo' => $user]);
|
||
}
|
||
|
||
/**
|
||
* 根据account获取用户信息
|
||
*/
|
||
public function getUserdata() {
|
||
$account = $this->request->post('account');
|
||
$where['account'] = $account;
|
||
if ($account == 'superadmin') {
|
||
$res = $this->admin_obj->where($where)->find();
|
||
} else {
|
||
$res = $this->user_obj->where($where)->find();
|
||
}
|
||
if ($res == null) {
|
||
return json(['code' => 1, 'msg' => '获取失败']);
|
||
} else {
|
||
return json(['code' => 0, 'data' => $res]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 注册功能
|
||
*/
|
||
public function register() {
|
||
$data = $this->request->post();
|
||
//检测是否用户名和邮箱已经占用
|
||
$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['name'];
|
||
$inser_data['ctime'] = time();
|
||
$this->user_obj->insert($inser_data);
|
||
//发送注册成功邮件
|
||
$tt = 'Hello,<br><br>';
|
||
$tt .= 'Your account has been created. You may check on the status of your manuscript using this submission and tracking system: https://submission.tmrjournals.com<br>';
|
||
$tt .= "Username:$account<br>";
|
||
$tt .= "Password:" . $data['password'] . '<br><br>';
|
||
$tt .= "Many thanks<br>TMR Publishing Group";
|
||
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt);
|
||
return json($inser_data);
|
||
}
|
||
|
||
/**
|
||
* 获取验证码图片(用户注册)
|
||
*/
|
||
public function testCaptcha() {
|
||
$data = $this->request->get();
|
||
$config = config('captcha');
|
||
$capt = new captcha\Captcha($config);
|
||
return $capt->entry($data['a']);
|
||
}
|
||
|
||
/**
|
||
* 修改密码
|
||
*/
|
||
public function retrieve() {
|
||
$data = $this->request->post();
|
||
//获取act信息
|
||
$act_where['act_key'] = $data['actkey'];
|
||
$actres = $this->user_act_obj->where($act_where)->find();
|
||
$act = json_decode($actres['param']);
|
||
$where['email'] = $act->email;
|
||
$res = $this->user_obj->where($where)->update(['password' => md5($data['password'])]);
|
||
if ($res > 0) {
|
||
$this->user_act_obj->where($act_where)->update(['state' => 1]);
|
||
return json(['code' => 0]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => '失败!']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取验证码图片(密码找回)
|
||
*/
|
||
public function retrieveCaptcha() {
|
||
$data = $this->request->get();
|
||
$config = config('captcha_retrieve');
|
||
$capt = new captcha\Captcha($config);
|
||
return $capt->entry($data['a']);
|
||
}
|
||
|
||
/**
|
||
* 找回密码第一步,获取邮箱
|
||
*/
|
||
public function retrieveGetEmail() {
|
||
$data = $this->request->post();
|
||
//验证验证码
|
||
if (!$this->my_checkcaptcha($data['code'], $data['random_num'])) {
|
||
return json(['code' => 1, 'msg' => '验证码错误']);
|
||
}
|
||
$res = $this->user_obj
|
||
->where('account|email', $data['username'])
|
||
->find();
|
||
if ($res == null) {
|
||
return json(['code' => 1, 'msg' => '查无此人']);
|
||
} else {
|
||
return json(['code' => 0, 'email' => $res['email']]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 找回密码第二部,发送邮件
|
||
*/
|
||
public function retrievePushEmail() {
|
||
$email = $this->request->post('email');
|
||
$where['email'] = $email;
|
||
$realname = $this->user_obj->where($where)->value('realname');
|
||
//插入数据库隐形操作表数据
|
||
$act_insert['act_key'] = authcode($email . time());
|
||
$act_insert['type'] = 'retrieve';
|
||
$act_insert['param'] = json_encode(['email' => $email]);
|
||
$act_insert['ctime'] = time();
|
||
$this->user_act_obj->insert($act_insert);
|
||
//发送邮件
|
||
$url = config('base_web_url') . 'retrieveact?actkey=' . $act_insert['act_key'];
|
||
$title = 'Your request to reset your password [TMR Publishing Group]';
|
||
$content = "$realname, we've received your request to reset your password.Please click the link below to change your password. <a href='$url' target='_blank'>$url</a>";
|
||
$res = sendEmail($email, $title, 'TMR', $content,);
|
||
if ($res['status'] == 1) {//成功
|
||
return json(['code' => 0, 'msg' => 'success']);
|
||
} else {//失败
|
||
return json(['code' => 1, 'msg' => $res['data']]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 验证修改密码页面的合法性
|
||
*/
|
||
public function checkActkey() {
|
||
$actkey = $this->request->post('actkey');
|
||
$where['act_key'] = $actkey;
|
||
$where['state'] = 0;
|
||
$res = $this->user_act_obj->where($where)->find();
|
||
if ($res == null) {
|
||
return json(['code' => 1, 'msg' => '查询失败']);
|
||
} else {
|
||
return json(['code' => 0, 'msg' => '查询成功']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 自定义验证验证码
|
||
*/
|
||
public function my_checkcaptcha($code, $id) {
|
||
$nowcode = Cache::get(md5($id));
|
||
$mbcode = authcode($code);
|
||
return $nowcode == $mbcode ? true : false;
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 获取审稿人列表
|
||
* @description 获取审稿人列表
|
||
* @author wangjinlei
|
||
* @url /api/User/getreviewerList
|
||
* @method POST
|
||
*
|
||
* @param name:username type:string require:1 desc:用户名
|
||
* @param name:journalId type:int require:1 desc:期刊id当全选时为0
|
||
* @param name:pageIndex type:int require:1 desc:开始页码
|
||
* @param name:pageSize type:int require:1 desc:每页是数据条数
|
||
*
|
||
*/
|
||
public function getreviewerList() {
|
||
$data = $this->request->post();
|
||
$editor_info = $this->user_obj->where('account',$data['username'])->where('state',0)->find();
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$jous = [];
|
||
if($data['journalId'] == 0){
|
||
$jous = $this->journal_obj->where('editor_id',$editor_info['user_id'])->where('state',0)->column('journal_id');
|
||
}else{
|
||
$jous[] = $data['journalId'];
|
||
}
|
||
$res = $this->reviewer_to_journal_obj
|
||
->field('t_reviewer_to_journal.is_yboard,t_user_reviewer_info.*,t_journal.*,t_user.*')
|
||
->join('t_journal','t_journal.journal_id = t_reviewer_to_journal.journal_id','left')
|
||
->join('t_user','t_user.user_id = t_reviewer_to_journal.reviewer_id','left')
|
||
->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_reviewer_to_journal.reviewer_id', 'LEFT')
|
||
->where('t_reviewer_to_journal.journal_id','in',$jous)
|
||
->where('t_reviewer_to_journal.state',0)
|
||
->limit($limit_start,$data['pageSize'])
|
||
->select();
|
||
$count = $this->reviewer_to_journal_obj->where('t_reviewer_to_journal.journal_id','in',$jous)->where('t_reviewer_to_journal.state',0)->count();
|
||
return json(['code' => 0, 'data' => $res, 'total' => $count]);
|
||
|
||
|
||
|
||
// $where['t_user.is_reviewer'] = 1;
|
||
// if ($data['journalId'] == 0) {
|
||
// $subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
|
||
// $journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
|
||
// $uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('state', 0)->column('reviewer_id');
|
||
// $where['t_user.user_id'] = ['in', $uids];
|
||
// } else {
|
||
// $uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->where('state', 0)->column('reviewer_id');
|
||
// $where['t_user.user_id'] = ['in', $uids];
|
||
// }
|
||
// $res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
|
||
// ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')
|
||
// ->where($where)
|
||
// ->limit($limit_start, $data['pageSize'])
|
||
// ->select();
|
||
// $total = $this->user_obj->where($where)->count();
|
||
// if ($res) {
|
||
// return json(['code' => 0, 'data' => $res, 'total' => $total]);
|
||
// } else {
|
||
// return json(['code' => 1]);
|
||
// }
|
||
}
|
||
|
||
/**
|
||
*
|
||
*/
|
||
public function deleteArticleReviewer() {
|
||
$data = $this->request->post();
|
||
$this->reviewer_to_journal_obj->where('reviewer_id', $data['reviewer_id'])->where('journal_id', $data['journal_id'])->update(['state' => 1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
*
|
||
*/
|
||
public function getReviewerForDel() {
|
||
$data = $this->request->post();
|
||
$user_info = $this->user_obj->where('user_id', $data['reviewer_id'])->find();
|
||
$editor_info = $this->user_obj->where('account', $data['editor_account'])->find();
|
||
$journals = $this->journal_obj->where("editor_id", $editor_info['user_id'])->column('journal_id');
|
||
$rtjs = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('reviewer_id', $data['reviewer_id'])->where('state', 0)->select();
|
||
foreach ($rtjs as $k => $v) {
|
||
$rtjs[$k]['reviewer'] = $user_info;
|
||
$rtjs[$k]['journal'] = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
|
||
}
|
||
return jsonSuccess($rtjs);
|
||
}
|
||
|
||
/**
|
||
* 获取审核员申请列表
|
||
*/
|
||
public function getReviewerApplyList() {
|
||
$data = $this->request->post();
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$where['state'] = 0;
|
||
if ($data['journalId'] == 0) {
|
||
$subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
|
||
$journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
|
||
$where['journal_id'] = ['in', $journals];
|
||
} else {
|
||
$where['journal_id'] = $data['journalId'];
|
||
}
|
||
$res = $this->user_reviewer_obj->where($where)->limit($limit_start, $data['pageSize'])->select();
|
||
$count = $this->user_reviewer_obj->where($where)->count();
|
||
return json(['total' => $count, 'data' => $res]);
|
||
}
|
||
|
||
/**
|
||
* 获取申请详情
|
||
*/
|
||
public function getApplyDetail() {
|
||
$reviewerId = $this->request->post('reviewerApplyId');
|
||
$where['t_user_reviewer_apply.reviewer_apply_id'] = $reviewerId;
|
||
$res = $this->user_reviewer_obj
|
||
->field('t_user_reviewer_apply.*,t_journal.title journal,t_reviewer_major.title major_title')
|
||
->join('t_journal', 't_journal.journal_id = t_user_reviewer_apply.journal_id', 'left')
|
||
->join('t_reviewer_major', 't_user_reviewer_apply.major = t_reviewer_major.major_id', 'LEFT')
|
||
->where($where)
|
||
->find();
|
||
if ($res) {
|
||
return json(['code' => 0, 'data' => $res]);
|
||
} else {
|
||
return json(['code' => 1]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 获取作者转审稿人列表
|
||
* @description 获取作者转审稿人列表
|
||
* @author wangjinlei
|
||
* @url /api/User/getAuthorToReviewerList
|
||
* @method POST
|
||
*
|
||
* @param name:username type:string require:1 desc:用户名
|
||
* @param name:journal_id type:int require:1 desc:期刊id0是全部
|
||
*
|
||
* @return reviewerTrans:列表#
|
||
*/
|
||
public function getAuthorToReviewerList(){
|
||
$data = $this->request->post();
|
||
$user_info = $this->user_obj->where('account',$data['username'])->find();
|
||
$journals = $this->journal_obj->where("editor_id",$user_info['user_id'])->where('state',0)->column("journal_id");
|
||
|
||
$where['t_reviewer_from_author.rfa_state'] = 0;
|
||
if($data['journal_id']==0){
|
||
$where['t_reviewer_from_author.journal_id'] = ["in",$journals];
|
||
}else{
|
||
$where['t_reviewer_from_author.journal_id'] = $data['journal_id'];
|
||
}
|
||
$list = $this->reviewer_from_author_obj
|
||
->field("t_reviewer_from_author.rfa_id,t_article_author.*,t_journal.title journal_title")
|
||
->join("t_article_author","t_reviewer_from_author.art_aut_id = t_article_author.art_aut_id","left")
|
||
->join("t_journal","t_journal.journal_id = t_reviewer_from_author.journal_id","left")
|
||
->where($where)
|
||
->select();
|
||
$re['reviewerTrans'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 获取作者转审稿人详情
|
||
* @description 获取作者转审稿人详情
|
||
* @author wangjinlei
|
||
* @url /api/User/getAuthorToReviewerDetail
|
||
* @method POST
|
||
*
|
||
* @param name:rfa_id type:int require:1 desc:实例id
|
||
*
|
||
* @return reviewerTrans:列表#
|
||
*/
|
||
public function getAuthorToReviewerDetail(){
|
||
$data = $this->request->post();
|
||
$detail = $this->reviewer_from_author_obj
|
||
->field("t_reviewer_from_author.rfa_id,t_article_author.*,t_journal.title journal_title")
|
||
->join("t_article_author","t_reviewer_from_author.art_aut_id = t_article_author.art_aut_id","left")
|
||
->join("t_journal","t_journal.journal_id = t_reviewer_from_author.journal_id","left")
|
||
->where("rfa_id",$data['rfa_id'])
|
||
->find();
|
||
|
||
$re['reviewerTran'] = $detail;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 作者转审稿人提交信息并通过
|
||
* @description 作者转审稿人提交信息并通过
|
||
* @author wangjinlei
|
||
* @url /api/User/ReviewerFromAuthorAdopt
|
||
* @method POST
|
||
*
|
||
* @param name:rfa_id type:int require:1 desc:实例id
|
||
* @param name:company type:String require:1 desc:单位
|
||
* @param name:country type:String require:1 desc:国家
|
||
* @param name:email type:String require:1 desc:邮箱
|
||
* @param name:field type:String require:1 desc:领域描述
|
||
* @param name:gender type:String require:1 desc:1男2女
|
||
* @param name:introduction type:String require:1 desc:简介
|
||
* @param name:major type:int require:1 desc:major_id
|
||
* @param name:qualifications type:String require:1 desc:cv地址
|
||
* @param name:author_title type:String require:1 desc:职称
|
||
*
|
||
*
|
||
*/
|
||
public function ReviewerFromAuthorAdopt(){
|
||
$data = $this->request->post();
|
||
$rfa_info = $this->reviewer_from_author_obj->where('rfa_id',$data['rfa_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$rfa_info['journal_id'])->find();
|
||
$art_aut_info = $this->article_author_obj->where('art_aut_id',$rfa_info['art_aut_id'])->find();
|
||
$user_info = $this->user_obj->where('email',$art_aut_info['email'])->where('state',0)->find();
|
||
if(!$user_info){
|
||
return jsonError("user no find!");
|
||
}
|
||
|
||
Db::startTrans();
|
||
|
||
$insert_info['reviewer_id'] = $user_info['user_id'];
|
||
$insert_info['gender'] = $data['gender'];
|
||
$insert_info['technical'] = $data['author_title'];
|
||
$insert_info['country'] = $data['country'];
|
||
$insert_info['introduction'] = $data['introduction'];
|
||
$insert_info['company'] = $data['company'];
|
||
$insert_info['major'] = $data['major'];
|
||
$insert_info['field'] = $data['field'];
|
||
$insert_info['qualifications'] = $data['qualifications'];
|
||
$res = $this->user_reviewer_info_obj->insertGetId($insert_info);
|
||
|
||
$insert_to['reviewer_id'] = $user_info['user_id'];
|
||
$insert_to['journal_id'] = $rfa_info['journal_id'];
|
||
$insert_to['account'] = $user_info['account'];
|
||
$insert_to['journal_title'] = $journal_info['title'];
|
||
$insert_to['ctime'] = time();
|
||
$res1 = $this->reviewer_to_journal_obj->insertGetId($insert_to);
|
||
|
||
$res2 = $this->reviewer_from_author_obj->where('rfa_id',$data['rfa_id'])->update(['rfa_state'=>1]);
|
||
|
||
if($res && $res1 && $res2){
|
||
Db::commit();
|
||
return jsonSuccess([]);
|
||
} else {
|
||
Db::rollback();
|
||
return jsonError("system error!");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 作者转审稿人拒绝
|
||
* @description 作者转审稿人拒绝
|
||
* @author wangjinlei
|
||
* @url /api/User/ReviewerFromAuthorReject
|
||
* @method POST
|
||
*
|
||
* @param name:rfa_id type:int require:1 desc:实例id
|
||
*
|
||
*
|
||
*/
|
||
public function ReviewerFromAuthorReject(){
|
||
$data = $this->request->post();
|
||
$this->reviewer_from_author_obj->where('rfa_id',$data['rfa_id'])->update(['rfa_state'=>2]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 通过审核人
|
||
*/
|
||
public function reviewerAdopt() {
|
||
$reviewerId = $this->request->post('reviewerApplyId');
|
||
$where['reviewer_apply_id'] = $reviewerId;
|
||
$apply_info = $this->user_reviewer_obj->where($where)->find();
|
||
$journal_info = $this->journal_obj->where('journal_id', $apply_info['journal_id'])->find();
|
||
$has_res = $this->user_obj->where('account', $apply_info['name'])->find();
|
||
//检测是否已经存在此审稿人
|
||
if($has_res){
|
||
$check = $this->reviewer_to_journal_obj->where('reviewer_id',$has_res['user_id'])->where('journal_id',$journal_info['journal_id'])->where('state',0)->find();
|
||
if($check){
|
||
return jsonError("has reviewer!");
|
||
}
|
||
}
|
||
Db::startTrans();
|
||
if ($has_res == null) {
|
||
$insert_data['account'] = $apply_info['name'];
|
||
$insert_data['password'] = md5('123456qwe');
|
||
$insert_data['email'] = $apply_info['email'];
|
||
$insert_data['realname'] = $apply_info['name'];
|
||
$insert_data['type'] = 1;
|
||
$insert_data['is_reviewer'] = 1;
|
||
$insert_data['ctime'] = time();
|
||
$add_res = $this->user_obj->insertGetId($insert_data);
|
||
$insert_info['reviewer_id'] = $add_res;
|
||
$insert_info['gender'] = $apply_info['gender'];
|
||
$insert_info['technical'] = $apply_info['technical'];
|
||
$insert_info['country'] = $apply_info['country'];
|
||
$insert_info['introduction'] = $apply_info['introduction'];
|
||
$insert_info['company'] = $apply_info['company'];
|
||
$insert_info['major'] = $apply_info['major'];
|
||
$insert_info['field'] = $apply_info['field'];
|
||
$insert_info['qualifications'] = $apply_info['qualifications'];
|
||
$addinfo_res = $this->user_reviewer_info_obj->insertGetId($insert_info);
|
||
$has_res = $this->user_obj->where('account', $apply_info['name'])->find();
|
||
} else {
|
||
$this->user_obj->where('user_id', $has_res['user_id'])->update(['is_reviewer' => 1]);
|
||
$cache_rev = $this->user_reviewer_info_obj->where('reviewer_id', $has_res['user_id'])->find();
|
||
if ($cache_rev == null) {
|
||
$insert_info['reviewer_id'] = $has_res['user_id'];
|
||
$insert_info['gender'] = $apply_info['gender'];
|
||
$insert_info['technical'] = $apply_info['technical'];
|
||
$insert_info['country'] = $apply_info['country'];
|
||
$insert_info['introduction'] = $apply_info['introduction'];
|
||
$insert_info['company'] = $apply_info['company'];
|
||
$insert_info['major'] = $apply_info['major'];
|
||
$insert_info['field'] = $apply_info['field'];
|
||
$insert_info['qualifications'] = $apply_info['qualifications'];
|
||
$this->user_reviewer_info_obj->insert($insert_info);
|
||
}
|
||
$add_res = true;
|
||
$addinfo_res = true;
|
||
}
|
||
$insert_rtj['reviewer_id'] = $has_res['user_id'];
|
||
$insert_rtj['journal_id'] = $journal_info['journal_id'];
|
||
$insert_rtj['account'] = $has_res['account'];
|
||
$insert_rtj['journal_title'] = $journal_info['title'];
|
||
$insert_rtj['ctime'] = time();
|
||
$res = $this->reviewer_to_journal_obj->insert($insert_rtj);
|
||
//发送email
|
||
$content = "Thank you for registering as a " . $journal_info['title'] . " reviewer<br/>"
|
||
. "At present, you have passed our examination<br/>";
|
||
$content .= '<a href="https://submission.tmrjournals.com">Submission System</a><br>';
|
||
$content .= '<p>username:' . $apply_info['name'] . '</p>';
|
||
$content .= '<p>Original Password: 123456qwe</p>'; //$has_res ? '' : '<p>password:123456qwe</p>';
|
||
sendEmail($apply_info['email'], $journal_info['title'], $journal_info['title'], $content, $journal_info['email'], $journal_info['epassword']);
|
||
$update_res = $this->user_reviewer_obj->where($where)->update(['state' => 1]);
|
||
if ($res && $add_res && $addinfo_res && $update_res) {
|
||
Db::commit();
|
||
return json(['code' => 0]);
|
||
} else {
|
||
Db::rollback();
|
||
return json(['code' => 1]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取用户消息
|
||
*/
|
||
public function getUserMsg() {
|
||
//接收参数
|
||
$data = $this->request->post();
|
||
$user_info = $this->user_obj->where('account', $data['account'])->find();
|
||
|
||
//查询msglist
|
||
$list = $this->user_msg_obj
|
||
->where('user_id', $user_info['user_id'])
|
||
->where('state', 0)
|
||
->order('user_msg_id desc')
|
||
->select();
|
||
|
||
return json($list);
|
||
}
|
||
|
||
/**
|
||
* 更改用户消息状态
|
||
*/
|
||
public function changeMsgState() {
|
||
//接收参数
|
||
$id = $this->request->post('id');
|
||
$this->user_msg_obj
|
||
->where('user_msg_id', $id)
|
||
->update(['state' => 1]);
|
||
return json(['code' => 0]);
|
||
}
|
||
|
||
/**
|
||
* 审核人审查去重
|
||
*/
|
||
public function checkReviewer() {
|
||
$username = $this->request->post('username');
|
||
$userres = $this->user_obj->where('account', $username)->find();
|
||
$applyres = $this->user_reviewer_obj->where("name = '$username' and state <> 2")->find();
|
||
if ($applyres || $userres) {
|
||
return json(['code' => 1]);
|
||
} else {
|
||
return json(['code' => 0]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 审查用户是否是审稿人
|
||
* @description 审查用户是否是审稿人
|
||
* @author wangjinlei
|
||
* @url /api/User/checkUserIsReviewer
|
||
* @method POST
|
||
*
|
||
* @param name:username type:String require:1 desc:account
|
||
*
|
||
* @return is:0否1是
|
||
*
|
||
*/
|
||
public function checkUserIsReviewer(){
|
||
$data = $this->request->post();
|
||
$user_info = $this->user_obj->where('account',$data['username'])->find();
|
||
$check = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
|
||
|
||
$re['is'] = $check==null?0:1;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 审查用户是否存在通过用户名或邮箱
|
||
* @description 审查用户是否存在通过用户名或邮箱
|
||
* @author wangjinlei
|
||
* @url /api/User/checkUserByAccountOrEmail
|
||
* @method POST
|
||
*
|
||
* @param name:username type:String require:1 desc:account/email
|
||
*
|
||
* @return has:0无1有
|
||
*
|
||
*/
|
||
public function checkUserByAccountOrEmail(){
|
||
$data = $this->request->post();
|
||
$check_info = $this->user_obj->where("account|email",$data['username'])->where("state",0)->find();
|
||
|
||
$re['has'] = $check_info==null?0:1;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 拒绝审核人
|
||
*/
|
||
public function reviewerRejec() {
|
||
$reviewerId = $this->request->post('reviewerApplyId');
|
||
$where['reviewer_apply_id'] = $reviewerId;
|
||
$this->user_reviewer_obj->where($where)->update(['state' => 2]);
|
||
|
||
//拒绝审稿人email-》审稿人
|
||
|
||
return json(['code' => 0]);
|
||
}
|
||
|
||
/**
|
||
* @title 获取专业列表(未来会废弃)
|
||
* @description 获取专业列表(未来会废弃)
|
||
* @author wangjinlei
|
||
* @url /api/User/getMajorList
|
||
* @method POST
|
||
*
|
||
*
|
||
* @return data:领域列表#
|
||
*/
|
||
public function getMajorList() {
|
||
$res = $this->reviewer_major_obj->select();
|
||
return json(['code' => 0, 'data' => $res]);
|
||
}
|
||
|
||
/**
|
||
* orcid登陆
|
||
*/
|
||
public function OrcidLogin() {
|
||
$data = $this->request->post();
|
||
$url = 'https://orcid.org/oauth/token';
|
||
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
|
||
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
|
||
$param['grant_type'] = "authorization_code";
|
||
$param['code'] = $data['code'];
|
||
$param['redirect_uri'] = "https://submission.tmrjournals.com/orcidLink";
|
||
$res = $this->myUrl($url, $param);
|
||
$r = json_decode($res);
|
||
//确定用户是否存在
|
||
$user = $this->user_obj->where('orcid', $r->orcid)->find();
|
||
if ($user == null) {
|
||
Cache::set($r->orcid, $res, 3600);
|
||
}
|
||
$roles = $this->getUserRoles($user['account']);
|
||
$re['roles'] = $roles;
|
||
$re['userinfo'] = $user;
|
||
$re['user'] = $user;
|
||
$re['orcid'] = $r->orcid;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 登陆后绑定orcid账号
|
||
*/
|
||
public function OrcidBinding() {
|
||
$data = $this->request->post();
|
||
$url = 'https://orcid.org/oauth/token';
|
||
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
|
||
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
|
||
$param['grant_type'] = "authorization_code";
|
||
$param['code'] = $data['code'];
|
||
$param['redirect_uri'] = "https://submission.tmrjournals.com/orcidBind";
|
||
$res = $this->myUrl($url, $param);
|
||
$r = json_decode($res);
|
||
|
||
|
||
$update['orcid'] = $r->orcid;
|
||
$update['orcid_code'] = $res;
|
||
|
||
$this->user_obj->where('account', $data['account'])->update($update);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 绑定orcid到系统内的用户
|
||
*/
|
||
public function orcidBind() {
|
||
$data = $this->request->post();
|
||
//确定系统内部有此账户
|
||
$serch['account'] = trim($data['username']);
|
||
$serch['password'] = md5($data['password']);
|
||
$user_info = $this->user_obj->where($serch)->find();
|
||
if ($user_info == null) {
|
||
return jsonError('The account does not exist or the password is wrong!');
|
||
}
|
||
$cache = Cache::get($data['orcid']);
|
||
if (!$cache) {
|
||
return jsonError('To complete the operation within one hour after verification, you have timed out');
|
||
}
|
||
$orcid_obj = $this->object2array(json_decode($cache));
|
||
$update['orcid'] = $orcid_obj['orcid'];
|
||
$update['orcid_code'] = $cache;
|
||
$this->user_obj->where('user_id', $user_info['user_id'])->update($update);
|
||
$new_info = $this->user_obj->where('user_id', $user_info['user_id'])->find();
|
||
|
||
$re['user'] = $new_info;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 注册绑定orcid至我们的账户
|
||
*/
|
||
public function orcidRegister() {
|
||
$data = $this->request->post();
|
||
$cache = Cache::get($data['orcid']);
|
||
$res = $this->object2array(json_decode($cache));
|
||
$insert['account'] = trim($data['username']);
|
||
$insert['password'] = md5($data['password']);
|
||
$insert['realname'] = trim($data['name']);
|
||
$insert['phone'] = trim($data['phone']);
|
||
$insert['email'] = trim($data['email']);
|
||
$insert['orcid'] = $res['orcid'];
|
||
$insert['orcid_code'] = $cache;
|
||
$insert['ctime'] = time();
|
||
$id = $this->user_obj->insertGetId($insert);
|
||
$user_info = $this->user_obj->where('user_id', $id)->find();
|
||
|
||
$re['user'] = $user_info;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 授权码转化成令牌,并存贮
|
||
*/
|
||
public function sq_to_lp() {
|
||
$url = 'https://orcid.org/oauth/token';
|
||
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
|
||
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
|
||
$param['grant_type'] = "authorization_code";
|
||
$param['code'] = "7wv2wR";
|
||
$param['redirect_uri'] = "https://www.tmrjournals.com";
|
||
$res = $this->myUrl($url, $param);
|
||
$r = json_decode($res);
|
||
echo $r->orcid;
|
||
}
|
||
|
||
private function myUrl($url, $param) {
|
||
$header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded');
|
||
$pp = http_build_query($param);
|
||
$httph = curl_init($url);
|
||
curl_setopt($httph, CURLOPT_AUTOREFERER, true);
|
||
curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, false);
|
||
curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, false);
|
||
curl_setopt($httph, CURLOPT_RETURNTRANSFER, true);
|
||
curl_setopt($httph, CURLOPT_POST, true); //设置为POST方式
|
||
curl_setopt($httph, CURLOPT_POSTFIELDS, $pp);
|
||
curl_setopt($httph, CURLOPT_HTTPHEADER, $header);
|
||
|
||
$rst = curl_exec($httph);
|
||
curl_close($httph);
|
||
|
||
return $rst;
|
||
}
|
||
|
||
/**
|
||
* 项目转数组
|
||
*/
|
||
private function object2array($object) {
|
||
if (is_object($object)) {
|
||
foreach ($object as $key => $value) {
|
||
$array[$key] = $value;
|
||
}
|
||
} else {
|
||
$array = $object;
|
||
}
|
||
return $array;
|
||
}
|
||
|
||
/**
|
||
* curl -i -H "Accept: application/vnd.orcid+xml" -H 'Authorization: Bearer dd91868d-d29a-475e-9acb-bd3fdf2f43f4' 'https://api.sandbox.orcid.org/v2.1/0000-0002-9227-8514/education/22423'
|
||
*/
|
||
public function geturl() {
|
||
// $url = "https://api.orcid.org/v3.0/0000-0003-3278-0964/record";
|
||
$url = "https://pub.orcid.org/v3.0/expanded-search/?q=0000-0003-3440-7901";
|
||
$headerArray = array("Content-type: application/vnd.orcid+json", "Authorization: Bearer 28924261-b2a9-4ed0-952c-e2647843d1ba");
|
||
$ch = curl_init();
|
||
curl_setopt($ch, CURLOPT_URL, $url);
|
||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
|
||
$output = curl_exec($ch);
|
||
$err = curl_error($ch);
|
||
curl_close($ch);
|
||
$output = json_decode($output, true);
|
||
echo '<pre>';
|
||
var_dump($output);
|
||
echo '</pre>';
|
||
echo '<pre>';
|
||
var_dump($err);
|
||
echo '</pre>';
|
||
die;
|
||
die;
|
||
// return $output;
|
||
}
|
||
|
||
}
|