WebFeedback.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * 官网反馈管理
  4. * Created by PhpStorm.
  5. * User: Administrator
  6. * Date: 2020/3/10
  7. * Time: 15:22
  8. */
  9. namespace app\admin\controller;
  10. class WebFeedback extends Admin{
  11. /**
  12. * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
  13. */
  14. protected function _initialize()
  15. {
  16. parent::_initialize();
  17. $this->feedbackModel = model('WebFeedback');
  18. }
  19. /**
  20. * 查询条件
  21. */
  22. public function getCondition() {
  23. $condition = [];
  24. $order_num = input('order_num','','trim');
  25. $username = input('username','','trim');
  26. $start = $this->request->param('start_time');
  27. $end = $this->request->param('end_time');
  28. $type = input('type',0,'intval');
  29. $from = input('from',0,'intval');
  30. if (!empty($order_num)){
  31. $condition['a.order_num'] = $order_num;
  32. }
  33. if (!empty($username)){
  34. $condition['b.username'] = $username;
  35. }
  36. if (!empty($type)){
  37. $condition['a.type'] = $type;
  38. }
  39. if (!empty($from)){
  40. $condition['a.from'] = $from;
  41. }
  42. //开始时间和结束时间不为空时
  43. if ($start != '' && $end != '') {
  44. $condition['a.create_time'] = [
  45. ['>=', strtotime($start)],
  46. ['<=', strtotime($end . ' 23:59:59')],
  47. ];
  48. } //开始时间不为空时
  49. elseif ($start != '') {
  50. $condition['a.create_time'] = ['>=', strtotime($start)];
  51. } //结束时间不为空时
  52. elseif ($end != '') {
  53. $condition['a.create_time'] = ['<=', strtotime($end . ' 23:59:59')];
  54. } else {}
  55. return $condition;
  56. }
  57. /**
  58. * 列表
  59. */
  60. public function index(){
  61. $condition = $this->getCondition();
  62. $list = $this->feedbackModel->alias('a')
  63. ->join('cy_members b','a.user_id = b.id','left')
  64. ->field('a.*,b.username')
  65. ->where($condition)
  66. ->order("a.create_time desc, a.id DESC")
  67. ->paginate(10,false, ['query' => input('get.')]);
  68. $this->assign('list',$list);
  69. $this->assign("page", $list->render());
  70. $this->assign("total", $list->total()); //总记录数
  71. return $this->fetch();
  72. }
  73. /**
  74. * 获取反馈内容
  75. */
  76. public function ajaxGetFeedbackContent(){
  77. $id = $this->request->param('id', 0, 'intval');
  78. if (!$id) $this->error('参数错误!');
  79. $info = $this->feedbackModel->field('content,order_num')->where('id',$id)->find();
  80. $this->success('','',$info);
  81. }
  82. /**
  83. * 查看详情
  84. */
  85. public function details(){
  86. $id = $this->request->param('id', 0, 'intval');
  87. if (!$id) $this->error('参数错误!');
  88. $info = $this->feedbackModel->alias('a')
  89. ->join('cy_members b','a.user_id = b.id','left')
  90. ->field('a.*,b.username')
  91. ->where('a.id',$id)->find();
  92. if (!empty($info['img_url'])){
  93. $info['img_url'] = explode(',',$info['img_url']);
  94. }
  95. $this->assign('info',$info);
  96. return $this->fetch();
  97. }
  98. }