Cms.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\cms\AuthorManuscript;
  4. use app\admin\model\cms\Channel;
  5. use app\common\controller\Api;
  6. use app\common\library\Ems as Emslib;
  7. use app\common\model\User;
  8. use think\Hook;
  9. /**
  10. * cms系统
  11. */
  12. class Cms extends Api
  13. {
  14. protected $noNeedLogin = '*';
  15. protected $noNeedRight = '*';
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. public function getChannelCycle()
  21. {
  22. $params = $this->request->param();
  23. if ($params['channel_id']) {
  24. // 获取当前期刊下所有手稿数量
  25. $manuscript_count = AuthorManuscript::where(['journal' => $params['channel_id']])->count();
  26. // 获取录用状态下的期刊数量
  27. $correct_manuscript_status = config('site.correct_manuscript_status');
  28. $correct_manuscript_count = 0;
  29. foreach ($correct_manuscript_status as $correct_status) {
  30. $correct_manuscript_count += AuthorManuscript::where(['journal' => $params['channel_id'], 'status' => $correct_status])->count();
  31. }
  32. }
  33. if ($correct_manuscript_count > 0) {
  34. $channel_rate = $correct_manuscript_count / $manuscript_count * 100;
  35. }
  36. $this->success('', $channel_rate ?? 0);
  37. }
  38. public function getChannelDiyname()
  39. {
  40. $params = $this->request->param();
  41. if ($params['channel_id']) {
  42. $channel = Channel::where(['id' => $params['channel_id']])->find();
  43. }
  44. $this->success('', $channel);
  45. }
  46. }