xielin il y a 5 ans
Parent
commit
69bed9e2da

+ 7 - 2
app/Transformers/Circle/DetailTransformer.php

@@ -24,7 +24,12 @@ class DetailTransformer extends TransformerAbstract
 
     public function transform(InterestCircle $interestCircle)
     {
-        $answer = $interestCircle['limit_condition'] - intval(Redis::get('circle_error_count_' . $this->uid));
+        if ($interestCircle['limit_condition']) {
+            $answer = $interestCircle['limit_condition'] - intval(Redis::get('circle_error_count_' . $this->uid));
+        } else {
+            $answer = -1;
+        }
+
         $row = [
             'id' => $interestCircle['id'],
             'name' => $interestCircle['name'],
@@ -32,7 +37,7 @@ class DetailTransformer extends TransformerAbstract
             'image' => $interestCircle['image'],
             'join_limit' => $interestCircle['join_limit'],
             'is_join' => $this->isJoin($this->uid, $interestCircle['id']),
-            'answer_count' => $answer > 0 ? $answer : 0,
+            'answer_count' => $answer,
             'is_black' => $this->isBlack($this->uid, $interestCircle['id'])
         ];
         $funs = $this->getFunction($interestCircle);

+ 5 - 1
app/Transformers/Circle/QuestionTransformer.php

@@ -24,7 +24,11 @@ class QuestionTransformer extends TransformerAbstract
 
     public function transform(InterestCircle $interestCircle)
     {
-        $answer = $interestCircle['limit_condition'] - intval(Redis::get('circle_error_count_' . $this->uid));
+        if ($interestCircle['limit_condition']) {
+            $answer = $interestCircle['limit_condition'] - intval(Redis::get('circle_error_count_' . $this->uid));
+        } else {
+            $answer = -1;
+        }
         return [
             'id' => $interestCircle['id'],
             'join_question' => $this->formatQuestion($interestCircle),