diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index cff664b..a5cebc2 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -986,7 +986,7 @@ class Article extends Controller { private function save_article_file($article_id, $user_id, $username, $url, $type_name) { //首先确定数据库里面是否存在此数据 $res = $this->article_file_obj->where(['file_url' => $url])->find(); - if ($res) { + if ($res) {//编辑的时候不能重复存储 return true; }else if($type_name=='picturesAndTables' && $url == ''){ return true; diff --git a/application/api/controller/Staff.php b/application/api/controller/Staff.php index 879abd3..b848f75 100644 --- a/application/api/controller/Staff.php +++ b/application/api/controller/Staff.php @@ -47,18 +47,6 @@ class Staff extends Controller { $this->staff_to_journal_obj = Db::name('staff_to_journal'); } - public function mytest(){ - $url = self::JURL; - $param = []; - $param['issn'] = '2413-3973'; - $res = json_decode(myPost($url,$param)); - echo '
'; - var_dump($res->data->cites); - echo ''; - die; - } - - /** * 添加工资level */ @@ -112,6 +100,7 @@ class Staff extends Controller { $insert['email'] = $data['email']; $insert['ident'] = $data['ident']; $insert['bank'] = $data['bank']; + $insert['type'] = $data['type']; $insert['password'] = md5($data['password']); $insert['add_price'] = $data['add_price']; $insert['add_reason'] = $data['add_reason']; @@ -141,6 +130,7 @@ class Staff extends Controller { $update['email'] = $data['email']; $update['ident'] = $data['ident']; $update['bank'] = $data['bank']; + $update['type'] = $data['type']; $update['add_price'] = $data['add_price']; $update['add_reason'] = $data['add_reason']; $update['sub_price'] = $data['sub_price']; @@ -166,6 +156,40 @@ class Staff extends Controller { $re['count'] = $count; return jsonSuccess($re); } + + public function test(){ + echo strtotime('2021-03-13 22:15:20'); + } + + /** + * 获取指定期刊一段时间的文章详情 + * @return type + */ + public function getStaffArticles(){ + $data = $this->request->post(); +// $data['staff_id'] = 8; +// $data['date'] = '202104'; +// $staff_info = $this->staff_obj->where('staff_id',$data['staff_id'])->find(); + $journals = $this->journal_obj->where('staff_id',$data['staff_id'])->select(); + if ($data['date'] != date('Ym')) { + $c_time = strtotime("-1 month", strtotime($data['date'] . '26 00:00:00')); + $c_time1 = strtotime($data['date'].'25 23:59:59'); + $where['ctime'] = array(['>', $c_time], ['<=', $c_time1]); + }else{ + $c_time = strtotime("-1 month", strtotime(date('Y-m') . '-26 00:00:00')); + $c_time1 = strtotime(date('Ym').'25 23:59:59'); + $where['ctime'] = array(['>', $c_time], ['<=', $c_time1]); + } + $articles = []; + foreach ($journals as $v){ + $where['accept_sn'] = ['like',$v['abbr'].'%']; + $list = $this->article_obj->where($where)->select(); + $articles = array_merge($articles,$list); + } + + $re['articles'] = $articles; + return jsonSuccess($re); + } /** * 获取全部员工 @@ -228,41 +252,43 @@ class Staff extends Controller { $journals = $this->journal_obj->where('staff_id', $value['staff_id'])->select(); $journal_price = 0; $cite_price = 0; - foreach ($journals as $v) { - $c_price = 0; -// $where['journal_id'] = $v['journal_id']; - $where['accept_sn'] = ['like',$v['abbr'].'%']; - $cache_articles = $this->article_obj->where($where)->select(); - $c_gn = 0; - $c_gw = 0; - foreach ($cache_articles as $vv) { - $c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country'); - $c_c = 'gn'; - foreach ($c_country as $vvv) { - if ($vvv != 'China' && $vvv != '') { - $c_c = 'gw'; + if($value['type']==0){ + foreach ($journals as $v) { + $c_price = 0; + // $where['journal_id'] = $v['journal_id']; + $where['accept_sn'] = ['like',$v['abbr'].'%']; + $cache_articles = $this->article_obj->where($where)->select(); + $c_gn = 0; + $c_gw = 0; + foreach ($cache_articles as $vv) { + $c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country'); + $c_c = 'gn'; + foreach ($c_country as $vvv) { + if ($vvv != 'China' && $vvv != '') { + $c_c = 'gw'; + } + } + if ($c_c == 'gn') { + $c_gn++; + } else { + $c_gw++; } } - if ($c_c == 'gn') { - $c_gn++; + if ($c_gn - $v['jour_num'] >= 0) { + $c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200; } else { - $c_gw++; + if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) { + $c_price = ($c_gn + $c_gw - $v['jour_num']) * 200; + } else { + $c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50; + } } + $journal_price += $c_price; + //获取cite提成 + $jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']])); + $jcs = $jcites->data->cites; + $cite_price += count($jcs)*500; } - if ($c_gn - $v['jour_num'] >= 0) { - $c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200; - } else { - if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) { - $c_price = ($c_gn + $c_gw - $v['jour_num']) * 200; - } else { - $c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50; - } - } - $journal_price += $c_price; - //获取cite提成 - $jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']])); - $jcs = $jcites->data->cites; - $cite_price += count($jcs)*500; } //添加数据 $ccc = $this->staff_log_obj->where('staff_id',$value['staff_id'])->where('date', date('Ym'))->find(); @@ -351,7 +377,6 @@ class Staff extends Controller { private function getTomonthPrice($name, $date) { $staff_info = $this->staff_obj->where('name', $name)->where('state',0)->find(); $baseprice = $this->getBasePrice($name); - if ($date != date('Ym')) { $log_res = $this->staff_log_obj->where('staff_id', $staff_info['staff_id'])->where('date', $date)->where('state', 0)->find(); if ($log_res) { @@ -391,41 +416,43 @@ class Staff extends Controller { $journals = $this->journal_obj->where('staff_id', $staff_info['staff_id'])->select(); $journal_price = 0; $cite_price = 0; - foreach ($journals as $v) { - $c_price = 0; - $where['accept_sn'] = ['like',$v['abbr'].'%']; - $cache_articles = $this->article_obj->where($where)->select(); - $c_gn = 0; - $c_gw = 0; - foreach ($cache_articles as $vv) { - $c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country'); - $c_c = 'gn'; - foreach ($c_country as $vvv) { - if ($vvv != 'China' && $vvv != '') { - $c_c = 'gw'; + if($staff_info['type']==0){ + foreach ($journals as $v) { + $c_price = 0; + $where['accept_sn'] = ['like',$v['abbr'].'%']; + $cache_articles = $this->article_obj->where($where)->select(); + $c_gn = 0; + $c_gw = 0; + foreach ($cache_articles as $vv) { + $c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country'); + $c_c = 'gn'; + foreach ($c_country as $vvv) { + if ($vvv != 'China' && $vvv != '') { + $c_c = 'gw'; + } + } + if ($c_c == 'gn') { + $c_gn++; + } else { + $c_gw++; } } - if ($c_c == 'gn') { - $c_gn++; + if ($c_gn - $v['jour_num'] >= 0) { + $c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200; } else { - $c_gw++; + if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) { + $c_price = ($c_gn + $c_gw - $v['jour_num']) * 200; + } else { + $c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50; + } } + $journal_price += $c_price; + + //获取cite提成 + $jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']])); + $jcs = $jcites->data->cites; + $cite_price += count($jcs)*500; } - if ($c_gn - $v['jour_num'] >= 0) { - $c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200; - } else { - if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) { - $c_price = ($c_gn + $c_gw - $v['jour_num']) * 200; - } else { - $c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50; - } - } - $journal_price += $c_price; - - //获取cite提成 - $jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']])); - $jcs = $jcites->data->cites; - $cite_price += count($jcs)*500; } $re['staff_log_id'] = 0; $re['baseprice'] = $baseprice; diff --git a/application/api/controller/Super.php b/application/api/controller/Super.php index ea1b99b..eb7a64d 100644 --- a/application/api/controller/Super.php +++ b/application/api/controller/Super.php @@ -43,12 +43,15 @@ class Super extends Controller{ } public function main() { + $data = $this->request->post(); + $start_time = strtotime($data['start']); + $end_time = strtotime($data['end'].' 23:59:59'); $list = $this->journal_obj->where('state',0)->select(); foreach ($list as $k => $v){ - $list[$k]['LYL'] = $this->getLYL($v['journal_id']); - $list[$k]['CC'] = $this->getCC($v['journal_id']); - $list[$k]['WS'] = $this->getWS($v['journal_id']); - $list[$k]['SJ'] = $this->getSJ($v['journal_id']); + $list[$k]['LYL'] = $this->getLYL($v['journal_id'],$start_time,$end_time); + $list[$k]['CC'] = $this->getCC($v['journal_id'],$start_time,$end_time); + $list[$k]['WS'] = $this->getWS($v['journal_id'],$start_time,$end_time); + $list[$k]['SJ'] = $this->getSJ($v['journal_id'],$start_time,$end_time); } return jsonSuccess($list); } @@ -60,13 +63,48 @@ class Super extends Controller{ } return jsonSuccess($list); } + + /** + * 获取查重文章 + */ + public function getCCArticles(){ + $data = $this->request->post(); +// $data['issn'] = '2522-6371'; +// $data['type'] = "low"; +// $data['start'] = '2021-01-01'; +// $data['end'] = '2021-04-08'; + $journal_info = $this->journal_obj->where('issn',$data['issn'])->find(); + $where['journal_id'] = $journal_info['journal_id']; + $where['ctime'] = [['>', strtotime($data['start'])],['<', strtotime($data['end'].' 23:59:59')]]; + $where['state'] = 5; + if($data['type']=='low'){ + $where['repetition'] = ['<=',20]; + }elseif($data['type']=='low1'){ + $where['repetition'] = [['>',20],['<=',30]]; + }elseif($data['type']=='mid'){ + $where['repetition'] = [['>',30],['<=',50]]; + }else{ + $where['repetition'] = ['>',50]; + } + $list = $this->article_obj->where($where)->select(); +// echo $this->article_obj->getLastSql(); + $re['articles'] = $list; + return jsonSuccess($re); + } /** * 获取录用率 */ - private function getLYL($journalId){ - $res = $this->article_obj->field('state,count(state) as num')->where('journal_id',$journalId)->where('state','in','3,5')->group('state')->select(); + private function getLYL($journalId,$start_time,$end_time){ + $res = $this->article_obj + ->field('state,count(state) as num') + ->where('journal_id',$journalId) + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->where('state','in','3,5') + ->group('state') + ->select(); $js = 0; $jj = 0; foreach ( $res as $v){ @@ -76,24 +114,29 @@ class Super extends Controller{ $js = $v['num']; } } - return $js/($js+$jj); + return $js+$jj==0?0:$js/($js+$jj); } /** * 获取查重异常 */ - private function getCC($journalId){ - $res = $this->article_obj->where('journal_id',$journalId)->where('state',5)->select(); + private function getCC($journalId,$start_time,$end_time){ + $res = $this->article_obj + ->where('journal_id',$journalId) + ->where('ctime','>=',$start_time) + ->where('ctime','<=',$end_time) + ->where('state',5) + ->select(); $low = 0; $low1 = 0; $mid = 0; $high = 0; foreach ($res as $v){ - if($v['repetition']<20){ + if($v['repetition']<=20){ $low++; - }elseif($v['repetition']>=20 && $v['repetition']<30){ + }elseif($v['repetition']>20 && $v['repetition']<=30){ $low1++; - }elseif($v['repetition']>=30 && $v['repetition']<50){ + }elseif($v['repetition']>30 && $v['repetition']<=50){ $mid++; }else{ $high++; @@ -110,8 +153,13 @@ class Super extends Controller{ /** * 获取外审异常 */ - private function getWS($journalId){ - $res = $this->article_obj->where('journal_id',$journalId)->where('state',5)->select(); + private function getWS($journalId,$start_time,$end_time){ + $res = $this->article_obj + ->where('journal_id',$journalId) + ->where('state',5) + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->select(); $np =0; foreach ( $res as $v){ $ca = $this->article_reviewer_obj->where('article_id',$v['article_id'])->count(); @@ -128,17 +176,40 @@ class Super extends Controller{ /** * 获取时间异常 */ - private function getSJ($journalId){ + private function getSJ($journalId,$start_time,$end_time){ //文章提交至接收超过48小时 - $res['t48'] = $this->article_obj->where('journal_id',$journalId)->where('state',0)->count(); + $res['t48'] = $this->article_obj + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->where('journal_id',$journalId) + ->where('state',0) + ->count(); //文章接受时间小于15天 - $res['j15'] = $this->article_obj->where('journal_id',$journalId)->where('state',5)->where('rtime','>',0)->where('(rtime-ctime)','<',3600*24*15)->count(); + $res['j15'] = $this->article_obj + ->where('journal_id',$journalId) + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->where('state',5) + ->where('rtime','>',0) + ->where('(rtime-ctime)','<',3600*24*15) + ->count(); //文章接收时间大于120天 - $res['j120'] = $this->article_obj->where('journal_id',$journalId)->where('state',5)->where('rtime','>',0)->where('(rtime-ctime)','>',3600*24*120)->count(); + $res['j120'] = $this->article_obj + ->where('journal_id',$journalId) + ->where('state',5) + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->where('rtime','>',0) + ->where('(rtime-ctime)','>',3600*24*120) + ->count(); //with editor时间超过三天(预留) //获取全部总数 - $res['al'] = $this->article_obj->where('journal_id',$journalId)->count(); + $res['al'] = $this->article_obj + ->where('journal_id',$journalId) + ->where('ctime','>',$start_time) + ->where('ctime','<',$end_time) + ->count(); return $res; } diff --git a/application/api/controller/User.php b/application/api/controller/User.php index eb08be9..81e4838 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -54,9 +54,14 @@ class User extends Controller { return json(['code'=>0,'userinfo'=>$admin_info]); } } else {//用户登录 - $where['account'] = $data['username']; - $where['password'] = md5($data['password']); - $user_info = $this->user_obj->where($where)->find(); +// $where['account'] = $data['username']; +// $where['password'] = md5($data['password']); +// $user_info = $this->user_obj->where($where)->find(); + + $user_info = $this->user_obj + ->where('account|email',$data['username']) + ->where('password', md5($data['password'])) + ->find(); if ($user_info == null) {//登陆失败 return json(['code' => 1]); } else {//登陆成功 @@ -185,8 +190,9 @@ class User extends Controller { if (!$this->my_checkcaptcha($data['code'], $data['random_num'])) { return json(['code' => 1, 'msg' => '验证码错误']); } - $where['account'] = $data['username']; - $res = $this->user_obj->where($where)->find(); + $res = $this->user_obj + ->where('account|email',$data['username']) + ->find(); if ($res == null) { return json(['code' => 1, 'msg' => '查无此人']); } else {