Ver código fonte

feat(feedback): 实现用户反馈回复列表功能

- 在Feedback控制器中添加getReplyList方法获取未读回复列表
- 修改返回数据结构将reply改为replyList并调用新的查询方法
- 在FeedbackDao中完善搜索条件的空格格式化处理
- 添加feedback_id查询条件支持按反馈ID筛选
- 在FeedbackRepository中实现getReplyList业务逻辑
- 查询用户未读反馈回复并关联反馈列表数据
shichen 4 meses atrás
pai
commit
cf60543694

+ 6 - 4
app/common/dao/user/FeedbackDao.php

@@ -45,15 +45,17 @@ class FeedbackDao extends BaseDao
45 45
         return Feedback::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
46 46
             $query->where('uid', $where['uid']);
47 47
         })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
48
-            $query->where('content','like', '%'.$where['keyword'].'%')->whereOr('reply','like', '%'.$where['keyword'].'%')->whereOr('remake','like', '%'.$where['keyword'].'%');
48
+            $query->where('content', 'like', '%' . $where['keyword'] . '%')->whereOr('reply', 'like', '%' . $where['keyword'] . '%')->whereOr('remake', 'like', '%' . $where['keyword'] . '%');
49 49
         })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
50
-            $query->where('type',$where['type']);
50
+            $query->where('type', $where['type']);
51 51
         })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
52 52
             $query->where('status', $where['status']);
53 53
         })->when(isset($where['realname']) && $where['realname'] !== '', function ($query) use ($where) {
54
-            $query->where('realname','like', '%'.$where['realname'].'%');
54
+            $query->where('realname', 'like', '%' . $where['realname'] . '%');
55 55
         })->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
56
-            $query->where('is_del',$where['is_del']);
56
+            $query->where('is_del', $where['is_del']);
57
+        })->when(isset($where['feedback_id']) && $where['feedback_id'] !== '', function ($query) use ($where) {
58
+            $query->where('feedback_id', 'in', $where['feedback_id']);
57 59
         });
58 60
     }
59 61
 

+ 12 - 0
app/common/repositories/user/FeedbackRepository.php

@@ -47,6 +47,18 @@ class FeedbackRepository extends BaseRepository
47 47
         return compact('count', 'list');
48 48
     }
49 49
 
50
+    public function getReplyList($userId, $page, $limit)
51
+    {
52
+        $feedbackIds = FeedbackReply::where(['uid' => $userId, 'user_read' => 0])
53
+            ->limit($page, $limit)
54
+            ->order('reply_id desc')
55
+            ->field('feedback_id')
56
+            ->select()
57
+            ->toArray();
58
+        $feedbackIds = array_column($feedbackIds,'feedback_id');
59
+        return $this->getList(['feedback_id'=>$feedbackIds], $page, $limit);
60
+    }
61
+
50 62
     public function get( $id)
51 63
     {
52 64
         // 获取反馈信息

+ 2 - 2
app/controller/api/user/Feedback.php

@@ -54,8 +54,8 @@ class Feedback
54 54
     {
55 55
         $data = request()->params(['page', 'limit']);
56 56
         $list = $this->repository->getList(['uid' => request()->uid(), 'is_del' => 0], $data['page'] ?? 1, $data['limit'] ?? 20);
57
-        $reply = true;
58
-        return app('json')->success(['list' => $list, 'reply' => $reply]);
57
+        $reply = $this->repository->getReplyList(request()->uid(), $data['page'] ?? 1, $data['limit'] ?? 20);
58
+        return app('json')->success(['list' => $list, 'replyList' => $reply]);
59 59
     }
60 60
 
61 61
     public function detail($id)