12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391 |
- <?php
- namespace app\index\controller;
- use addons\wechat\model\WechatCaptcha;
- use app\admin\model\Admin;
- use app\admin\model\cms\AuthorManuscript;
- use app\admin\model\cms\Channel;
- use app\admin\model\cms\ChannelAdmin;
- use app\admin\model\cms\Comment;
- use app\admin\model\cms\Comments;
- use app\admin\model\cms\InviteReviewer;
- use app\admin\model\cms\Issue;
- use app\admin\model\cms\ManuscriptInvite;
- use app\admin\model\cms\Participate;
- use app\admin\model\EmailContent;
- use app\common\controller\Frontend;
- use app\common\library\Ems;
- use app\common\library\Sms;
- use app\common\model\Attachment;
- use app\common\model\UserRoleContent;
- use app\common\model\UserRoleLog;
- use app\manytenant\model\Manytenant;
- use fast\Tree;
- use think\Config;
- use think\Cookie;
- use think\Db;
- use think\exception\PDOException;
- use think\exception\ValidateException;
- use think\Hook;
- use think\Session;
- use think\Validate;
- /**
- * 会员中心
- */
- class User extends Frontend
- {
- protected $layout = 'default';
- protected $noNeedLogin = ['login', 'register', 'third', 'jump'];
- protected $noNeedRight = ['*'];
- protected $position = 0;
- protected $channelIds = [];
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $auth = $this->auth;
- $this->model = new AuthorManuscript();
- if (!Config::get('fastadmin.usercenter')) {
- $this->error(__('User center already closed'), '/');
- }
- //监听注册登录退出的事件
- Hook::add('user_login_successed', function ($user) use ($auth) {
- $expire = input('post.keeplogin') ? 30 * 86400 : 0;
- Cookie::set('uid', $user->id, $expire);
- Cookie::set('token', $auth->getToken(), $expire);
- });
- Hook::add('user_register_successed', function ($user) use ($auth) {
- Cookie::set('uid', $user->id);
- Cookie::set('token', $auth->getToken());
- });
- Hook::add('user_delete_successed', function ($user) use ($auth) {
- Cookie::delete('uid');
- Cookie::delete('token');
- });
- Hook::add('user_logout_successed', function ($user) use ($auth) {
- Cookie::delete('uid');
- Cookie::delete('token');
- });
- $disabledIds = [];
- $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
- $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
- $channelIds = array_merge($parentChannelIds, $sonChannelIds);
- $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
- $tree = Tree::instance()->init($all, 'parent_id');
- $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", '', $disabledIds);
- $this->view->assign('channelOptions', $channelOptions);
- // 根据不同用户展示不同字段
- $fieldsList = \app\admin\model\workorder\Fields::where([
- 'status' => 1,
- 'position' => $this->position,
- 'type_list' => ['<>', 'text']
- ])->order('weigh', 'DESC')->select();
- $fields = [];
- foreach ($fieldsList as $index => $item) {
- if ($item['isfilter']) {
- $fields[] = [
- 'field' => $item['name'],
- 'title' => $item['title'],
- 'type' => $item['type_list'],
- 'values' => $item['values_list']
- ];
- }
- }
- $this->assignconfig('fields', $fields);
- $this->view->assign('fields', $this->model->getFields(null, 0));
- }
- function getChildren($parentId) {
- $children = Channel::where(['parent_id' => $parentId, 'type' => 'channel'])->column('id');
- foreach ($children as $childId) {
- $grandChildren = getChildren($childId);
- if ($grandChildren) {
- $children = array_merge($children, $grandChildren);
- }
- }
- return $children;
- }
- /**
- * 会员中心
- */
- public function index()
- {
- $this->view->assign('title', __('User center'));
- return $this->view->fetch();
- }
- /**
- * 注册会员
- */
- public function register()
- {
- $url = $this->request->request('url', '', 'trim');
- if ($this->auth->id) {
- $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
- }
- if ($this->request->isPost()) {
- $username = $this->request->post('username');
- $password = $this->request->post('password');
- $password_confirm = $this->request->post('password_confirm');
- // 判断密码是否一致
- if ($password != $password_confirm) {
- $this->error('Inconsistent password input', null, ['token' => $this->request->token()]);
- }
- $email = $this->request->post('email');
- $mobile = $this->request->post('mobile', '');
- $token = $this->request->post('__token__');
- $rule = [
- 'username' => 'require|length:3,30',
- 'password' => 'require|length:6,30',
- '__token__' => 'require|token',
- ];
- $msg = [
- 'username.require' => 'Username can not be empty',
- 'username.length' => 'Username must be 3 to 30 characters',
- 'password.require' => 'Password can not be empty',
- 'password.length' => 'Password must be 6 to 30 characters',
- ];
- $data = [
- 'username' => $username,
- 'password' => $password,
- 'email' => $email,
- 'mobile' => $mobile,
- '__token__' => $token,
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if (!$result) {
- $this->error($validate->getError(), null, ['token' => $this->request->token()]);
- }
- if ($this->auth->register($username, $password)) {
- $this->success('Registration successful, please go to the corresponding email to check and verify', $url ? $url : url('user/login'));
- } else {
- $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
- }
- }
- //判断来源
- $referer = $this->request->server('HTTP_REFERER');
- if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
- && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
- $url = $referer;
- }
- $this->view->assign('url', $url);
- $this->view->assign('title', 'Register');
- return $this->view->fetch();
- }
- /**
- * 会员登录
- */
- public function login()
- {
- $url = $this->request->request('url', '', 'trim');
- $token = $this->request->request('token');
- if ($token) {
- $token = $this->request->request('token');
- $uid = explode('-', $token)[5];
- $user = \app\admin\model\User::get($uid);
- $user->is_register = 'normal';
- if ($user->save()) {
- if ($this->auth->direct($user->id)) {
- url('/index/user/index');
- } else {
- url('/');
- }
- }
- }
- if ($this->auth->id) {
- $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
- }
- if ($this->request->isPost()) {
- $account = $this->request->post('account');
- $password = $this->request->post('password');
- $keeplogin = (int)$this->request->post('keeplogin');
- // $token = $this->request->post('__token__');
- $rule = [
- 'account' => 'require|length:3,50',
- 'password' => 'require|length:6,30',
- // '__token__' => 'require|token',
- ];
- $msg = [
- 'account.require' => 'Account can not be empty',
- 'account.length' => 'Account must be 3 to 50 characters',
- 'password.require' => 'Password can not be empty',
- 'password.length' => 'Password must be 6 to 30 characters',
- ];
- $data = [
- 'account' => $account,
- 'password' => $password,
- // '__token__' => $token,
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if (!$result) {
- // $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
- $this->error(__($validate->getError()), null);
- return false;
- }
- if ($this->auth->login($account, $password)) {
- // $this->success('Logged in successful', $url ? $url : url('user/index'));
- $this->success('Logged in successful', url('/'));
- } else {
- // $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
- $this->error($this->auth->getError(), null);
- }
- }
- //判断来源
- $referer = $this->request->server('HTTP_REFERER');
- if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
- && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
- $url = $referer;
- }
- $this->view->assign('url', $url);
- $this->view->assign('title', __('Login'));
- return $this->view->fetch();
- }
- /**
- * 退出登录
- */
- public function logout()
- {
- if ($this->request->isPost()) {
- $this->token();
- //退出本站
- $this->auth->logout();
- // $this->success(__('Logout successful'), url('user/index'));
- // $this->success('Logout successful', url('/'));
- $this->redirect(url('user/jump'));
- }
- $html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";
- $html .= "<script>document.forms['logout_submit'].submit();</script>";
- return $html;
- }
- /**
- * 退出登录
- *
- * @return string
- * @throws \think\Exception
- */
- public function jump()
- {
- $this->view->assign('title', 'Logout out');
- return $this->view->fetch();
- }
- /**
- * 个人信息
- */
- public function profile()
- {
- $this->view->assign('title', __('Profile'));
- return $this->view->fetch();
- }
- /**
- * 修改密码
- */
- public function changepwd()
- {
- if ($this->request->isPost()) {
- $oldpassword = $this->request->post("oldpassword");
- $newpassword = $this->request->post("newpassword");
- $renewpassword = $this->request->post("renewpassword");
- $token = $this->request->post('__token__');
- $rule = [
- 'oldpassword' => 'require|regex:\S{6,30}',
- 'newpassword' => 'require|regex:\S{6,30}',
- 'renewpassword' => 'require|regex:\S{6,30}|confirm:newpassword',
- '__token__' => 'token',
- ];
- $msg = [
- 'renewpassword.confirm' => 'Password and confirm password don\'t match'
- ];
- $data = [
- 'oldpassword' => $oldpassword,
- 'newpassword' => $newpassword,
- 'renewpassword' => $renewpassword,
- '__token__' => $token,
- ];
- $field = [
- 'oldpassword' => 'Old password',
- 'newpassword' => 'New password',
- 'renewpassword' => 'Renew password'
- ];
- $validate = new Validate($rule, $msg, $field);
- $result = $validate->check($data);
- if (!$result) {
- $this->error($validate->getError(), null, ['token' => $this->request->token()]);
- return false;
- }
- $ret = $this->auth->changepwd($newpassword, $oldpassword);
- if ($ret) {
- $this->success('Reset password successful', url('user/login'));
- } else {
- $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
- }
- }
- $this->view->assign('title', 'Change password');
- return $this->view->fetch();
- }
- public function attachment()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- $mimetypeQuery = [];
- $where = [];
- $filter = $this->request->request('filter');
- $filterArr = (array)json_decode($filter, true);
- if (isset($filterArr['mimetype']) && preg_match("/(\/|\,|\*)/", $filterArr['mimetype'])) {
- $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]);
- $mimetypeQuery = function ($query) use ($filterArr) {
- $mimetypeArr = array_filter(explode(',', $filterArr['mimetype']));
- foreach ($mimetypeArr as $index => $item) {
- $query->whereOr('mimetype', 'like', '%' . str_replace("/*", "/", $item) . '%');
- }
- };
- } elseif (isset($filterArr['mimetype'])) {
- $where['mimetype'] = ['like', '%' . $filterArr['mimetype'] . '%'];
- }
- if (isset($filterArr['filename'])) {
- $where['filename'] = ['like', '%' . $filterArr['filename'] . '%'];
- }
- if (isset($filterArr['createtime'])) {
- $timeArr = explode(' - ', $filterArr['createtime']);
- $where['createtime'] = ['between', [strtotime($timeArr[0]), strtotime($timeArr[1])]];
- }
- $search = $this->request->get('search');
- if ($search) {
- $where['filename'] = ['like', '%' . $search . '%'];
- }
- $model = new Attachment();
- $offset = $this->request->get("offset", 0);
- $limit = $this->request->get("limit", 0);
- $total = $model
- ->where($where)
- ->where($mimetypeQuery)
- ->where('user_id', $this->auth->id)
- ->order("id", "DESC")
- ->count();
- $list = $model
- ->where($where)
- ->where($mimetypeQuery)
- ->where('user_id', $this->auth->id)
- ->order("id", "DESC")
- ->limit($offset, $limit)
- ->select();
- $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
- foreach ($list as $k => &$v) {
- $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
- }
- unset($v);
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- $mimetype = $this->request->get('mimetype', '');
- $mimetype = substr($mimetype, -1) === '/' ? $mimetype . '*' : $mimetype;
- $this->view->assign('mimetype', $mimetype);
- $this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList());
- return $this->view->fetch();
- }
- /**
- * 我的个人主页
- */
- public function homepage()
- {
- $this->view->assign('title', 'My Personal Homepage');
- return $this->view->fetch();
- }
- /**
- * 我得邮箱页
- */
- public function inbox()
- {
- // 获取当前用户的邮箱内容信息
- $email_contents = EmailContent::where(['email' => $this->auth->email])->paginate();
- foreach ($email_contents as $content) {
- $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
- if ($content['type'] == 'admin') {
- $content['user'] = Admin::where(['id' => $content['user_id']])->find();
- }
- $content['createtime'] = date('Y-m-d', $content['createtime']);
- if ($content['status'] == 'normal') {
- $content['status'] = 'READ';
- } else {
- $content['status'] = 'Unread';
- }
- }
- $this->view->assign('list', $email_contents);
- $this->view->assign('title', 'INBOX');
- return $this->view->fetch();
- }
- /**
- * 我的未读邮件页
- */
- public function unread()
- {
- // 获取当前用户的邮箱内容信息
- $email_contents = EmailContent::where(['email' => $this->auth->email, 'status' => 'hidden'])->paginate();
- foreach ($email_contents as $content) {
- $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
- if ($content['type'] == 'admin') {
- $content['user'] = Admin::where(['id' => $content['user_id']])->find();
- }
- $content['createtime'] = date('Y-m-d', $content['createtime']);
- $content['status'] = 'Unread';
- }
- $this->view->assign('list', $email_contents);
- $this->view->assign('title', 'Unread');
- return $this->view->fetch();
- }
- /**
- * 提交手稿
- */
- public function submit_manuscript($id = null)
- {
- $row = [
- 'id' => '',
- 'manuscript_zip' => '',
- 'manuscript_pdf' => '',
- 'cover_letter' => '',
- 'graphical_abstract' => '',
- 'non_material' => '',
- 'is_copyright' => '',
- 'copyright_files' => '',
- 'image' => '',
- 'journal' => '',
- 'article_type' => '',
- 'title' => '',
- 'abstract' => '',
- 'keywords' => '',
- 'number_page' => '',
- 'is_funding' => '',
- 'funding_content' => '',
- 'is_interest' => '',
- 'interest_content' => '',
- 'statement_type' => '',
- 'article_one' => '',
- 'article_two' => '',
- 'article_three' => '',
- 'country' => '',
- 'affiliation' => '',
- 'name' => '',
- 'invoice_email' => '',
- 'order_email' => '',
- 'address' => '',
- 'zip_code' => '',
- 'city' => '',
- 'telephone' => '',
- 'fax' => '',
- 'vat' => '',
- 'is_become_review' => '',
- 'field' => '',
- ];
- $id = $this->request->param('id');
- if ($id) {
- $row = AuthorManuscript::where(['id' => $id])->find();
- $row->author_content = json_decode($row->author_content, true);
- $row->review_content = json_decode($row->review_content, true);
- $disabledIds = [];
- $disabledIds = array_diff($disabledIds, [$row['journal']]);
- $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
- $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
- $channelIds = array_merge($parentChannelIds, $sonChannelIds);
- $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
- $tree = Tree::instance()->init($all, 'parent_id');
- $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", $row['journal'], $disabledIds);
- $this->view->assign('channelOptions', $channelOptions);
- }
- $this->view->assign('fields', $this->model->getFields($row, 0));
- $this->view->assign('row', $row);
- $this->view->assign('title', 'Submit Manuscript');
- return $this->view->fetch();
- }
- /**
- * 手稿状态
- */
- public function display_submitted()
- {
- // 构建分页参数
- $limit = $this->request->param('limit', 10);
- $status = $this->request->param('status', 'all');
- $where = [];
- if ($status != 'all') {
- $where = ['status' => $status];
- }
- // 查询当前用户手稿
- $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id])
- ->where($where)
- ->field('id,title,image,createtime,journal,status')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- $author_edit_status = config('site.author_edit_status');
- $author_comments_status = config('site.author_comments_status');
- foreach ($manuscripts as $manuscript) {
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
- $manuscript['is_edit'] = false; // 是否可修改手稿信息按钮状态
- $manuscript['is_comments'] = false; // 回复审稿意见按钮状态
- $manuscript['is_view_comments'] = false; // 查看审稿意见按钮状态
- if (in_array($manuscript['status'], $author_edit_status)) {
- $manuscript['is_edit'] = true;
- }
- if (in_array($manuscript['status'], $author_comments_status)) {
- $manuscript['is_comments'] = true;
- }
- // 查询当前手稿下是否有可查看的审稿意见数量
- $comment_count = Comments::where(['manuscript_id' => $manuscript['id'], 'type' => 'reviewer', 'is_send' => 'normal'])->count();
- if ($comment_count > 0) {
- $manuscript['is_view_comments'] = true;
- }
- }
- if ($this->request->isAjax()) {
- $keyword = $this->request->param('keyword');
- $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id])
- ->where(function ($query) use ($keyword, $status) {
- if ($status != 'all') {
- return $query->where(['status' => $status]);
- }
- if ($keyword != '') {
- return $query->where(['title' => ['like', '%'. $keyword .'%']]);
- }
- })->field('id,title,image,createtime,journal,status')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
- $manuscript['is_edit'] = false;
- $manuscript['is_comments'] = false;
- $manuscript['is_view_comments'] = false;
- if (in_array($manuscript['status'], $author_edit_status)) {
- $manuscript['is_edit'] = true;
- }
- if (in_array($manuscript['status'], $author_comments_status)) {
- $manuscript['is_comments'] = true;
- }
- // 查询当前手稿下是否有可查看的审稿意见数量
- $comment_count = Comments::where(['manuscript_id' => $manuscript['id'], 'type' => 'reviewer', 'is_send' => 'normal'])->count();
- if ($comment_count > 0) {
- $manuscript['is_view_comments'] = true;
- }
- }
- $this->success('', '', $manuscripts);
- }
- $this->view->assign('status', $status);
- $this->view->assign('list', $manuscripts);
- $this->view->assign('title', 'Dispaly Submitted');
- return $this->view->fetch();
- }
- /**
- * 审核人信息
- */
- public function reviewer_information()
- {
- $user_role = UserRoleLog::where(['user_id' => $this->auth->id, 'type' => 'review', 'is_adopt' => ['in', ['review', 'fault']]])->order('createtime', 'DESC')->find();
- $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->find();
- if (empty($user_content)) {
- $user_content['field'] = '';
- $user_content['degree'] = '';
- $user_content['affiliation'] = '';
- $user_content['publication'] = '';
- $user_content['orcid'] = '';
- $user_content['homepage'] = '';
- $user_content['review_journal'] = '';
- $user_content['interested_journal'] = '';
- $user_content['resume'] = '';
- $user_content['journal_ids'] = '';
- }
- $this->view->assign('row', $user_content);
- $this->view->assign('user_role', $user_role);
- $this->view->assign('title', 'Reviewer Information');
- return $this->view->fetch();
- }
- /**
- * 审稿邀请函
- *
- * @return string
- * @throws \think\Exception
- */
- public function invitation_letter()
- {
- $limit = $this->request->param('limit', 10);
- $status = $this->request->param('status', 'audit');
- $where = ['status' => $status];
- // 根据用户的审稿角色id查询对应的邀请审稿信息
- $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
- $manuscript_id_arr = InviteReviewer::where(['role_id' => $role_id])->where($where)->order('createtime', 'DESC')->column('manuscript_id');
- // 查询当前用户手稿
- $manuscripts = AuthorManuscript::where(['id' => ['in', $manuscript_id_arr]])
- ->field('id,title,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
- }
- if ($this->request->isAjax()) {
- $keyword = $this->request->param('keyword');
- $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%']])
- ->where(['id' => ['in', $manuscript_id_arr]])
- ->field('id,title,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
- }
- $this->success('', '', $manuscripts);
- }
- $this->view->assign('status', $status);
- $this->view->assign('list', $manuscripts);
- $this->view->assign('title', 'Invitation Letter for Review');
- return $this->view->fetch();
- }
- /**
- * 审阅的手稿
- */
- public function show_reviewed_manuscripts()
- {
- $limit = $this->request->param('limit', 10);
- $status = $this->request->param('status', 'comment_submission');
- $where = ['status' => $status];
- $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
- $manuscript_id_arr = InviteReviewer::where(['role_id' => $role_id, 'status' => 'accept'])->order('createtime', 'DESC')->column('manuscript_id');
- // 查询当前用户手稿
- $manuscripts = AuthorManuscript::where($where)
- ->where(['id' => ['in', $manuscript_id_arr]])
- ->field('id,title,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
- }
- if ($this->request->isAjax()) {
- $keyword = $this->request->param('keyword');
- $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%'], 'status' => $status])
- // ->whereRaw("FIND_IN_SET(". $this->auth->id .", `reviewer_ids`)")
- ->where(['id' => ['in', $manuscript_id_arr]])
- ->field('id,title,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
- }
- $this->success('', '', $manuscripts);
- }
- $this->view->assign('status', $status);
- $this->view->assign('list', $manuscripts);
- $this->view->assign('title', 'Show Reviewed Manuscripts');
- return $this->view->fetch();
- }
- /**
- * 手稿详情
- */
- public function article_details($id = null)
- {
- $id = $this->request->param('id');
- $type = $this->request->param('type');
- $status = $this->request->param('status', 'reviewer_details');
- $row = AuthorManuscript::where(['id' => $id])->find();
- $row['review_content'] = json_decode($row['review_content'], true);
- if ($row) {
- // $row['keywords'] = explode(',', $row['keywords']);
- $row['journal'] = Channel::where(['id' => $row['journal']])->value('name') ?? '-';
- }
- // 判断是审稿人还是编辑,如果是编辑则可以看到全部意见
- $comments = Comments::where(['manuscript_id' => $row['id']])->select();
- if ($type == 'reviewer') {
- $comments = Comments::where(['manuscript_id' => $row['id'], 'type' => 'reviewer'])->select();
- }
- if ($type == 'editor' || $type == 'author') {
- $reviewers = InviteReviewer::where(['manuscript_id' => $row['id']])->select();
- // 邀请的审稿人信息
- if ($status == 'reviewer_details') {
- foreach ($reviewers as $reviewer) {
- $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
- if ($reviewer_role) {
- // 查询审稿人提交意见信息
- $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
- ->order('createtime', 'DESC')
- ->find();
- $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
- if ($reviewer_comment) {
- $reviewer['reply_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? time());
- $reviewer['submission_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? time());
- $reviewer['status'] = $reviewer_comment['recommendation'] ?? '';
- }
- }
- $reviewer['nickname'] = $reviewer_user['nickname'];
- $reviewer['invited_time'] = date('Y-m-d', $reviewer['createtime']);
- }
- }
- // 审稿人信息
- if ($status == 'reviewer_suggestion') {
- foreach ($reviewers as $reviewer) {
- $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
- if ($reviewer_role) {
- // 查询审稿人提交意见数量
- $reviewer_comment_num = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
- ->count();
- $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
- }
- $reviewer['nickname'] = $reviewer_user['nickname'];
- $reviewer['affiliation'] = $reviewer_role['affiliation'];
- $reviewer['comment_num'] = $reviewer_comment_num;
- }
- }
- // 审稿人意见信息
- if ($status == 'review_report') {
- foreach ($reviewers as $reviewer) {
- $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
- if ($reviewer_role) {
- // 查询审稿人提交意见信息
- $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
- ->order('createtime', 'DESC')
- ->find();
- $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
- }
- $reviewer['nickname'] = $reviewer_user['nickname'];
- $reviewer['recommendation'] = $reviewer_comment['recommendation'];
- $reviewer['comment'] = $reviewer_comment['comments'];
- $reviewer['createtime'] = date('Y-m-d', $reviewer_comment['createtime']);
- $reviewer['comment_id'] = $reviewer_comment['id'];
- $reviewer['is_send'] = $reviewer_comment['is_send'];
- }
- }
- // 作者回复意见
- if ($status == 'author_report') {
- // 查询作者提交意见信息回复
- $author_comment = Comments::where(['user_id' => $row['user_id'], 'manuscript_id' => $row['id'], 'type' => 'author'])
- ->order('createtime', 'DESC')
- ->find();
- if ($author_comment) {
- $author_user = \app\admin\model\User::where(['id' => $row['user_id']])->find();
- $author['nickname'] = $author_user['nickname'] ?? '';
- $author['comment'] = $author_comment['comments'] ?? '';
- $author['createtime'] = date('Y-m-d', $author_comment['createtime']);
- }
- }
- $row['reviewer'] = $reviewers;
- $row['author'] = $author ?? [];
- }
- $row['comments'] = $comments ?? [];
- $this->view->assign('status', $status);
- $this->view->assign('row', $row);
- $this->view->assign('type', $type);
- $this->view->assign('title', 'Article Details');
- return $this->view->fetch();
- }
- /**
- * 审稿页面
- */
- public function conduct_review($id = null)
- {
- $id = $this->request->param('id');
- $type = $this->request->param('type');
- $row = Comments::where(['manuscript_id' => $id, 'type' => $type])->find();
- $manuscript = AuthorManuscript::where(['id' => $id])->find();
- $this->view->assign('row', $row);
- $this->view->assign('manuscript', $manuscript);
- $this->view->assign('id', $id);
- $this->view->assign('type', $type);
- $this->view->assign('title', 'Conduct Review');
- return $this->view->fetch();
- }
- /**
- * 申请创建特刊
- */
- public function special_issue($id = null)
- {
- $special_issue = [
- 'id' => '',
- 'image' => '',
- 'journal' => '',
- 'issue_name' => '',
- 'proposal_text' => '',
- 'publication_cycle' => '',
- 'editor' => '',
- 'statement_type' => '',
- ];
- if ($id) {
- $special_issue = Issue::where(['id' => $id])->find();
- $special_issue->editor = json_decode($special_issue['editor']);
- }
- $this->view->assign('row', $special_issue);
- $this->view->assign('title', 'Apply to creat a special issue');
- return $this->view->fetch();
- }
- /**
- * 申请成为编辑
- */
- public function become_an_editor()
- {
- $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => ['in', ['editor', 'chief']]])->find();
- $user = \app\common\model\User::get($this->auth->id);
- // 因为是主编和编辑共用一个页面所以只查询这两个角色下最后一个申请记录就可以
- $user_role_log = UserRoleLog::where(['user_id' => $this->auth->id, 'type' => ['in', ['editor', 'chief']]])->order('createtime', 'DESC')->find();
- if (empty($user_content)) {
- $user_content['degree'] = '';
- $user_content['affiliation'] = '';
- $user_content['publication'] = '';
- $user_content['orcid'] = '';
- $user_content['homepage'] = '';
- $user_content['review_journal'] = '';
- $user_content['interested_journal'] = '';
- $user_content['resume'] = '';
- $user_content['journal_ids'] = '';
- $user_content['is_chief'] = '';
- $user_content['is_editor'] = '';
- } else {
- $user_content['is_chief'] = $user['is_chief'];
- $user_content['is_editor'] = $user['is_editor'];
- }
- $this->view->assign('row', $user_content);
- $this->view->assign('user_role', $user_role_log);
- $this->view->assign('user', $user);
- $this->view->assign('title', 'Apply to become an editor');
- return $this->view->fetch();
- }
- /**
- * 编辑手稿
- */
- public function editing_manuscripts()
- {
- $limit = $this->request->param('limit', 10);
- $type = $this->request->param('type');
- $status = $this->request->param('status', 'all');
- $where = [];
- if ($status != 'all') {
- $where = ['status' => $status];
- }
- $user = $this->auth;
- // 查询当前用户手稿
- $manuscripts = AuthorManuscript::where(function ($query) use ($user) {
- if ($user->is_chief == 'correct') {
- $query->where(['chief_id' => $this->auth->id]);
- }
- if ($user->is_editor == 'correct') {
- $query->whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)");
- }
- })->where($where)->field('id,title,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
- }
- if ($this->request->isAjax()) {
- $keyword = $this->request->param('keyword');
- $manuscripts = AuthorManuscript::where(function ($query) use ($user) {
- if ($user->is_chief == 'correct') {
- $query->where(['chief_id' => $this->auth->id]);
- }
- if ($user->is_editor == 'correct') {
- $query->whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)");
- }
- })->where($where)->where(['title' => ['like', '%'. $keyword .'%']])->field('id,title,image,createtime,journal')->order('createtime', 'DESC')->paginate($limit);
- foreach ($manuscripts as $manuscript) {
- $manuscript['is_chief'] = false;
- $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
- $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
- if ($this->auth->is_chief == 'correct') {
- $manuscript['is_chief'] = true;
- }
- }
- $this->success('', '', $manuscripts);
- }
- $this->view->assign('status', $status);
- $this->view->assign('type', $type);
- $this->view->assign('list', $manuscripts);
- $this->view->assign('title', 'Editing Manuscripts');
- return $this->view->fetch();
- }
- /**
- * 提交处理意见
- */
- public function handing_suggestions()
- {
- $id = $this->request->param('id');
- $type = $this->request->param('type');
- $row = Comments::where(['manuscript_id' => $id, 'type' => $type, 'user_id' => $this->auth->id])->find();
- $manuscript = AuthorManuscript::where(['id' => $id])->find();
- if (empty($row)) {
- $row['is_interest'] = '';
- }
- $this->view->assign('row', $row);
- $this->view->assign('manuscript', $manuscript);
- $this->view->assign('id', $id);
- $this->view->assign('type', $type);
- $this->view->assign('title', 'Submit Handing Suggestions');
- return $this->view->fetch();
- }
- /**
- * 邀请审稿人
- */
- public function invite_reviewers()
- {
- $id = $this->request->param('id');
- $manuscript = AuthorManuscript::get($id);
- $manuscript_review_id_arr = explode(',', $manuscript['reviewer_ids']);
- $review_user_content = UserRoleContent::where(['user_id' => ['in', $manuscript_review_id_arr], 'type' => 'review'])->select();
- // 获取审稿人信息
- $review_id_arr = \app\common\model\User::where(['is_review' => 'correct', 'id' => ['<>', $manuscript->user_id]])->column('id');
- $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->select();
- // $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
- foreach ($list as $value) {
- $channel_name_arr = Channel::where(['id' => ['in', explode(',', $value['journal_ids'])]])->column('name');
- $value['journal'] = implode(',', $channel_name_arr);
- $value['is_checked'] = false;
- if (in_array($value['user_id'], $manuscript_review_id_arr)) {
- $value['is_checked'] = true;
- }
- }
- $this->view->assign('id', $id);
- $this->view->assign('list', $list);
- $this->view->assign('reviewer_user_content', $review_user_content);
- $this->view->assign('title', 'Invite Reviewers');
- return $this->view->fetch();
- }
- /**
- * 获取审稿人列表
- *
- * @return void
- * @throws \think\exception\DbException
- */
- public function getReviewerList()
- {
- // 构建分页参数
- $limit = $this->request->param('limit', 10);
- // 获取审稿人信息
- $review_id_arr = \app\common\model\User::where(['is_review' => 'correct'])->column('id');
- $data = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
- foreach ($data as $value) {
- $value['user']['first_name'] = $value['user']['first_name'] ?? '-';
- $value['user']['last_name'] = $value['user']['last_name'] ?? '-';
- $value['affiliation'] = $value['affiliation'] ?? '-';
- }
- // 返回表格数据和分页信息
- $this->success('', '', $data);
- }
- /**
- * 提交会议
- *
- * @return string
- * @throws \think\Exception
- */
- public function submit_conference()
- {
- $this->view->assign('title', 'Submit Conference');
- return $this->view->fetch();
- }
- /**
- * 参加会议
- *
- * @return string
- * @throws \think\Exception
- */
- public function conference_participate()
- {
- $param = $this->request->param();
- $id = $param['id'];
- $row = Participate::where(['id' => $id])->find();
- $this->view->assign('id', $id);
- $this->view->assign('row', $row);
- $this->view->assign('title', 'Submit Conference');
- return $this->view->fetch();
- }
- /**
- * 特刊列表页
- *
- * @return string
- * @throws \think\Exception
- * @throws \think\exception\DbException
- */
- public function special_issue_list()
- {
- $status = $this->request->param('status', 'all');
- $where = ['user_id' => $this->auth->id];
- if ($status != 'all') {
- $where = ['status' => $status, 'user_id' => $this->auth->id];
- }
- if ($status == 'all') {
- unset($where['status']);
- }
- $special_issues = Issue::where($where)->order('createtime', 'DESC')->paginate();
- if ($this->request->isAjax()) {
- $keyword = $this->request->param('keyword');
- if ($status == 'all') {
- $status = '';
- }
- $special_issues = Issue::where(['user_id' => $this->auth->id, 'issue_name' => ['like', '%'. $keyword .'%']])
- ->where(function ($query) use ($status) {
- if ($status) {
- $query->where(['status' => $status]);
- }
- })->field('id,issue_name,image,createtime,journal')
- ->order('createtime', 'DESC')
- ->paginate();
- foreach ($special_issues as $special_issue) {
- $special_issue['createtime'] = date('Y-m-d', $special_issue['createtime']);
- $special_issue['journal'] = Channel::where(['id' => $special_issue['journal']])->value('name');
- }
- $this->success('', '', $special_issues);
- }
- foreach ($special_issues as $special_issue) {
- $special_issue['createtime'] = date('Y-m-d', $special_issue['createtime']);
- $special_issue['journal'] = Channel::where(['id' => $special_issue['journal']])->value('name');
- }
- $this->view->assign('status', $status);
- $this->view->assign('title', 'Special Issue List');
- $this->view->assign('list', $special_issues);
- return $this->view->fetch();
- }
- /**
- * 作者审稿意见
- *
- * @return string
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function review_comments()
- {
- $param = $this->request->param();
- $type = $param['type'];
- $row = Comments::where(['manuscript_id' => $param['id']])->find();
- $manuscript = AuthorManuscript::get($param['id']);
- if (empty($row)) {
- $row['manuscript_id'] = $param['id'];
- $row['comments'] = '';
- $row['status'] = $manuscript['status'];
- }
- $this->view->assign('row', $row);
- $this->view->assign('type', $type);
- return $this->view->fetch();
- }
- /**
- * 发送邮件列表
- *
- * @return string
- * @throws \think\Exception
- * @throws \think\exception\DbException
- */
- public function send_email()
- {
- $param = $this->request->param();
- $type = $param['type'];
- $row = AuthorManuscript::get($param['id']);
- // 身份是不同的则需要查询不同人的列表
- if ($type == 'author') {
- /** 审稿人 编辑 */
- $review_ids = explode(',', $row['reviewer_ids']);
- $editor_ids = explode(',', $row['editor_ids']);
- $user_arr = array_merge($review_ids, $editor_ids);
- $user_arr = array_unique($user_arr);
- }
- if ($type == 'reviewer') {
- /** 作者 编辑 */
- $editor_ids = explode(',', $row['editor_ids']);
- $author_ids = [$row['user_id']];
- $user_arr = array_merge($editor_ids, $author_ids);
- $user_arr = array_unique($user_arr);
- }
- if ($type == 'editor') {
- /** 作者 审稿人 */
- $author_ids = [$row['user_id']];
- $review_ids = explode(',', $row['reviewer_ids']);
- $user_arr = array_merge($review_ids, $author_ids);
- $user_arr = array_unique($user_arr);
- }
- $user_list = \app\admin\model\User::where(['id' => ['in', $user_arr]])->column('email', 'id');
- $this->view->assign('type', $type);
- $this->view->assign('user_list', $user_list);
- $this->view->assign('row', $row);
- $this->view->assign('mail_smtp_host', $this->auth->mail_smtp_host);
- $this->view->assign('mail_smtp_port', $this->auth->mail_smtp_port);
- $this->view->assign('mail_smtp_user', $this->auth->mail_smtp_user);
- $this->view->assign('mail_smtp_pass', $this->auth->mail_smtp_pass);
- $this->view->assign('title', 'Send Email');
- return $this->view->fetch();
- }
- /**
- * 邀请编辑页
- *
- * @return string
- * @throws \think\Exception
- * @throws \think\exception\DbException
- */
- public function invite_editor()
- {
- $param = $this->request->param();
- $type = $param['type'];
- $row = AuthorManuscript::get($param['id']);
- $this->view->assign('row', $row);
- $this->view->assign('type', $type);
- $this->view->assign('title', 'Invite Editor');
- return $this->view->fetch();
- }
- /**
- * 选择编辑
- *
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function choose_editor()
- {
- $info = \app\common\model\User::where(['is_editor' => 'correct', 'id' => ['not in', $this->auth->id]])->field('nickname, id')->select();
- $params = $this->request->request();
- if (array_key_exists('name', $params) && $params['name']) {
- $info = \app\common\model\User::where(['is_editor' => 'correct', 'nickname' => ['like', '%' . $params['name'] . '%'], 'id' => ['not in', $this->auth->id]])->field('nickname, id')->select();
- }
- if ($this->request->request("keyValue")) {
- $id_arr = $this->request->request('keyValue');
- $info = \app\common\model\User::where(['id' => ['in', $id_arr]])->field('nickname, id')->select();
- }
- $arr = [];
- foreach ($info as $item) {
- $v['id'] = $item['id'];
- $v['name'] = $item['nickname'];
- $arr[] = $v;
- }
- $data['list'] = $arr;
- $data['total'] = count($arr);
- return json($data);
- }
- /**
- * 选择期刊
- *
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function choose_journal()
- {
- $type = $this->request->request("type");
- $where = [];
- if ($type == 'author') {
- $where['chief_id'] = ['<>', 0];
- }
- $info = Channel::where(['parent_id' => 1])->where($where)->field('name, id')->select();
- $params = $this->request->request();
- if (array_key_exists('name', $params) && $params['name']) {
- $info = Channel::where(['parent_id' => 1, 'name' => ['like', '%' . $params['name'] . '%']])->where($where)->field('name, id')->select();
- }
- if ($this->request->request("keyValue")) {
- $id_arr = $this->request->request('keyValue');
- $info = Channel::where(['id' => ['in', $id_arr]])->where($where)->field('name, id')->select();
- }
- $arr = [];
- foreach ($info as $item) {
- $v['id'] = $item['id'];
- $v['name'] = $item['name'];
- $arr[] = $v;
- }
- $data['list'] = $arr;
- $data['total'] = count($arr);
- return json($data);
- }
- /**
- * 邀请函操作
- *
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function invitation_letter_operate()
- {
- $params = $this->request->request();
- $manuscript_id = $params['id'];
- $status = $params['status'];
- Db::startTrans();
- try {
- $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
- $invite_content = InviteReviewer::where(['role_id' => $role_id, 'manuscript_id' => $manuscript_id])->order('createtime', 'DESC')->find();
- if ($invite_content) {
- $invite_content->status = $status;
- $invite_content->save();
- }
- Db::commit();
- } catch (ValidateException|PDOException|Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('Successful');
- }
- /**
- * 意见转呈
- *
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function send_author_comments()
- {
- $params = $this->request->request();
- $comment_id = $params['comment_id'];
- Db::startTrans();
- try {
- $comment = Comments::where(['id' => $comment_id])->find();
- if ($comment) {
- $comment->is_send = 'normal';
- $comment->save();
- }
- Db::commit();
- } catch (ValidateException|PDOException|Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('Successful');
- }
- /**
- * 获取擅长领域
- *
- * @return \think\response\Json
- */
- public function choose_field()
- {
- $info = config('site.review_field');
- $params = $this->request->request();
- if (array_key_exists('name', $params) && $params['name']) {
- $new_info = [];
- foreach ($info as $key => $value) {
- if (strstr(mb_strtolower($value), $params['name'])) {
- $new_info[$key] = $value;
- }
- }
- $arr = [];
- foreach ($new_info as $key => $item) {
- $v['id'] = $key;
- $v['name'] = $item;
- $arr[] = $v;
- }
- $data['list'] = $arr;
- $data['total'] = count($arr);
- return json($data);
- }
- if ($this->request->request("keyValue")) {
- $id_arr = $this->request->request('keyValue');
- $new_info = [];
- foreach ($info as $key => $value) {
- if (!is_array($id_arr)) {
- $id_arr = explode(',', $id_arr);
- }
- if (in_array($key, $id_arr)) {
- $new_info[$key] = $value;
- }
- }
- $arr = [];
- foreach ($new_info as $key => $item) {
- $v['id'] = $key;
- $v['name'] = $item;
- $arr[] = $v;
- }
- $data['list'] = $arr;
- $data['total'] = count($arr);
- return json($data);
- }
- $arr = [];
- foreach ($info as $key => $item) {
- $v['id'] = $key;
- $v['name'] = $item;
- $arr[] = $v;
- }
- $data['list'] = $arr;
- $data['total'] = count($arr);
- return json($data);
- }
- }
|