FeedBack.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. *
  4. */
  5. namespace app\controller\admin\user;
  6. use crmeb\basic\BaseController;
  7. use think\App;
  8. use app\common\repositories\user\FeedbackRepository as repository;
  9. use think\facade\Db;
  10. class FeedBack extends BaseController
  11. {
  12. /**
  13. * @var UserRepository
  14. */
  15. protected $repository;
  16. /**
  17. * User constructor.
  18. * @param App $app
  19. * @param $repository
  20. */
  21. public function __construct(App $app, repository $repository)
  22. {
  23. parent::__construct($app);
  24. $this->repository = $repository;
  25. }
  26. /**
  27. * @return mixed
  28. * @author Qinii
  29. */
  30. public function lst()
  31. {
  32. $where = $this->request->params(['keyword', 'type', 'status','realname',['is_del',0]]);
  33. [$page, $limit] = $this->getPage();
  34. return app('json')->success($this->repository->getList($where, $page, $limit));
  35. }
  36. /**
  37. * @param $id
  38. * @return mixed
  39. * @author Qinii
  40. */
  41. public function detail($id)
  42. {
  43. if (!$this->repository->fieldExists('feedback_id', $id))
  44. return app('json')->fail('数据不存在');
  45. $feedback = $this->repository->get($id, 'admin_read')->toArray();
  46. //[$feedback['category'], $feedback['type']] = explode('/', $feedback['type'], 2);
  47. return app('json')->success($feedback);
  48. }
  49. /**
  50. * @param $id
  51. * @return mixed
  52. * @throws \think\db\exception\DbException
  53. * @author Qinii
  54. */
  55. public function reply($id)
  56. {
  57. if (!$this->repository->fieldExists('feedback_id', $id))
  58. return app('json')->fail('数据不存在');
  59. $data = $this->request->params(['reply', 'remake', 'status']);
  60. $data['reply_time'] = date("Y-m-d H:i:s");
  61. $this->repository->update($id, $data);
  62. $this->repository->reply($id, 0,$data['reply']);
  63. return app('json')->success('回复成功');
  64. }
  65. /**
  66. * @param $id
  67. * @return mixed
  68. * @author Qinii
  69. */
  70. public function delete($id)
  71. {
  72. if (!$this->repository->fieldExists('feedback_id',$id))
  73. return app('json')->fail('数据不存在');
  74. $this->repository->update($id,['is_del' => 1]);
  75. return app('json')->success('删除成功');
  76. }
  77. /**
  78. * 意见反馈详情,展示意见反馈内容与图片,反馈人员以及处理结果
  79. */
  80. public function feedback_detail($id)
  81. {
  82. $data=Db::name('feedback')->where('feedback_id',$id)->find();
  83. if(empty($data)){
  84. return app('json')->fail('没有此条反馈');
  85. }
  86. $return_data=[
  87. 'user'=>Db::name('user')->where('uid',$data['uid'])->field('nickname,avatar,uid')->find(),
  88. 'content'=>$data['content'],
  89. 'images'=>$data['images'],
  90. 'realname'=>$data['realname'],
  91. 'contact'=>$data['contact'],
  92. 'create_time'=>$data['create_time'],
  93. 'status'=>$data['status'],
  94. 'reply'=>$data['reply'],
  95. 'remake'=>$data['remake'],
  96. 'reply_time'=>$data['reply_time'],
  97. 'is_del'=>$data['is_del'],
  98. 'type'=>Db::name('feedback_category')->where('feedback_category_id',$data['type'])->value('cate_name')
  99. ];
  100. return app('json')->success($return_data);
  101. }
  102. }