User.php 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391
  1. <?php
  2. namespace app\index\controller;
  3. use addons\wechat\model\WechatCaptcha;
  4. use app\admin\model\Admin;
  5. use app\admin\model\cms\AuthorManuscript;
  6. use app\admin\model\cms\Channel;
  7. use app\admin\model\cms\ChannelAdmin;
  8. use app\admin\model\cms\Comment;
  9. use app\admin\model\cms\Comments;
  10. use app\admin\model\cms\InviteReviewer;
  11. use app\admin\model\cms\Issue;
  12. use app\admin\model\cms\ManuscriptInvite;
  13. use app\admin\model\cms\Participate;
  14. use app\admin\model\EmailContent;
  15. use app\common\controller\Frontend;
  16. use app\common\library\Ems;
  17. use app\common\library\Sms;
  18. use app\common\model\Attachment;
  19. use app\common\model\UserRoleContent;
  20. use app\common\model\UserRoleLog;
  21. use app\manytenant\model\Manytenant;
  22. use fast\Tree;
  23. use think\Config;
  24. use think\Cookie;
  25. use think\Db;
  26. use think\exception\PDOException;
  27. use think\exception\ValidateException;
  28. use think\Hook;
  29. use think\Session;
  30. use think\Validate;
  31. /**
  32. * 会员中心
  33. */
  34. class User extends Frontend
  35. {
  36. protected $layout = 'default';
  37. protected $noNeedLogin = ['login', 'register', 'third', 'jump'];
  38. protected $noNeedRight = ['*'];
  39. protected $position = 0;
  40. protected $channelIds = [];
  41. protected $model = null;
  42. public function _initialize()
  43. {
  44. parent::_initialize();
  45. $auth = $this->auth;
  46. $this->model = new AuthorManuscript();
  47. if (!Config::get('fastadmin.usercenter')) {
  48. $this->error(__('User center already closed'), '/');
  49. }
  50. //监听注册登录退出的事件
  51. Hook::add('user_login_successed', function ($user) use ($auth) {
  52. $expire = input('post.keeplogin') ? 30 * 86400 : 0;
  53. Cookie::set('uid', $user->id, $expire);
  54. Cookie::set('token', $auth->getToken(), $expire);
  55. });
  56. Hook::add('user_register_successed', function ($user) use ($auth) {
  57. Cookie::set('uid', $user->id);
  58. Cookie::set('token', $auth->getToken());
  59. });
  60. Hook::add('user_delete_successed', function ($user) use ($auth) {
  61. Cookie::delete('uid');
  62. Cookie::delete('token');
  63. });
  64. Hook::add('user_logout_successed', function ($user) use ($auth) {
  65. Cookie::delete('uid');
  66. Cookie::delete('token');
  67. });
  68. $disabledIds = [];
  69. $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
  70. $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
  71. $channelIds = array_merge($parentChannelIds, $sonChannelIds);
  72. $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
  73. $tree = Tree::instance()->init($all, 'parent_id');
  74. $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", '', $disabledIds);
  75. $this->view->assign('channelOptions', $channelOptions);
  76. // 根据不同用户展示不同字段
  77. $fieldsList = \app\admin\model\workorder\Fields::where([
  78. 'status' => 1,
  79. 'position' => $this->position,
  80. 'type_list' => ['<>', 'text']
  81. ])->order('weigh', 'DESC')->select();
  82. $fields = [];
  83. foreach ($fieldsList as $index => $item) {
  84. if ($item['isfilter']) {
  85. $fields[] = [
  86. 'field' => $item['name'],
  87. 'title' => $item['title'],
  88. 'type' => $item['type_list'],
  89. 'values' => $item['values_list']
  90. ];
  91. }
  92. }
  93. $this->assignconfig('fields', $fields);
  94. $this->view->assign('fields', $this->model->getFields(null, 0));
  95. }
  96. function getChildren($parentId) {
  97. $children = Channel::where(['parent_id' => $parentId, 'type' => 'channel'])->column('id');
  98. foreach ($children as $childId) {
  99. $grandChildren = getChildren($childId);
  100. if ($grandChildren) {
  101. $children = array_merge($children, $grandChildren);
  102. }
  103. }
  104. return $children;
  105. }
  106. /**
  107. * 会员中心
  108. */
  109. public function index()
  110. {
  111. $this->view->assign('title', __('User center'));
  112. return $this->view->fetch();
  113. }
  114. /**
  115. * 注册会员
  116. */
  117. public function register()
  118. {
  119. $url = $this->request->request('url', '', 'trim');
  120. if ($this->auth->id) {
  121. $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
  122. }
  123. if ($this->request->isPost()) {
  124. $username = $this->request->post('username');
  125. $password = $this->request->post('password');
  126. $password_confirm = $this->request->post('password_confirm');
  127. // 判断密码是否一致
  128. if ($password != $password_confirm) {
  129. $this->error('Inconsistent password input', null, ['token' => $this->request->token()]);
  130. }
  131. $email = $this->request->post('email');
  132. $mobile = $this->request->post('mobile', '');
  133. $token = $this->request->post('__token__');
  134. $rule = [
  135. 'username' => 'require|length:3,30',
  136. 'password' => 'require|length:6,30',
  137. '__token__' => 'require|token',
  138. ];
  139. $msg = [
  140. 'username.require' => 'Username can not be empty',
  141. 'username.length' => 'Username must be 3 to 30 characters',
  142. 'password.require' => 'Password can not be empty',
  143. 'password.length' => 'Password must be 6 to 30 characters',
  144. ];
  145. $data = [
  146. 'username' => $username,
  147. 'password' => $password,
  148. 'email' => $email,
  149. 'mobile' => $mobile,
  150. '__token__' => $token,
  151. ];
  152. $validate = new Validate($rule, $msg);
  153. $result = $validate->check($data);
  154. if (!$result) {
  155. $this->error($validate->getError(), null, ['token' => $this->request->token()]);
  156. }
  157. if ($this->auth->register($username, $password)) {
  158. $this->success('Registration successful, please go to the corresponding email to check and verify', $url ? $url : url('user/login'));
  159. } else {
  160. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  161. }
  162. }
  163. //判断来源
  164. $referer = $this->request->server('HTTP_REFERER');
  165. if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
  166. && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
  167. $url = $referer;
  168. }
  169. $this->view->assign('url', $url);
  170. $this->view->assign('title', 'Register');
  171. return $this->view->fetch();
  172. }
  173. /**
  174. * 会员登录
  175. */
  176. public function login()
  177. {
  178. $url = $this->request->request('url', '', 'trim');
  179. $token = $this->request->request('token');
  180. if ($token) {
  181. $token = $this->request->request('token');
  182. $uid = explode('-', $token)[5];
  183. $user = \app\admin\model\User::get($uid);
  184. $user->is_register = 'normal';
  185. if ($user->save()) {
  186. if ($this->auth->direct($user->id)) {
  187. url('/index/user/index');
  188. } else {
  189. url('/');
  190. }
  191. }
  192. }
  193. if ($this->auth->id) {
  194. $this->success('You\'ve logged in, do not login again', $url ? $url : url('user/index'));
  195. }
  196. if ($this->request->isPost()) {
  197. $account = $this->request->post('account');
  198. $password = $this->request->post('password');
  199. $keeplogin = (int)$this->request->post('keeplogin');
  200. // $token = $this->request->post('__token__');
  201. $rule = [
  202. 'account' => 'require|length:3,50',
  203. 'password' => 'require|length:6,30',
  204. // '__token__' => 'require|token',
  205. ];
  206. $msg = [
  207. 'account.require' => 'Account can not be empty',
  208. 'account.length' => 'Account must be 3 to 50 characters',
  209. 'password.require' => 'Password can not be empty',
  210. 'password.length' => 'Password must be 6 to 30 characters',
  211. ];
  212. $data = [
  213. 'account' => $account,
  214. 'password' => $password,
  215. // '__token__' => $token,
  216. ];
  217. $validate = new Validate($rule, $msg);
  218. $result = $validate->check($data);
  219. if (!$result) {
  220. // $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
  221. $this->error(__($validate->getError()), null);
  222. return false;
  223. }
  224. if ($this->auth->login($account, $password)) {
  225. // $this->success('Logged in successful', $url ? $url : url('user/index'));
  226. $this->success('Logged in successful', url('/'));
  227. } else {
  228. // $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  229. $this->error($this->auth->getError(), null);
  230. }
  231. }
  232. //判断来源
  233. $referer = $this->request->server('HTTP_REFERER');
  234. if (!$url && (strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
  235. && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
  236. $url = $referer;
  237. }
  238. $this->view->assign('url', $url);
  239. $this->view->assign('title', __('Login'));
  240. return $this->view->fetch();
  241. }
  242. /**
  243. * 退出登录
  244. */
  245. public function logout()
  246. {
  247. if ($this->request->isPost()) {
  248. $this->token();
  249. //退出本站
  250. $this->auth->logout();
  251. // $this->success(__('Logout successful'), url('user/index'));
  252. // $this->success('Logout successful', url('/'));
  253. $this->redirect(url('user/jump'));
  254. }
  255. $html = "<form id='logout_submit' name='logout_submit' action='' method='post'>" . token() . "<input type='submit' value='ok' style='display:none;'></form>";
  256. $html .= "<script>document.forms['logout_submit'].submit();</script>";
  257. return $html;
  258. }
  259. /**
  260. * 退出登录
  261. *
  262. * @return string
  263. * @throws \think\Exception
  264. */
  265. public function jump()
  266. {
  267. $this->view->assign('title', 'Logout out');
  268. return $this->view->fetch();
  269. }
  270. /**
  271. * 个人信息
  272. */
  273. public function profile()
  274. {
  275. $this->view->assign('title', __('Profile'));
  276. return $this->view->fetch();
  277. }
  278. /**
  279. * 修改密码
  280. */
  281. public function changepwd()
  282. {
  283. if ($this->request->isPost()) {
  284. $oldpassword = $this->request->post("oldpassword");
  285. $newpassword = $this->request->post("newpassword");
  286. $renewpassword = $this->request->post("renewpassword");
  287. $token = $this->request->post('__token__');
  288. $rule = [
  289. 'oldpassword' => 'require|regex:\S{6,30}',
  290. 'newpassword' => 'require|regex:\S{6,30}',
  291. 'renewpassword' => 'require|regex:\S{6,30}|confirm:newpassword',
  292. '__token__' => 'token',
  293. ];
  294. $msg = [
  295. 'renewpassword.confirm' => 'Password and confirm password don\'t match'
  296. ];
  297. $data = [
  298. 'oldpassword' => $oldpassword,
  299. 'newpassword' => $newpassword,
  300. 'renewpassword' => $renewpassword,
  301. '__token__' => $token,
  302. ];
  303. $field = [
  304. 'oldpassword' => 'Old password',
  305. 'newpassword' => 'New password',
  306. 'renewpassword' => 'Renew password'
  307. ];
  308. $validate = new Validate($rule, $msg, $field);
  309. $result = $validate->check($data);
  310. if (!$result) {
  311. $this->error($validate->getError(), null, ['token' => $this->request->token()]);
  312. return false;
  313. }
  314. $ret = $this->auth->changepwd($newpassword, $oldpassword);
  315. if ($ret) {
  316. $this->success('Reset password successful', url('user/login'));
  317. } else {
  318. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  319. }
  320. }
  321. $this->view->assign('title', 'Change password');
  322. return $this->view->fetch();
  323. }
  324. public function attachment()
  325. {
  326. //设置过滤方法
  327. $this->request->filter(['strip_tags']);
  328. if ($this->request->isAjax()) {
  329. $mimetypeQuery = [];
  330. $where = [];
  331. $filter = $this->request->request('filter');
  332. $filterArr = (array)json_decode($filter, true);
  333. if (isset($filterArr['mimetype']) && preg_match("/(\/|\,|\*)/", $filterArr['mimetype'])) {
  334. $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]);
  335. $mimetypeQuery = function ($query) use ($filterArr) {
  336. $mimetypeArr = array_filter(explode(',', $filterArr['mimetype']));
  337. foreach ($mimetypeArr as $index => $item) {
  338. $query->whereOr('mimetype', 'like', '%' . str_replace("/*", "/", $item) . '%');
  339. }
  340. };
  341. } elseif (isset($filterArr['mimetype'])) {
  342. $where['mimetype'] = ['like', '%' . $filterArr['mimetype'] . '%'];
  343. }
  344. if (isset($filterArr['filename'])) {
  345. $where['filename'] = ['like', '%' . $filterArr['filename'] . '%'];
  346. }
  347. if (isset($filterArr['createtime'])) {
  348. $timeArr = explode(' - ', $filterArr['createtime']);
  349. $where['createtime'] = ['between', [strtotime($timeArr[0]), strtotime($timeArr[1])]];
  350. }
  351. $search = $this->request->get('search');
  352. if ($search) {
  353. $where['filename'] = ['like', '%' . $search . '%'];
  354. }
  355. $model = new Attachment();
  356. $offset = $this->request->get("offset", 0);
  357. $limit = $this->request->get("limit", 0);
  358. $total = $model
  359. ->where($where)
  360. ->where($mimetypeQuery)
  361. ->where('user_id', $this->auth->id)
  362. ->order("id", "DESC")
  363. ->count();
  364. $list = $model
  365. ->where($where)
  366. ->where($mimetypeQuery)
  367. ->where('user_id', $this->auth->id)
  368. ->order("id", "DESC")
  369. ->limit($offset, $limit)
  370. ->select();
  371. $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
  372. foreach ($list as $k => &$v) {
  373. $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
  374. }
  375. unset($v);
  376. $result = array("total" => $total, "rows" => $list);
  377. return json($result);
  378. }
  379. $mimetype = $this->request->get('mimetype', '');
  380. $mimetype = substr($mimetype, -1) === '/' ? $mimetype . '*' : $mimetype;
  381. $this->view->assign('mimetype', $mimetype);
  382. $this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList());
  383. return $this->view->fetch();
  384. }
  385. /**
  386. * 我的个人主页
  387. */
  388. public function homepage()
  389. {
  390. $this->view->assign('title', 'My Personal Homepage');
  391. return $this->view->fetch();
  392. }
  393. /**
  394. * 我得邮箱页
  395. */
  396. public function inbox()
  397. {
  398. // 获取当前用户的邮箱内容信息
  399. $email_contents = EmailContent::where(['email' => $this->auth->email])->paginate();
  400. foreach ($email_contents as $content) {
  401. $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
  402. if ($content['type'] == 'admin') {
  403. $content['user'] = Admin::where(['id' => $content['user_id']])->find();
  404. }
  405. $content['createtime'] = date('Y-m-d', $content['createtime']);
  406. if ($content['status'] == 'normal') {
  407. $content['status'] = 'READ';
  408. } else {
  409. $content['status'] = 'Unread';
  410. }
  411. }
  412. $this->view->assign('list', $email_contents);
  413. $this->view->assign('title', 'INBOX');
  414. return $this->view->fetch();
  415. }
  416. /**
  417. * 我的未读邮件页
  418. */
  419. public function unread()
  420. {
  421. // 获取当前用户的邮箱内容信息
  422. $email_contents = EmailContent::where(['email' => $this->auth->email, 'status' => 'hidden'])->paginate();
  423. foreach ($email_contents as $content) {
  424. $content['user'] = \app\admin\model\User::where(['id' => $content['user_id']])->find();
  425. if ($content['type'] == 'admin') {
  426. $content['user'] = Admin::where(['id' => $content['user_id']])->find();
  427. }
  428. $content['createtime'] = date('Y-m-d', $content['createtime']);
  429. $content['status'] = 'Unread';
  430. }
  431. $this->view->assign('list', $email_contents);
  432. $this->view->assign('title', 'Unread');
  433. return $this->view->fetch();
  434. }
  435. /**
  436. * 提交手稿
  437. */
  438. public function submit_manuscript($id = null)
  439. {
  440. $row = [
  441. 'id' => '',
  442. 'manuscript_zip' => '',
  443. 'manuscript_pdf' => '',
  444. 'cover_letter' => '',
  445. 'graphical_abstract' => '',
  446. 'non_material' => '',
  447. 'is_copyright' => '',
  448. 'copyright_files' => '',
  449. 'image' => '',
  450. 'journal' => '',
  451. 'article_type' => '',
  452. 'title' => '',
  453. 'abstract' => '',
  454. 'keywords' => '',
  455. 'number_page' => '',
  456. 'is_funding' => '',
  457. 'funding_content' => '',
  458. 'is_interest' => '',
  459. 'interest_content' => '',
  460. 'statement_type' => '',
  461. 'article_one' => '',
  462. 'article_two' => '',
  463. 'article_three' => '',
  464. 'country' => '',
  465. 'affiliation' => '',
  466. 'name' => '',
  467. 'invoice_email' => '',
  468. 'order_email' => '',
  469. 'address' => '',
  470. 'zip_code' => '',
  471. 'city' => '',
  472. 'telephone' => '',
  473. 'fax' => '',
  474. 'vat' => '',
  475. 'is_become_review' => '',
  476. 'field' => '',
  477. ];
  478. $id = $this->request->param('id');
  479. if ($id) {
  480. $row = AuthorManuscript::where(['id' => $id])->find();
  481. $row->author_content = json_decode($row->author_content, true);
  482. $row->review_content = json_decode($row->review_content, true);
  483. $disabledIds = [];
  484. $disabledIds = array_diff($disabledIds, [$row['journal']]);
  485. $parentChannelIds = Channel::where(['parent_id' => 1, 'type' => 'channel'])->column('id');
  486. $sonChannelIds = Channel::where(['parent_id' => ['in', $parentChannelIds]])->column('id');
  487. $channelIds = array_merge($parentChannelIds, $sonChannelIds);
  488. $all = collection(Channel::where(['id' => ['in', $channelIds]])->order("weigh desc,id desc")->select())->toArray();
  489. $tree = Tree::instance()->init($all, 'parent_id');
  490. $channelOptions = $tree->getTree(1, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", $row['journal'], $disabledIds);
  491. $this->view->assign('channelOptions', $channelOptions);
  492. }
  493. $this->view->assign('fields', $this->model->getFields($row, 0));
  494. $this->view->assign('row', $row);
  495. $this->view->assign('title', 'Submit Manuscript');
  496. return $this->view->fetch();
  497. }
  498. /**
  499. * 手稿状态
  500. */
  501. public function display_submitted()
  502. {
  503. // 构建分页参数
  504. $limit = $this->request->param('limit', 10);
  505. $status = $this->request->param('status', 'all');
  506. $where = [];
  507. if ($status != 'all') {
  508. $where = ['status' => $status];
  509. }
  510. // 查询当前用户手稿
  511. $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id])
  512. ->where($where)
  513. ->field('id,title,image,createtime,journal,status')
  514. ->order('createtime', 'DESC')
  515. ->paginate($limit);
  516. $author_edit_status = config('site.author_edit_status');
  517. $author_comments_status = config('site.author_comments_status');
  518. foreach ($manuscripts as $manuscript) {
  519. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  520. $manuscript['is_edit'] = false; // 是否可修改手稿信息按钮状态
  521. $manuscript['is_comments'] = false; // 回复审稿意见按钮状态
  522. $manuscript['is_view_comments'] = false; // 查看审稿意见按钮状态
  523. if (in_array($manuscript['status'], $author_edit_status)) {
  524. $manuscript['is_edit'] = true;
  525. }
  526. if (in_array($manuscript['status'], $author_comments_status)) {
  527. $manuscript['is_comments'] = true;
  528. }
  529. // 查询当前手稿下是否有可查看的审稿意见数量
  530. $comment_count = Comments::where(['manuscript_id' => $manuscript['id'], 'type' => 'reviewer', 'is_send' => 'normal'])->count();
  531. if ($comment_count > 0) {
  532. $manuscript['is_view_comments'] = true;
  533. }
  534. }
  535. if ($this->request->isAjax()) {
  536. $keyword = $this->request->param('keyword');
  537. $manuscripts = AuthorManuscript::where(['user_id' => $this->auth->id])
  538. ->where(function ($query) use ($keyword, $status) {
  539. if ($status != 'all') {
  540. return $query->where(['status' => $status]);
  541. }
  542. if ($keyword != '') {
  543. return $query->where(['title' => ['like', '%'. $keyword .'%']]);
  544. }
  545. })->field('id,title,image,createtime,journal,status')
  546. ->order('createtime', 'DESC')
  547. ->paginate($limit);
  548. foreach ($manuscripts as $manuscript) {
  549. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  550. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
  551. $manuscript['is_edit'] = false;
  552. $manuscript['is_comments'] = false;
  553. $manuscript['is_view_comments'] = false;
  554. if (in_array($manuscript['status'], $author_edit_status)) {
  555. $manuscript['is_edit'] = true;
  556. }
  557. if (in_array($manuscript['status'], $author_comments_status)) {
  558. $manuscript['is_comments'] = true;
  559. }
  560. // 查询当前手稿下是否有可查看的审稿意见数量
  561. $comment_count = Comments::where(['manuscript_id' => $manuscript['id'], 'type' => 'reviewer', 'is_send' => 'normal'])->count();
  562. if ($comment_count > 0) {
  563. $manuscript['is_view_comments'] = true;
  564. }
  565. }
  566. $this->success('', '', $manuscripts);
  567. }
  568. $this->view->assign('status', $status);
  569. $this->view->assign('list', $manuscripts);
  570. $this->view->assign('title', 'Dispaly Submitted');
  571. return $this->view->fetch();
  572. }
  573. /**
  574. * 审核人信息
  575. */
  576. public function reviewer_information()
  577. {
  578. $user_role = UserRoleLog::where(['user_id' => $this->auth->id, 'type' => 'review', 'is_adopt' => ['in', ['review', 'fault']]])->order('createtime', 'DESC')->find();
  579. $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->find();
  580. if (empty($user_content)) {
  581. $user_content['field'] = '';
  582. $user_content['degree'] = '';
  583. $user_content['affiliation'] = '';
  584. $user_content['publication'] = '';
  585. $user_content['orcid'] = '';
  586. $user_content['homepage'] = '';
  587. $user_content['review_journal'] = '';
  588. $user_content['interested_journal'] = '';
  589. $user_content['resume'] = '';
  590. $user_content['journal_ids'] = '';
  591. }
  592. $this->view->assign('row', $user_content);
  593. $this->view->assign('user_role', $user_role);
  594. $this->view->assign('title', 'Reviewer Information');
  595. return $this->view->fetch();
  596. }
  597. /**
  598. * 审稿邀请函
  599. *
  600. * @return string
  601. * @throws \think\Exception
  602. */
  603. public function invitation_letter()
  604. {
  605. $limit = $this->request->param('limit', 10);
  606. $status = $this->request->param('status', 'audit');
  607. $where = ['status' => $status];
  608. // 根据用户的审稿角色id查询对应的邀请审稿信息
  609. $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
  610. $manuscript_id_arr = InviteReviewer::where(['role_id' => $role_id])->where($where)->order('createtime', 'DESC')->column('manuscript_id');
  611. // 查询当前用户手稿
  612. $manuscripts = AuthorManuscript::where(['id' => ['in', $manuscript_id_arr]])
  613. ->field('id,title,image,createtime,journal')
  614. ->order('createtime', 'DESC')
  615. ->paginate($limit);
  616. foreach ($manuscripts as $manuscript) {
  617. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  618. }
  619. if ($this->request->isAjax()) {
  620. $keyword = $this->request->param('keyword');
  621. $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%']])
  622. ->where(['id' => ['in', $manuscript_id_arr]])
  623. ->field('id,title,image,createtime,journal')
  624. ->order('createtime', 'DESC')
  625. ->paginate($limit);
  626. foreach ($manuscripts as $manuscript) {
  627. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  628. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
  629. }
  630. $this->success('', '', $manuscripts);
  631. }
  632. $this->view->assign('status', $status);
  633. $this->view->assign('list', $manuscripts);
  634. $this->view->assign('title', 'Invitation Letter for Review');
  635. return $this->view->fetch();
  636. }
  637. /**
  638. * 审阅的手稿
  639. */
  640. public function show_reviewed_manuscripts()
  641. {
  642. $limit = $this->request->param('limit', 10);
  643. $status = $this->request->param('status', 'comment_submission');
  644. $where = ['status' => $status];
  645. $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
  646. $manuscript_id_arr = InviteReviewer::where(['role_id' => $role_id, 'status' => 'accept'])->order('createtime', 'DESC')->column('manuscript_id');
  647. // 查询当前用户手稿
  648. $manuscripts = AuthorManuscript::where($where)
  649. ->where(['id' => ['in', $manuscript_id_arr]])
  650. ->field('id,title,image,createtime,journal')
  651. ->order('createtime', 'DESC')
  652. ->paginate($limit);
  653. foreach ($manuscripts as $manuscript) {
  654. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  655. }
  656. if ($this->request->isAjax()) {
  657. $keyword = $this->request->param('keyword');
  658. $manuscripts = AuthorManuscript::where(['title' => ['like', '%'. $keyword .'%'], 'status' => $status])
  659. // ->whereRaw("FIND_IN_SET(". $this->auth->id .", `reviewer_ids`)")
  660. ->where(['id' => ['in', $manuscript_id_arr]])
  661. ->field('id,title,image,createtime,journal')
  662. ->order('createtime', 'DESC')
  663. ->paginate($limit);
  664. foreach ($manuscripts as $manuscript) {
  665. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  666. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
  667. }
  668. $this->success('', '', $manuscripts);
  669. }
  670. $this->view->assign('status', $status);
  671. $this->view->assign('list', $manuscripts);
  672. $this->view->assign('title', 'Show Reviewed Manuscripts');
  673. return $this->view->fetch();
  674. }
  675. /**
  676. * 手稿详情
  677. */
  678. public function article_details($id = null)
  679. {
  680. $id = $this->request->param('id');
  681. $type = $this->request->param('type');
  682. $status = $this->request->param('status', 'reviewer_details');
  683. $row = AuthorManuscript::where(['id' => $id])->find();
  684. $row['review_content'] = json_decode($row['review_content'], true);
  685. if ($row) {
  686. // $row['keywords'] = explode(',', $row['keywords']);
  687. $row['journal'] = Channel::where(['id' => $row['journal']])->value('name') ?? '-';
  688. }
  689. // 判断是审稿人还是编辑,如果是编辑则可以看到全部意见
  690. $comments = Comments::where(['manuscript_id' => $row['id']])->select();
  691. if ($type == 'reviewer') {
  692. $comments = Comments::where(['manuscript_id' => $row['id'], 'type' => 'reviewer'])->select();
  693. }
  694. if ($type == 'editor' || $type == 'author') {
  695. $reviewers = InviteReviewer::where(['manuscript_id' => $row['id']])->select();
  696. // 邀请的审稿人信息
  697. if ($status == 'reviewer_details') {
  698. foreach ($reviewers as $reviewer) {
  699. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  700. if ($reviewer_role) {
  701. // 查询审稿人提交意见信息
  702. $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  703. ->order('createtime', 'DESC')
  704. ->find();
  705. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  706. if ($reviewer_comment) {
  707. $reviewer['reply_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? time());
  708. $reviewer['submission_time'] = date('Y-m-d', $reviewer_comment['createtime'] ?? time());
  709. $reviewer['status'] = $reviewer_comment['recommendation'] ?? '';
  710. }
  711. }
  712. $reviewer['nickname'] = $reviewer_user['nickname'];
  713. $reviewer['invited_time'] = date('Y-m-d', $reviewer['createtime']);
  714. }
  715. }
  716. // 审稿人信息
  717. if ($status == 'reviewer_suggestion') {
  718. foreach ($reviewers as $reviewer) {
  719. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  720. if ($reviewer_role) {
  721. // 查询审稿人提交意见数量
  722. $reviewer_comment_num = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  723. ->count();
  724. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  725. }
  726. $reviewer['nickname'] = $reviewer_user['nickname'];
  727. $reviewer['affiliation'] = $reviewer_role['affiliation'];
  728. $reviewer['comment_num'] = $reviewer_comment_num;
  729. }
  730. }
  731. // 审稿人意见信息
  732. if ($status == 'review_report') {
  733. foreach ($reviewers as $reviewer) {
  734. $reviewer_role = UserRoleContent::where(['id' => $reviewer['role_id']])->find();
  735. if ($reviewer_role) {
  736. // 查询审稿人提交意见信息
  737. $reviewer_comment = Comments::where(['user_id' => $reviewer_role['user_id'], 'manuscript_id' => $row['id']])
  738. ->order('createtime', 'DESC')
  739. ->find();
  740. $reviewer_user = \app\admin\model\User::where(['id' => $reviewer_role['user_id']])->find();
  741. }
  742. $reviewer['nickname'] = $reviewer_user['nickname'];
  743. $reviewer['recommendation'] = $reviewer_comment['recommendation'];
  744. $reviewer['comment'] = $reviewer_comment['comments'];
  745. $reviewer['createtime'] = date('Y-m-d', $reviewer_comment['createtime']);
  746. $reviewer['comment_id'] = $reviewer_comment['id'];
  747. $reviewer['is_send'] = $reviewer_comment['is_send'];
  748. }
  749. }
  750. // 作者回复意见
  751. if ($status == 'author_report') {
  752. // 查询作者提交意见信息回复
  753. $author_comment = Comments::where(['user_id' => $row['user_id'], 'manuscript_id' => $row['id'], 'type' => 'author'])
  754. ->order('createtime', 'DESC')
  755. ->find();
  756. if ($author_comment) {
  757. $author_user = \app\admin\model\User::where(['id' => $row['user_id']])->find();
  758. $author['nickname'] = $author_user['nickname'] ?? '';
  759. $author['comment'] = $author_comment['comments'] ?? '';
  760. $author['createtime'] = date('Y-m-d', $author_comment['createtime']);
  761. }
  762. }
  763. $row['reviewer'] = $reviewers;
  764. $row['author'] = $author ?? [];
  765. }
  766. $row['comments'] = $comments ?? [];
  767. $this->view->assign('status', $status);
  768. $this->view->assign('row', $row);
  769. $this->view->assign('type', $type);
  770. $this->view->assign('title', 'Article Details');
  771. return $this->view->fetch();
  772. }
  773. /**
  774. * 审稿页面
  775. */
  776. public function conduct_review($id = null)
  777. {
  778. $id = $this->request->param('id');
  779. $type = $this->request->param('type');
  780. $row = Comments::where(['manuscript_id' => $id, 'type' => $type])->find();
  781. $manuscript = AuthorManuscript::where(['id' => $id])->find();
  782. $this->view->assign('row', $row);
  783. $this->view->assign('manuscript', $manuscript);
  784. $this->view->assign('id', $id);
  785. $this->view->assign('type', $type);
  786. $this->view->assign('title', 'Conduct Review');
  787. return $this->view->fetch();
  788. }
  789. /**
  790. * 申请创建特刊
  791. */
  792. public function special_issue($id = null)
  793. {
  794. $special_issue = [
  795. 'id' => '',
  796. 'image' => '',
  797. 'journal' => '',
  798. 'issue_name' => '',
  799. 'proposal_text' => '',
  800. 'publication_cycle' => '',
  801. 'editor' => '',
  802. 'statement_type' => '',
  803. ];
  804. if ($id) {
  805. $special_issue = Issue::where(['id' => $id])->find();
  806. $special_issue->editor = json_decode($special_issue['editor']);
  807. }
  808. $this->view->assign('row', $special_issue);
  809. $this->view->assign('title', 'Apply to creat a special issue');
  810. return $this->view->fetch();
  811. }
  812. /**
  813. * 申请成为编辑
  814. */
  815. public function become_an_editor()
  816. {
  817. $user_content = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => ['in', ['editor', 'chief']]])->find();
  818. $user = \app\common\model\User::get($this->auth->id);
  819. // 因为是主编和编辑共用一个页面所以只查询这两个角色下最后一个申请记录就可以
  820. $user_role_log = UserRoleLog::where(['user_id' => $this->auth->id, 'type' => ['in', ['editor', 'chief']]])->order('createtime', 'DESC')->find();
  821. if (empty($user_content)) {
  822. $user_content['degree'] = '';
  823. $user_content['affiliation'] = '';
  824. $user_content['publication'] = '';
  825. $user_content['orcid'] = '';
  826. $user_content['homepage'] = '';
  827. $user_content['review_journal'] = '';
  828. $user_content['interested_journal'] = '';
  829. $user_content['resume'] = '';
  830. $user_content['journal_ids'] = '';
  831. $user_content['is_chief'] = '';
  832. $user_content['is_editor'] = '';
  833. } else {
  834. $user_content['is_chief'] = $user['is_chief'];
  835. $user_content['is_editor'] = $user['is_editor'];
  836. }
  837. $this->view->assign('row', $user_content);
  838. $this->view->assign('user_role', $user_role_log);
  839. $this->view->assign('user', $user);
  840. $this->view->assign('title', 'Apply to become an editor');
  841. return $this->view->fetch();
  842. }
  843. /**
  844. * 编辑手稿
  845. */
  846. public function editing_manuscripts()
  847. {
  848. $limit = $this->request->param('limit', 10);
  849. $type = $this->request->param('type');
  850. $status = $this->request->param('status', 'all');
  851. $where = [];
  852. if ($status != 'all') {
  853. $where = ['status' => $status];
  854. }
  855. $user = $this->auth;
  856. // 查询当前用户手稿
  857. $manuscripts = AuthorManuscript::where(function ($query) use ($user) {
  858. if ($user->is_chief == 'correct') {
  859. $query->where(['chief_id' => $this->auth->id]);
  860. }
  861. if ($user->is_editor == 'correct') {
  862. $query->whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)");
  863. }
  864. })->where($where)->field('id,title,image,createtime,journal')
  865. ->order('createtime', 'DESC')
  866. ->paginate($limit);
  867. foreach ($manuscripts as $manuscript) {
  868. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name');
  869. }
  870. if ($this->request->isAjax()) {
  871. $keyword = $this->request->param('keyword');
  872. $manuscripts = AuthorManuscript::where(function ($query) use ($user) {
  873. if ($user->is_chief == 'correct') {
  874. $query->where(['chief_id' => $this->auth->id]);
  875. }
  876. if ($user->is_editor == 'correct') {
  877. $query->whereRaw("FIND_IN_SET(". $this->auth->id .", `editor_ids`)");
  878. }
  879. })->where($where)->where(['title' => ['like', '%'. $keyword .'%']])->field('id,title,image,createtime,journal')->order('createtime', 'DESC')->paginate($limit);
  880. foreach ($manuscripts as $manuscript) {
  881. $manuscript['is_chief'] = false;
  882. $manuscript['createtime'] = date('Y-m-d', $manuscript['createtime']);
  883. $manuscript['journal'] = Channel::where(['id' => $manuscript['journal']])->value('name') ?? '';
  884. if ($this->auth->is_chief == 'correct') {
  885. $manuscript['is_chief'] = true;
  886. }
  887. }
  888. $this->success('', '', $manuscripts);
  889. }
  890. $this->view->assign('status', $status);
  891. $this->view->assign('type', $type);
  892. $this->view->assign('list', $manuscripts);
  893. $this->view->assign('title', 'Editing Manuscripts');
  894. return $this->view->fetch();
  895. }
  896. /**
  897. * 提交处理意见
  898. */
  899. public function handing_suggestions()
  900. {
  901. $id = $this->request->param('id');
  902. $type = $this->request->param('type');
  903. $row = Comments::where(['manuscript_id' => $id, 'type' => $type, 'user_id' => $this->auth->id])->find();
  904. $manuscript = AuthorManuscript::where(['id' => $id])->find();
  905. if (empty($row)) {
  906. $row['is_interest'] = '';
  907. }
  908. $this->view->assign('row', $row);
  909. $this->view->assign('manuscript', $manuscript);
  910. $this->view->assign('id', $id);
  911. $this->view->assign('type', $type);
  912. $this->view->assign('title', 'Submit Handing Suggestions');
  913. return $this->view->fetch();
  914. }
  915. /**
  916. * 邀请审稿人
  917. */
  918. public function invite_reviewers()
  919. {
  920. $id = $this->request->param('id');
  921. $manuscript = AuthorManuscript::get($id);
  922. $manuscript_review_id_arr = explode(',', $manuscript['reviewer_ids']);
  923. $review_user_content = UserRoleContent::where(['user_id' => ['in', $manuscript_review_id_arr], 'type' => 'review'])->select();
  924. // 获取审稿人信息
  925. $review_id_arr = \app\common\model\User::where(['is_review' => 'correct', 'id' => ['<>', $manuscript->user_id]])->column('id');
  926. $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->select();
  927. // $list = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
  928. foreach ($list as $value) {
  929. $channel_name_arr = Channel::where(['id' => ['in', explode(',', $value['journal_ids'])]])->column('name');
  930. $value['journal'] = implode(',', $channel_name_arr);
  931. $value['is_checked'] = false;
  932. if (in_array($value['user_id'], $manuscript_review_id_arr)) {
  933. $value['is_checked'] = true;
  934. }
  935. }
  936. $this->view->assign('id', $id);
  937. $this->view->assign('list', $list);
  938. $this->view->assign('reviewer_user_content', $review_user_content);
  939. $this->view->assign('title', 'Invite Reviewers');
  940. return $this->view->fetch();
  941. }
  942. /**
  943. * 获取审稿人列表
  944. *
  945. * @return void
  946. * @throws \think\exception\DbException
  947. */
  948. public function getReviewerList()
  949. {
  950. // 构建分页参数
  951. $limit = $this->request->param('limit', 10);
  952. // 获取审稿人信息
  953. $review_id_arr = \app\common\model\User::where(['is_review' => 'correct'])->column('id');
  954. $data = UserRoleContent::with(['user'])->where(['user_id' => ['in', $review_id_arr], 'type' => 'review'])->paginate($limit);
  955. foreach ($data as $value) {
  956. $value['user']['first_name'] = $value['user']['first_name'] ?? '-';
  957. $value['user']['last_name'] = $value['user']['last_name'] ?? '-';
  958. $value['affiliation'] = $value['affiliation'] ?? '-';
  959. }
  960. // 返回表格数据和分页信息
  961. $this->success('', '', $data);
  962. }
  963. /**
  964. * 提交会议
  965. *
  966. * @return string
  967. * @throws \think\Exception
  968. */
  969. public function submit_conference()
  970. {
  971. $this->view->assign('title', 'Submit Conference');
  972. return $this->view->fetch();
  973. }
  974. /**
  975. * 参加会议
  976. *
  977. * @return string
  978. * @throws \think\Exception
  979. */
  980. public function conference_participate()
  981. {
  982. $param = $this->request->param();
  983. $id = $param['id'];
  984. $row = Participate::where(['id' => $id])->find();
  985. $this->view->assign('id', $id);
  986. $this->view->assign('row', $row);
  987. $this->view->assign('title', 'Submit Conference');
  988. return $this->view->fetch();
  989. }
  990. /**
  991. * 特刊列表页
  992. *
  993. * @return string
  994. * @throws \think\Exception
  995. * @throws \think\exception\DbException
  996. */
  997. public function special_issue_list()
  998. {
  999. $status = $this->request->param('status', 'all');
  1000. $where = ['user_id' => $this->auth->id];
  1001. if ($status != 'all') {
  1002. $where = ['status' => $status, 'user_id' => $this->auth->id];
  1003. }
  1004. if ($status == 'all') {
  1005. unset($where['status']);
  1006. }
  1007. $special_issues = Issue::where($where)->order('createtime', 'DESC')->paginate();
  1008. if ($this->request->isAjax()) {
  1009. $keyword = $this->request->param('keyword');
  1010. if ($status == 'all') {
  1011. $status = '';
  1012. }
  1013. $special_issues = Issue::where(['user_id' => $this->auth->id, 'issue_name' => ['like', '%'. $keyword .'%']])
  1014. ->where(function ($query) use ($status) {
  1015. if ($status) {
  1016. $query->where(['status' => $status]);
  1017. }
  1018. })->field('id,issue_name,image,createtime,journal')
  1019. ->order('createtime', 'DESC')
  1020. ->paginate();
  1021. foreach ($special_issues as $special_issue) {
  1022. $special_issue['createtime'] = date('Y-m-d', $special_issue['createtime']);
  1023. $special_issue['journal'] = Channel::where(['id' => $special_issue['journal']])->value('name');
  1024. }
  1025. $this->success('', '', $special_issues);
  1026. }
  1027. foreach ($special_issues as $special_issue) {
  1028. $special_issue['createtime'] = date('Y-m-d', $special_issue['createtime']);
  1029. $special_issue['journal'] = Channel::where(['id' => $special_issue['journal']])->value('name');
  1030. }
  1031. $this->view->assign('status', $status);
  1032. $this->view->assign('title', 'Special Issue List');
  1033. $this->view->assign('list', $special_issues);
  1034. return $this->view->fetch();
  1035. }
  1036. /**
  1037. * 作者审稿意见
  1038. *
  1039. * @return string
  1040. * @throws \think\Exception
  1041. * @throws \think\db\exception\DataNotFoundException
  1042. * @throws \think\db\exception\ModelNotFoundException
  1043. * @throws \think\exception\DbException
  1044. */
  1045. public function review_comments()
  1046. {
  1047. $param = $this->request->param();
  1048. $type = $param['type'];
  1049. $row = Comments::where(['manuscript_id' => $param['id']])->find();
  1050. $manuscript = AuthorManuscript::get($param['id']);
  1051. if (empty($row)) {
  1052. $row['manuscript_id'] = $param['id'];
  1053. $row['comments'] = '';
  1054. $row['status'] = $manuscript['status'];
  1055. }
  1056. $this->view->assign('row', $row);
  1057. $this->view->assign('type', $type);
  1058. return $this->view->fetch();
  1059. }
  1060. /**
  1061. * 发送邮件列表
  1062. *
  1063. * @return string
  1064. * @throws \think\Exception
  1065. * @throws \think\exception\DbException
  1066. */
  1067. public function send_email()
  1068. {
  1069. $param = $this->request->param();
  1070. $type = $param['type'];
  1071. $row = AuthorManuscript::get($param['id']);
  1072. // 身份是不同的则需要查询不同人的列表
  1073. if ($type == 'author') {
  1074. /** 审稿人 编辑 */
  1075. $review_ids = explode(',', $row['reviewer_ids']);
  1076. $editor_ids = explode(',', $row['editor_ids']);
  1077. $user_arr = array_merge($review_ids, $editor_ids);
  1078. $user_arr = array_unique($user_arr);
  1079. }
  1080. if ($type == 'reviewer') {
  1081. /** 作者 编辑 */
  1082. $editor_ids = explode(',', $row['editor_ids']);
  1083. $author_ids = [$row['user_id']];
  1084. $user_arr = array_merge($editor_ids, $author_ids);
  1085. $user_arr = array_unique($user_arr);
  1086. }
  1087. if ($type == 'editor') {
  1088. /** 作者 审稿人 */
  1089. $author_ids = [$row['user_id']];
  1090. $review_ids = explode(',', $row['reviewer_ids']);
  1091. $user_arr = array_merge($review_ids, $author_ids);
  1092. $user_arr = array_unique($user_arr);
  1093. }
  1094. $user_list = \app\admin\model\User::where(['id' => ['in', $user_arr]])->column('email', 'id');
  1095. $this->view->assign('type', $type);
  1096. $this->view->assign('user_list', $user_list);
  1097. $this->view->assign('row', $row);
  1098. $this->view->assign('mail_smtp_host', $this->auth->mail_smtp_host);
  1099. $this->view->assign('mail_smtp_port', $this->auth->mail_smtp_port);
  1100. $this->view->assign('mail_smtp_user', $this->auth->mail_smtp_user);
  1101. $this->view->assign('mail_smtp_pass', $this->auth->mail_smtp_pass);
  1102. $this->view->assign('title', 'Send Email');
  1103. return $this->view->fetch();
  1104. }
  1105. /**
  1106. * 邀请编辑页
  1107. *
  1108. * @return string
  1109. * @throws \think\Exception
  1110. * @throws \think\exception\DbException
  1111. */
  1112. public function invite_editor()
  1113. {
  1114. $param = $this->request->param();
  1115. $type = $param['type'];
  1116. $row = AuthorManuscript::get($param['id']);
  1117. $this->view->assign('row', $row);
  1118. $this->view->assign('type', $type);
  1119. $this->view->assign('title', 'Invite Editor');
  1120. return $this->view->fetch();
  1121. }
  1122. /**
  1123. * 选择编辑
  1124. *
  1125. * @return \think\response\Json
  1126. * @throws \think\db\exception\DataNotFoundException
  1127. * @throws \think\db\exception\ModelNotFoundException
  1128. * @throws \think\exception\DbException
  1129. */
  1130. public function choose_editor()
  1131. {
  1132. $info = \app\common\model\User::where(['is_editor' => 'correct', 'id' => ['not in', $this->auth->id]])->field('nickname, id')->select();
  1133. $params = $this->request->request();
  1134. if (array_key_exists('name', $params) && $params['name']) {
  1135. $info = \app\common\model\User::where(['is_editor' => 'correct', 'nickname' => ['like', '%' . $params['name'] . '%'], 'id' => ['not in', $this->auth->id]])->field('nickname, id')->select();
  1136. }
  1137. if ($this->request->request("keyValue")) {
  1138. $id_arr = $this->request->request('keyValue');
  1139. $info = \app\common\model\User::where(['id' => ['in', $id_arr]])->field('nickname, id')->select();
  1140. }
  1141. $arr = [];
  1142. foreach ($info as $item) {
  1143. $v['id'] = $item['id'];
  1144. $v['name'] = $item['nickname'];
  1145. $arr[] = $v;
  1146. }
  1147. $data['list'] = $arr;
  1148. $data['total'] = count($arr);
  1149. return json($data);
  1150. }
  1151. /**
  1152. * 选择期刊
  1153. *
  1154. * @return \think\response\Json
  1155. * @throws \think\db\exception\DataNotFoundException
  1156. * @throws \think\db\exception\ModelNotFoundException
  1157. * @throws \think\exception\DbException
  1158. */
  1159. public function choose_journal()
  1160. {
  1161. $type = $this->request->request("type");
  1162. $where = [];
  1163. if ($type == 'author') {
  1164. $where['chief_id'] = ['<>', 0];
  1165. }
  1166. $info = Channel::where(['parent_id' => 1])->where($where)->field('name, id')->select();
  1167. $params = $this->request->request();
  1168. if (array_key_exists('name', $params) && $params['name']) {
  1169. $info = Channel::where(['parent_id' => 1, 'name' => ['like', '%' . $params['name'] . '%']])->where($where)->field('name, id')->select();
  1170. }
  1171. if ($this->request->request("keyValue")) {
  1172. $id_arr = $this->request->request('keyValue');
  1173. $info = Channel::where(['id' => ['in', $id_arr]])->where($where)->field('name, id')->select();
  1174. }
  1175. $arr = [];
  1176. foreach ($info as $item) {
  1177. $v['id'] = $item['id'];
  1178. $v['name'] = $item['name'];
  1179. $arr[] = $v;
  1180. }
  1181. $data['list'] = $arr;
  1182. $data['total'] = count($arr);
  1183. return json($data);
  1184. }
  1185. /**
  1186. * 邀请函操作
  1187. *
  1188. * @return void
  1189. * @throws \think\db\exception\DataNotFoundException
  1190. * @throws \think\db\exception\ModelNotFoundException
  1191. * @throws \think\exception\DbException
  1192. */
  1193. public function invitation_letter_operate()
  1194. {
  1195. $params = $this->request->request();
  1196. $manuscript_id = $params['id'];
  1197. $status = $params['status'];
  1198. Db::startTrans();
  1199. try {
  1200. $role_id = UserRoleContent::where(['user_id' => $this->auth->id, 'type' => 'review'])->order('createtime', 'DESC')->value('id');
  1201. $invite_content = InviteReviewer::where(['role_id' => $role_id, 'manuscript_id' => $manuscript_id])->order('createtime', 'DESC')->find();
  1202. if ($invite_content) {
  1203. $invite_content->status = $status;
  1204. $invite_content->save();
  1205. }
  1206. Db::commit();
  1207. } catch (ValidateException|PDOException|Exception $e) {
  1208. Db::rollback();
  1209. $this->error($e->getMessage());
  1210. }
  1211. $this->success('Successful');
  1212. }
  1213. /**
  1214. * 意见转呈
  1215. *
  1216. * @return void
  1217. * @throws \think\db\exception\DataNotFoundException
  1218. * @throws \think\db\exception\ModelNotFoundException
  1219. * @throws \think\exception\DbException
  1220. */
  1221. public function send_author_comments()
  1222. {
  1223. $params = $this->request->request();
  1224. $comment_id = $params['comment_id'];
  1225. Db::startTrans();
  1226. try {
  1227. $comment = Comments::where(['id' => $comment_id])->find();
  1228. if ($comment) {
  1229. $comment->is_send = 'normal';
  1230. $comment->save();
  1231. }
  1232. Db::commit();
  1233. } catch (ValidateException|PDOException|Exception $e) {
  1234. Db::rollback();
  1235. $this->error($e->getMessage());
  1236. }
  1237. $this->success('Successful');
  1238. }
  1239. /**
  1240. * 获取擅长领域
  1241. *
  1242. * @return \think\response\Json
  1243. */
  1244. public function choose_field()
  1245. {
  1246. $info = config('site.review_field');
  1247. $params = $this->request->request();
  1248. if (array_key_exists('name', $params) && $params['name']) {
  1249. $new_info = [];
  1250. foreach ($info as $key => $value) {
  1251. if (strstr(mb_strtolower($value), $params['name'])) {
  1252. $new_info[$key] = $value;
  1253. }
  1254. }
  1255. $arr = [];
  1256. foreach ($new_info as $key => $item) {
  1257. $v['id'] = $key;
  1258. $v['name'] = $item;
  1259. $arr[] = $v;
  1260. }
  1261. $data['list'] = $arr;
  1262. $data['total'] = count($arr);
  1263. return json($data);
  1264. }
  1265. if ($this->request->request("keyValue")) {
  1266. $id_arr = $this->request->request('keyValue');
  1267. $new_info = [];
  1268. foreach ($info as $key => $value) {
  1269. if (!is_array($id_arr)) {
  1270. $id_arr = explode(',', $id_arr);
  1271. }
  1272. if (in_array($key, $id_arr)) {
  1273. $new_info[$key] = $value;
  1274. }
  1275. }
  1276. $arr = [];
  1277. foreach ($new_info as $key => $item) {
  1278. $v['id'] = $key;
  1279. $v['name'] = $item;
  1280. $arr[] = $v;
  1281. }
  1282. $data['list'] = $arr;
  1283. $data['total'] = count($arr);
  1284. return json($data);
  1285. }
  1286. $arr = [];
  1287. foreach ($info as $key => $item) {
  1288. $v['id'] = $key;
  1289. $v['name'] = $item;
  1290. $arr[] = $v;
  1291. }
  1292. $data['list'] = $arr;
  1293. $data['total'] = count($arr);
  1294. return json($data);
  1295. }
  1296. }