request->post(); return jsonSuccess(['mycode'=>md5($data['mmm'])]); } public function emailTest(){ $email = '751475802@qq.com'; $title = 'testemail'; $tt = 'content'; $journal_info = $this->journal_obj->where('journal_id',12)->find(); $res = sendEmail($email, $title, $title, $tt, $journal_info['email'],$journal_info['epassword']); dump($res); } /** * 获取编辑人员列表(分页) */ public function getEditor() { $data = $this->request->post(); $where['type'] = 2; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $res = $this->user_obj->where($where)->limit($limit_start, $data['pageSize'])->select(); $count = $this->user_obj->where($where)->count(); return json(['total' => $count, 'data' => $res]); } /** * 获取所有编辑 */ public function getEditorList() { $where['type'] = 2; $res = $this->user_obj->where($where)->select(); return $res == null ? json(['code' => 1, 'msg' => 'Acquisition failed']) : json(['code' => 0, 'data' => $res]); } /** * 添加编辑 */ public function addEditor() { $data = $this->request->post(); $checkres = $this->user_obj->where(['account' => $data['username']])->whereOr(['email' => $data['email']])->find(); if ($checkres != null) { return json(['code' => 1, 'msg' => 'username or email has registered']); } $insert_data['account'] = $data['username']; $insert_data['password'] = md5($data['password']); $insert_data['email'] = $data['email']; $insert_data['phone'] = $data['phone']; $insert_data['realname'] = $data['realname']; $insert_data['type'] = 2; $insert_data['ctime'] = time(); $this->user_obj->insert($insert_data); return json(['code' => 0]); } /** * 获取文章(admin) */ public function getArticle() { //接收参数 $data = $this->request->post(); // $data['journal'] = 0; // $data['pageIndex'] = 1; // $data['pageSize'] = 10; //构造查询条件 $where = []; if ($data['journal'] != 0) { $where['t_article.journal_id'] = $data['journal']; } if ($data['state'] >= 0) { $where['t_article.state'] = $data['state']; } else { if ($data['act'] == 1) { $where['t_article.state'] = array('in', [0, 1, 2, 4, 6]); } else if ($data['act'] == 2) { $where['t_article.state'] = array('in', [3, 5]); } } //分页查询数据 $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $res = $this->article_obj->field('t_article.*,t_journal.title journalname,t_journal.abbr abbr,t_user.account username,t_user.realname realname') ->join('t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT') ->join('t_user', 't_journal.editor_id = t_user.user_id', 'LEFT') ->where($where) ->order('article_id desc') ->limit($limit_start, $data['pageSize'])->select(); $count = $this->article_obj->where($where)->count(); //收集文章的国家 foreach ($res as $k => $v) { $c_res = $this->article_author_obj->where('article_id', $v['article_id'])->select(); $c_frag = []; foreach ($c_res as $vv) { if ($vv['country'] == "") { continue; } if (!in_array($vv['country'], $c_frag)) { $c_frag[] = $vv['country']; } } $res[$k]['country'] = implode(',', $c_frag); } //返回数据 return json(['total' => $count, 'data' => $res]); } /** * 获取文章详情 */ public function getArticleDetail() { //接受参数 $data = $this->request->post(); //查询文章基础数据 $where['t_article.article_id'] = $data['articleId']; $article_res = $this->article_obj->field('t_article.*,t_journal.title journalname,t_user.account')->join(array(['t_journal', 't_journal.journal_id = t_article.journal_id', 'LEFT'], ['t_user', 't_user.user_id = t_article.user_id', 'LEFT']))->where($where)->find(); //查询文章状态跟踪信息 $article_msg = $this->article_msg_obj->where(['article_id' => $data['articleId']])->select(); $suggest = ''; //如果是退修状态,显示退休信息 if ($article_res['state'] == 4) { $lastbean = end($article_msg); $suggest = $lastbean['content']; } //查询major信息 $major_data = []; if($article_res['major_id']!=0){ $major_data['major'] = $this->reviewer_major_obj->where('major_id',$article_res['major_id'])->find(); }else{ $major_data['major'] = null; } if($article_res['cmajor_id']!=0){ $major_data['cmajor'] = $this->reviewer_major_obj->where('major_id',$article_res['cmajor_id'])->find(); }else{ $major_data['cmajor'] = null; } //查询文章作者信息 $author_res = $this->article_author_obj->where('article_id', $data['articleId'])->where('state', 0)->select(); return json(['article' => $article_res, 'msg' => $article_msg, 'authors' => $author_res, 'suggest' => $suggest,'major'=>$major_data]); } /** * 获取期刊列表 */ public function getJournals() { $data = $this->request->post(); $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'] ; $res = $this->journal_obj->field('t_journal.*,t_user.account editor')->join('t_user', 't_user.user_id=t_journal.editor_id', 'left')->order('t_journal.journal_id')->limit($limit_start, $data['pageSize'])->select(); $count = $this->journal_obj->count(); return json(['total' => $count, 'data' => $res]); } /** * 添加期刊 */ public function journalAdd() { $data = $this->request->post(); $checkres = $this->journal_obj->where(['title' => $data['title']])->whereOr(['issn' => $data['issn']])->find(); if ($checkres != null) { return json(['code' => 1, 'msg' => 'title or issn already exists']); } $insert_data['title'] = $data['title']; $insert_data['issn'] = $data['issn']; $insert_data['alias'] = $data['alias']; $this->journal_obj->insert($insert_data); return json(['code' => 0]); } /** * 更改期刊编辑 */ public function journalEditorChange() { $data = $this->request->post(); $update['editor_id'] = $data['editorId']; $where['journal_id'] = $data['journalId']; $res = $this->journal_obj->where($where)->update($update); return json(['code' => $res == null ? 1 : 0]); } /** * @title 上传reviewer申请 * @description 上传reviewer申请 * @author wangjinlei * @url /api/Admin/reviewer * @method POST * * @param name:company type:String require:1 desc:单位 * @param name:country type:String require:1 desc:国家 * @param name:email type:String require:1 desc:邮箱 * @param name:field type:String require:1 desc:领域描述 * @param name:gender type:String require:1 desc:1男2女 * @param name:introduction type:String require:1 desc:简介 * @param name:journal type:int require:1 desc:journal_id * @param name:major type:int require:1 desc:major_id * @param name:qualifications type:String require:1 desc:cv地址 * @param name:technical type:String require:1 desc:职称 * @param name:username type:String require:1 desc:申请者用户名 * */ public function reviewer() { die("service stop!!"); //接受参数 $data = $this->request->post(); $journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find(); $editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find(); //组合数据,insert $insert_data['journal_id'] = $data['journal']; $insert_data['name'] = $data['username']; $insert_data['introduction'] = $data['introduction']; $insert_data['email'] = $data['email']; $insert_data['company'] = $data['company']; $insert_data['country'] = $data['country']; $insert_data['major'] = $data['major']; $insert_data['technical'] = $data['technical']; $insert_data['field'] = $data['field']; $insert_data['gender'] = $data['gender']; $insert_data['qualifications'] = $data['qualifications']; $insert_data['ctime'] = time(); $res = $this->user_reviewer_obj->insertGetId($insert_data); if ($res > 0) { //发送email-》编辑 $tt = 'Dear editor,
'; $tt .= 'Please check the new reviewer application.'; $sendUser=[ 'title'=>$journal_info['title'], // 邮件标题 'content'=>$tt,//邮件内容 'user_id'=>$editor_info['user_id'], //收件人ID 'email'=>$editor_info['email'],// 收件人邮箱 'journal_id'=>$journal_info['journal_id'], // 期刊ID 'sendEmail'=>$journal_info['email'], // 期刊邮箱 'sendPassword'=>$journal_info['epassword'], // 期刊密码 'from_name'=>$journal_info['title'] ]; // Queue::push('app\api\job\domail@fire',$sendUser,'domail'); sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); //发送消息信息--编辑 $journal_res = $this->journal_obj->where('journal_id', $data['journal'])->find(); add_usermsg($journal_res['editor_id'], '新增审稿人申请,申请人(' . $data['username'] . ')', '/reviewerApplyDetail?id=' . $res); return json(['code' => 0]); } else { return json(['code' => 1, 'msg' => 'reviewer submit error']); } } /** * 作者申请成为审稿人 */ public function becameReviewer() { die("service stop!!"); //接受参数,查询参数 $data = $this->request->post(); $user_info = $this->user_obj->where('account', $data['username'])->find(); $journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find(); $editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find(); //存储数据 $insert['journal_id'] = $data['journal']; $insert['name'] = $data['username']; $insert['gender'] = $data['gender']; $insert['technical'] = $data['technical']; $insert['country'] = $data['country']; $insert['introduction'] = $data['introduction']; $insert['email'] = $user_info['email']; $insert['company'] = $data['company']; $insert['major'] = $data['major']; $insert['field'] = $data['field']; $insert['qualifications'] = $data['qualifications']; $insert['ctime'] = time(); $res = $this->user_reviewer_obj->insertGetId($insert); //发送email-》编辑 $tt = 'Dear editor,
'; $tt .= 'Please check the new reviewer application.'; $sendUser=[ 'title'=>$journal_info['title'], // 邮件标题 'content'=>$tt,//邮件内容 'user_id'=>$editor_info['user_id'], //收件人ID 'email'=>$editor_info['email'],// 收件人邮箱 'journal_id'=>$journal_info['journal_id'], // 期刊ID 'sendEmail'=>$journal_info['email'], // 期刊邮箱 'sendPassword'=>$journal_info['epassword'], // 期刊密码 'from_name'=>$journal_info['title'] ]; // Queue::push('app\api\job\domail@fire',$sendUser,'domail'); sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']); //发送消息信息--编辑 $journal_res = $this->journal_obj->where('journal_id', $data['journal'])->find(); add_usermsg($journal_res['editor_id'], 'New reviewer apply(' . $data['username'] . ')', '/reviewerApplyDetail?id=' . $res); return json(['code' => 0]); } /** * 获取城市 */ public function getCountrys() { $res = $this->country_obj->order('en_name')->select(); return json($res); } /** * 获取领域分类 */ public function getMajor(){ $majors = $this->reviewer_major_obj->where('pid',0)->select(); return json(['code'=>0,'data'=>$majors]); } public function getMajors(){ $rid = $this->request->post('rid'); $reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$rid)->find(); $majors = $this->reviewer_major_obj->where('pid',0)->select(); $cmajors = $this->reviewer_major_obj->where('pid',$reviewer_info['major'])->select(); return json(['code'=>0,'data'=>$majors,'cmajors'=>$cmajors]); } /** * 获取major子项目 */ public function majorChild(){ $majorid = $this->request->post('majorid'); $ds = $this->reviewer_major_obj->where('pid',$majorid)->select(); return json(['code'=>0,'data'=>$ds]); } /** * 获取期刊除了已申请过的期刊 */ public function getJournalchu() { $data = $this->request->post(); $journals = $this->reviewer_to_journal_obj->where('account', $data['username'])->column('journal_id'); $res = $this->journal_obj->where('journal_id', 'not in', $journals)->select(); return json($res); } /** * 获取excel数据 */ public function getExcelData() { //接收数据 $data = $this->request->post(); $path = ROOT_PATH . 'public' . DS . $data['url']; $frag = self::readExcel($path); return json($frag); } /** * 验证用户名是否存在 */ private function get_username($username) { return $this->user_obj->where('account', $username)->find(); } /** * 验证major是否合法 */ private function get_major($major) { return $this->reviewer_major_obj->where('title', $major)->find(); } /** * 获取对应关系 */ private function get_retojo($reviewer_id, $journal_id) { return $this->reviewer_to_journal_obj->where('reviewer_id', $reviewer_id)->where('journal_id', $journal_id)->where('state',0)->find(); } /** * 获取此邮箱注册用户 */ private function get_userByEmail($email) { return $this->user_obj->where('email', $email)->find(); } /** * 读取excel数据 */ private function readExcel($path) { $extension = substr($path, strrpos($path, '.') + 1); vendor("PHPExcel.PHPExcel"); if ($extension == 'xlsx') { $objReader = new \PHPExcel_Reader_Excel2007(); $objPHPExcel = $objReader->load($path); } else if ($extension == 'xls') { $objReader = new \PHPExcel_Reader_Excel5(); $objPHPExcel = $objReader->load($path); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $frag = []; for ($i = 2; $i <= $highestRow; $i++) { $aa['username'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue(); $aa['realname'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue(); $aa['gender'] = $objPHPExcel->getActiveSheet()->getCell("C" . $i)->getValue(); $aa['email'] = $objPHPExcel->getActiveSheet()->getCell("D" . $i)->getValue(); $aa['technical'] = $objPHPExcel->getActiveSheet()->getCell("E" . $i)->getValue(); $aa['country'] = $objPHPExcel->getActiveSheet()->getCell("F" . $i)->getValue(); $aa['company'] = $objPHPExcel->getActiveSheet()->getCell("G" . $i)->getValue(); $aa['major'] = $objPHPExcel->getActiveSheet()->getCell("H" . $i)->getValue(); $aa['field'] = $objPHPExcel->getActiveSheet()->getCell("I" . $i)->getValue(); $aa['introduction'] = $objPHPExcel->getActiveSheet()->getCell("J" . $i)->getValue(); $aa['qualifications'] = $objPHPExcel->getActiveSheet()->getCell("K" . $i)->getValue(); $frag[] = $aa; } return $frag; } /** * 接收文件 */ public function up_file() { $file = request()->file('qualifications'); 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()]); } } } /** * 接收导入文件 * @return type */ public function up_import() { $file = request()->file('importExcel'); if ($file) { $info = $file->move(ROOT_PATH . 'public' . DS . 'reviewer' . DS . 'import'); if ($info) { return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]); } else { return json(['code' => 1, 'msg' => $file->getError()]); } } } public function info(){ phpinfo(); } }