This commit is contained in:
王金磊
2023-03-30 11:44:37 +08:00
parent 34494929a6
commit e4be850ba1
14 changed files with 625 additions and 910 deletions

View File

@@ -2,7 +2,7 @@
namespace app\api\controller;
use think\Controller;
use app\api\controller\Base;
use think\Db;
use think\captcha;
use think\Cache;
@@ -15,67 +15,12 @@ use think\Validate;
* @title 用户相关接口
* @description 用户相关接口
*/
class User extends Controller
class User extends Base
{
protected $user_obj = '';
protected $captcha_obj = '';
protected $article_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 = '';
protected $user_black_obj = '';
protected $user_to_special_obj = '';
protected $user_register_check_obj = '';
protected $user_cert_obj = '';
protected $apply_board_obj = '';
protected $apply_yboard_obj = '';
protected $user_score_log_obj = '';
protected $user_index_log_obj = '';
protected $article_reviewer_obj = '';
protected $user_ash_obj = '';
protected $major_obj = '';
protected $user_to_yboard_obj = '';
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
$this->user_obj = Db::name('user');
$this->captcha_obj = Db::name('captcha');
$this->article_obj = Db::name('article');
$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');
$this->user_black_obj = Db::name('user_black');
$this->user_to_special_obj = Db::name('user_to_special');
$this->user_register_check_obj = Db::name('user_register_check');
$this->user_cert_obj = Db::name('user_cert');
$this->apply_board_obj = Db::name('apply_board');
$this->apply_yboard_obj = Db::name('apply_yboard');
$this->user_score_log_obj = Db::name('user_score_log');
$this->user_index_log_obj = Db::name('user_index_log');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->user_ash_obj = Db::name('user_ash');
$this->major_obj = Db::name('major');
$this->user_to_yboard_obj = Db::name('user_to_yboard');
}
public function pstest(){
@@ -601,27 +546,8 @@ class User extends Controller
return jsonSuccess($re);
}
private function majorids($major_id){
$frag[]=$major_id;
$list = $this->major_obj->where('pid',$major_id)->select();
foreach($list as $v){
$cache = self::majorids($v['major_id']);
$frag = array_merge($frag,$cache);
}
return $frag;
}
private function getMajorShu($major){
if($major==0){
return '';
}
$res = $this->major_obj->where('major_id',$major)->find();
if($res['pid']==1){
return $res['major_id'];
}
$p = self::getMajorShu($res['pid']);
return $p.','.$res['major_id'];
}
/**
* 添加灰库用户单个
@@ -662,20 +588,7 @@ class User extends Controller
}
private function getMajorStr($major_id)
{
$frag = '';
$major_info = $this->major_obj->where('major_id', $major_id)->find();
if ($major_info == null) {
return '';
}
if ($major_info['major_level'] == 1) {
return 'Medicine';
} else {
$frag = $this->getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title'];
}
return $frag;
}
/**
* 灰库导入excel用户
@@ -987,7 +900,7 @@ class User extends Controller
$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();
$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");
}
@@ -1003,6 +916,37 @@ class User extends Controller
return jsonSuccess([]);
}
/**
* 添加作者用户
*/
public function addUserForAuthor(){
$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)));
dump($list);
// foreach($list as $v){
// 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'] = $val['author_country'];
// $this->user_reviewer_info_obj->insert($uir);
// $check_user = $this->user_obj->where('user_id',$uid)->find();
// }
// }
// }
}
/**
* 拒绝青年科学家申请
*/
@@ -1481,9 +1425,13 @@ class User extends Controller
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->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) {
@@ -2119,7 +2067,7 @@ class User extends Controller
$insert_info['company'] = $apply_info['company'];
$insert_info['major'] = $apply_info['major'];
$insert_info['field'] = $apply_info['field'];
$insert_info['qualifications'] = $apply_info['qualifications'];
// $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 {
@@ -2134,8 +2082,18 @@ class User extends Controller
$insert_info['company'] = $apply_info['company'];
$insert_info['major'] = $apply_info['major'];
$insert_info['field'] = $apply_info['field'];
$insert_info['qualifications'] = $apply_info['qualifications'];
// $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;
@@ -2436,37 +2394,21 @@ class User extends Controller
return jsonSuccess($insert);
}
private function createYboardCert($user_info,$journal_info,$start_time,$year){
if(!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'])){
mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id']);
}
$sj_num = rand(1000,9999);
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'yboard_template.png';
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
$ziti1 = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'Georgia0.ttf';
$image = \think\Image::open($template);
$ys = date("F Y",$start_time)." to ".date("F Y",strtotime("+ ".$year." year",$start_time));
$image->text($user_info['realname'], $ziti, 45, '#000000', [1060, 750])
->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015])
->text(date("Y.m.d",$start_time), $ziti, 25, '#000000', [500, 1280])
->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930])
->save(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'].DS. $user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png');
return $journal_info['journal_id'].DS.$user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png';
}
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);
// 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';
}
// $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至我们的账户