User.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. use app\common\model\UserUsdtAddress;
  5. /**
  6. * 会员管理
  7. *
  8. * @icon fa fa-user
  9. */
  10. class User extends Backend
  11. {
  12. protected $relationSearch = true;
  13. /**
  14. * @var \app\admin\model\User
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = model('User');
  21. }
  22. /**
  23. * 查看
  24. */
  25. public function index()
  26. {
  27. //设置过滤方法
  28. $this->request->filter(['strip_tags']);
  29. if ($this->request->isAjax()) {
  30. //如果发送的来源是Selectpage,则转发到Selectpage
  31. if ($this->request->request('keyField')) {
  32. return $this->selectpage();
  33. }
  34. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  35. $total = $this->model
  36. ->with('group')
  37. ->where($where)
  38. ->order($sort, $order)
  39. ->count();
  40. $list = $this->model
  41. ->with('group')
  42. ->where($where)
  43. ->order($sort, $order)
  44. ->limit($offset, $limit)
  45. ->select();
  46. foreach ($list as $k => $v) {
  47. $v->hidden(['password', 'salt']);
  48. $list[$k]['trx_key']=UserUsdtAddress::where('user_id',$v['id'])->value('trx_key');
  49. $list[$k]['bsc_key']=UserUsdtAddress::where('user_id',$v['id'])->value('bsc_key');
  50. }
  51. $result = array("total" => $total, "rows" => $list);
  52. return json($result);
  53. }
  54. return $this->view->fetch();
  55. }
  56. /**
  57. * 编辑
  58. */
  59. public function edit($ids = NULL)
  60. {
  61. $row = $this->model->get($ids);
  62. if (!$row)
  63. $this->error(__('No Results were found'));
  64. $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
  65. return parent::edit($ids);
  66. }
  67. /**
  68. * 选择用户
  69. */
  70. public function selectuser()
  71. {
  72. if ($this->request->isAjax()) {
  73. return $this->index();
  74. }
  75. return $this->view->fetch();
  76. }
  77. }