From e4be850ba191e03f4381b6041267b4261c05708d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=87=91=E7=A3=8A?= <751475802@qq.com> Date: Thu, 30 Mar 2023 11:44:37 +0800 Subject: [PATCH] 1 --- application/api/controller/Admin.php | 38 +-- application/api/controller/Article.php | 135 ++-------- application/api/controller/Auto.php | 15 ++ application/api/controller/Base.php | 253 +++++++++++++++++++ application/api/controller/Chief.php | 20 +- application/api/controller/Journal.php | 36 +-- application/api/controller/Production.php | 133 +--------- application/api/controller/Publish.php | 60 +---- application/api/controller/Reviewer.php | 186 +++----------- application/api/controller/Special.php | 3 +- application/api/controller/Typeset.php | 118 +++------ application/api/controller/Ucenter.php | 57 +---- application/api/controller/User.php | 196 ++++++--------- application/common.php | 285 +++++++++++++--------- 14 files changed, 625 insertions(+), 910 deletions(-) create mode 100644 application/api/controller/Base.php diff --git a/application/api/controller/Admin.php b/application/api/controller/Admin.php index 32c978a..bafdf03 100644 --- a/application/api/controller/Admin.php +++ b/application/api/controller/Admin.php @@ -2,49 +2,17 @@ namespace app\api\controller; -use think\Controller; -use think\Db; -use think\Queue; +use app\api\controller\Base; /** * @title 公共管理相关 * @description 公共管理相关 */ -class Admin extends Controller { +class Admin extends Base { - protected $user_obj = ''; - protected $captcha_obj = ''; - protected $journal_obj = ''; - protected $user_act_obj = ''; - protected $reviewer_major_obj = ''; - protected $article_obj = ''; - protected $article_msg_obj = ''; - protected $article_author_obj = ''; - protected $admin_obj = ''; - protected $country_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $user_reviewer_obj = ''; - protected $user_msg_obj = ''; - protected $article_reviewer_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->captcha_obj = Db::name('captcha'); - $this->user_act_obj = Db::name('user_act'); - $this->admin_obj = Db::name('admin'); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->journal_obj = Db::name('journal'); - $this->user_reviewer_obj = Db::name('user_reviewer_apply'); - $this->user_reviewer_info_obj = Db::name('user_reviewer_info'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_obj = Db::name('article'); - $this->user_msg_obj = Db::name('user_msg'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_author_obj = Db::name('article_author'); - $this->country_obj = Db::name('country'); - $this->article_reviewer_obj = Db::name('article_reviewer'); } @@ -257,6 +225,7 @@ class Admin extends Controller { * */ public function reviewer() { + die("service stop!!"); //接受参数 $data = $this->request->post(); $journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find(); @@ -307,6 +276,7 @@ class Admin extends Controller { * 作者申请成为审稿人 */ public function becameReviewer() { + die("service stop!!"); //接受参数,查询参数 $data = $this->request->post(); diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index c6b32a8..61ed094 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -2,7 +2,7 @@ namespace app\api\controller; -use think\Controller; +use app\api\controller\Base; use think\Db; use think\Queue; use think\Validate; @@ -11,73 +11,13 @@ use think\Validate; * @title 文章接口 * @description 文章接口 */ -class Article extends Controller +class Article extends Base { - protected $article_obj = ''; - protected $country_obj = ''; - protected $user_obj = ''; - protected $user_act_obj = ''; - protected $journal_obj = ''; - protected $user_log_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $reviewer_major_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $article_reviewer_question_obj = ''; - protected $article_msg_obj = ''; - protected $article_file_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_author_obj = ''; - protected $article_transfer_obj = ''; - protected $chief_to_journal_obj = ''; - protected $login_auto_obj = ''; - protected $major_obj = ""; - protected $major_to_journal_obj = ''; - protected $reviewer_from_author_obj = ''; - protected $article_dialog_obj = ''; - protected $article_proposal_obj = ''; - protected $article_response_to_reviewer_obj = ''; - protected $user_black_obj = ''; - protected $user_reviewer_recommend_obj = ''; - protected $email_log_obj = ''; - protected $email_template_obj = ''; - protected $production_article_obj = ''; - protected $company_top_obj = ''; - protected $user_score_log_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->country_obj = Db::name('country'); - $this->user_act_obj = Db::name('user_act'); - $this->article_obj = Db::name('article'); - $this->journal_obj = Db::name('journal'); - $this->user_log_obj = Db::name('user_log'); - $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_file_obj = Db::name('article_file'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_author_obj = Db::name('article_author'); - $this->article_transfer_obj = Db::name('article_transfer'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->login_auto_obj = Db::name('login_auto'); - $this->major_obj = Db::name("major"); - $this->major_to_journal_obj = Db::name('major_to_journal'); - $this->reviewer_from_author_obj = Db::name("reviewer_from_author"); - $this->article_dialog_obj = Db::name('article_dialog'); - $this->article_proposal_obj = Db::name('article_proposal'); - $this->article_response_to_reviewer_obj = Db::name('article_response_to_reviewer'); - $this->user_black_obj = Db::name('user_black'); - $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); - $this->email_log_obj = Db::name('email_log'); - $this->email_template_obj = Db::name('email_template'); - $this->production_article_obj = Db::name('production_article'); - $this->company_top_obj = Db::name('company_top'); - $this->user_score_log_obj = Db::name('user_score_log'); } /** @@ -415,20 +355,6 @@ class Article extends Controller return json(['article' => $article_res, 'msg' => $article_msg, 'authors' => $author_res, 'suggest' => $suggest, 'transfer' => $transfer_res, 'transinfo' => $transfer_info, 'major' => $major]); } - 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 ''; - } else { - $frag = $this->getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title']; - } - return $frag; - } /** @@ -1117,8 +1043,8 @@ class Article extends Controller return json(['code' => 1, 'msg' => "More than two available reviewer-comments are necessary before going next step."]); } } - //接收必须查重小于30% - if ($data['state'] == 5 && $article_info['repetition'] > 30) { + //接收必须查重小于20% + if ($data['state'] == 5 && $article_info['repetition'] > 20) { return jsonError("Submissions with a repetition rate greater than thirty percent will not be accepted"); } @@ -1406,6 +1332,16 @@ class Article extends Controller //接受参数 $data = $this->request->post(); $this->article_obj->where('article_id', $data['articleId'])->update(['repetition' => $data['repefen'], 'repeurl' => $data['zipurl']]); + //当文章重复率大于50%时,拒稿,拉作者进黑名单 + if($data['repefen']>=50){ + $article_info = $this->article_obj->where('article_id',$data['articleId'])->find(); + $user_info = $this->user_obj->where('user_id',$article_info['user_id'])->find(); + $insert['user_id'] = $data['user_id']; + $insert['reason'] = "The author was blacklisted due to the check rate exceeded 50%"; + $insert['black_ctime'] = time(); + $this->user_black_obj->insert($insert); + $this->article_obj->where('article_id',$data['articleId'])->update(['state'=>3]); + } return json(['code' => 0]); } @@ -2840,47 +2776,6 @@ class Article extends Controller return jsonSuccess($re); } - - - /** - * 存储article文件历史信息 - */ - private function save_article_file($article_id, $user_id, $username, $url, $type_name) - { - //首先确定数据库里面是否存在此数据 - $res = $this->article_file_obj->where(['file_url' => $url])->find(); - if ($res) { //编辑的时候不能重复存储 - return true; - } else if ($type_name == 'picturesAndTables' && trim($url) == '') { - return true; - } else if ($type_name == 'coverLetter' && trim($url) == '') { - return true; - } else if ($type_name == 'totalpage' && trim($url) == '') { - return true; - } - $insert_data['article_id'] = $article_id; - $insert_data['user_id'] = $user_id; - $insert_data['username'] = $username; - $insert_data['file_url'] = $url; - $insert_data['type_name'] = $type_name; - $insert_data['ctime'] = time(); - return $this->article_file_obj->insertGetId($insert_data); - } - - /** - * 获取文章作者字符串 - * @param type $article_id - */ - public function getArticleAuthors($article_id) - { - $res = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select(); - $frag = ''; - foreach ($res as $v) { - $frag .= $v['firstname'] . $v['lastname'] . ','; - } - return substr($frag, 0, -1); - } - // 给审稿人发送邮件- 稿件的基本情况 public function sendEmailToReviewer($articleId, $state) { @@ -2974,7 +2869,7 @@ class Article extends Controller $this->article_obj->where('article_id', $article_id)->update(['editor_act' => 1]); $author = $this->user_obj->where('user_id', $article['user_id'])->find(); // 发邮件 - $content = 'Dear ' . $res['realname'] . ',
'; + $content = 'Dear ' . $author['realname'] . ',
'; $content .= 'Thank you for contacting our editor.
ID: ' . $article['accept_sn'] . '.

'; $content .= ' Your manuscript: ' . $article['accept_sn'] . ' has received a new reply; please login https://submission.tmrjournals.com/login to check.
'; $content .= 'Sincerely,
' . $article['title']; diff --git a/application/api/controller/Auto.php b/application/api/controller/Auto.php index eed6a5f..b0b79d6 100644 --- a/application/api/controller/Auto.php +++ b/application/api/controller/Auto.php @@ -261,6 +261,21 @@ class Auto extends Controller return jsonSuccess($re); } + /** + * 补充doi缺失的全文内容 + */ + // public function pushCrossrefForDoiB(){ + // $url = "https://doi.crossref.org/servlet/deposit"; + // $file = "D://cr396e3d57186c1f28fcb-6cc5.xml"; + // $program['operation'] = "doDOICitUpload"; + // $program['login_id'] = "books@tmrjournals.com"; + // $program['login_passwd'] = "849192806pnX"; + // $program['fname'] = $file; + // $res = myPost($url,$program); + // echo $res; + // // return jsonSuccess($res); + // } + public function qqqq() { diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php new file mode 100644 index 0000000..3594527 --- /dev/null +++ b/application/api/controller/Base.php @@ -0,0 +1,253 @@ +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'); + $this->country_obj = Db::name('country'); + $this->user_log_obj = Db::name('user_log'); + $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); + $this->article_msg_obj = Db::name('article_msg'); + $this->article_file_obj = Db::name('article_file'); + $this->article_transfer_obj = Db::name('article_transfer'); + $this->login_auto_obj = Db::name('login_auto'); + $this->major_to_journal_obj = Db::name('major_to_journal'); + $this->article_dialog_obj = Db::name('article_dialog'); + $this->article_proposal_obj = Db::name('article_proposal'); + $this->article_response_to_reviewer_obj = Db::name('article_response_to_reviewer'); + $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); + $this->email_log_obj = Db::name('email_log'); + $this->email_template_obj = Db::name('email_template'); + $this->production_article_obj = Db::name('production_article'); + $this->company_top_obj = Db::name('company_top'); + $this->user_cv_obj = Db::name('user_cv'); + $this->ts_obj = Db::name('ts'); + $this->ts_refer_obj = Db::name('ts_refer'); + $this->ts_frag_obj = Db::name('ts_frag'); + $this->online_obj = Db::name('online'); + $this->article_reviewer_file_obj = Db::name('article_reviewer_file'); + $this->production_article_obj = Db::name('production_article'); + $this->production_article_author_obj = Db::name('production_article_author'); + $this->production_article_organ_obj = Db::name('production_article_organ'); + $this->production_article_refer_obj = Db::name('production_article_refer'); + $this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ'); + $this->production_article_frag_obj = Db::name('production_article_frag'); + } + + + + public function pdfAddProof($article_id) + { + $p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find(); + vendor('fpdf.fpdf'); + vendor('fpdi/fpdi'); + $pdf = new \FPDI(); + $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS . $p_info['file_pdf']); + for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { + $templateId = $pdf->importPage($pageNo); + $size = $pdf->getTemplateSize($templateId); + if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); + else $pdf->AddPage('P', array($size['w'], $size['h'])); + $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); + $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); + $pdf->useTemplate($templateId); + } + $pdf->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . '.pdf'); + if ($p_info['file_sub'] != '' && substr($p_info['file_sub'], strripos($p_info['file_sub'], '.') + 1) == 'pdf') { + $pdf1 = new \FPDI(); + $pageCount1 = $pdf1->setSourceFile(ROOT_PATH . 'public' . DS . "articleSUB" . DS . $p_info['file_sub']); + for ($pageNo = 1; $pageNo <= $pageCount1; $pageNo++) { + $templateId1 = $pdf1->importPage($pageNo); + $size = $pdf1->getTemplateSize($templateId1); + if ($size['w'] > $size['h']) $pdf1->AddPage('L', array($size['w'], $size['h'])); + else $pdf1->AddPage('P', array($size['w'], $size['h'])); + $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); + $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); + $pdf1->useTemplate($templateId1); + } + $pdf1->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . 'SUB.pdf'); + } + } + + public 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'; + } + + public 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; + } + + + public 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 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; + } + + + public function save_article_file($article_id, $user_id, $username, $url, $type_name) + { + //首先确定数据库里面是否存在此数据 + $res = $this->article_file_obj->where(['file_url' => $url])->find(); + if ($res) { //编辑的时候不能重复存储 + return true; + } else if ($type_name == 'picturesAndTables' && trim($url) == '') { + return true; + } else if ($type_name == 'coverLetter' && trim($url) == '') { + return true; + } else if ($type_name == 'totalpage' && trim($url) == '') { + return true; + } + $insert_data['article_id'] = $article_id; + $insert_data['user_id'] = $user_id; + $insert_data['username'] = $username; + $insert_data['file_url'] = $url; + $insert_data['type_name'] = $type_name; + $insert_data['ctime'] = time(); + return $this->article_file_obj->insertGetId($insert_data); + } + + + public function getArticleAuthors($article_id) + { + $res = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select(); + $frag = ''; + foreach ($res as $v) { + $frag .= $v['firstname'] . $v['lastname'] . ','; + } + return substr($frag, 0, -1); + } + +} +?> \ No newline at end of file diff --git a/application/api/controller/Chief.php b/application/api/controller/Chief.php index b038837..983ad6c 100644 --- a/application/api/controller/Chief.php +++ b/application/api/controller/Chief.php @@ -6,6 +6,7 @@ use think\Controller; use think\Db; use think\Env; use think\Queue; +use think\Validate; /** * @title 主编相关接口 @@ -240,10 +241,11 @@ class Chief extends Controller { //加上文章领域 foreach($list as $k => $v){ - $major = $this->reviewer_major_obj->where('major_id',$v['major_id'])->find(); - $cmajor = $this->reviewer_major_obj->where('major_id',$v['cmajor_id'])->find(); - $list[$k]['major'] = $major['title']; - $list[$k]['cmajor'] = $cmajor['title']; + $list[$k]['major_str'] = getMajorStr($v['major_id']); + // $major = $this->reviewer_major_obj->where('major_id',$v['major_id'])->find(); + // $cmajor = $this->reviewer_major_obj->where('major_id',$v['cmajor_id'])->find(); + // $list[$k]['major'] = $major['title']; + // $list[$k]['cmajor'] = $cmajor['title']; } $re['articles'] = $list; @@ -288,15 +290,17 @@ class Chief extends Controller { } //加上文章领域 foreach($list as $k => $v){ - $major = $this->reviewer_major_obj->where('major_id',$v['major_id'])->find(); - $cmajor = $this->reviewer_major_obj->where('major_id',$v['cmajor_id'])->find(); - $list[$k]['major'] = $major['title']; - $list[$k]['cmajor'] = $cmajor['title']; + // $major = $this->reviewer_major_obj->where('major_id',$v['major_id'])->find(); + // $cmajor = $this->reviewer_major_obj->where('major_id',$v['cmajor_id'])->find(); + $list[$k]['major_str'] = getMajorStr($v['major_id']); + // $list[$k]['major'] = $major['title']; + // $list[$k]['cmajor'] = $cmajor['title']; } $re['count'] = $count; $re['articles'] = $list; return jsonSuccess($re); } + /** * @title 获取主编期刊列表 diff --git a/application/api/controller/Journal.php b/application/api/controller/Journal.php index 7a0ab16..42b21fb 100644 --- a/application/api/controller/Journal.php +++ b/application/api/controller/Journal.php @@ -2,51 +2,19 @@ namespace app\api\controller; -use think\Controller; -use think\Db; +use app\api\controller\Base; use think\Validate; use app\api\controller\User as usercontroller; -use think\Queue; /** * @title 期刊相关 * @description 期刊相关 */ -class Journal extends Controller { +class Journal extends Base { - protected $user_obj = ''; - protected $captcha_obj = ''; - protected $journal_obj = ''; - protected $user_act_obj = ''; - protected $reviewer_major_obj = ''; - protected $article_obj = ''; - protected $article_msg_obj = ''; - protected $article_author_obj = ''; - protected $admin_obj = ''; - protected $country_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $user_reviewer_obj = ''; - protected $user_msg_obj = ''; - protected $user_to_special_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->captcha_obj = Db::name('captcha'); - $this->user_act_obj = Db::name('user_act'); - $this->admin_obj = Db::name('admin'); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->journal_obj = Db::name('journal'); - $this->user_reviewer_obj = Db::name('user_reviewer_apply'); - $this->user_reviewer_info_obj = Db::name('user_reviewer_info'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_obj = Db::name('article'); - $this->user_msg_obj = Db::name('user_msg'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_author_obj = Db::name('article_author'); - $this->country_obj = Db::name('country'); - $this->user_to_special_obj = Db::name('user_to_special'); } /** diff --git a/application/api/controller/Production.php b/application/api/controller/Production.php index e624b9c..d9896f0 100644 --- a/application/api/controller/Production.php +++ b/application/api/controller/Production.php @@ -5,7 +5,7 @@ namespace app\api\controller; use Mpdf\Config\ConfigVariables; use Mpdf\Config\FontVariables; use Mpdf\Mpdf; -use think\Controller; +use app\api\controller\Base; use think\Db; use think\Queue; use think\Validate; @@ -14,78 +14,12 @@ use think\Validate; * @title 公共管理相关 * @description 公共管理相关 */ -class Production extends Controller +class Production extends Base { - protected $article_obj = ''; - protected $user_obj = ''; - protected $user_act_obj = ''; - protected $journal_obj = ''; - protected $user_log_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $reviewer_major_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $article_reviewer_question_obj = ''; - protected $article_msg_obj = ''; - protected $article_file_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_author_obj = ''; - protected $article_transfer_obj = ''; - protected $chief_to_journal_obj = ''; - protected $login_auto_obj = ''; - protected $major_obj = ""; - protected $major_to_journal_obj = ''; - protected $reviewer_from_author_obj = ''; - protected $article_dialog_obj = ''; - protected $article_proposal_obj = ''; - protected $user_black_obj = ''; - protected $user_reviewer_recommend_obj = ''; - protected $ts_obj = ''; - protected $ts_refer_obj = ''; - protected $ts_frag_obj = ''; - protected $online_obj = ''; - protected $production_article_obj = ''; - protected $production_article_author_obj = ''; - protected $production_article_organ_obj = ''; - protected $production_article_refer_obj = ''; - protected $production_article_author_to_organ_obj = ''; - protected $production_article_frag_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->user_act_obj = Db::name('user_act'); - $this->article_obj = Db::name('article'); - $this->journal_obj = Db::name('journal'); - $this->user_log_obj = Db::name('user_log'); - $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_file_obj = Db::name('article_file'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_author_obj = Db::name('article_author'); - $this->article_transfer_obj = Db::name('article_transfer'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->login_auto_obj = Db::name('login_auto'); - $this->major_obj = Db::name("major"); - $this->major_to_journal_obj = Db::name('major_to_journal'); - $this->reviewer_from_author_obj = Db::name("reviewer_from_author"); - $this->article_dialog_obj = Db::name('article_dialog'); - $this->article_proposal_obj = Db::name('article_proposal'); - $this->user_black_obj = Db::name('user_black'); - $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); - $this->ts_obj = Db::name('ts'); - $this->ts_refer_obj = Db::name('ts_refer'); - $this->ts_frag_obj = Db::name('ts_frag'); - $this->online_obj = Db::name('online'); - $this->production_article_obj = Db::name('production_article'); - $this->production_article_author_obj = Db::name('production_article_author'); - $this->production_article_organ_obj = Db::name('production_article_organ'); - $this->production_article_refer_obj = Db::name('production_article_refer'); - $this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ'); - $this->production_article_frag_obj = Db::name('production_article_frag'); } /** @@ -1429,68 +1363,7 @@ class Production extends Controller self::pdfAddProof($article_id); } - private function pdfAddProof($article_id) - { - $p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find(); - vendor('fpdf.fpdf'); - vendor('fpdi/fpdi'); - $pdf = new \FPDI(); - $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS . $p_info['file_pdf']); - // iterate through all pages - for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { - // import a page - $templateId = $pdf->importPage($pageNo); - - // get the size of the imported page - $size = $pdf->getTemplateSize($templateId); - - // create a page (landscape or portrait depending on the imported page size) - if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); - else $pdf->AddPage('P', array($size['w'], $size['h'])); - - // use the imported page - // $pdf->useTemplate($templateId); - - $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); - $pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); - $pdf->useTemplate($templateId); - // $pdf->SetFont('Arial', 'B', '12'); - // // sign with current date - // $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values - // $pdf->Write(7, date('Y-m-d')); - } - $pdf->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . '.pdf'); - - - - if ($p_info['file_sub'] != '' && substr($p_info['file_sub'], strripos($p_info['file_sub'], '.') + 1) == 'pdf') { - $pdf1 = new \FPDI(); - $pageCount1 = $pdf1->setSourceFile(ROOT_PATH . 'public' . DS . "articleSUB" . DS . $p_info['file_sub']); - for ($pageNo = 1; $pageNo <= $pageCount1; $pageNo++) { - // import a page - $templateId1 = $pdf1->importPage($pageNo); - - // get the size of the imported page - $size = $pdf1->getTemplateSize($templateId1); - - // create a page (landscape or portrait depending on the imported page size) - if ($size['w'] > $size['h']) $pdf1->AddPage('L', array($size['w'], $size['h'])); - else $pdf1->AddPage('P', array($size['w'], $size['h'])); - - // use the imported page - // $pdf->useTemplate($templateId); - - $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80); - $pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80); - $pdf1->useTemplate($templateId1); - // $pdf->SetFont('Arial', 'B', '12'); - // // sign with current date - // $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values - // $pdf->Write(7, date('Y-m-d')); - } - $pdf1->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . 'SUB.pdf'); - } - } + /** * @title 文章文件上传 diff --git a/application/api/controller/Publish.php b/application/api/controller/Publish.php index 7b54f56..7af1e40 100644 --- a/application/api/controller/Publish.php +++ b/application/api/controller/Publish.php @@ -2,75 +2,19 @@ namespace app\api\controller; -use think\Controller; -use think\Db; -use think\Queue; +use app\api\controller\Base; use think\Validate; /** * @title 公共管理相关 * @description 公共管理相关 */ -class Publish extends Controller +class Publish extends Base { - protected $article_obj = ''; - protected $user_obj = ''; - protected $user_act_obj = ''; - protected $journal_obj = ''; - protected $user_log_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $reviewer_major_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $article_reviewer_question_obj = ''; - protected $article_msg_obj = ''; - protected $article_file_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_author_obj = ''; - protected $article_transfer_obj = ''; - protected $chief_to_journal_obj = ''; - protected $login_auto_obj = ''; - protected $major_obj = ""; - protected $major_to_journal_obj = ''; - protected $reviewer_from_author_obj = ''; - protected $article_dialog_obj = ''; - protected $article_proposal_obj = ''; - protected $user_black_obj = ''; - protected $user_reviewer_recommend_obj = ''; - protected $ts_obj = ''; - protected $ts_refer_obj = ''; - protected $ts_frag_obj = ''; - protected $online_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->user_act_obj = Db::name('user_act'); - $this->article_obj = Db::name('article'); - $this->journal_obj = Db::name('journal'); - $this->user_log_obj = Db::name('user_log'); - $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_file_obj = Db::name('article_file'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_author_obj = Db::name('article_author'); - $this->article_transfer_obj = Db::name('article_transfer'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->login_auto_obj = Db::name('login_auto'); - $this->major_obj = Db::name("major"); - $this->major_to_journal_obj = Db::name('major_to_journal'); - $this->reviewer_from_author_obj = Db::name("reviewer_from_author"); - $this->article_dialog_obj = Db::name('article_dialog'); - $this->article_proposal_obj = Db::name('article_proposal'); - $this->user_black_obj = Db::name('user_black'); - $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); - $this->ts_obj = Db::name('ts'); - $this->ts_refer_obj = Db::name('ts_refer'); - $this->ts_frag_obj = Db::name('ts_frag'); - $this->online_obj = Db::name('online'); } /** diff --git a/application/api/controller/Reviewer.php b/application/api/controller/Reviewer.php index f231d9e..4ab6969 100644 --- a/application/api/controller/Reviewer.php +++ b/application/api/controller/Reviewer.php @@ -2,60 +2,21 @@ namespace app\api\controller; -use think\Controller; +use app\api\controller\Base; use think\Db; use think\Validate; -use TCPDF; -use think\Queue; /** * @title 审稿人接口 * @description 审稿人接口 */ -class Reviewer extends Controller +class Reviewer extends Base { - protected $user_obj = ''; - protected $user_reviewer_obj = ''; - protected $journal_obj = ''; - protected $reviewer_major_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $user_log_obj = ''; - protected $article_obj = ''; - protected $article_file_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_reviewer_file_obj = ''; - protected $article_reviewer_question_obj = ''; - protected $chief_to_journal_obj = ''; - protected $board_to_journal_obj = ''; - protected $login_auto_obj = ''; - protected $country_obj = ''; - protected $user_reviewer_recommend_obj = ''; - protected $article_msg_obj = ''; - //put your code here public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $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_log_obj = Db::name('user_log'); - $this->article_obj = Db::name('article'); - $this->article_file_obj = Db::name('article_file'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_reviewer_file_obj = Db::name('article_reviewer_file'); - $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->board_to_journal_obj = Db::name('board_to_journal'); - $this->login_auto_obj = Db::name('login_auto'); - $this->country_obj = Db::name('country'); - $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); - $this->article_msg_obj = Db::name('article_msg'); } /** @@ -250,6 +211,8 @@ class Reviewer extends Controller ->where('t_user.account|t_user.email', 'like', '%' . $data['account'] . '%') ->where('t_user.state', 0) ->find(); + $check['majorshu'] = getMajorShu($check['major']); + $check['cvs'] = getReviewerCvs($check['user_id']); $check['title'] = $check['technical']; $re['reviewer'] = $check; return jsonSuccess($re); @@ -1402,7 +1365,6 @@ class Reviewer extends Controller $info_insert['introduction'] = isset($data['introduction']) ? trim($data['introduction']) : ''; $info_insert['company'] = isset($data['company']) ? trim($data['company']) : ''; $info_insert['major'] = $data['major']; - $info_insert['cmajor'] = $data['cmajor']; $info_insert['qualifications'] = isset($data['cv'])?trim($data['cv']):''; $info_insert['field'] = trim($data['field']); $res1 = $this->user_reviewer_info_obj->insertGetId($info_insert); @@ -1469,7 +1431,7 @@ class Reviewer extends Controller $info_insert['introduction'] = isset($data['introduction']) ? trim($data['introduction']) : ''; $info_insert['company'] = isset($data['company']) ? trim($data['company']) : ''; $info_insert['major'] = $data['major']; - $info_insert['cmajor'] = $data['cmajor']; + // $info_insert['cmajor'] = $data['cmajor']; $info_insert['field'] = trim($data['field']); $info_insert['qualifications'] = trim($data['cv']); if ($reviewer_info == null) { @@ -1602,10 +1564,11 @@ class Reviewer extends Controller } foreach($res as $k => $v){ - $major_res = $this->reviewer_major_obj->where('major_id', $v['major'])->column('title'); - $res[$k]['major_title'] = $major_res ? $major_res[0] : ''; - $cmajor_res = $this->reviewer_major_obj->where('major_id', $v['cmajor'])->column('title'); - $res[$k]['cmajor_title'] = $cmajor_res ? $cmajor_res[0] : ''; + $res[$k]['major_title'] = getMajorStr($v['major']); + // $major_res = $this->reviewer_major_obj->where('major_id', $v['major'])->column('title'); + // $res[$k]['major_title'] = $major_res ? $major_res[0] : ''; + // $cmajor_res = $this->reviewer_major_obj->where('major_id', $v['cmajor'])->column('title'); + // $res[$k]['cmajor_title'] = $cmajor_res ? $cmajor_res[0] : ''; } return json(['code' => 0, 'data' => $res, 'total' => $count]); } @@ -1693,116 +1656,45 @@ class Reviewer extends Controller public function searchReviewer() { $data = $this->request->post(); + $rule = new Validate([ + 'article_id'=>'require', + 'pageIndex'=>'require', + 'pageSize'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } $article_info = $this->article_obj->where("article_id", $data['article_id'])->find(); $noids = $this->article_reviewer_obj->where('article_id', $data['article_id'])->column('reviewer_id'); $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $list = []; - $gradewhere = ''; - if(isset($data['grade'])){ - $gradewhere = 't_reviewer_to_journal.grade = "'.$data['grade'].'"'; + + $where['t_reviewer_to_journal.journal_id'] = $article_info['journal_id']; + $where['t_reviewer_to_journal.reviewer_id'] = ['not in',$noids]; + $where['t_reviewer_to_journal.state'] = 0; + if(isset($data['keywords'])&&$data['keywords']!=''){ + $where['t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname'] = ['like',"%" . $data["keywords"] . "%"]; } - $count = 0; - if ($data["keywords"] == "") { - if ($data["major_id"] == 0) { - $list = $this->reviewer_to_journal_obj - ->field("t_user.user_id,t_user.realname,t_reviewer_major.title cmajor,t_reviewer_to_journal.grade,t_user.account,t_user_reviewer_info.company,t_user_reviewer_info.field,t_user.rs_num,t_user.rd_num") - ->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") - ->join("t_reviewer_major", "t_reviewer_major.major_id = t_user_reviewer_info.cmajor", "left") - ->where('t_reviewer_to_journal.journal_id', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where('t_reviewer_to_journal.state', 0) - ->order("t_user.rs_num desc") - ->limit($limit_start, $data['pageSize']) - ->select(); - $count = $this->reviewer_to_journal_obj - ->where('t_reviewer_to_journal.journal_id', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where('t_reviewer_to_journal.state', 0) - ->count(); - } else { - $list = $this->reviewer_to_journal_obj - ->field("t_user.user_id,t_user.realname,t_reviewer_major.title cmajor,t_reviewer_to_journal.grade,t_user.account,t_user_reviewer_info.company,t_user_reviewer_info.field,t_user.rs_num,t_user.rd_num") - ->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") - ->join("t_reviewer_major", "t_reviewer_major.major_id = t_user_reviewer_info.cmajor", "left") - ->where('t_reviewer_to_journal.journal_id', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.major", $data['major_id']) - ->where('t_reviewer_to_journal.state', 0) - ->order("t_user.rs_num desc") - ->limit($limit_start, $data['pageSize']) - ->select(); - $count = $this->reviewer_to_journal_obj - ->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', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.major", $data['major_id']) - ->where('t_reviewer_to_journal.state', 0) - ->count(); - } - } else { - if ($data["major_id"] == 0) { - $list = $this->reviewer_to_journal_obj - ->field("t_user.user_id,t_user.realname,t_reviewer_major.title cmajor,t_reviewer_to_journal.grade,t_user.account,t_user_reviewer_info.company,t_user_reviewer_info.field,t_user.rs_num,t_user.rd_num") - ->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") - ->join("t_reviewer_major", "t_reviewer_major.major_id = t_user_reviewer_info.cmajor", "left") - ->where('t_reviewer_to_journal.journal_id', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname", "like", "%" . $data["keywords"] . "%") - ->where('t_reviewer_to_journal.state', 0) - ->order("t_user.rs_num desc") - ->limit($limit_start, $data['pageSize']) - ->select(); - $count = $this->reviewer_to_journal_obj - ->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', $article_info['journal_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname", "like", "%" . $data["keywords"] . "%") - ->where('t_reviewer_to_journal.state', 0) - ->count(); - } else { - $list = $this->reviewer_to_journal_obj - ->field("t_user.user_id,t_user.realname,t_reviewer_major.title cmajor,t_reviewer_to_journal.grade,t_user.account,t_user_reviewer_info.company,t_user_reviewer_info.field,t_user.rs_num,t_user.rd_num") - ->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") - ->join("t_reviewer_major", "t_reviewer_major.major_id = t_user_reviewer_info.cmajor", "left") - ->where('t_reviewer_to_journal.journal_id', $article_info['journal_id']) - ->where("t_user_reviewer_info.major", $data['major_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname", "like", "%" . $data["keywords"] . "%") - ->where('t_reviewer_to_journal.state', 0) - ->order("t_user.rs_num desc") - ->limit($limit_start, $data['pageSize']) - ->select(); - $count = $this->reviewer_to_journal_obj - ->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', $article_info['journal_id']) - ->where("t_user_reviewer_info.major", $data['major_id']) - ->where('t_reviewer_to_journal.reviewer_id', 'not in', $noids) - ->where($gradewhere) - ->where("t_user_reviewer_info.introduction|t_user_reviewer_info.field|t_user.account|t_user.email|t_user.realname", "like", "%" . $data["keywords"] . "%") - ->where('t_reviewer_to_journal.state', 0) - ->count(); - } + if(isset($data['major_id'])&&$data['major_id']!=0){ + $where['t_user_reviewer_info.major'] = $data['major_id']; } + $list = $this->reviewer_to_journal_obj + ->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($where) + ->order('t_user.rs_num desc') + ->limit($limit_start, $data['pageSize']) + ->select(); + $count = $this->reviewer_to_journal_obj + ->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($where) + ->count(); foreach($list as $k => $v){ + $list[$k]['majorstr'] = getMajorStr($v['major']); $list[$k]['now'] = $this->article_reviewer_obj->where('reviewer_id',$v['user_id'])->where('state',0)->count(); } - - - $re['reviewers'] = $list; $re['count'] = $count; return jsonSuccess($re); diff --git a/application/api/controller/Special.php b/application/api/controller/Special.php index a892a4d..ba5160e 100644 --- a/application/api/controller/Special.php +++ b/application/api/controller/Special.php @@ -749,7 +749,6 @@ class Special extends Controller 'realname' => 'require', 'article_id' => 'require', 'major' => 'require', - 'cmajor' => 'require', 'country' => 'require' ]); if (!$rule->check($data)) { @@ -784,7 +783,7 @@ class Special extends Controller if ($uri == null) { //添加审稿人信息 $insert_reviewer_info['reviewer_id'] = $reviewer_info['user_id']; $insert_reviewer_info['major'] = $data['major']; - $insert_reviewer_info['cmajor'] = $data['cmajor']; + // $insert_reviewer_info['cmajor'] = $data['cmajor']; $insert_reviewer_info['country'] = $data['country']; $res2 = $this->user_reviewer_info_obj->insert($insert_reviewer_info); } diff --git a/application/api/controller/Typeset.php b/application/api/controller/Typeset.php index 25d6c23..8340500 100644 --- a/application/api/controller/Typeset.php +++ b/application/api/controller/Typeset.php @@ -2,7 +2,7 @@ namespace app\api\controller; -use think\Controller; +use app\api\controller\Base; use think\Db; use think\Queue; use think\Validate; @@ -11,66 +11,12 @@ use think\Validate; * @title 公共管理相关 * @description 公共管理相关 */ -class Typeset extends Controller +class Typeset extends Base { - protected $article_obj = ''; - protected $user_obj = ''; - protected $user_act_obj = ''; - protected $journal_obj = ''; - protected $user_log_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $reviewer_major_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $article_reviewer_question_obj = ''; - protected $article_msg_obj = ''; - protected $article_file_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_author_obj = ''; - protected $article_transfer_obj = ''; - protected $chief_to_journal_obj = ''; - protected $login_auto_obj = ''; - protected $major_obj = ""; - protected $major_to_journal_obj = ''; - protected $reviewer_from_author_obj = ''; - protected $article_dialog_obj = ''; - protected $article_proposal_obj = ''; - protected $user_black_obj = ''; - protected $user_reviewer_recommend_obj = ''; - protected $ts_obj = ''; - protected $ts_refer_obj = ''; - protected $ts_frag_obj = ''; - protected $online_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->user_act_obj = Db::name('user_act'); - $this->article_obj = Db::name('article'); - $this->journal_obj = Db::name('journal'); - $this->user_log_obj = Db::name('user_log'); - $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); - $this->reviewer_major_obj = Db::name('reviewer_major'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); - $this->article_msg_obj = Db::name('article_msg'); - $this->article_file_obj = Db::name('article_file'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_author_obj = Db::name('article_author'); - $this->article_transfer_obj = Db::name('article_transfer'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->login_auto_obj = Db::name('login_auto'); - $this->major_obj = Db::name("major"); - $this->major_to_journal_obj = Db::name('major_to_journal'); - $this->reviewer_from_author_obj = Db::name("reviewer_from_author"); - $this->article_dialog_obj = Db::name('article_dialog'); - $this->article_proposal_obj = Db::name('article_proposal'); - $this->user_black_obj = Db::name('user_black'); - $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); - $this->ts_obj = Db::name('ts'); - $this->ts_refer_obj = Db::name('ts_refer'); - $this->ts_frag_obj = Db::name('ts_frag'); - $this->online_obj = Db::name('online'); } public function getTypeSet() @@ -535,41 +481,41 @@ class Typeset extends Controller return jsonSuccess([]); } - /** - * pdf文件加水印 - */ - public function pdfAddProof() - { - vendor('fpdf.fpdf'); - vendor('fpdi/fpdi'); - $pdf = new \FPDI(); - $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS.'pdf'.DS.'test.pdf'); + // /** + // * pdf文件加水印 + // */ + // public function pdfAddProof() + // { + // vendor('fpdf.fpdf'); + // vendor('fpdi/fpdi'); + // $pdf = new \FPDI(); + // $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS.'pdf'.DS.'test.pdf'); - // iterate through all pages - for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { - // import a page - $templateId = $pdf->importPage($pageNo); + // // iterate through all pages + // for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { + // // import a page + // $templateId = $pdf->importPage($pageNo); - // get the size of the imported page - $size = $pdf->getTemplateSize($templateId); + // // get the size of the imported page + // $size = $pdf->getTemplateSize($templateId); - // create a page (landscape or portrait depending on the imported page size) - if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); - else $pdf->AddPage('P', array($size['w'], $size['h'])); + // // create a page (landscape or portrait depending on the imported page size) + // if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); + // else $pdf->AddPage('P', array($size['w'], $size['h'])); - // use the imported page - // $pdf->useTemplate($templateId); + // // use the imported page + // // $pdf->useTemplate($templateId); - $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 25, 80); - $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 155, 80); - $pdf->useTemplate($templateId); - // $pdf->SetFont('Arial', 'B', '12'); - // // sign with current date - // $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values - // $pdf->Write(7, date('Y-m-d')); - } - $pdf->Output(ROOT_PATH . 'public' . DS.'pdf'.DS.'word.pdf'); - } + // $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 25, 80); + // $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 155, 80); + // $pdf->useTemplate($templateId); + // // $pdf->SetFont('Arial', 'B', '12'); + // // // sign with current date + // // $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values + // // $pdf->Write(7, date('Y-m-d')); + // } + // $pdf->Output(ROOT_PATH . 'public' . DS.'pdf'.DS.'word.pdf'); + // } /** * 获取online的分期 diff --git a/application/api/controller/Ucenter.php b/application/api/controller/Ucenter.php index c511142..1caafd5 100644 --- a/application/api/controller/Ucenter.php +++ b/application/api/controller/Ucenter.php @@ -2,49 +2,16 @@ namespace app\api\controller; -use think\Controller; -use think\Db; +use app\api\controller\Base; use think\Validate; -class Ucenter extends Controller{ +class Ucenter extends Base{ - protected $user_obj = ''; - protected $user_reviewer_info_obj = ''; - protected $journal_obj = ''; - protected $reviewer_to_journal_obj = ''; - protected $article_reviewer_obj = ''; - protected $article_obj = ''; - protected $chief_to_journal_obj = ''; - protected $board_to_journal_obj = ''; - protected $major_obj = ""; - protected $major_to_journal_obj = ''; - protected $user_cv_obj = ''; - protected $apply_board_obj = ''; - 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) { parent::__construct($request); - $this->user_obj = Db::name('user'); - $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); - $this->journal_obj = Db::name('journal'); - $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); - $this->article_reviewer_obj = Db::name('article_reviewer'); - $this->article_obj = Db::name('article'); - $this->chief_to_journal_obj = Db::name('chief_to_journal'); - $this->board_to_journal_obj = Db::name('board_to_journal'); - $this->major_obj = Db::name("major"); - $this->major_to_journal_obj = Db::name('major_to_journal'); - $this->user_cv_obj = Db::name('user_cv'); - $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->user_to_yboard_obj = Db::name('user_to_yboard'); } @@ -81,6 +48,8 @@ class Ucenter extends Controller{ ->where('t_user.user_id',$data['user_id']) ->find(); + $userInfo['baseInfo']['majorshu'] = $userInfo['baseInfo']['major']==0?'':getMajorShu($userInfo['baseInfo']['major']); + $userInfo['baseInfo']['majorStr'] = $userInfo['baseInfo']['major']==0?'':getMajorStr($userInfo['baseInfo']['major']); //cv信息 $cvs = $this->user_cv_obj->where('user_id',$data['user_id'])->where('state',0)->select(); $userInfo['cvs'] = $cvs; @@ -253,13 +222,14 @@ class Ucenter extends Controller{ if(isset($data['phone'])&&$data['phone']!=''){ $update['phone'] = $data['phone']; } + $update['localname'] = isset($data['localname'])?trim($data['localname']):''; $this->user_obj->where(['user_id'=>$data['user_id']])->update($update); $updata1=[ 'technical'=>$data['technical'], 'country'=>$data['country'], 'major'=>$data['major'], 'field'=>$data['field'], - 'introduction'=>$data['introduction'], + 'introduction'=>isset($data['introduction'])?$data['introduction']:'', 'company'=>$data['company'] ]; $this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata1); @@ -414,7 +384,7 @@ class Ucenter extends Controller{ // 获取审稿人基本信息 $res = $this->user_reviewer_info_obj->where(['reviewer_id'=>$userId])->find(); - $res['majors'] = self::getMajorShu($res['major']); + $res['majors'] = getMajorShu($res['major']); // 获取审稿人期刊 @@ -430,19 +400,6 @@ class Ucenter extends Controller{ return $res; } - 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']; - } - /** * Notes: 编辑的期刊资料 * User: wangzhaocui diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 50c863a..32a3f22 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -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至我们的账户 diff --git a/application/common.php b/application/common.php index 0441766..cd86db5 100644 --- a/application/common.php +++ b/application/common.php @@ -15,7 +15,8 @@ use think\Env; // | Author: 流年 // +---------------------------------------------------------------------- // 应用公共文件 -function authcode($str) { +function authcode($str) +{ $key = substr(md5('ThinkPHP.CN'), 5, 8); $str1 = substr(md5($str), 8, 10); return md5($key . $str1); @@ -33,7 +34,8 @@ function authcode($str) { * @param $attachmentFile 附件 (string | array) * @return array */ -function sendEmail($email = '', $title = '', $from_name = '', $content = '', $memail = '', $mpassword = '', $attachmentFile = '') { +function sendEmail($email = '', $title = '', $from_name = '', $content = '', $memail = '', $mpassword = '', $attachmentFile = '') +{ date_default_timezone_set('PRC'); //Create a new PHPMailer instance $mail = new PHPMailer; @@ -72,7 +74,7 @@ function sendEmail($email = '', $title = '', $from_name = '', $content = '', $me //组合邮件模板的头尾 $pre = Env::get('emailtemplete.pre'); $net = Env::get('emailtemplete.net'); - $net = str_replace("{{email}}",$memail,$net); + $net = str_replace("{{email}}", $memail, $net); // $mail->msgHTML($pre.$content.$net); $mail->msgHTML($content); @@ -80,21 +82,20 @@ function sendEmail($email = '', $title = '', $from_name = '', $content = '', $me $mail->AltBody = ''; if (is_array($attachmentFile)) { for ($i = 0; $i < count($attachmentFile); $i++) { - if($attachmentFile[$i]!=''){ - $mail->addAttachment($attachmentFile[$i],substr($attachmentFile[$i],strrpos($attachmentFile[$i],DS)+1)); //这里可以是多维数组,然后循环附件的文件和名称 + if ($attachmentFile[$i] != '') { + $mail->addAttachment($attachmentFile[$i], substr($attachmentFile[$i], strrpos($attachmentFile[$i], DS) + 1)); //这里可以是多维数组,然后循环附件的文件和名称 } } } else { if ($attachmentFile != '') { //Attach an image file - $mail->addAttachment($attachmentFile, substr($attachmentFile,strrpos($attachmentFile,DS)+1)); + $mail->addAttachment($attachmentFile, substr($attachmentFile, strrpos($attachmentFile, DS) + 1)); } } //send the message, check for errors if (!$mail->send()) { $status = 0; - $data = "邮件发送失败" . $mail->ErrorInfo; - ; + $data = "邮件发送失败" . $mail->ErrorInfo;; } else { $status = 1; $data = "邮件发送成功"; @@ -102,7 +103,8 @@ function sendEmail($email = '', $title = '', $from_name = '', $content = '', $me return ['status' => $status, 'data' => $data]; //返回值(可选) } -function object_to_array($obj) { +function object_to_array($obj) +{ $obj = (array) $obj; foreach ($obj as $k => $v) { if (gettype($v) == 'resource') { @@ -115,45 +117,47 @@ function object_to_array($obj) { return $obj; } -function get_str(){ - +function get_str() +{ + $length = 32; $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $len = strlen($str)-1; - $randstr = ''; - for ($i=0;$i<$length;$i++) { - $num=mt_rand(0,$len); + $len = strlen($str) - 1; + $randstr = ''; + for ($i = 0; $i < $length; $i++) { + $num = mt_rand(0, $len); $randstr .= $str[$num]; - } - return md5($randstr.time()); - + } + return md5($randstr . time()); } -function getRandPassword(){ - +function getRandPassword() +{ + $length = 8; $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $len = strlen($str)-1; - $randstr = ''; - for ($i=0;$i<$length;$i++) { - $num=mt_rand(0,$len); + $len = strlen($str) - 1; + $randstr = ''; + for ($i = 0; $i < $length; $i++) { + $num = mt_rand(0, $len); $randstr .= $str[$num]; - } - return $randstr; - + } + return $randstr; } -function proofState($article_id){ +function proofState($article_id) +{ $p_article_obj = Db::name('production_article'); - $p_article_obj->where('article_id',$article_id)->where('state','<>',1)->where('proof_etime','<',time())->where('proof_state',1)->update(['proof_state'=>2]); + $p_article_obj->where('article_id', $article_id)->where('state', '<>', 1)->where('proof_etime', '<', time())->where('proof_state', 1)->update(['proof_state' => 2]); } /** * 生成文章sn号 * @return type */ -function getArticleSN($abbr, $type) { +function getArticleSN($abbr, $type) +{ $str = $abbr; $str .= date('Y', time()) . $type . date('md', time()); $where['accept_sn'] = ['like', "$str%"]; @@ -171,7 +175,8 @@ function getArticleSN($abbr, $type) { return $str; } -function translateType($type) { +function translateType($type) +{ $frag = ''; switch ($type) { case "A": @@ -244,9 +249,10 @@ function translateType($type) { return $frag; } -function search_array_val($arr,$val){ - foreach($arr as $k => $v){ - if($v == $val){ +function search_array_val($arr, $val) +{ + foreach ($arr as $k => $v) { + if ($v == $val) { return $k; } } @@ -256,76 +262,80 @@ function search_array_val($arr,$val){ * GET 请求 * @param string $url */ -function myGet($url){ +function myGet($url) +{ $oCurl = curl_init(); - if(stripos($url,"https://")!==FALSE){ + if (stripos($url, "https://") !== FALSE) { curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1 } - curl_setopt($oCurl, CURLOPT_URL, $url);//目标URL - curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );//设定是否显示头信息,1为显示 - curl_setopt($oCurl, CURLOPT_BINARYTRANSFER, true) ;//在启用CURLOPT_RETURNTRANSFER时候将获取数据返回 + curl_setopt($oCurl, CURLOPT_URL, $url); //目标URL + curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); //设定是否显示头信息,1为显示 + curl_setopt($oCurl, CURLOPT_BINARYTRANSFER, true); //在启用CURLOPT_RETURNTRANSFER时候将获取数据返回 $sContent = curl_exec($oCurl); - $aStatus = curl_getinfo($oCurl);//获取页面各种信息 + $aStatus = curl_getinfo($oCurl); //获取页面各种信息 curl_close($oCurl); - if(intval($aStatus["http_code"])==200){ + if (intval($aStatus["http_code"]) == 200) { return $sContent; - }else{ + } else { return false; } } -function my_doiToFrag($data){ +function my_doiToFrag($data) +{ $ts_refer_obj = Db::name('ts_refer'); - if($data['refer_doi']==''){ + if ($data['refer_doi'] == '') { return 0; } - $doi = str_replace('/','%2F',$data['refer_doi']); + $doi = str_replace('/', '%2F', $data['refer_doi']); $url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US"; $res = myGet($url); - $frag = trim(substr($res,strpos($res,'.')+1)); + $frag = trim(substr($res, strpos($res, '.') + 1)); $f = ''; $cs = 0; - if($frag==""){ + if ($frag == "") { $f = $data['refer_content']; - }else{ - $c_frag = rtrim($frag,'.'); - $f = substr_replace($c_frag,PHP_EOL,strripos($c_frag,"http"),0); + } else { + $c_frag = rtrim($frag, '.'); + $f = substr_replace($c_frag, PHP_EOL, strripos($c_frag, "http"), 0); $cs = 1; } - $ts_refer_obj->where('ts_refer_id',$data['ts_refer_id'])->update(['refer_frag'=>$f,"cs"=>$cs]); + $ts_refer_obj->where('ts_refer_id', $data['ts_refer_id'])->update(['refer_frag' => $f, "cs" => $cs]); $ts_refer_obj->close(); } -function my_doiToFrag1($data){ +function my_doiToFrag1($data) +{ $p_refer_obj = Db::name('production_article_refer'); - if($data['refer_doi']==''){ + if ($data['refer_doi'] == '') { return 0; } - $doi = str_replace('/','%2F',$data['refer_doi']); + $doi = str_replace('/', '%2F', $data['refer_doi']); // $url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US"; $url = "https://citation.crosscite.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US"; $res = myGet($url); - $frag = trim(substr($res,strpos($res,'.')+1)); + $frag = trim(substr($res, strpos($res, '.') + 1)); $f = ''; $cs = 0; - if($frag==""){ + if ($frag == "") { $f = $data['refer_content']; - }else{ - $c_frag = rtrim($frag,'.'); + } else { + $c_frag = rtrim($frag, '.'); // $f = substr_replace($c_frag,PHP_EOL,strripos($c_frag,"http"),0); - $f = $c_frag." Available at: ".PHP_EOL."http://doi.org/".$data['refer_doi']; + $f = $c_frag . " Available at: " . PHP_EOL . "http://doi.org/" . $data['refer_doi']; $cs = 1; } - $p_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['refer_frag'=>$f,"cs"=>$cs]); + $p_refer_obj->where('p_refer_id', $data['p_refer_id'])->update(['refer_frag' => $f, "cs" => $cs]); $p_refer_obj->close(); } /** * 增加用户积分log信息 */ -function addUserScoreLog($user_id,$score,$content,$ctime,$act='+'){ +function addUserScoreLog($user_id, $score, $content, $ctime, $act = '+') +{ $score_obj = Db::name('user_score_log'); $insert['user_id'] = $user_id; $insert['content'] = trim($content); @@ -336,103 +346,143 @@ function addUserScoreLog($user_id,$score,$content,$ctime,$act='+'){ } -function my_doiToFrag2($data){ +function my_doiToFrag2($data) +{ $p_refer_obj = Db::name('production_article_refer'); - if($data['refer_doi']==''){ + if ($data['refer_doi'] == '') { return 0; } - $doi = str_replace('/','%2F',$data['refer_doi']); + $doi = str_replace('/', '%2F', $data['refer_doi']); // $url = "https://citation.crosscite.org/format?doi=$doi&style=american-veterinary-medical-association&lang=en-US"; $url = "https://citation.crosscite.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US"; $res = myGet($url); - $frag = trim(substr($res,strpos($res,'.')+1)); + $frag = trim(substr($res, strpos($res, '.') + 1)); $update = []; - if($frag==""){ + if ($frag == "") { $update['refer_frag'] = $data['refer_content']; - }else{ + } else { // preg_match("/[0-9]{4}/",$frag,$math); // $year = $math[0]; // $qbj=trim(substr($frag,0,stripos($frag,$year))) ; - if(mb_substr_count($frag,'.')!=3){ - $f = $frag." Available at: ".PHP_EOL."http://doi.org/".$data['refer_doi']; + if (mb_substr_count($frag, '.') != 3) { + $f = $frag . " Available at: " . PHP_EOL . "http://doi.org/" . $data['refer_doi']; $update['refer_frag'] = $f; $update['cs'] = 1; - }else{ - $res = explode('.',$frag); + } else { + $res = explode('.', $frag); $update['author'] = prgeAuthor($res[0]); $update['title'] = trim($res[1]); $bj = bekjournal($res[2]); $joura = formateJournal(trim($bj[0])); $update['joura'] = $joura; $is_js = 0; - if($joura==trim($bj[0])){ - + if ($joura == trim($bj[0])) { } - $update['is_ja'] = $joura==trim($bj[0])?0:1; - $update['dateno'] = str_replace(' ','',str_replace('-','–',trim($bj[1]))); - $update['doilink'] = "http://doi.org/".$data['refer_doi']; + $update['is_ja'] = $joura == trim($bj[0]) ? 0 : 1; + $update['dateno'] = str_replace(' ', '', str_replace('-', '–', trim($bj[1]))); + $update['doilink'] = "http://doi.org/" . $data['refer_doi']; $update['cs'] = 1; } } - $p_refer_obj->where('p_refer_id',$data['p_refer_id'])->update($update); + $p_refer_obj->where('p_refer_id', $data['p_refer_id'])->update($update); $p_refer_obj->close(); } -function bekjournal($str){ - preg_match("/[0-9]{4}/",$str,$math); +function bekjournal($str) +{ + preg_match("/[0-9]{4}/", $str, $math); $year = $math[0]; - $frag[0]=trim(substr($str,0,stripos($str,$year))) ; - $frag[1]=substr($str,stripos($str,$year)); + $frag[0] = trim(substr($str, 0, stripos($str, $year))); + $frag[1] = substr($str, stripos($str, $year)); return $frag; } -function formateJournal($fullname){ +function formateJournal($fullname) +{ $obj = Db::name('journal_abbr'); - $r = $obj->where('full_name',$fullname)->find(); - if($r){ + $r = $obj->where('full_name', $fullname)->find(); + if ($r) { return $r['little_name']; - }else{ + } else { return $fullname; } } -function prgeAuthor($author){ - $a = explode(',',$author); - if(count($a)<7){ - return $author.'.'; - }else{ - return trim($a[0]).', '.trim($a[1]).', '.trim($a[2]).', et al.'; +function prgeAuthor($author) +{ + $a = explode(',', $author); + if (count($a) < 7) { + return $author . '.'; + } else { + return trim($a[0]) . ', ' . trim($a[1]) . ', ' . trim($a[2]) . ', et al.'; } } -function my_tg_pushmail($data){ - $res = sendEmail($data['email'],$data['title'],$data['title'],$data['content'],$data['tmail'],$data['tpassword'],$data['attachmentFile']); - if(isset($res['status'])){ +function my_tg_pushmail($data) +{ + $res = sendEmail($data['email'], $data['title'], $data['title'], $data['content'], $data['tmail'], $data['tpassword'], $data['attachmentFile']); + if (isset($res['status'])) { $log_obj = Db::name('email_log'); $insert['article_id'] = $data['article_id']; $insert['email'] = $data['email']; $insert['content'] = $data['content']; $insert['is_success'] = $res['status']; - $insert['attachment'] = $data['attachmentFile']!=''?substr($data['attachmentFile'],strrpos($data['attachmentFile'],'enclosure/')+10):''; + $insert['attachment'] = $data['attachmentFile'] != '' ? substr($data['attachmentFile'], strrpos($data['attachmentFile'], 'enclosure/') + 10) : ''; $insert['ctime'] = time(); $log_obj->insert($insert); $log_obj->close(); } - +} + +function getMajorStr($major_id) +{ + $major_obj = Db::name('major'); + $frag = ''; + $major_info = $major_obj->where('major_id', $major_id)->find(); + if ($major_info == null) { + return ''; + } + if ($major_info['major_level'] == 1) { + return 'Medicine'; + } else { + $frag = getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title']; + } + return $frag; +} + +function getMajorShu($major) +{ + $major_obj = Db::name('major'); + if ($major == 0) { + return; + } + $res = $major_obj->where('major_id', $major)->find(); + if ($res['pid'] == 1) { + return $res['major_id']; + } + + $p = getMajorShu($res['pid']); + return $p . ',' . $res['major_id']; +} + +function getReviewerCvs($reviewer_id){ + $cvs = Db::name('user_cv')->where('user_id',$reviewer_id)->where('state',0)->select(); + return $cvs; } /** * 增加usermsg */ -function add_usermsg($userid, $content, $url) { +function add_usermsg($userid, $content, $url) +{ $msg_obj = Db::name('user_msg'); $msg_info = $msg_obj->where('user_id', $userid) - ->where('url', $url) - ->where('state', 0) - ->find(); + ->where('url', $url) + ->where('state', 0) + ->find(); if ($msg_info) { return true; } @@ -443,15 +493,18 @@ function add_usermsg($userid, $content, $url) { return $msg_obj->insert($msgdata); } -function jsonSuccess($data) { +function jsonSuccess($data) +{ return json(['code' => 0, 'msg' => 'success', 'data' => $data]); } -function jsonError($msg) { +function jsonError($msg) +{ return json(['code' => 1, 'msg' => $msg]); } -function choiseJabbr($article_id, $jabbr) { +function choiseJabbr($article_id, $jabbr) +{ if ($article_id < 1799 && $jabbr == "Cancer Adv") { return "TMR Cancer"; } @@ -468,7 +521,8 @@ function choiseJabbr($article_id, $jabbr) { -function myPost($url, $param = array()) { +function myPost($url, $param = array()) +{ if (!is_array($param)) { @@ -477,8 +531,8 @@ function myPost($url, $param = array()) { $httph = curl_init($url); -// curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0); -// curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1); + // curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0); + // curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($httph, CURLOPT_RETURNTRANSFER, 1); @@ -488,8 +542,10 @@ function myPost($url, $param = array()) { curl_setopt($httph, CURLOPT_POSTFIELDS, $param); -// curl_setopt($httph, CURLOPT_RETURNTRANSFER,0); -// curl_setopt($httph, CURLOPT_HEADER,1); + curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, false); + + // curl_setopt($httph, CURLOPT_RETURNTRANSFER,0); + // curl_setopt($httph, CURLOPT_HEADER,1); $rst = curl_exec($httph); @@ -498,7 +554,8 @@ function myPost($url, $param = array()) { return $rst; } -function myPost1($url, $param = array()) { +function myPost1($url, $param = array()) +{ if (!is_array($param)) { @@ -509,10 +566,10 @@ function myPost1($url, $param = array()) { $httph = curl_init($url); curl_setopt($httph, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - )); + )); -// curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0); -// curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1); + // curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0); + // curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($httph, CURLOPT_RETURNTRANSFER, 1); @@ -522,8 +579,8 @@ function myPost1($url, $param = array()) { curl_setopt($httph, CURLOPT_POSTFIELDS, $data); -// curl_setopt($httph, CURLOPT_RETURNTRANSFER,0); -// curl_setopt($httph, CURLOPT_HEADER,1); + // curl_setopt($httph, CURLOPT_RETURNTRANSFER,0); + // curl_setopt($httph, CURLOPT_HEADER,1); $rst = curl_exec($httph);