From 34494929a6f3ed95f5838e5849d3966492650759 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E9=87=91=E7=A3=8A?= <751475802@qq.com>
Date: Fri, 17 Mar 2023 15:06:31 +0800
Subject: [PATCH] 1
---
application/api/controller/Article.php | 8 +-
application/api/controller/Board.php | 1 +
application/api/controller/Journal.php | 11 +
application/api/controller/Production.php | 7 +
application/api/controller/Ucenter.php | 34 +-
application/api/controller/User.php | 567 +++++++++++++++++++++-
6 files changed, 606 insertions(+), 22 deletions(-)
diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php
index c8cfebc..c6b32a8 100644
--- a/application/api/controller/Article.php
+++ b/application/api/controller/Article.php
@@ -939,12 +939,12 @@ class Article extends Controller
$h_check = false;
foreach ($authors as $v) {
$cache_report = $this->user_obj->where('email', $v['email'])->find();
- if ($article_info['state'] != 0 || $cache_report['google_time'] != 0|| $cache_report['google_index'] != 0 || $data['state'] == 3) {
+ if ($cache_report==null||$article_info['state'] != 0 || $cache_report['google_time'] != 0|| $cache_report['google_index'] != 0 || $data['state'] == 3) {
$h_check = true;
break;
}
}
- if ($h_check == false) {
+ if ($article_info['state'] == 0&&$authors && $h_check == false) {
return jsonError('Please complete the H-index before proceeding');
}
@@ -1737,7 +1737,7 @@ class Article extends Controller
$report_tt .= "and you can access your account by visiting " . $journal_info['website'] . " and logging in.
";
$report_tt .= "If you have any questions or need assistance with accessing your account, please don't hesitate to contact us. We are here to support you throughout the submission and review process.
";
$report_tt .= "Thank you for choosing to submit your work to our journal. We look forward to working with you.
";
- $report_tt .= "Best regards,
" . $inser_data['realname'] . '
' . $journal_info['title'];
+ $report_tt .= "Best regards,
" . $journal_info['title'];
$maidata['email'] = trim($v['email']);
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $report_tt;
@@ -2203,7 +2203,7 @@ class Article extends Controller
foreach ($reviewers as $v) {
$this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $data['article_id']);
}
- $this->article_obj->where('article_id', $data['article_id'])->update(['state' => 0]);
+ $this->article_obj->where('article_id', $data['article_id'])->update(['state' => 0,'ctime'=>time()]);
$this->ai_scor($data['article_id']);
return json(['code' => 0]);
}
diff --git a/application/api/controller/Board.php b/application/api/controller/Board.php
index b9d6d88..9de8aeb 100644
--- a/application/api/controller/Board.php
+++ b/application/api/controller/Board.php
@@ -325,6 +325,7 @@ class Board extends Controller {
$boards[$k]['wos_time'] = $cache_user['wos_time'];
$boards[$k]['google_index'] = $cache_user['google_index'];
$boards[$k]['google_time'] = $cache_user['google_time'];
+ $boards[$k]['score'] = $cache_user['score'];
}
foreach ($boards as $v) {
diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php
index 9134187..7a0ab16 100644
--- a/application/api/controller/Journal.php
+++ b/application/api/controller/Journal.php
@@ -101,6 +101,17 @@ class Journal extends Controller {
return jsonSuccess($re);
}
+ /**
+ * 获取期刊列表
+ */
+ public function getJournalByeditor()
+ {
+ $user_id = $this->request->post('user_id');
+ $list = $this->journal_obj->where('editor_id',$user_id)->select();
+ $re['journals'] = $list;
+ return jsonSuccess($re);
+ }
+
/**
* 获取可申请审稿人的期刊
diff --git a/application/api/controller/Production.php b/application/api/controller/Production.php
index eea5bcc..e624b9c 100644
--- a/application/api/controller/Production.php
+++ b/application/api/controller/Production.php
@@ -121,6 +121,7 @@ class Production extends Controller
$program['fileRoute'] = "https://submission.tmrjournals.com/public/" . $files[0]['file_url'];
$res = object_to_array(json_decode(myPost($url, $program)));
+ return jsonSuccess($program);
$file_runs = $res['data'];
//整理信息
@@ -1422,6 +1423,12 @@ class Production extends Controller
echo 'Commit Succeeded';
}
+
+ public function myproofAdd(){
+ $article_id = $this->request->post("article_id");
+ self::pdfAddProof($article_id);
+ }
+
private function pdfAddProof($article_id)
{
$p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find();
diff --git a/application/api/controller/Ucenter.php b/application/api/controller/Ucenter.php
index a87ca51..c511142 100644
--- a/application/api/controller/Ucenter.php
+++ b/application/api/controller/Ucenter.php
@@ -24,6 +24,7 @@ class Ucenter extends Controller{
protected $apply_yboard_obj = '';
protected $user_score_log_obj = '';
protected $user_index_log_obj = '';
+ protected $user_to_yboard_obj = '';
public function __construct(\think\Request $request = null)
{
@@ -43,6 +44,7 @@ class Ucenter extends Controller{
$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->user_to_yboard_obj = Db::name('user_to_yboard');
}
@@ -66,7 +68,6 @@ class Ucenter extends Controller{
// 基本信息
$baseInfo = $this->user_obj->where(['user_id' => $data['user_id']])->find();
- // $userInfo['baseInfo'] = $baseInfo;
//检查用户reviewer的info信息
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->find();
@@ -74,9 +75,8 @@ class Ucenter extends Controller{
$insert_reviewer['reviewer_id'] = $data['user_id'];
$this->user_reviewer_info_obj->insert($insert_reviewer);
}
-
+
$userInfo['baseInfo']=$this->user_obj
- // ->field("t_user.*,")
->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id','left')
->where('t_user.user_id',$data['user_id'])
->find();
@@ -89,17 +89,26 @@ class Ucenter extends Controller{
if($isAuthor){
$userInfo['asAuthor'] = self::getAsAuthor($baseInfo['user_id']);
}
+
+
//审稿人
$isReviewer = $this->reviewer_to_journal_obj->where(['reviewer_id'=>$baseInfo['user_id'],'state'=>0])->find();
if($isReviewer){
$userInfo['asReviewer'] = self::getAsReviewer($baseInfo['user_id']);
}
+
//编委信息
$isBoard = $this->board_to_journal_obj->where('user_id',$baseInfo['user_id'])->where('state',0)->select();
if($isBoard){
$userInfo['asBoard'] = self::getAsBoard($baseInfo['user_id']);
}
+ //青年科学家
+ $isYboard = $this->user_to_yboard_obj->where('user_id',$data['user_id'])->where('state',0)->select();
+ if($isYboard){
+ $userInfo['Yboard'] = self::getAsYboard($baseInfo['user_id']);
+ }
+
return jsonSuccess($userInfo);
}
@@ -126,7 +135,8 @@ class Ucenter extends Controller{
if(!$rule->check($data)){
return jsonError($rule->getError());
}
- $ids = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->where('state',0)->where('is_yboard',0)->column('journal_id');
+ // $ids = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->where('state',0)->where('is_yboard',0)->column('journal_id');
+ $ids = $this->user_to_yboard_obj->where('user_id',$data['user_id'])->where('start_date','<=',time())->where('end_date',">=",time())->where('state',0)->column("journal_id");
$journals = $this->journal_obj->where('journal_id','in',$ids)->where('state',0)->select();
$re['journals'] = $journals;
return jsonSuccess($re);
@@ -152,6 +162,19 @@ class Ucenter extends Controller{
return jsonSuccess([]);
}
+ public function getAsYboard($user_id){
+ $user_info = $this->user_obj->where('user_id',$user_id)->find();
+ $list = $this->user_to_yboard_obj->where('user_id',$user_id)->where('state',0)->group('journal_id')->select();
+ $frag = [];
+ foreach($list as $v){
+ $journal = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
+ $cl = $this->user_to_yboard_obj->where('user_id',$user_id)->where('journal_id',$v['journal_id'])->select();
+ $journal['sd'] = $cl;
+ $frag[] = $journal;
+ }
+ return $frag;
+ }
+
public function applyBoard(){
$data = $this->request->post();
$rule = new Validate([
@@ -408,6 +431,9 @@ class Ucenter extends Controller{
}
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'];
diff --git a/application/api/controller/User.php b/application/api/controller/User.php
index fb25d2d..50c863a 100644
--- a/application/api/controller/User.php
+++ b/application/api/controller/User.php
@@ -42,6 +42,9 @@ class User extends Controller
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)
{
@@ -70,6 +73,9 @@ class User extends Controller
$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(){
@@ -137,6 +143,172 @@ class User extends Controller
}
}
+ /**
+ * 增加青年科学家
+ */
+ 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);
+ }
+
/**
* 用户评价
*/
@@ -338,6 +510,289 @@ class User extends Controller
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);
+ }
+
+ 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'];
+ }
+
+ /**
+ * 添加灰库用户单个
+ */
+ 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([]);
+ }
+
+
+ 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用户
+ */
+ 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'] = $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 获取所有用户
@@ -504,7 +959,54 @@ class User extends Controller
return jsonSuccess($re);
}
- public function delYboardApply(){
+ // 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 refuseYboardApply(){
$data = $this->request->post();
$rules = new Validate([
'ap_yboard_id' => 'require'
@@ -1068,6 +1570,22 @@ class User extends Controller
}
}
+ /**
+ * 查找用户信息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);
+ }
+
/**
* 注册功能
*/
@@ -1887,11 +2405,11 @@ class User extends Controller
* 添加用户证书
*/
public function addUserCert(){
+ die("service stop");
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'journal_id'=>'require',
- 'type'=>'require',
'year'=>'require'
]);
if(!$rule->check($data)){
@@ -1899,24 +2417,45 @@ class User extends Controller
}
$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");
- }
- $this->createCert($user_info,$journal_info,$data['year'],$data['type']);
+ // $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['year'] = $data['year'];
- $insert['url'] = "/cert/".$data['user_id'].'_'.$data['type'].'_'.$data['year'] . '.png';
- $insert['ctime'] = time();
- $this->user_cert_obj->insert($insert);
+ // $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([]);
+ 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);
@@ -1926,7 +2465,7 @@ class User extends Controller
->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 ROOT_PATH . 'public' . DS . 'cert' . DS . $user_info['user_id'] . '.png';
+ return $user_info['user_id'].'_'.$type.'_'.$year . '.png';
}
/**