User.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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('uid',$v['id'])->value('trx_key');
  49. $list[$k]['bsc_key']=UserUsdtAddress::where('uid',$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. public function usdt_address()
  78. {
  79. // 获取请求参数
  80. $uid = $this->request->get('uid/d', 0);
  81. if (!$uid) {
  82. $this->error(__('参数错误'));
  83. }
  84. // 查询用户是否存在
  85. $user = $this->model->get($uid);
  86. if (!$user) {
  87. $this->error(__('用户不存在'));
  88. }
  89. // 查询钱包地址
  90. $usdtAddress = UserUsdtAddress::where('uid', $uid)->find();
  91. if (!$usdtAddress) {
  92. $this->error(__('钱包地址未设置'));
  93. }
  94. // 返回标准API格式数据
  95. $this->success('', null, [
  96. 'trx_key' => $usdtAddress->trx_key,
  97. 'bsc_key' => $usdtAddress->bsc_key
  98. ]);
  99. }
  100. }