2632 lines
99 KiB
PHP
2632 lines
99 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use app\api\controller\Base;
|
||
use think\Db;
|
||
use think\captcha;
|
||
use think\Cache;
|
||
use think\Env;
|
||
use think\Loader;
|
||
use think\Queue;
|
||
use think\Validate;
|
||
|
||
/**
|
||
* @title 用户相关接口
|
||
* @description 用户相关接口
|
||
*/
|
||
class User extends Base
|
||
{
|
||
|
||
public function __construct(\think\Request $request = null)
|
||
{
|
||
parent::__construct($request);
|
||
}
|
||
|
||
public function pstest(){
|
||
echo md5('mtrsuper999');
|
||
}
|
||
|
||
/**
|
||
* @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]);
|
||
}
|
||
|
||
if($user_info['register_check']==0){
|
||
return jsonError('Please click on the link sent to your email inbox to complete your registration.');
|
||
}
|
||
//黑名单验证
|
||
$blackCheck = $this->user_black_obj->where('user_id', $user_info['user_id'])->where('black_state', 0)->find();
|
||
if ($blackCheck) {
|
||
return jsonError("Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.");
|
||
}
|
||
$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 addYboard(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'journal_id'=>'require',
|
||
'year'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$check = $this->user_to_yboard_obj
|
||
->where('user_id',$data['user_id'])
|
||
->where('journal_id',$data['journal_id'])
|
||
->where('end_date','>',time())
|
||
->find();
|
||
if($check){
|
||
return jsonError('Already exists');
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
$start_time = time();
|
||
//生成证书
|
||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||
|
||
//添加数据
|
||
$insert['user_id'] = $data['user_id'];
|
||
$insert['journal_id'] = $data['journal_id'];
|
||
$insert['start_date'] = $start_time;
|
||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||
$insert['icon'] = $icon;
|
||
$insert['ctime'] = time();
|
||
$this->user_to_yboard_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 续约青年科学家
|
||
*/
|
||
public function addYboardContinue(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'journal_id'=>'require',
|
||
'year'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$check = $this->user_to_yboard_obj
|
||
->where('user_id',$data['user_id'])
|
||
->where('journal_id',$data['journal_id'])
|
||
->where('end_date','>',time())
|
||
->find();
|
||
$start_time = 0;
|
||
if($check){
|
||
$start_time = $check['end_date'];
|
||
}else{
|
||
$start_time = time();
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
//生成证书
|
||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||
|
||
//添加数据
|
||
$insert['user_id'] = $data['user_id'];
|
||
$insert['journal_id'] = $data['journal_id'];
|
||
$insert['start_date'] = $start_time;
|
||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||
$insert['icon'] = $icon;
|
||
$insert['ctime'] = time();
|
||
$this->user_to_yboard_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
|
||
}
|
||
|
||
/**
|
||
* 删除青年编委
|
||
*/
|
||
public function delYboard(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'utyb_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$this->user_to_yboard_obj->where('utyb_id',$data['utyb_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取青年科学家列表
|
||
*/
|
||
public function getYboardlist(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'journal_id'=>'require',
|
||
"type"=>'require',
|
||
'pageIndex'=>'require',
|
||
'pageSize'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$time = time();
|
||
$where['t_user_to_yboard.journal_id'] = $data['journal_id'];
|
||
$where['t_user_to_yboard.state'] = 0;
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
if($data['type']==1){//当职
|
||
$where['t_user_to_yboard.start_date'] = ['<=',$time];
|
||
$where['t_user_to_yboard.end_date'] = [">=",$time];
|
||
}elseif($data['type']==2){//过期
|
||
$where['t_user_to_yboard.end_date'] = ["<",$time];
|
||
}else{//按年份
|
||
// $where["_string"] = "t_user_to_yboard.start_date >= 1";
|
||
$where['t_user_to_yboard.start_date'] = ['<= time',$data['year']."-12-31 23:59:59"];
|
||
$where['t_user_to_yboard.end_date'] = [">= time",$data['year']."-1-1 00:00:00"];
|
||
}
|
||
if(isset($data['keywords'])&&$data['keywords']!=''){
|
||
$where['t_user.account|t_user.email|t_user.realname'] = ['like',"%".trim($data['keywords'])."%"];
|
||
}
|
||
if(isset($data['fieldkey'])&&$data['fieldkey']!=''){
|
||
$fk = str_replace(";",";",trim($data['fieldkey']));
|
||
$farr = explode(";",$fk);
|
||
$ws = [];
|
||
foreach($farr as $val){
|
||
$ws[] = ['like',"%".$val."%"];
|
||
}
|
||
$where['t_user_reviewer_info.field'] = count($ws)>1?$ws:$ws[0];
|
||
}
|
||
$order = '';
|
||
if(isset($data['order_remark'])&&$data['order_remark']==1){
|
||
$order = "t_user.remark desc,t_user.score desc";
|
||
}else{
|
||
$order = "t_user.score desc";
|
||
}
|
||
$list = $this->user_to_yboard_obj
|
||
->field("t_user.account,t_user.realname,t_user.email,t_user.score,t_user.remark,t_user.wos_index,t_user.wos_time,t_user.google_index,t_user.google_time,t_user_reviewer_info.field,t_user_reviewer_info.company,t_user_to_yboard.*")
|
||
->join("t_user",'t_user.user_id = t_user_to_yboard.user_id','left')
|
||
->join("t_user_reviewer_info",'t_user_reviewer_info.reviewer_id = t_user.user_id','left')
|
||
->where($where)
|
||
->group("t_user_to_yboard.user_id")
|
||
->order($order)
|
||
->limit($limit_start,$data['pageSize'])
|
||
->select();
|
||
//总结时间段
|
||
foreach($list as $k=>$v){
|
||
$ca_list = $this->user_to_yboard_obj->where("journal_id",$data['journal_id'])->where('user_id',$v['user_id'])->where('state',0)->select();
|
||
$ca_arr = [];
|
||
foreach($ca_list as $val){
|
||
$c['start_date'] = $val['start_date'];
|
||
$c['end_date'] = $val['end_date'];
|
||
$ca_arr[] = $c;
|
||
}
|
||
$list[$k]['sd'] = $ca_arr;
|
||
}
|
||
$count = $this->user_to_yboard_obj->join("t_user",'t_user.user_id = t_user_to_yboard.user_id','left')->join("t_user_reviewer_info",'t_user_reviewer_info.reviewer_id = t_user.user_id','left')->where($where)->count();
|
||
$re['yboards'] = $list;
|
||
$re['count'] = $count;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 用户评价
|
||
*/
|
||
public function userScore1(){
|
||
die();
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'num'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
// $user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
// if(!$user_info){
|
||
// return jsonError("user not has");
|
||
// }
|
||
$limit_start = ($data['num'] - 1) * 500;
|
||
$list = $this->article_obj
|
||
->field("t_article.*,t_journal.level")
|
||
->join("t_journal","t_article.journal_id = t_journal.journal_id",'left')
|
||
->where('t_article.state',5)
|
||
->limit($limit_start,500)
|
||
->select();
|
||
foreach($list as $v){
|
||
$check = $this->user_obj->where('user_id',$v['user_id'])->find();
|
||
if(!$check){
|
||
continue;
|
||
}
|
||
if($v['journal_id']==1&&$v['ctime']<1609430400){
|
||
continue;
|
||
}
|
||
if(($v['journal_id']==12||$v['journal_id']==9||$v['journal_id']==7||$v['journal_id']==16)&&$v['ctime']<1672502400){
|
||
continue;
|
||
}
|
||
if(($v['journal_id']==18||$v['journal_id']==21)&&$v['ctime']<1696089600){
|
||
continue;
|
||
}
|
||
if($v['journal_id']!=1&&$v['journal_id']!=12&&$v['journal_id']!=9&&$v['journal_id']!=7&&$v['journal_id']!=16&&$v['journal_id']!=18&&$v['journal_id']!=21&&$v['ctime']<1659283200){
|
||
continue;
|
||
}
|
||
$score = 0;
|
||
if($v['level']=='A'){
|
||
$score=1;
|
||
}elseif($v['level']=='B'){
|
||
$score=0.5;
|
||
}else{
|
||
$score=0.2;
|
||
}
|
||
addUserScoreLog($v['user_id'],$score,"add score ".$score." for submit article :".$v['accept_sn'],$v['ctime']);
|
||
$this->user_obj->where('user_id',$v['user_id'])->setInc('score',$score);
|
||
}
|
||
dump($list);
|
||
|
||
}
|
||
|
||
/**
|
||
*
|
||
*/
|
||
public function userScore2(){
|
||
die();
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'num'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
// $user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
// if(!$user_info){
|
||
// return jsonError("user not has");
|
||
// }
|
||
$limit_start = ($data['num'] - 1) * 500;
|
||
$list = $this->article_reviewer_obj
|
||
->field("t_article_reviewer.*,t_journal.level,t_journal.journal_id")
|
||
->join('t_article','t_article.article_id = t_article_reviewer.article_id','left')
|
||
->join('t_journal','t_journal.journal_id=t_article.journal_id','left')
|
||
->where('t_article_reviewer.state','in',[1,2,3])
|
||
->limit($limit_start,500)
|
||
->select();
|
||
|
||
foreach($list as $v){
|
||
$check = $this->user_obj->where('user_id',$v['reviewer_id'])->find();
|
||
if(!$check){
|
||
continue;
|
||
}
|
||
if($v['journal_id']==1&&$v['ctime']<1609430400){
|
||
continue;
|
||
}
|
||
if(($v['journal_id']==12||$v['journal_id']==9||$v['journal_id']==7||$v['journal_id']==16)&&$v['ctime']<1672502400){
|
||
continue;
|
||
}
|
||
if(($v['journal_id']==18||$v['journal_id']==21)&&$v['ctime']<1696089600){
|
||
continue;
|
||
}
|
||
if($v['journal_id']!=1&&$v['journal_id']!=12&&$v['journal_id']!=9&&$v['journal_id']!=7&&$v['journal_id']!=16&&$v['journal_id']!=18&&$v['journal_id']!=21&&$v['ctime']<1659283200){
|
||
continue;
|
||
}
|
||
$score = 0;
|
||
if($v['level']=='A'){
|
||
$score = 0.2;
|
||
// }elseif($v['level']=="B"){
|
||
// $score = 0.2;
|
||
}else{
|
||
$score = 0.1;
|
||
}
|
||
addUserScoreLog($v['reviewer_id'],$score,"add score ".$score." for submit article",$v['ctime']);
|
||
$this->user_obj->where('user_id',$v['reviewer_id'])->setInc('score',$score);
|
||
}
|
||
dump($list);
|
||
}
|
||
|
||
public function addIndexApply(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'journal_id'=>'require',
|
||
'local_doi'=>'require',
|
||
'pub_doi'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
$insert['user_id'] = $data['user_id'];
|
||
$insert['local_doi'] = $data['local_doi'];
|
||
$insert['pub_doi'] = $data['pub_doi'];
|
||
$insert['ctime'] = time();
|
||
$this->user_index_log_obj->insert($insert);
|
||
$score = 0;
|
||
if($journal_info['level']=='A'){
|
||
$score = 0.5;
|
||
}elseif($journal_info['level']=="B"){
|
||
$score = 0.2;
|
||
}else{
|
||
$score = 0.1;
|
||
}
|
||
addUserScoreLog($data['user_id'],$score,"add score ".$score." for cite a manuscript",time());
|
||
$this->user_obj->where('user_id',$data['user_id'])->setInc('score',$score);
|
||
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取作者库列表
|
||
*/
|
||
public function getAuthorUserList(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'journal_id' => 'require',
|
||
'pageIndex' => 'require',
|
||
'pageSize' => 'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
$where['t_user_author.journal_title'] = $journal_info['title'];
|
||
$where['t_user_author.state'] = 0;
|
||
if(isset($data['major'])&&$data['major']!=0){
|
||
$where['t_user_reviewer_info.major'] = $data['major'];
|
||
}
|
||
if(isset($data['keywords'])&&trim($data['keywords'])!=''){
|
||
$where['t_user.account|t_user.email|t_user.realname'] = ['like',"%".trim($data['keywords'])."%"];
|
||
}
|
||
$list = $this->user_author_obj
|
||
->join([['t_user','t_user.user_id = t_user_author.user_id','left'],['t_user_reviewer_info','t_user_reviewer_info.reviewer_id=t_user.user_id','left']])
|
||
->where($where)
|
||
->page($data['pageIndex'],$data['pageSize'])
|
||
->group("t_user_author.user_id")
|
||
->select();
|
||
$count = $this->user_author_obj->join([['t_user','t_user.user_id = t_user_author.user_id','left'],['t_user_reviewer_info','t_user_reviewer_info.reviewer_id=t_user.user_id','left']])->where($where)->group("t_user_author.user_id")->count();
|
||
|
||
foreach($list as $k=>$v){
|
||
$ca = $this->user_author_obj->where('user_id',$v['user_id'])->where('state',0)->select();
|
||
$carr = [];
|
||
foreach($ca as $val){
|
||
$a = $this->journal_obj->where('title',$val['journal_title'])->find();
|
||
$c['journal_abbr'] = $a['abbr'];
|
||
$c['doi'] = $val['w_article_doi'];
|
||
$c['link'] = "https://www.tmrjournals.com/article.html?J_num=".$a['web_journal_id']."&a_id=".$val['w_article_id'];
|
||
$carr[] = $c;
|
||
}
|
||
$list[$k]['art_detail'] = $carr;
|
||
$list[$k]['major_str'] = getMajorStr($v['major']);
|
||
}
|
||
|
||
$re['list'] = $list;
|
||
$re['count'] = $count;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 编辑用户指数信息
|
||
*/
|
||
public function editUserMsg(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'realname'=>'require',
|
||
'wos_index'=>'require',
|
||
'google_index'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
$updata = [];
|
||
if($data['wos_index']!=$user_info['wos_index']){
|
||
$updata['wos_index'] = $data['wos_index'];
|
||
$updata['wos_time'] = time();
|
||
}
|
||
if($data['google_index']!=$user_info['google_index']){
|
||
$updata['google_index'] = $data['google_index'];
|
||
$updata['google_time'] = time();
|
||
}
|
||
$updata['realname'] = trim($data['realname']);
|
||
$updata['localname'] = trim($data['localname']);
|
||
if(count($updata)>0){
|
||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||
}
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 编辑灰库人员信息
|
||
*/
|
||
public function editAshUser(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'ash_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$updata = [];
|
||
if(isset($data['name'])){
|
||
$updata['name'] = trim($data['name']);
|
||
}
|
||
if(isset($data['email'])){
|
||
$updata['email'] = trim($data['email']);
|
||
}
|
||
if(isset($data['field'])){
|
||
$updata['field'] = trim($data['field']);
|
||
}
|
||
if(isset($data['intro'])){
|
||
$updata['intro'] = trim($data['intro']);
|
||
}
|
||
if(isset($data['remark'])){
|
||
$updata['remark'] = trim($data['remark']);
|
||
}
|
||
if(isset($data['company'])){
|
||
$updata['company'] = trim($data['company']);
|
||
}
|
||
if(isset($data['country'])){
|
||
$updata['country'] = $data['country'];
|
||
}
|
||
if(isset($data['major'])){
|
||
$updata['major'] = $data['major'];
|
||
}
|
||
if(isset($data['title'])){
|
||
$updata['title'] = $data['title'];
|
||
}
|
||
$this->user_ash_obj->where('ash_id',$data['ash_id'])->update($updata);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
public function researchAshUser(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'pageIndex'=>'require',
|
||
'pageSize'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$where['state']=0;
|
||
if(isset($data['major'])&&$data['major']!=0){
|
||
$where_mids = self::majorids($data['major']);
|
||
$where['major'] = ['in',$where_mids];
|
||
}
|
||
if(isset($data['keywords'])&&$data['keywords']!=''){
|
||
$where['name|email|intro|company'] = ['like',"%".trim($data['keywords'])."%"];
|
||
}
|
||
if(isset($data['title'])&&$data['title']!="all"){
|
||
$where['title'] = $data['title'];
|
||
}
|
||
if(isset($data['fieldkey'])&&$data['fieldkey']!=''){
|
||
$fk = str_replace(";",";",$data['fieldkey']);
|
||
$farr = explode(";",$fk);
|
||
$ws = [];
|
||
foreach($farr as $val){
|
||
$ws[] = ['like',"%".$val."%"];
|
||
}
|
||
$where['field'] = count($ws)>1?$ws:$ws[0];
|
||
}
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$list = $this->user_ash_obj->where($where)->limit($limit_start,$data['pageSize'])->select();
|
||
$count = $this->user_ash_obj->where($where)->count();
|
||
|
||
foreach($list as $k=>$v){
|
||
if($v['major']==0){
|
||
$list[$k]['major_str'] = '';
|
||
$list[$k]['major_shu'] = 0;
|
||
continue;
|
||
}
|
||
$list[$k]['major_str'] = trim(self::getMajorStr($v['major']),'>');
|
||
$list[$k]['major_shu'] = self::getMajorShu($v['major']);
|
||
}
|
||
|
||
$re['data']=$list;
|
||
$re['count'] = $count;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 添加灰库用户单个
|
||
*/
|
||
public function addAshUser(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'name'=>'require',
|
||
'email'=>'require',
|
||
'major'=>'require',
|
||
'company'=>'require',
|
||
'field'=>'require',
|
||
'title'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$check1 = $this->user_obj->where('email',$data['email'])->find();
|
||
if($check1){
|
||
return jsonError("用户存在于正式库");
|
||
}
|
||
$check2 = $this->user_ash_obj->where('email',$data['email'])->find();
|
||
if($check2){
|
||
return jsonError("用户存在于灰库");
|
||
}
|
||
|
||
$insert['name']=trim($data['name']);
|
||
$insert['email']=trim($data['email']);
|
||
$insert['major']=$data['major'];
|
||
$insert['company']=trim($data['company']);
|
||
$insert['field'] = trim($data['field']);
|
||
$insert['intro'] = isset($data['intro'])?trim($data['intro']):'';
|
||
$insert['country'] = isset($data['country'])?trim($data['country']):'';
|
||
$insert['title'] = trim($data['title']);
|
||
$insert['ctime'] = time();
|
||
$this->user_ash_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 灰库导入excel用户
|
||
*/
|
||
public function importExcelUser(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
// 'users'=>'require|array'
|
||
'file'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$ds = self::readExcel($data['file']);
|
||
$frag_suc = [];
|
||
$frag_err = [];
|
||
$title_arr = ['Prof','Associate Prof.','Assistant Prof.','Ph.D.','Researcher','Researcher','Associate research fellow','Assistant research fellow','Engineer','Senior engineer'];
|
||
foreach($ds as $v){
|
||
if(!$v['email']||!isset($v['field'])||!isset($v['company'])){
|
||
$v['msg'] = '信息不全或错误';
|
||
$frag_err[] = $v;
|
||
continue;
|
||
}
|
||
if($v['title']!=''&&!in_array($v['title'],$title_arr)){
|
||
$v['msg'] = 'title信息错误';
|
||
$frag_err[] = $v;
|
||
continue;
|
||
}
|
||
$check1 = $this->user_obj->where('email',trim($v['email']))->find();
|
||
if($check1){
|
||
$v['msg'] = '用户存在正式库';
|
||
$frag_err[] = $v;
|
||
continue;
|
||
}
|
||
$check2 = $this->user_ash_obj->where('email',trim($v['email']))->find();
|
||
if($check2){
|
||
$v['msg'] = "用户存在于灰库";
|
||
$frag_err[] = $v;
|
||
continue;
|
||
}
|
||
$insert['name'] = $v['name'];
|
||
$insert['email'] = trim($v['email']);
|
||
$major_res=$this->major_obj->where('major_title',trim($v['major']))->find();
|
||
$major_id = 0;
|
||
if($major_res){
|
||
$major_id = $major_res['major_id'];
|
||
}
|
||
$insert['major'] = $major_id;
|
||
$insert['field'] = trim($v['field']);
|
||
$insert['company'] = trim($v['company']);
|
||
$insert['intro'] = isset($v['intro'])?trim($v['intro']):'';
|
||
$insert['title'] = trim($v['title']);
|
||
$insert['remark'] = isset($v['remark'])?trim($v['remark']):'';
|
||
$insert['ctime'] = time();
|
||
$this->user_ash_obj->insert($insert);
|
||
$frag_suc[] = $v;
|
||
}
|
||
|
||
$re['suc'] = $frag_suc;
|
||
$re['err'] = $frag_err;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
|
||
public function upImportFile(){
|
||
$file = request()->file('userFile');
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . "userFile");
|
||
if ($info) {
|
||
$r = self::readExcel($info->getSaveName());
|
||
$re['data'] = $r;
|
||
$re['file'] = str_replace("\\", "/", $info->getSaveName());
|
||
return jsonSuccess($re);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
|
||
private function readExcel($file){
|
||
$afile = ROOT_PATH . 'public' . DS . "userFile".DS.$file;
|
||
$extension = substr($afile, strrpos($afile, '.') + 1);
|
||
vendor("PHPExcel.PHPExcel");
|
||
if ($extension == 'xlsx') {
|
||
$objReader = new \PHPExcel_Reader_Excel2007();
|
||
$objPHPExcel = $objReader->load($afile);
|
||
} else if ($extension == 'xls') {
|
||
$objReader = new \PHPExcel_Reader_Excel5();
|
||
$objPHPExcel = $objReader->load($afile);
|
||
}
|
||
$sheet = $objPHPExcel->getSheet(0);
|
||
$highestRow = $sheet->getHighestRow();
|
||
$frag = [];
|
||
for ($i = 2; $i <= $highestRow; $i++) {
|
||
if($objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue()==''){
|
||
continue ;
|
||
}
|
||
$aa['name'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
|
||
$aa['email'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue();
|
||
$aa['major'] = $objPHPExcel->getActiveSheet()->getCell("C" . $i)->getValue();
|
||
$aa['field'] = $objPHPExcel->getActiveSheet()->getCell("D" . $i)->getValue();
|
||
$aa['intro'] = $objPHPExcel->getActiveSheet()->getCell("E" . $i)->getValue();
|
||
$aa['company'] = $objPHPExcel->getActiveSheet()->getCell("F" . $i)->getValue();
|
||
$aa['title'] = trim($objPHPExcel->getActiveSheet()->getCell("G" . $i)->getValue());
|
||
$aa['remark'] = $objPHPExcel->getActiveSheet()->getCell("H" . $i)->getValue();
|
||
// $aa['username'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
|
||
// $aa['has'] = '未出证';
|
||
// if($aa['username']==''){
|
||
// continue;
|
||
// }
|
||
$frag[] = $aa;
|
||
|
||
}
|
||
return $frag;
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 获取所有用户
|
||
* @description 获取所有用户
|
||
* @author wangjinlei
|
||
* @url /api/User/getAllUser
|
||
* @method POST
|
||
*
|
||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||
* @param name:username type:string require:1 desc:用户名或邮箱
|
||
* @param name:role type:string require:1 desc:0:全部1:editor2:reviewer3:board
|
||
*
|
||
* @return users:用户列表#
|
||
* @return count:总数
|
||
*/
|
||
public function getAllUser()
|
||
{
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'pageIndex'=>'require',
|
||
'pageSize'=>'require',
|
||
'role'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$black_list = $this->user_black_obj->where('black_state', 0)->column("user_id");
|
||
$frag = [];
|
||
$count = 0;
|
||
$where = [];
|
||
$where['state'] = 0;
|
||
// $where['user_id'] = ['not in',$black_list];
|
||
if ($data['username'] != "") {
|
||
$where["account|email"] = ['like','%' . trim($data['username'] . '%')];
|
||
}
|
||
if($data['role']==1){
|
||
$where['type'] = 2;
|
||
}elseif($data['role']==2){
|
||
$c = $this->reviewer_to_journal_obj->where('state',0)->column('reviewer_id');
|
||
$where['user_id'] = ['in',$c];
|
||
}elseif($data['role']==3){
|
||
$cc = $this->board_to_journal_obj->where('state',0)->column('user_id');
|
||
$where['user_id'] = ['in',$cc];
|
||
}
|
||
|
||
|
||
if(isset($where['user_id'])){
|
||
$where['user_id'] = [['not in',$black_list],$where['user_id']];
|
||
}else{
|
||
$where['user_id'] = ['not in',$black_list];
|
||
}
|
||
|
||
$frag = $this->user_obj->where($where)->limit($limit_start, $data['pageSize'])->select();
|
||
$count = $this->user_obj->where($where)->count();
|
||
|
||
|
||
foreach ($frag as $k => $v) {
|
||
$frag[$k]['roles'] = $this->getUserRoles($v['account']);
|
||
}
|
||
$re['users'] = $frag;
|
||
$re['count'] = $count;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 拉黑用户
|
||
* @description 拉黑用户
|
||
* @author wangjinlei
|
||
* @url /api/User/pushUserToBlack
|
||
* @method POST
|
||
*
|
||
* @param name:user_id type:int require:1 desc:用户id
|
||
* @param name:reason type:string require:1 desc:拉黑原因
|
||
*
|
||
*/
|
||
public function pushUserToBlack()
|
||
{
|
||
$data = $this->request->post();
|
||
$check_black = $this->user_black_obj->where('user_id', $data['user_id'])->where('black_state', 0)->find();
|
||
if ($check_black) {
|
||
return jsonError("repeat !");
|
||
}
|
||
$insert['user_id'] = $data['user_id'];
|
||
$insert['reason'] = trim($data['reason']);
|
||
$insert['black_ctime'] = time();
|
||
$this->user_black_obj->insert($insert);
|
||
return jsonSuccess($data);
|
||
}
|
||
|
||
/**
|
||
* @title 获取黑名单列表
|
||
* @description 获取黑名单列表
|
||
* @author wangjinlei
|
||
* @url /api/User/getUserBlackList
|
||
* @method POST
|
||
*
|
||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||
*
|
||
* @return blacks:黑名单列表#
|
||
* @return count:总数
|
||
*/
|
||
public function getUserBlackList()
|
||
{
|
||
$data = $this->request->post();
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$list = $this->user_black_obj
|
||
->field("t_user.account,t_user.email,t_user.realname,t_user_black.*")
|
||
->join('t_user', 't_user.user_id = t_user_black.user_id', 'left')
|
||
->where('t_user_black.black_state', 0)
|
||
->limit($limit_start, $data['pageSize'])->select();
|
||
$count = $this->user_black_obj->where('black_state', 0)->count();
|
||
$re['blacks'] = $list;
|
||
$re['count'] = $count;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
public function getBoardApplys(){
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'editor_id' => 'require'
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$ids = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
|
||
$list = $this->apply_board_obj
|
||
->field("t_journal.title,t_apply_board.*,t_user.account,t_user.email,t_user.realname")
|
||
->join("t_journal",'t_journal.journal_id = t_apply_board.journal_id','left')
|
||
->join("t_user","t_user.user_id = t_apply_board.user_id",'left')
|
||
->where('t_apply_board.journal_id','in',$ids)->where('t_apply_board.state',0)->select();
|
||
$re['applys'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
public function delBoardApply(){
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'ap_board_id' => 'require'
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$this->apply_board_obj->where('ap_board_id',$data['ap_board_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
public function getYboardApplys(){
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'editor_id' => 'require'
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$ids = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
|
||
$list = $this->apply_yboard_obj
|
||
->field("t_journal.title,t_apply_yboard.*,t_user.account,t_user.email,t_user.realname")
|
||
->join("t_journal",'t_journal.journal_id = t_apply_yboard.journal_id','left')
|
||
->join("t_user","t_user.user_id = t_apply_yboard.user_id",'left')
|
||
->where('t_apply_yboard.journal_id','in',$ids)->where('t_apply_yboard.state',0)->select();
|
||
$re['applys'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
// public function delYboardApply(){
|
||
// $data = $this->request->post();
|
||
// $rules = new Validate([
|
||
// 'ap_yboard_id' => 'require'
|
||
// ]);
|
||
// if (!$rules->check($data)) {
|
||
// return jsonError($rules->getError());
|
||
// }
|
||
// $this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
|
||
// return jsonSuccess([]);
|
||
// }
|
||
|
||
/**
|
||
* 同意青年科学家申请
|
||
*/
|
||
public function agreeYboardApply(){
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'ap_yboard_id' => 'require',
|
||
'year'=>'require'
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$start_time = time();
|
||
$app_info = $this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->find();
|
||
$user_info = $this->user_obj->where('user_id',$app_info['user_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$app_info['journal_id'])->find();
|
||
$check = $this->user_to_yboard_obj->where('user_id',$app_info['user_id'])->where('journal_id',$app_info['journal_id'])->where('start_date',"<=",$start_time)->where('end_date',">=",$start_time)->find();
|
||
if($check){
|
||
return jsonError("Already exists");
|
||
}
|
||
$icon = self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||
$insert['user_id'] = $app_info['user_id'];
|
||
$insert['journal_id'] = $app_info['journal_id'];
|
||
$insert['start_date'] = $start_time;
|
||
$insert['end_date'] = strtotime("+ ".$data['year']." year",$start_time);
|
||
$insert['icon'] = $icon;
|
||
$insert['ctime'] = $start_time;
|
||
$this->user_to_yboard_obj->insert($insert);
|
||
$this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 添加作者用户
|
||
*/
|
||
public function addUserForAuthor(){
|
||
die("service stop!!");
|
||
$num = $this->request->post('num');
|
||
// $num =1;
|
||
$cs['num'] = $num;
|
||
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleReportAuthors';
|
||
$list = object_to_array(json_decode(myPost($url, $cs)));
|
||
$count = 0;
|
||
foreach($list['data']['list'] as $v){
|
||
if(!isset($v['author'])||!is_array($v['author'])){
|
||
echo 'ok';
|
||
continue;
|
||
}
|
||
foreach($v['author'] as $val){
|
||
$check_user = $this->user_obj->where('email',$val['email'])->where('state',0)->find();
|
||
if(!$check_user){
|
||
$ui['account'] = $val['email'];
|
||
$ui['password'] = md5("123456qwe");
|
||
$ui['email'] = $val['email'];
|
||
$ui['realname'] = $val['author_name'];
|
||
$ui['ctime'] = time();
|
||
$uid = $this->user_obj->insertGetId($ui);
|
||
$uir['reviewer_id'] = $uid;
|
||
$uir['country'] = trim($val['author_country']);
|
||
$this->user_reviewer_info_obj->insert($uir);
|
||
$check_user = $this->user_obj->where('user_id',$uid)->find();
|
||
}
|
||
$iau['user_id'] = $check_user['user_id'];
|
||
$iau['w_article_id'] = $v['article_id'];
|
||
$iau['w_article_doi'] = $v['doi'];
|
||
$iau['journal_title'] = $v['journal_title'];
|
||
$this->user_author_obj->insert($iau);
|
||
}
|
||
$count++;
|
||
}
|
||
return jsonSuccess(['count'=>$count]);
|
||
}
|
||
|
||
/**
|
||
* 拒绝青年科学家申请
|
||
*/
|
||
public function refuseYboardApply(){
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'ap_yboard_id' => 'require'
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$this->apply_yboard_obj->where('ap_yboard_id',$data['ap_yboard_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 添加用户
|
||
*/
|
||
public function addUser()
|
||
{
|
||
$data = $this->request->post();
|
||
$rules = new Validate([
|
||
'account' => 'require|alphaNum|min:5',
|
||
'email' => 'require|email',
|
||
'password' => 'require',
|
||
]);
|
||
if (!$rules->check($data)) {
|
||
return jsonError($rules->getError());
|
||
}
|
||
$check = $this->user_obj
|
||
->where('state', 0)
|
||
->where('account = "' . trim($data['account']) . '" or email = "' . trim($data['email']) . '"')
|
||
->find();
|
||
if ($check) {
|
||
return jsonError('The user already exists');
|
||
}
|
||
$inser_data['account'] = $data['account'];
|
||
$inser_data['password'] = md5($data['password']);
|
||
$inser_data['email'] = $data['email'];
|
||
$inser_data['phone'] = isset($data['phone']) ? $data['phone'] : '';
|
||
$inser_data['realname'] = isset($data['realname']) ? $data['realname'] : '';
|
||
$inser_data['ctime'] = time();
|
||
$id = $this->user_obj->insertGetId($inser_data);
|
||
$insert_reviewer['reviewer_id'] = $id;
|
||
$this->user_reviewer_info_obj->insert($insert_reviewer);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取所有编辑
|
||
*/
|
||
public function getAllEditor()
|
||
{
|
||
$editors = $this->user_obj->where('type', 2)->where('state', 0)->select();
|
||
//获取编辑管理的期刊
|
||
foreach ($editors as $k => $v) {
|
||
$cache_journals = $this->journal_obj->where('editor_id', $v['user_id'])->where('state', 0)->select();
|
||
$editors[$k]['journals'] = $cache_journals;
|
||
}
|
||
$re['editors'] = $editors;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 修改编辑密码
|
||
*/
|
||
public function changeEditorPassword()
|
||
{
|
||
$data = $this->request->post();
|
||
// 验证规则
|
||
$rule = new Validate([
|
||
'user_id' => 'require|number',
|
||
'password' => 'require'
|
||
]);
|
||
if (!$rule->check($data)) {
|
||
return json(['code' => 1, 'msg' => $rule->getError()]);
|
||
}
|
||
$this->user_obj->where('user_id', $data['user_id'])->update(['password' => md5($data['password'])]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 消除黑名单
|
||
* @description 消除黑名单
|
||
* @author wangjinlei
|
||
* @url /api/User/clearBlack
|
||
* @method POST
|
||
*
|
||
* @param name:black_id type:int require:1 desc:黑名单id
|
||
*
|
||
*/
|
||
public function clearBlack()
|
||
{
|
||
$data = $this->request->post();
|
||
$this->user_black_obj->where("black_id", $data['black_id'])->update(['black_state' => 1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 退订用户的广告邮件
|
||
*/
|
||
public function unAdvertForUser($uid){
|
||
$this->user_obj->where('user_id',$uid)->update(['is_advert'=>1]);
|
||
echo 'Unsubscribe successfully!';
|
||
}
|
||
|
||
/**
|
||
* @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()
|
||
{
|
||
die("service stop!!");
|
||
$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-》编辑
|
||
$sendEditor = [
|
||
'title' => $journal_info['title'], // 邮件标题
|
||
'content' => 'Dear editor,<br> Please check the new reviewer application.', //邮件内容
|
||
'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',$sendEditor,'domail');
|
||
|
||
$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([]);
|
||
}
|
||
|
||
/**
|
||
* 获取用户详细信息
|
||
*/
|
||
public function getUserDetail()
|
||
{
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id' => 'require'
|
||
]);
|
||
if (!$rule->check($data)) {
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->where("user_id", $data['user_id'])->where('state', 0)->find();
|
||
$user_info['roles'] = $this->getUserRoles($user_info['account']);
|
||
//获取用户的客座期刊的详细信息
|
||
$list = $this->user_to_special_obj->where('user_id', $user_info['user_id'])->where('uts_state', 0)->select();
|
||
$specials = [];
|
||
foreach ($list as $k => $v) {
|
||
$cache_info = $this->getSpecialDetailById($v['special_id']);
|
||
$cache_journal = $this->journal_obj->where('issn', $cache_info['journal_issn'])->find();
|
||
$cache_info['journal_id'] = $cache_journal['journal_id'];
|
||
$specials[] = $cache_info;
|
||
}
|
||
|
||
//如果是审稿人的,获取期审稿人的附加信息
|
||
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->where('state',0)->find();
|
||
if($reviewer_info){
|
||
$user_info['company'] = $reviewer_info['company'];
|
||
}
|
||
$user_info['specials'] = $specials;
|
||
$re['user'] = $user_info;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 获取用户所有客座专刊
|
||
*/
|
||
public function getUserAllSpecials()
|
||
{
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id' => 'require'
|
||
]);
|
||
if (!$rule->check($data)) {
|
||
return jsonError($rule->getError());
|
||
}
|
||
$list = $this->user_to_special_obj->where('user_id', $data['user_id'])->where('uts_state', 0)->select();
|
||
$specials = [];
|
||
foreach ($list as $k => $v) {
|
||
$cache_info = $this->getSpecialDetailById($v['special_id']);
|
||
$cache_journal = $this->journal_obj->where('issn', $cache_info['journal_issn'])->find();
|
||
$cache_info['journal_id'] = $cache_journal['journal_id'];
|
||
$specials[] = $cache_info;
|
||
}
|
||
$re['specials'] = $specials;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
|
||
public function getSpecialDetailById($special_id)
|
||
{
|
||
$base_url = Env::get('journal.base_url');
|
||
$api_url = $base_url . "/master/special/getSpecialDetailById";
|
||
$res = object_to_array(json_decode(myPost($api_url, ['journal_special_id' => $special_id])));
|
||
$special_info = $res['data']['special'];
|
||
unset($special_info['journal_id']);
|
||
return $special_info;
|
||
}
|
||
|
||
/**
|
||
* 添加用户身份
|
||
*/
|
||
public function addUserRole()
|
||
{
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id' => 'require',
|
||
'role_type' => 'require'
|
||
]);
|
||
if (!$rule->check($data)) {
|
||
return jsonError($rule->getError());
|
||
}
|
||
if ($data['role_type'] == 'special') {
|
||
if (!isset($data['special_id'])) {
|
||
return jsonError("When adding a passenger editing identity, the passenger ID is required");
|
||
}
|
||
|
||
$check = $this->user_to_special_obj->where("user_id", $data['user_id'])->where('special_id', $data['special_id'])->where('uts_state', 0)->find();
|
||
if ($check) {
|
||
return jsonError("Cannot be added repeatedly");
|
||
}
|
||
$insert_uts['user_id'] = $data['user_id'];
|
||
$insert_uts['special_id'] = $data['special_id'];
|
||
$insert_uts['uts_ctime'] = time();
|
||
$this->user_to_special_obj->insert($insert_uts);
|
||
return jsonSuccess([]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 谷歌测试
|
||
*/
|
||
public function googleTest(){
|
||
Loader::import("google.google-search-results");
|
||
Loader::import("google.restclient");
|
||
// require 'path/to/google-search-results.php';
|
||
// require 'path/to/restclient.php';
|
||
|
||
// $query = [
|
||
// "engine" => "google_scholar",
|
||
// "q" => "biology",
|
||
// ];
|
||
// $query = [
|
||
// "engine" => "google_scholar_author",
|
||
// "author_id" => "YrGbzsEAAAAJ",
|
||
// ];
|
||
|
||
$query = [
|
||
"engine" => "google_scholar_profiles",
|
||
"mauthors" => "biol",
|
||
];
|
||
|
||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||
$result = $search->get_json($query);
|
||
// $organic_results = $result->organic_results;
|
||
$organic_results = $result;
|
||
dump($organic_results);
|
||
}
|
||
|
||
/**
|
||
* 获取google学术人物列表
|
||
*/
|
||
public function googleGetAuthor(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
if($user_info['g_author']!=''||$user_info['realname']==''){
|
||
return jsonError('Google account is tied/Please tied your realname first before proceeding to the next step');
|
||
}
|
||
Loader::import("google.google-search-results");
|
||
Loader::import("google.restclient");
|
||
|
||
$query = [
|
||
"engine" => "google_scholar_profiles",
|
||
"mauthors" => $user_info['realname'],
|
||
];
|
||
|
||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||
$result = $search->get_json($query);
|
||
$organic_results = object_to_array($result);
|
||
|
||
if(isset($organic_results['profiles'])){
|
||
$re['authors'] = $organic_results['profiles'];
|
||
return jsonSuccess($re);
|
||
}else{
|
||
return jsonError('no date');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 绑定谷歌用户id
|
||
*/
|
||
public function googleBindAuthor(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'g_author'=>'require',
|
||
// 'website'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
// $this->user_obj->where('user_id',$data['user_id'])->update(['g_author'=>trim($data['g_author']),'g_website'=>trim($data['website'])]);
|
||
$this->user_obj->where('user_id',$data['user_id'])->update(['g_author'=>trim($data['g_author'])]);
|
||
//绑定完成后自动获取指数
|
||
Loader::import("google.google-search-results");
|
||
Loader::import("google.restclient");
|
||
|
||
$query = [
|
||
"engine" => "google_scholar_author",
|
||
"author_id" => $data['g_author']
|
||
];
|
||
|
||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||
$result = $search->get_json($query);
|
||
$organic_results = object_to_array($result);
|
||
$h_index= 0;
|
||
// if(isset($organic_results['cited_by']['table']['h_index'])){
|
||
$h_index = $organic_results['cited_by']['table'][1]['h_index']['all'];
|
||
// }else{
|
||
// $h_index = $organic_results['cited_by']['table']['indice_h']['all'];
|
||
// }
|
||
|
||
$updata['google_index'] = $h_index;
|
||
$updata['google_time'] = time();
|
||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||
|
||
|
||
return jsonSuccess($organic_results);
|
||
}
|
||
|
||
/**
|
||
* 获取H指数
|
||
*/
|
||
public function googleGetIndex(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
if($user_info['google_time']>strtotime('-1 year')){
|
||
return jsonError('The time interval obtained is one year');
|
||
}
|
||
if($user_info['g_author']==''){
|
||
return jsonError('google_id is null , please bind google_id before the request.');
|
||
}
|
||
Loader::import("google.google-search-results");
|
||
Loader::import("google.restclient");
|
||
|
||
$query = [
|
||
"engine" => "google_scholar_author",
|
||
"author_id" => $user_info['g_author']
|
||
];
|
||
|
||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||
$result = $search->get_json($query);
|
||
$organic_results = object_to_array($result);
|
||
|
||
$h_index= 0;
|
||
// if(isset($organic_results['cited_by']['table']['h_index'])){
|
||
$h_index = $organic_results['cited_by']['table'][1]['h_index']['all'];
|
||
// }else{
|
||
// $h_index = $organic_results['cited_by']['table']['indice_h']['all'];
|
||
// }
|
||
|
||
$updata['google_index'] = $h_index;
|
||
$updata['google_time'] = time();
|
||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||
return jsonSuccess($organic_results);
|
||
}
|
||
|
||
public function getUserScoreLog(){
|
||
|
||
}
|
||
|
||
/**
|
||
* @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';
|
||
// }
|
||
$yboard_res = $this->user_to_yboard_obj->where('user_id',$user_info['user_id'])->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';
|
||
}
|
||
$special_res = $this->user_to_special_obj->where('user_id', $user_info['user_id'])->where("uts_state", 0)->find();
|
||
if ($special_res != null) {
|
||
$roles[] = 'special';
|
||
}
|
||
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]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 查找用户信息byaccountemail
|
||
*/
|
||
public function searchUserByAccountEmail(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'account'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->join('t_user_reviewer_info','t_user_reviewer_info.reviewer_id=t_user.user_id','left')->where('t_user.account|t_user.email',$data['account'])->find();
|
||
$re['user'] = $user_info;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 注册功能
|
||
*/
|
||
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');
|
||
}
|
||
|
||
$code = get_str();
|
||
|
||
Db::startTrans();
|
||
//存入数据
|
||
$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();
|
||
$id = $this->user_obj->insertGetId($inser_data);
|
||
|
||
//存入个人额外信息
|
||
$insert_reviewer['reviewer_id'] = $id;
|
||
$r_res = $this->user_reviewer_info_obj->insert($insert_reviewer);
|
||
|
||
//存储注册验证信息
|
||
$insert_check['user_id'] = $id;
|
||
$insert_check['code'] = $code;
|
||
$insert_check['ctime'] = time();
|
||
$i_res = $this->user_register_check_obj->insert($insert_check);
|
||
|
||
//发送注册成功邮件
|
||
$tt = "Hello,<br><br>";
|
||
$tt .= "To protect the email relationship unobstructed. <br><br>";
|
||
$tt .= "Please verify your email address to complete the account registration:<br><br>";
|
||
$tt .= "<a href='https://submission.tmrjournals.com/login?code=".$code."'>https://submission.tmrjournals.com/login?code=".$code."</a><br><br>";
|
||
$tt .= "Thank you.<br>TMR Publishing Group<br>https://www.tmrjournals.com";
|
||
|
||
if($id&&$i_res&&$r_res){
|
||
Db::commit();
|
||
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt);
|
||
return jsonSuccess([]);
|
||
}else{
|
||
Db::rollback();
|
||
return jsonError("system error");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 审核注册验证码
|
||
*/
|
||
public function checkRegisterCode(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'code'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonSuccess($rule->getError());
|
||
}
|
||
$check_info = $this->user_register_check_obj->where('code',$data['code'])->where('state',0)->find();
|
||
if(!$check_info){
|
||
return jsonError('not find this code');
|
||
}
|
||
$this->user_obj->where('user_id',$check_info['user_id'])->update(['register_check'=>1]);
|
||
$this->user_register_check_obj->where('user_rc_id',$check_info['user_rc_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 获取验证码图片(用户注册)
|
||
*/
|
||
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' => 'fail']);
|
||
}
|
||
}
|
||
|
||
|
||
public function getUserForJournal(){
|
||
$data = $this->request->post();
|
||
$num = $data['num'];
|
||
$limit_start = ($num - 1) * 1000;
|
||
$list = $this->user_obj->limit($limit_start,1000)->select();
|
||
$re['list'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 修改用户备注
|
||
*/
|
||
public function editRemarkForUser(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require|number',
|
||
'remark'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$this->user_obj->where('user_id',$data['user_id'])->update(['remark'=>$data['remark']]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取验证码图片(密码找回)
|
||
*/
|
||
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' => 'Wrong captcha']);
|
||
}
|
||
$res = $this->user_obj
|
||
->where('account|email', $data['username'])
|
||
->find();
|
||
if ($res == null) {
|
||
return json(['code' => 1, 'msg' => 'Incorrect user ID or password']);
|
||
} else {
|
||
return json(['code' => 0, 'email' => $res['email']]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 找回密码第二部,发送邮件
|
||
*/
|
||
public function retrievePushEmail()
|
||
{
|
||
$email = $this->request->post('email');
|
||
$where['email'] = $email;
|
||
$user = $this->user_obj->where($where)->field('realname,user_id')->find();
|
||
$realname = $user['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, Env::get('email.send_email'), Env::get("email.send_email_password"));
|
||
// if ($isUserPushed) {//成功
|
||
return json(['code' => 0, 'msg' => 'success']);
|
||
// } else {//失败
|
||
// return json(['code' => 1, 'msg' => 'fail']);
|
||
// }
|
||
}
|
||
|
||
/**
|
||
* 验证修改密码页面的合法性
|
||
*/
|
||
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' => 'Query failed']);
|
||
} else {
|
||
return json(['code' => 0, 'msg' => 'Query was successful']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 自定义验证验证码
|
||
*/
|
||
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 getApplyReviewerList(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'journal_id'=>'require',
|
||
'editor_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$where['t_apply_reviewer.state'] = 0;
|
||
if($data['journal_id']==0){
|
||
$journalIds = $this->journal_obj->where('editor_id',$data['editor_id'])->column("journal_id");
|
||
$where['t_apply_reviewer.journal_id'] = ['in',$journalIds];
|
||
}else{
|
||
$where['t_apply_reviewer.journal_id'] = $data['journal_id'];
|
||
}
|
||
$list = $this->apply_reviewer_obj
|
||
->field("t_user.*,t_journal.title journal_title,t_apply_reviewer.ap_reviewer_id,t_apply_reviewer.ctime apply_time")
|
||
->join("t_user","t_user.user_id = t_apply_reviewer.user_id",'left')
|
||
->join("t_journal","t_journal.journal_id=t_apply_reviewer.journal_id","left")
|
||
->where($where)
|
||
->select();
|
||
|
||
$re['list'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 同意审稿人身份申请
|
||
*/
|
||
public function agreeReviewerApply(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'ap_reviewer_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$ap_reviewer_info = $this->apply_reviewer_obj->where('ap_reviewer_id',$data['ap_reviewer_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$ap_reviewer_info['journal_id'])->find();
|
||
$user_info = $this->user_obj->where('user_id',$ap_reviewer_info['user_id'])->find();
|
||
$check = $this->reviewer_to_journal_obj->where('reviewer_id',$ap_reviewer_info['user_id'])->where('journal_id',$journal_info['journal_id'])->where('state',0)->find();
|
||
if($check){
|
||
return jsonSuccess([]);
|
||
}
|
||
$insert['reviewer_id'] = $ap_reviewer_info['user_id'];
|
||
$insert['journal_id'] = $journal_info['journal_id'];
|
||
$insert['account'] = $user_info['account'];
|
||
$insert['journal_title'] = $journal_info['title'];
|
||
$insert['ctime'] = time();
|
||
$this->reviewer_to_journal_obj->insert($insert);
|
||
$this->apply_reviewer_obj->where('ap_reviewer_id',$data['ap_reviewer_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 拒绝审稿人申请
|
||
*/
|
||
public function refuseReviewerApply(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'ap_reviewer_id'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$this->apply_reviewer_obj->where('ap_reviewer_id',$data['ap_reviewer_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* 获取审核员申请列表
|
||
*/
|
||
public function getReviewerApplyList()
|
||
{
|
||
die("service stop!!");
|
||
$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()
|
||
{
|
||
die("service stop!!");
|
||
$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!");
|
||
}
|
||
|
||
$check = $this->reviewer_to_journal_obj->where("journal_id", $journal_info['journal_id'])->where('reviewer_id', $user_info['user_id'])->where('state', 0)->find();
|
||
|
||
if ($check) {
|
||
return jsonError("has reviewer");
|
||
}
|
||
|
||
$info_check = $this->user_reviewer_info_obj->where('reviewer_id', $user_info['user_id'])->find();
|
||
|
||
Db::startTrans();
|
||
|
||
$res = true;
|
||
if ($info_check==null) {
|
||
$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()
|
||
{
|
||
die("service stop!!");
|
||
$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'])->whereOr("email", $apply_info['email'])->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) {
|
||
$this->user_reviewer_obj->where($where)->update(['state' => 1]);
|
||
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);
|
||
}else{
|
||
$update_info['gender'] = $apply_info['gender'];
|
||
$update_info['technical'] = $apply_info['technical'];
|
||
$update_info['country'] = $apply_info['country'];
|
||
$update_info['introduction'] = $apply_info['introduction'];
|
||
$update_info['company'] = $apply_info['company'];
|
||
$update_info['major'] = $apply_info['major'];
|
||
$update_info['field'] = $apply_info['field'];
|
||
// $update_info['qualifications'] = $apply_info['qualifications'];
|
||
$this->user_reviewer_info_obj->where('reviewer_id',$has_res['user_id'])->update($update_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>';
|
||
$sendUser = [
|
||
'title' => $journal_info['title'], // 邮件标题
|
||
'content' => $content, //邮件内容
|
||
'user_id' => $has_res['user_id'], //收件人ID
|
||
'email' => $apply_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($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 checkUserByEmail()
|
||
{
|
||
$data = $this->request->post();
|
||
$check_info = $this->user_obj->where("email", $data['email'])->where("state", 0)->find();
|
||
|
||
$re['has'] = $check_info == null ? 0 : 1;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 审查用户通过账号
|
||
*/
|
||
public function checkUserByAccount()
|
||
{
|
||
$data = $this->request->post();
|
||
$check_info = $this->user_obj->where("account", $data['account'])->where("state", 0)->find();
|
||
|
||
$re['has'] = $check_info == null ? 0 : 1;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* 拒绝审核人
|
||
*/
|
||
public function reviewerRejec()
|
||
{
|
||
die("service stop!!");
|
||
$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);
|
||
}
|
||
//确定用户是否属于黑名单
|
||
$black_check = $this->user_black_obj->where('user_id', $user['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.");
|
||
}
|
||
$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);
|
||
}
|
||
|
||
/**
|
||
* 添加用户证书
|
||
*/
|
||
public function addUserCert(){
|
||
die("service stop");
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
'user_id'=>'require',
|
||
'journal_id'=>'require',
|
||
'year'=>'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
// $check = $this->user_cert_obj->where('user_id',$data['user_id'])->where('type',$data['type'])->where('journal_id',$data['journal_id'])->where('year',$data['year'])->where('state',0)->find();
|
||
// if($check){
|
||
// return jsonError("Certificate cannot be issued repeatedly");
|
||
// }
|
||
$start_time = time();
|
||
// $this->createCert($user_info,$journal_info,$data['year'],$data['type']);
|
||
self::createYboardCert($user_info,$journal_info,$start_time,$data['year']);
|
||
|
||
$insert['user_id']=$data['user_id'];
|
||
$insert['journal_id'] = $data['journal_id'];
|
||
// $insert['type'] = $data['type'];
|
||
$insert['start_date'] = $start_time;
|
||
$insert['end_date'] = strtotime("+ ".$data['year'].' year',$start_time);//date("+ ".$data['year']." year",$start_time);
|
||
$insert['url'] = "/cert/".$data['user_id'].'_yboard_'.$data['year'] . '.png';
|
||
$insert['ctime'] = $start_time;
|
||
// $this->user_cert_obj->insert($insert);
|
||
|
||
return jsonSuccess($insert);
|
||
}
|
||
|
||
|
||
// private function createCert($user_info,$journal_info,$year,$type){
|
||
// //type:1编委,2青年科学家
|
||
// $template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'cert_template.png';
|
||
// $ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
|
||
// $image = \think\Image::open($template);
|
||
|
||
// $image->text($user_info['realname'], $ziti, 50, '#000000', [1060, 760])
|
||
// ->text($year, $ziti, 50, '#C49A6C', [1850, 505])
|
||
// ->text($year, $ziti, 36, '#C49A6C', [1665, 1052])
|
||
// ->text($journal_info['title'], $ziti, 36, '#C49A6C', [920, 980])
|
||
// ->save(ROOT_PATH . 'public' . DS . 'cert' . DS . $user_info['user_id'].'_'.$type.'_'.$year . '.png');
|
||
// return $user_info['user_id'].'_'.$type.'_'.$year . '.png';
|
||
// }
|
||
|
||
/**
|
||
* 注册绑定orcid至我们的账户
|
||
*/
|
||
public function orcidRegister()
|
||
{
|
||
$data = $this->request->post();
|
||
$cache = Cache::get($data['orcid']);
|
||
$res = $this->object2array(json_decode($cache));
|
||
|
||
$check1 = $this->user_obj->where("account", trim($data['username']))->where("state", 0)->find();
|
||
$check2 = $this->user_obj->where("email", trim($data['email']))->where("state", 0)->find();
|
||
if ($check1 || $check2) {
|
||
return jsonError("User has registed");
|
||
}
|
||
|
||
$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;
|
||
}
|
||
}
|