瀏覽代碼

fix(feedback): 修复反馈回复状态判断逻辑

- 修改查询变量名从 userReply 到 isReply
- 添加用户回复存在性检查条件 where(['user_id', '>', 0])
- 重构回复状态判断逻辑,先检查用户是否已回复
- 保留管理员读取状态的原有判断逻辑
- 优化代码结构提高可读性
shichen 4 月之前
父節點
當前提交
e76785a4b8
共有 1 個文件被更改,包括 11 次插入3 次删除
  1. 11 3
      app/common/repositories/user/FeedbackRepository.php

+ 11 - 3
app/common/repositories/user/FeedbackRepository.php

@@ -48,11 +48,19 @@ class FeedbackRepository extends BaseRepository
48 48
         })->select();
49 49
 
50 50
         foreach ($list as &$item) {
51
-            $userReply = Db::name('feedback_reply')
51
+            $isReply = Db::name('feedback_reply')
52 52
                 ->where(['feedback_id' => $item['feedback_id']])
53
-                ->where(['admin_read' => 0])
53
+                ->where(['user_id', '>', 0])
54 54
                 ->find();
55
-            $item['userReply'] = $userReply ? 1 : 0;
55
+            if (!$isReply) {
56
+                $item['userReply'] = 0;
57
+            }else{
58
+                $userReply = Db::name('feedback_reply')
59
+                    ->where(['feedback_id' => $item['feedback_id']])
60
+                    ->where(['admin_read' => 0])
61
+                    ->find();
62
+                $item['userReply'] = $userReply ? 1 : 0;
63
+            }
56 64
         }
57 65
 
58 66
         return compact('count', 'list');