Преглед на файлове

答对一题得N票,得N分,有个基数

lizhen_gitee преди 2 дни
родител
ревизия
0f23d99efa
променени са 1 файла, в които са добавени 10 реда и са изтрити 6 реда
  1. 10 6
      app/Controller/Api/v1/QuestionController.php

+ 10 - 6
app/Controller/Api/v1/QuestionController.php

@@ -48,16 +48,16 @@ class QuestionController extends AbstractController
         $jigou_id = $params['jigou_id'];
         $jigou_info = Db::table('vote_jigou')->where('id',$jigou_id)->first();
         if(!$jigou_info){
-            return AppResult::error('不存在的工会');
+            return AppResult::error('不存在的单位');
         }
 
         $times = site('bind_jigou_times');
         if($user['bind_jigou_times'] >= $times){
-            return AppResult::error('最多修改绑定工会'.$times.'次');
+            return AppResult::error('最多修改绑定单位'.$times.'次');
         }
 
         if($user['bind_jigou_id'] == $jigou_id){
-            return AppResult::error('绑定工会没有改变');
+            return AppResult::error('绑定单位没有改变');
         }
 
         $data = [
@@ -103,7 +103,7 @@ class QuestionController extends AbstractController
 
         //上次绑定选手的时间不是今天
         if(empty($user['bind_jigou_id'])){
-            return AppResult::response_fast(2,'先绑定工会再答题');//给不同的code,0报错,2跳到答题
+            return AppResult::response_fast(2,'先绑定单位再答题');//给不同的code,0报错,2跳到答题
         }
 
         //检查今日答题次数
@@ -141,6 +141,7 @@ class QuestionController extends AbstractController
                 'user_id'     => $user['id'],
                 'question_id' => $question['id'],
                 'is_right'    => $is_right ? 1 : 0,
+                'score'       => $is_right ? site('question_right_getscore') : 0,
                 'jigou_id'   => $user['bind_jigou_id'],
                 'createtime'  => time(),
                 'createdate'  => strtotime(date('Y-m-d')),
@@ -158,13 +159,16 @@ class QuestionController extends AbstractController
         }
 
         //答题日志
-        $this->service->questionPush(['log_data' => $log_data, 'is_right_number' => $is_right_number, 'bind_jigou_id' => $user['bind_jigou_id']], 0);
+        $right_score = intval(bcmul($is_right_number,site('question_right_getscore'),0));//乘以基数,也就是答题获得的分数
+        $this->service->questionPush(['log_data' => $log_data, 'is_right_number' => $right_score, 'bind_jigou_id' => $user['bind_jigou_id']], 0);
         //给选手加分
 
 
         //返回正确了几道题,剩余答题次数
+        $right_vote    = intval(bcmul($is_right_number,site('question_right_getvotenum'),0));//乘以基数,也就是答题获得的票数
+        $question_vote = intval(bcmul($exam_times_user_eday,site('question_right_getvotenum'),0));//乘以基数,也就是答题获得的票数
         $result = [
-            'remark' => '答题完成,获得'.$is_right_number.'次投票次数,答题最多可获得'.$exam_times_user_eday.'次投票机会',
+            'remark' => '答对'.$is_right_number.'题,获得'.$right_vote.'次投票次数,答题最多可获得'.$question_vote.'次投票机会',
             'submit_number'=> count($user_questions),
             'right_number' => $is_right_number,
             'remain'       => $exam_times_user_eday - $count,