Blacklist.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\kefu;
  3. use app\common\controller\Backend;
  4. /**
  5. * 客服黑名单管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Blacklist extends Backend
  10. {
  11. /**
  12. * KeFuBlacklist模型对象
  13. * @var \app\admin\model\KeFuBlacklist
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\KeFuBlacklist;
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //当前是否为关联查询
  27. $this->relationSearch = true;
  28. //设置过滤方法
  29. $this->request->filter(['strip_tags']);
  30. if ($this->request->isAjax()) {
  31. //如果发送的来源是Selectpage,则转发到Selectpage
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  36. $total = $this->model->with(['admin', 'kefuuser'])->where($where)->order($sort, $order)->count();
  37. $list = $this->model->with(['admin', 'kefuuser'])
  38. ->where($where)
  39. ->order($sort, $order)
  40. ->limit($offset, $limit)
  41. ->select();
  42. foreach ($list as $row) {
  43. $row->getRelation('admin')->visible(['nickname']);
  44. if ($row->kefuuser->user_id) {
  45. $row->fu_user_nickname = \think\Db::name('user')
  46. ->where('id', $row->kefuuser->user_id)
  47. ->value('nickname');
  48. }
  49. }
  50. $list = collection($list)->toArray();
  51. $result = ["total" => $total, "rows" => $list];
  52. return json($result);
  53. }
  54. return $this->view->fetch();
  55. }
  56. }