Files
tougao/application/api/controller/Ucenter.php
2025-05-21 11:55:23 +08:00

741 lines
30 KiB
PHP

<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Validate;
use think\Queue;
class Ucenter extends Base{
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
}
/**
* Notes:获取个人基本信息
* User: wangzhaocui
* Date: 2022/3/11
* Time: 18:12
* @return \think\response\Json
*/
public function getUserInfo(){
//接收参数
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
// 基本信息
$baseInfo = $this->user_obj->where(['user_id' => $data['user_id']])->find();
if(!$baseInfo){
return jsonError("error");
}
//用户推荐码
if($baseInfo['code']==''){
$d['code'] = $this->creatUserCode($baseInfo['user_id']).$baseInfo['user_id'];
$this->user_obj->where('user_id',$baseInfo['user_id'])->update($d);
}
//检查用户reviewer的info信息
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->find();
if(!$reviewer_info){
$insert_reviewer['reviewer_id'] = $data['user_id'];
$insert_reviewer['test_from'] = "getUserInfo";
$this->user_reviewer_info_obj->insert($insert_reviewer);
}
$userInfo['baseInfo']=$this->user_obj
->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();
//获取用户的领域
$userInfo['baseInfo']['majorshu'] = $userInfo['baseInfo']['major']==0?'':getMajorShu($userInfo['baseInfo']['major']);
$userInfo['baseInfo']['majorStr'] = $userInfo['baseInfo']['major']==0?'':getMajorStr($userInfo['baseInfo']['major']);
$majors = $this->major_to_user_obj->where("user_id",$data['user_id'])->where("state",0)->select();
foreach ($majors as $k => $v){
$majors[$k]['shu'] = $this->getMajorShu($v['major_id']);
$majors[$k]['str'] = $this->getMajorStr($v['major_id']);
}
$userInfo['baseInfo']['majors'] = $majors;
//cv信息
$cvs = $this->user_cv_obj->where('user_id',$data['user_id'])->where('state',0)->select();
$userInfo['cvs'] = $cvs;
// 默认为作者(若作者没有发表过文章则不返回)
$isAuthor = $this->article_obj->where(['user_id'=>$baseInfo['user_id']])->find();
if($isAuthor){
$userInfo['asAuthor'] = self::getAsAuthor($baseInfo['user_id']);
}
$userInfo['Author'] = self::getAsAuthorNew($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);
}
/**
* 检测是否可申请审稿人
*/
public function checkApplyReviewer(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->find();
}
public function getCanApplyJournal(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journals = $this->apply_board_obj->where('user_id',$data['user_id'])->where('state',0)->column("journal_id");
$js = $this->board_to_journal_obj->where('user_id',$data['user_id'])->where('state',0)->column('journal_id');
$list = $this->journal_obj->where('journal_id','not in',$journals)->where('journal_id','not in',$js)->where('state',0)->select();
$re['journals'] = $list;
return jsonSuccess($re);
}
public function getCanApplyYjournal(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require'
]);
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->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','not in',$ids)->where('state',0)->select();
$re['journals'] = $journals;
return jsonSuccess($re);
}
public function applyYboard(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'journal_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$check = $this->apply_yboard_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find();
if($check){
return jsonError("Your application for Editorial Board is processing. Please do not repeat it.");
}
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['ctime'] = time();
$id = $this->apply_yboard_obj->insertGetId($insert);
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$user_info = $this->user_obj->where('user_id',$data['user_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
//发送邮件给用户
$dd = "Dear Dr. ".$user_info['realname'].",<br/><br/>";
$dd .= "We are writing to inform you that the Editorial Office has received your application for the position of Young Scientist Board Member of <i>".$journal_info['title']."</i> journal. Your application is currently under review and has been assigned the application number TMR-".$journal_info['abbr']."-".$id.".<br/><br/>";
$dd .= "We would like to take this opportunity to briefly introduce you to the rights and obligations of a Youth Scientist Board Member.<br/><br/>";
$dd .= "Rights:<br/><br/>";
$dd .= "1. Electronic Certificate: As a Young Scientist Board Member, you will receive an electronic certificate to acknowledge your position in our publication.<br/>";
$dd .= "2. Opportunity for Advancement: Outstanding Young Scientist Board Member may be considered as potential candidates for the Editorial Board.<br/>";
$dd .= "3. Special Issues: You will have the opportunity to apply for a special Issue to expand your influence and that of your team.<br/><br/>";
$dd .= "Obligations:<br/><br/>";
$dd .= "1. Peer Review: As a Young Scientist Board Member, you will be required to review and assess 3-5 manuscripts per year, based on your area of research.<br/>";
$dd .= "2. Active Promotion: You should actively promote our publication in your academic and professional circles and recommend quality manuscripts to scholars in your network.<br/>";
$dd .= "3. Provide Feedback: You should provide constructive feedback and suggestions to improve the direction and style of our publication. If feasible, you may also attend small forums or conferences to represent our publication.<br/><br/>";
$dd .= "We appreciate your interest in becoming a Young Scientist Board Member and we will inform you of the outcome of your application as soon as possible. If you have any questions or concerns, please do not hesitate to contact us.<br/><br/><br/>";
$dd .= 'Sincerely,<br>Editorial Office<br>';
$dd .= $journal_info['title'] . '<br>';
$dd .= 'Email: ' . $journal_info['email'] . '<br>';
$dd .= 'Website: ' . $journal_info['website'] . '<br>';
$maidata['email'] = $user_info['email'];
$maidata['title'] = $journal_info['title'];
$maidata['content'] = $dd;
$maidata['tmail'] = $journal_info['email'];
$maidata['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $maidata, "tmail");
//发送邮件给编辑
$vv = "Dear editor,<br/><br/>";
$vv .= "Please check the new application for Young Scientist Board Member for ".$journal_info['title']." Journal.";
$mai['email'] = $editor_info['email'];
$mai['title'] = $journal_info['title'];
$mai['content'] = $vv;
$mai['tmail'] = $journal_info['email'];
$mai['tpassword'] = $journal_info['epassword'];
Queue::push('app\api\job\mail@fire', $mai, "tmail");
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();
$list = $this->user_to_yboard_obj->where('user_id',$user_id)->where('state',0)->order('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;
$journal['article_num'] = $this->article_obj->where('user_id',$user_id)->where('state',5)->where('journal_id',$v['journal_id'])->count();
$journal['reviewer_num'] = $this->article_reviewer_obj
->join("t_article","t_article.article_id = t_article_reviewer.article_id","left")
->where('t_article_reviewer.reviewer_id',$user_id)
->where('t_article.journal_id',$v['journal_id'])
->where('t_article_reviewer.state','in',[1,2,3])
->count();
$frag[] = $journal;
}
return $frag;
}
/**
* 审查用户对身份的申请条件是否通过
*/
public function checkApply(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'type'=>'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.user_id',$data['user_id'])->find();
$cv = $this->user_cv_obj->where('user_id',$data['user_id'])->where('state',0)->find();
if($user_info['realname']==''||$user_info['company']==''||$user_info['technical']==''||$user_info['major']==0||$user_info['field']==''||!$cv){
$str = '';
switch($data['type']){
case 1:
$str = "Please kindly note that before proceeding to the reviewer application, it is essential to complete your profile with the following details: your full name, affiliation, academic title, academic website, research interests, and curriculum vitae. Thank you for your interest in making a valuable contribution to our journal as a reviewer.";
break;
case 2:
$str = "Please kindly note that before proceeding to the young scientist application, it is essential to complete your profile with the following details: your full name, affiliation, academic title, academic website, research interests, and curriculum vitae. Thank you for your interest in making a valuable contribution to our journal as a young scientist.";
break;
case 3:
$str = "Please kindly note that before proceeding to the editorial board member application, it is essential to complete your profile with the following details: your full name, affiliation, academic title, academic website, research interests, and curriculum vitae. Thank you for your interest in making a valuable contribution to our journal as an editorial board member.";
break;
default :
$str = "Please kindly note that before proceeding to the reviewer application, it is essential to complete your profile with the following details: your full name, affiliation, academic title, academic website, research interests, and curriculum vitae. Thank you for your interest in making a valuable contribution to our journal as a reviewer.";
}
return jsonError($str);
}
return jsonSuccess([]);
}
public function applyBoard(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'journal_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$check = $this->apply_board_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->where('state',0)->find();
if($check){
return jsonError("");
}
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['ctime'] = time();
$this->apply_board_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 申请成为审稿人
*/
public function applyReviewer(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'journal_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$check1 = $this->apply_reviewer_obj->where('user_id',$data['user_id'])->where('journal_id',$data['journal_id'])->find();
$check2 = $this->reviewer_to_journal_obj->where('reviewer_id',$data['user_id'])->where('journal_id',$data['journal_id'])->find();
if($check1||$check2){
return jsonError("Your reviewer application is already under review or has been accepted. Please do not submit a duplicate application.");
}
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['ctime'] = time();
$this->apply_reviewer_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 增加用户cv
*/
public function addUserCv(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'cv'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$insert['user_id'] = $data['user_id'];
$insert['cv'] = $data['cv'];
$insert['ctime'] = time();
$this->user_cv_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 删除用户简历
*/
public function delUserCv(){
$data = $this->request->post();
$rule = new Validate([
'user_cv_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->user_cv_obj->where('user_cv_id',$data['user_cv_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**
* Notes: 修改个人基本信息baseInfo
* User: wangzhaocui
* Date: 2022/3/14
* Time: 12:23
* @return \think\response\Json
*/
public function updateUserInfo(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'realname'=>'require',
'technical'=>'require',
'country'=>'require',
'major'=>'require|number',
'field'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$update['realname'] = trim($data['realname']);
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'=>isset($data['introduction'])?$data['introduction']:'',
"website"=>isset($data['website'])?$data["website"]:"",
'company'=>$data['company']
];
$this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata1);
return jsonSuccess([]);
}
/**
* Notes: 修改 asReviewe 信息
* User: wangzhaocui
* Date: 2022/3/14
* Time: 17:02
* @return \think\response\Json
*/
// public function updateAsReviewerInfo(){
// $data = $this->request->post();
// // 验证规则
// $rule = new Validate([
// 'user_id'=>'require|number',
// 'technical'=>'require',
// 'country'=>'require',
// 'major'=>'require|number',
// 'field'=>'require'
// ]);
// if(!$rule->check($data)){
// return json(['code' => 1,'msg'=>$rule->getError()]);
// }
// $updata=[
// 'technical'=>$data['technical'],
// 'country'=>$data['country'],
// 'major'=>$data['major'],
// 'field'=>$data['field'],
// 'introduction'=>$data['introduction'],
// ];
// $this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata);
// return jsonSuccess([]);
// }
/**
* Notes:修改 asEditor 信息
* User: wangzhaocui
* Date: 2022/3/16
* Time: 10:16
*/
public function updateAsEditorInfo(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'user_id'=>'require|number',
'journal_id'=>'require|number',
'email'=>'require|email',
'password'=>'require'
]);
if(!$rule->check($data)){
return json(['code' => 1,'msg'=>$rule->getError()]);
}
$isExist = $this->journal_obj->where(['journal_id'=>$data['journal_id'],'editor_id'=>$data['user_id']])->find();
if(empty($isExist)){
return json(['code' => 1,'msg'=>'not exist']);
}
$update=[
'email'=>$data['email'],
'epassword'=>$data['password']
];
$this->journal_obj->where(['journal_id'=>$data['journal_id'],'editor_id'=>$data['user_id']])->update($update);
return jsonSuccess([]);
}
/**
* Notes:修改个人头像
* User: wangzhaocui
* Date: 2022/3/14
* Time: 10:52
* @return \think\response\Json
*/
public function updateIncon(){
// 获取表单上传文件
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
'icon'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->user_obj->where(['user_id'=>$data['user_id']])->update(['icon'=>$data['icon']]);
return jsonSuccess([]);
}
public function up_userIcon_file()
{
$file = request()->file('icon');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'usericon');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
/**
* Notes: 作者信息
* User: wangzhaocui
* Date: 2022/3/14
* Time: 14:49
* @param $userId
* @return array
*/
private function getAsAuthor($userId){
// 作者发表文章总数
$user_info = $this->user_obj->where('user_id',$userId)->find();
$manuscriptNum = $this->article_obj->where(['user_id'=>$userId])->count();
$journal = $this->article_obj->field('t_journal.title,t_journal.abbr')
->join('t_journal','t_journal.journal_id = t_article.journal_id','RIGHT')
->where(['user_id'=>$userId])
->distinct('t_article.journal_id')
->select();
//推荐总数
if($user_info['code']!=''){
$tj_num = $this->article_obj->where("code",$user_info['code'])->count();
}else{
$tj_num = 0 ;
}
// 发表文章通过数
$accept = $this->article_obj->where(['user_id'=>$userId,'state'=>5])->count();
$indexs = $this->user_index_log_obj->where('user_id',$userId)->where('state',0)->count();
$res = [
'manuscriptNum'=>$manuscriptNum,
'accept'=>$accept,
"tj"=>$tj_num,
'journal'=>$journal,
'index'=>$indexs
];
return $res;
}
// private function getAsAuthorNew($userId){
// $user_info = $this->user_obj->where("user_id",$userId)->find();
// $flag = [];
// //推荐总数
// if($user_info['code']!=''){
// $tj_num = $this->article_obj->where("code",$user_info['code'])->count();
// }else{
// $tj_num = 0 ;
// }
// $flag['tj'] = $tj_num;
// //获取作为提交者的文章
// $ids1 = $this->article_obj->where("t_article.user_id",$userId)->column("article_id");
// //获取作为作者的文章
// $ids2 = $this->article_author_obj->where("email",$user_info['email'])->where("state",0)->column("article_id");
// $ids = array_unique(array_merge($ids1,$ids2));
// $articles = $this->article_obj
// ->field("t_article.*,t_journal.title as journal_title,t_journal.abbr")
// ->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
// ->whereIn("t_article.article_id",$ids)
// ->select();
// foreach ($articles as $k => $v){
// $role = [];
// if($v['user_id'] == $user_info['user_id']){
// $role[] = "user";
// }
// $author_check = $this->article_author_obj->where("email",$user_info['email'])->where("article_id",$v['article_id'])->where("state",0)->find();
// if($author_check){
// $role[] = "author";
// }
// $articles[$k]['role'] = $role;
// if($v['state']==5){
// $check = $this->production_article_obj->where("article_id",$v['article_id'])->where("state",2)->find();
// if($check){
// $articles[$k]['link'] = "https://doi.org/10.53388/".$check['doi'];
// }
// }
// }
// $flag['articles'] = $articles;
// return $flag;
// }
private function getAsAuthorNew($userId){
$user_info = $this->user_obj->where("user_id",$userId)->find();
$flag = [];
//推荐总数
$tj_num = 0 ;
if($user_info['code']!=''){
$tj_num = $this->article_obj->where("code",$user_info['code'])->count();
}
$flag['tj'] = $tj_num;
//获取作为提交者的文章
$ids1 = $this->article_obj->where("t_article.user_id",$userId)->column("article_id");
//获取作为作者的文章
$ids2 = $this->article_author_obj->where("email",$user_info['email'])->where("state",0)->column("article_id");
//文章ID合并
$ids = array_unique(array_merge($ids1,$ids2));
$flag['articles'] = [];
if(empty($ids)){
return $flag;
}
//查询文章信息
$aArticle = $aProductionArticle = [];
$aChunksId = array_chunk($ids, 200);
foreach ($aChunksId as $value) {
$articles = $this->article_obj
->field("t_article.*,t_journal.title as journal_title,t_journal.abbr")
->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
->whereIn("article_id",$value)
->select();
if(!empty($articles)){
//查询生产文章主表
$aArticleId = array_column($articles, 'article_id');
$aProductionArticleInfo = $this->production_article_obj->whereIn("article_id",$aArticleId)->where("state",2)->column('article_id,doi');
if(!empty($aProductionArticleInfo)){
$aProductionArticle += $aProductionArticleInfo;
}
}
$aArticle = array_merge($aArticle,$articles);
}
//数据处理
foreach ($aArticle as $k => $v){
$role = [];
if($v['user_id'] == $user_info['user_id']){
$role[] = "user";
}
if(!empty($ids2) && in_array($v['article_id'], $ids2)){
$role[] = "author";
}
$articles[$k]['role'] = $role;
if($v['state']==5 && !empty($aProductionArticle[$v['article_id']])){
$articles[$k]['link'] = empty($aProductionArticle[$v['article_id']]) ? '' : "https://doi.org/10.53388/".$aProductionArticle[$v['article_id']];
}
}
$flag['articles'] = $articles;
return $flag;
}
public function getMajor(){
$data = $this->request->post();
$rule = new Validate([
'major_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$major = $this->major_obj->where('major_id',$data['major_id'])->where("major_state",0)->find();
$major['children'] = $this->major_obj->where('pid',$major['major_id'])->where("major_state",0)->select();
$re['major'] = $major;
return jsonSuccess($re);
}
/**
* Notes:获取审稿人
* User: admin
* Date: 2022/3/14
* Time: 14:45
* @param $account
*/
private function getAsReviewer($userId){
// 获取审稿人基本信息
$res = $this->user_reviewer_info_obj->where(['reviewer_id'=>$userId])->find();
$res['majors'] = getMajorShu($res['major']);
// 获取审稿人期刊
$journal = $this->reviewer_to_journal_obj->field('t_journal.title,t_journal.abbr')
->join('t_journal','t_journal.journal_id = t_reviewer_to_journal.journal_id','LEFT')
->where(['t_reviewer_to_journal.reviewer_id'=>$userId,'t_reviewer_to_journal.state'=>0])
->select();
// 审稿人成功审稿次数
$successReview = $this->article_reviewer_obj->where('reviewer_id',$userId)->where('state','in',[1,2,3])->count();
$res['successReview'] = $successReview;
$res['journal'] = $journal;
return $res;
}
/**
* Notes: 编辑的期刊资料
* User: wangzhaocui
* Date: 2022/3/15
* Time: 15:36
* @param $userId
*/
private function getAsEditor($userId){
$res = $this->journal_obj->field('journal_id,title,abbr,issn,email,epassword')->where(['editor_id'=>$userId])->select();
foreach ($res as $k =>$v){
$res[$k]['notApproved'] = $this->article_obj->where(['journal_id'=>$v['journal_id'],'state'=>0])->count();
}
return $res;
}
/**
* Notes: 主编资料
* User: wangzhaocui
* Date: 2022/3/15
* Time: 14:17
* @param $userId
*/
private function getAsChief($userId){
$res = $this->chief_to_journal_obj->field('t_chief_to_journal.journal_id,t_journal.title,t_journal.issn,t_journal.abbr,t_user.realname as editorRealname')
->join('t_journal','t_journal.journal_id = t_chief_to_journal.journal_id','LEFT')
->join('t_user','t_user.user_id = t_journal.editor_id','LEFT')
->where(['t_chief_to_journal.user_id'=>$userId])
->select();
foreach ( $res as $k=>$v){
//期刊发表投稿总数
$res[$k]['totalManuscripts'] = $this->article_obj->where(['journal_id'=>$v['journal_id']])->count();
//期刊已录用数
$res[$k]['acceptManuscripts'] = $this->article_obj->where(['journal_id'=>$v['journal_id'],'state'=>5])->count();
}
return $res;
}
/**
* Notes: 编委信息 asBoard 信息
* User: wangzhaocui
* Date: 2022/3/16
* Time: 16:15
* @param $data
* @return array
*/
private function getAsBoard($user_id){
$data = $this->board_to_journal_obj->where('user_id',$user_id)->where('state',0)->select();
foreach ($data as $k=>$v){
// 查找期刊title
// $data[$k]= $this->journal_obj->where('journal_id',$v['journal_id'])->field('journal_id,title,issn,abbr')->find();
$data[$k]= $this->journal_obj->where('journal_id',$v['journal_id'])->find();
// 其他编委名字
// $otherBoards = $this->board_to_journal_obj->field('t_user.realname')
// ->join('t_user','t_user.user_id = t_board_to_journal.user_id')
// ->where('t_board_to_journal.journal_id',$v['journal_id'])
// ->select();
// $data[$k]['otherBoards'] = array_column($otherBoards, 'realname');
}
return $data;
}
public function up_cv_file()
{
$file = request()->file('reviewerCV');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'reviewer');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
}