From 1395f15d360853de7bc6f72f5bd284906c123946 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Wed, 18 Dec 2019 20:28:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BD=91=E9=A1=B5=E4=B8=8A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=90=E7=BB=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/common.php | 5 ++++- app/chengji/controller/Index.php | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/chengji/common.php b/app/chengji/common.php index 8101e3e9..efe12f6e 100644 --- a/app/chengji/common.php +++ b/app/chengji/common.php @@ -3,13 +3,16 @@ // 获取学科满分 function getmanfen($kaohaoid,$subjectid) { + // 获取考试号 $kh = new app\kaoshi\model\Kaohao; $kaoshiid = $kh->where('id',$kaohaoid)->value('kaoshi'); + // 根据考试号和学科名获取满分 $KSXK = new app\kaoshi\model\KaoshiSubject; - $manfen = $KSXK->where('kaoshiid',$kaoshiid)->where('subjectid','in',$subjectid)->value('manfen'); + $manfen = $KSXK->where('kaoshiid',$kaoshiid)->where('subjectid',$subjectid)->value('manfen'); + $manfen = floatval($manfen); return $manfen; } diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php index 949f3d60..767f7688 100644 --- a/app/chengji/controller/Index.php +++ b/app/chengji/controller/Index.php @@ -78,10 +78,13 @@ class Index extends BaseController 'newdefen'] ,'post'); $list['kaohao_id'] = $id; - // 获取学科信息 + + + // 获取学科id $subject = new \app\teach\model\Subject; $subject_id = $subject->where('lieming',$list['colname'])->value('id'); + // 成绩验证 $manfen = getmanfen($list['kaohao_id'],$subject_id); $mfyz = manfenvalidate($list['newdefen'],$manfen); @@ -90,32 +93,34 @@ class Index extends BaseController return json($mfyz); } + + // 更新成绩 $cj = new Chengji; $cjinfo = Chengji::withTrashed() ->where('kaohao_id',$list['kaohao_id']) ->where('subject_id',$subject_id) ->find(); + // 如果存在成绩则更新,不存在则添加 if($cjinfo){ $cjinfo->restore(); $cjinfo->defen = $list['newdefen']; - $cjinfo->user_id = session('userid'); + $cjinfo->userId = session('userid'); $data = $cjinfo->save(); }else{ $cj->defen = $list['newdefen']; - $cj->kaohao_id = $list['kaohao_id']; - $cj->subject_id = $subject_id; - $cj->user_id = session('userid'); + $cj->kaohaoId = $list['kaohao_id']; + $cj->subjectId = $subject_id; + $cj->userId = session('userid'); $data = $cj->save(); } - // update(['defen'=>$list['newdefen']]); // 判断返回内容 $data ? $data=['msg'=>'录入成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; // 返回更新结果 - return $data; + return json($data); }