瀏覽代碼

feat(feedback): 添加反馈回复功能

- 在路由中添加 /feedback/reply 接口
- 创建 FeedbackReply 模型用于存储反馈回复
- 创建 FeedbackReplyDao 数据访问对象
- 修改 Feedback 控制器移除父类继承并更新请求获取方式
- 添加 reply 方法处理用户反馈回复逻辑
- 在 FeedbackRepository 中实现回复功能的数据操作
shichen 4 月之前
父節點
當前提交
fc37e6ece6

+ 35 - 0
app/common/dao/user/FeedbackReplyDao.php

@@ -0,0 +1,35 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020/5/28
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\dao\user;
12
+
13
+
14
+use app\common\dao\BaseDao;
15
+use app\common\model\user\FeedbackReply;
16
+
17
+/**
18
+ * Class FeedbackDao
19
+ * @package app\common\dao\user
20
+ * @author xaboy
21
+ * @day 2020/5/28
22
+ */
23
+class FeedbackReplyDao extends BaseDao
24
+{
25
+
26
+    /**
27
+     * @return string
28
+     * @author xaboy
29
+     * @day 2020/5/28
30
+     */
31
+    protected function getModel(): string
32
+    {
33
+        return FeedbackReply::class;
34
+    }
35
+}

+ 26 - 0
app/common/model/user/FeedbackReply.php

@@ -0,0 +1,26 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020/5/28
7
+ *
8
+ * 
9
+ */
10
+namespace app\common\model\user;
11
+
12
+use app\common\model\BaseModel;
13
+
14
+class FeedbackReply extends BaseModel
15
+{
16
+
17
+    public static function tablePk(): ?string
18
+    {
19
+        return 'reply_id';
20
+    }
21
+
22
+    public static function tableName(): string
23
+    {
24
+        return 'feedback_reply';
25
+    }
26
+}

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

@@ -12,6 +12,8 @@ namespace app\common\repositories\user;
12 12
 
13 13
 
14 14
 use app\common\dao\user\FeedbackDao;
15
+use app\common\dao\user\FeedbackReplyDao;
16
+use app\common\model\user\FeedbackReply;
15 17
 use app\common\repositories\BaseRepository;
16 18
 
17 19
 /**
@@ -55,4 +57,23 @@ class FeedbackRepository extends BaseRepository
55 57
         return $data;
56 58
     }
57 59
 
60
+    /**
61
+     * @param $feedbackId
62
+     * @param $userId
63
+     * @param $content
64
+     * @return int|string
65
+     * @author 史晨
66
+     * @date 2026/3/17 14:15
67
+     * 回复反馈
68
+     */
69
+    public function reply($feedbackId, $userId, $content)
70
+    {
71
+        $insert = [
72
+            'feedback_id' => $feedbackId,
73
+            'uid' => $userId,
74
+            'content' => $content,
75
+        ];
76
+        return FeedbackReply::insert($insert);
77
+    }
78
+
58 79
 }

+ 30 - 9
app/controller/api/user/Feedback.php

@@ -5,7 +5,7 @@
5 5
  * @author xaboy<xaboy2005@qq.com>
6 6
  * @day 2020/5/28
7 7
  *
8
- * 
8
+ *
9 9
  */
10 10
 
11 11
 namespace app\controller\api\user;
@@ -15,13 +15,13 @@ use app\common\repositories\user\FeedbackRepository;
15 15
 use app\validate\api\FeedbackValidate;
16 16
 use think\App;
17 17
 
18
-class Feedback extends BaseController
18
+class Feedback
19 19
 {
20 20
     protected $repository;
21 21
 
22 22
     public function __construct(App $app, FeedbackRepository $repository)
23 23
     {
24
-        parent::__construct($app);
24
+        // parent::__construct($app);
25 25
         $this->repository = $repository;
26 26
     }
27 27
 
@@ -34,13 +34,13 @@ class Feedback extends BaseController
34 34
      */
35 35
     public function feedback(FeedbackValidate $validate)
36 36
     {
37
-        $data = $this->request->params(['type', 'content', 'images', 'realname', 'contact']);
38
-        if (!is_array($data["images"])){
39
-            $data["images"]=explode(",",  $data["images"]);
37
+        $data = request()->params(['type', 'content', 'images', 'realname', 'contact']);
38
+        if (!is_array($data["images"])) {
39
+            $data["images"] = explode(",", $data["images"]);
40 40
 
41 41
         }
42 42
         $validate->check($data);
43
-        $data['uid'] = $this->request->uid();
43
+        $data['uid'] = request()->uid();
44 44
         $this->repository->create($data);
45 45
         return app('json')->success('反馈成功');
46 46
     }
@@ -53,14 +53,35 @@ class Feedback extends BaseController
53 53
     public function feedbackList()
54 54
     {
55 55
         [$page, $limit] = $this->getPage();
56
-        return app('json')->success($this->repository->getList(['uid' => $this->request->uid(),'is_del' => 0], $page, $limit));
56
+        return app('json')->success($this->repository->getList(['uid' => request()->uid(), 'is_del' => 0], $page, $limit));
57 57
     }
58 58
 
59 59
     public function detail($id)
60 60
     {
61
-        if (!$this->repository->uidExists($id, $this->request->uid()))
61
+        if (!$this->repository->uidExists($id, request()->uid()))
62 62
             return app('json')->fail('数据不存在');
63 63
         $feedback = $this->repository->get($id);
64 64
         return app('json')->success($feedback);
65 65
     }
66
+
67
+    /**
68
+     * @return void
69
+     * @author 史晨
70
+     * @date 2026/3/17 14:07
71
+     * 用户回复反馈
72
+     */
73
+    public function reply()
74
+    {
75
+        $data = request()->params(['feedback_id', 'content']);
76
+        if (empty($data['feedback_id']) || empty($data['content'])) {
77
+            return app('json')->fail('参数错误');
78
+        }
79
+
80
+        $res = $this->repository->reply($data['feedback_id'], request()->uid(), $data['content']);
81
+
82
+        if (!$res) {
83
+            return app('json')->fail('回复失败');
84
+        }
85
+        return app('json')->success('回复成功');
86
+    }
66 87
 }

+ 2 - 0
route/api.php

@@ -201,6 +201,8 @@ Route::group('api/', function () {
201 201
             Route::post('/feedback', 'Feedback/feedback');
202 202
             Route::get('/feedback/list', 'Feedback/feedbackList');
203 203
             Route::get('/feedback/detail/:id', 'Feedback/detail');
204
+            // 反馈回复
205
+            Route::post('/feedback/reply', 'Feedback/reply');
204 206
             //充值
205 207
             Route::post('/recharge', 'UserRecharge/recharge');
206 208
             Route::post('/recharge/brokerage', 'UserRecharge/brokerage');