Просмотр исходного кода

fix(admin): 修复反馈详情获取和已读状态更新逻辑

- 修复了字段存在检查时的参数格式问题
- 调整了反馈详情查询方法,支持指定已读状态类型
- 移除了管理端详情页面的重复已读状态更新调用
- 优化了反馈仓库中的get方法,支持传入已读类型参数
- 统一了已读状态更新的调用方式,避免重复操作
shichen месяцев назад: 4
Родитель
Сommit
125c1fdcf8

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

@@ -73,17 +73,17 @@ class FeedbackRepository extends BaseRepository
73 73
         return $this->getList(['feedback_id'=>$feedbackIds], $page, $limit);
74 74
     }
75 75
 
76
-    public function get( $id)
76
+    public function get($id, $type = 'user_read')
77 77
     {
78 78
         // 获取反馈信息
79
-        $data = $this->dao->getWhere([$this->dao->getPk() => $id],'*',['getReply']);
79
+        $data = $this->dao->getWhere([$this->dao->getPk() => $id], '*', ['getReply']);
80 80
         $type = app()->make(FeedBackCategoryRepository::class)->getWhere(['feedback_category_id' => $data['type']]);
81 81
         $parent = app()->make(FeedBackCategoryRepository::class)->getWhere(['feedback_category_id' => $type['pid']]);
82 82
         $data['type'] = $type['cate_name'];
83 83
         $data['category'] = $parent['cate_name'];
84 84
 
85 85
         // 更改已读状态
86
-        $this->read($id, 'user_read');
86
+        $this->read($id, $type);
87 87
         return $data;
88 88
     }
89 89
 

+ 2 - 4
app/controller/admin/user/FeedBack.php

@@ -47,9 +47,9 @@ class FeedBack extends BaseController
47 47
      */
48 48
     public function detail($id)
49 49
     {
50
-        if (!$this->repository->fieldExists('feedback_id',$id))
50
+        if (!$this->repository->fieldExists('feedback_id', $id))
51 51
             return app('json')->fail('数据不存在');
52
-        $feedback = $this->repository->get($id)->toArray();
52
+        $feedback = $this->repository->get($id, 'admin_read')->toArray();
53 53
         //[$feedback['category'], $feedback['type']] = explode('/', $feedback['type'], 2);
54 54
         return app('json')->success($feedback);
55 55
     }
@@ -106,8 +106,6 @@ class FeedBack extends BaseController
106 106
             'is_del'=>$data['is_del'],
107 107
             'type'=>Db::name('feedback_category')->where('feedback_category_id',$data['type'])->value('cate_name')
108 108
         ];
109
-        // 修改已读状态
110
-        $this->repository->read($id,'admin_read');
111 109
         return app('json')->success($return_data);
112 110
     }
113 111