Feedback.php 2.2 KB

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