From 84cc4478b3de21f8ddbbd41ac05632e1194f6760 Mon Sep 17 00:00:00 2001 From: chengxl Date: Fri, 18 Apr 2025 11:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AE=A1=E6=A0=B8=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E7=BB=9F=E8=AE=A1=E5=AE=A1=E7=A8=BF=E4=BA=BA=E7=9A=84?= =?UTF-8?q?=E5=AE=A1=E7=A8=BF=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Article.php | 83 +++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 7a5a23a..f726739 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -298,7 +298,6 @@ class Article extends Base //接受参数 $data = $this->request->post(); - if (isset($data['sn']) && trim($data['sn']) != "") { $where["t_article.accept_sn"] = trim($data['sn']); $sn_info = $this->article_obj->where('accept_sn', trim($data['sn']))->find(); @@ -1196,6 +1195,7 @@ class Article extends Base */ public function editArticleEditor() { + //接受参数,查询信息 $data = $this->request->post(); $where_editor['account'] = $data['editname']; @@ -1608,6 +1608,9 @@ class Article extends Base //增加usermsg add_usermsg($article_info['user_id'], 'Your manuscript has new process: ' . $article_info['title'], '/articleDetail?id=' . $article_info['article_id']); + //重新计算审稿人的审稿质量 chengxiaoling start 0416 + $this->reviewQuality($article_info['article_id']); + //重新计算审稿人的审稿质量 chengxiaoling end 0416 return json(['code' => 0]); } @@ -4312,4 +4315,82 @@ class Article extends Base $total = mb_strlen($filteredStr, 'UTF-8'); return $total >= $num; } + /** + * 审稿人审稿质量 + * @param $article_id 文章ID + * @return void + */ + private function reviewQuality($article_id = ''){ + $article_id = empty($article_id) ? $this->request->post('article_id') : $article_id; + if(empty($article_id)){ + return json(['status' => 2,'msg' => '请选择要查询的文章']); + } + //查询文章状态 + $aWhere = [ + 'article_id'=>$article_id, + 'state'=>['in',[3,5]] + ]; + $aArticle = Db::name('article')->field('article_id,state')->where($aWhere)->find(); + + if(empty($aArticle)){ + return json(['status' => 1,'msg' => '暂无数据']); + } + //获取该文章审核人的信息 + $aWhere = [ + 'article_id'=>$aArticle['article_id'], + 'state'=>['in',[2,3]] + ]; + $aReviewer = Db::name('article_reviewer')->where($aWhere)->column('reviewer_id,state'); + if(empty($aReviewer)){ + return json(['status' => 1,'msg' => '未查询到审核人信息']); + } + + //查询审核人信息 + $aUserId = array_keys($aReviewer); + $aUser = Db::name('user')->field('user_id,rs_num,rigxht_times,error_times')->whereIn('user_id',$aUserId)->select(); + if(empty($aUser)){ + return json(['status' => 1,'msg' => '未查询到审核人信息']); + } + //处理数据并组装数据 + $aCase = ['right_times' => '', 'right_rate' => '','error_times' => '', 'error_rate' => '']; + $aToState = [2 => 3,3 => 5];//文章3拒稿5录用 审稿人2拒稿3通过 + foreach ($aUser as $key => $value) { + $iState = empty($aReviewer[$value['user_id']]) ? 0 : $aReviewer[$value['user_id']]; + if(empty($iState)){ + continue; + } + if(empty($aToState[$iState])){ + continue; + } + if($aArticle['state'] == $aToState[$iState]){ + $iTimes = $value['right_times']+1; + $iRightNum = empty($value['rs_num']) ? 0 : round($iTimes/$value['rs_num'],2); + $aCase['right_times'] .= "WHEN {$value['user_id']} THEN "; + $aCase['right_times'] .= "'{$iTimes}' "; + $aCase['right_rate'] .= "WHEN {$value['user_id']} THEN "; + $aCase['right_rate'] .= "'{$iRightNum}' "; + } + if($aArticle['state'] != $aToState[$iState]){ + $iErrorTimes = $value['error_times']+1; + $iErrorNum = empty($value['rs_num']) ? 0 : round($iErrorTimes/$value['rs_num'],2); + $aCase['error_times'] .= "WHEN {$value['user_id']} THEN "; + $aCase['error_times'] .= "'{$iErrorTimes}' "; + $aCase['error_rate'] .= "WHEN {$value['user_id']} THEN "; + $aCase['error_rate'] .= "'{$iErrorNum}' "; + } + $aId[] = $value['user_id']; + } + //更新数据库 + foreach ($aCase as $key => $value) { + if(empty($value)){ + continue; + } + $aUpdate[$key] = Db::raw('CASE user_id '.$value.'END'); + } + if(empty($aUpdate) || empty($aId)){ + return json(['status' => 1,'msg' => '未查询到审核人信息']); + } + Db::name('user')->where('user_id', 'IN', $aId)->limit(count($aId))->update($aUpdate); + return json(['status' => 1,'msg' => '执行成功']); + } }