Feedback.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use think\facade\Db;
  5. //投诉反馈控制器
  6. class Feedback extends BaseController
  7. {
  8. protected $noNeedLogin = [];
  9. // 获取我的投诉与反馈
  10. public function getMyFeedback()
  11. {
  12. $user_id = $this->getUser()->user_id;
  13. if(!is_numeric($user_id)){
  14. $this->fail(500, '无法获取用户信息');
  15. }
  16. $data = Db::table('tb_feedback')->where('user_id')->select();
  17. $this->success('success', $data);
  18. }
  19. // 发起投诉与反馈
  20. public function submitFeedback()
  21. {
  22. $content = $this->request->post('content'); // 投诉建议正文
  23. $user_id = $this->getUser()->user_id;
  24. if(!is_numeric($user_id)||!$content){
  25. $this->fail(500, '参数校验错误!');
  26. }
  27. Db::table('tb_feedback')
  28. ->insert([
  29. 'user_id' => $user_id,
  30. 'content' => $content,
  31. 'create_at' => time()
  32. ]);
  33. $this->success('success', null);
  34. }
  35. // 获取我反馈的Bug
  36. public function getMyReportBug()
  37. {
  38. $user_id = $this->getUser()->user_id;
  39. if(!is_numeric($user_id)){
  40. $this->fail(500, '无法获取用户信息');
  41. }
  42. $data = Db::table('tb_user_bug')->where('user_id')->select();
  43. $this->success('success', $data);
  44. }
  45. // 发起Bug反馈
  46. public function reportBug()
  47. {
  48. $type = $this->request->post('type'); // 反馈类型 1单机游戏 2收费辅助
  49. $game_id = $this->request->post('game_id'); // 对应游戏ID
  50. $content = $this->request->post('content'); // Bug反馈正文(富文本)
  51. $content = html_entity_decode($content);
  52. $user_id = $this->getUser()->user_id;
  53. if(!is_numeric($type)||!is_numeric($game_id)||!is_numeric($user_id)||!$content){
  54. $this->fail(500, '参数校验错误!');
  55. }
  56. Db::table('tb_user_bug')
  57. ->insert([
  58. 'user_id' => $user_id,
  59. 'type' => $type,
  60. 'content' => $content,
  61. 'create_at' => time()
  62. ]);
  63. $this->success('success', null);
  64. }
  65. }