Comment.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\admin\controller\service\order;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 评论管理
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Comment extends Backend
  11. {
  12. /**
  13. * Comment模型对象
  14. * @var \app\admin\model\service\order\Comment
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\service\order\Comment;
  21. $this->view->assign("stateList", $this->model->getStateList());
  22. }
  23. public function index()
  24. {
  25. //设置过滤方法
  26. $this->request->filter(['strip_tags', 'trim']);
  27. if (false === $this->request->isAjax()) {
  28. return $this->view->fetch();
  29. }
  30. //如果发送的来源是 Selectpage,则转发到 Selectpage
  31. if ($this->request->request('keyField')) {
  32. return $this->selectpage();
  33. }
  34. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  35. $list = $this->model
  36. ->where($where)
  37. ->order($sort, $order)
  38. ->paginate($limit);
  39. foreach ($list as &$val)
  40. {
  41. $val->user = db('user')->where('id',$val->user_id)->field('avatar,nickname,mobile')->find();
  42. $val->skill = $val->skill_id?db('service_skill')->field('name,mobile,image')->where('id',$val->skill_id)->find():'';
  43. $val->shop = $val->shop_id?db('service_shop')->where('id',$val->shop_id)->field('name,abbr,logo_image,leader_name,leader_mobile')->find():'';
  44. $val->goodsname = db('service_order_detail')->where('order_id',$val->order_id)->value('name');
  45. }
  46. $result = ['total' => $list->total(), 'rows' => $list->items()];
  47. return json($result);
  48. }
  49. }