Ghuser.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 会员管理
  7. *
  8. * @icon fa fa-user
  9. */
  10. class Ghuser extends Backend
  11. {
  12. /**
  13. * Ghuser模型对象
  14. * @var \app\admin\model\Ghuser
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Ghuser;
  21. $this->view->assign("realStatusList", $this->model->getRealStatusList());
  22. $this->view->assign("genderList", $this->model->getGenderList());
  23. $this->view->assign("idcardStatusList", $this->model->getIdcardStatusList());
  24. $this->view->assign("statusList", $this->model->getStatusList());
  25. $this->view->assign("openMatchVideoList", $this->model->getOpenMatchVideoList());
  26. $this->view->assign("openMatchAudioList", $this->model->getOpenMatchAudioList());
  27. $this->view->assign("openMatchTypingList", $this->model->getOpenMatchTypingList());
  28. $this->view->assign("freeVideoList", $this->model->getFreeVideoList());
  29. $this->view->assign("freeAudioList", $this->model->getFreeAudioList());
  30. $this->view->assign("freeTypingList", $this->model->getFreeTypingList());
  31. $this->view->assign("hideIsFinishinfoList", $this->model->getHideIsFinishinfoList());
  32. $this->view->assign("isGuildList", $this->model->getIsGuildList());
  33. $this->view->assign("isOnlineList", $this->model->getIsOnlineList());
  34. $this->view->assign("isLivebcList", $this->model->getIsLivebcList());
  35. $this->view->assign("isActiveList", $this->model->getIsActiveList());
  36. $this->view->assign("secretvideoStatusList", $this->model->getSecretvideoStatusList());
  37. }
  38. public function import()
  39. {
  40. parent::import();
  41. }
  42. /**
  43. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  44. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  45. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  46. */
  47. /**
  48. * 查看
  49. */
  50. public function index()
  51. {
  52. //当前是否为关联查询
  53. $this->relationSearch = true;
  54. //设置过滤方法
  55. $this->request->filter(['strip_tags', 'trim']);
  56. if ($this->request->isAjax()) {
  57. //如果发送的来源是Selectpage,则转发到Selectpage
  58. if ($this->request->request('keyField')) {
  59. return $this->selectpage();
  60. }
  61. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  62. //公会分权限
  63. $gh_map = [];
  64. $gh_ids = db('admin')->where('id',$this->auth->id)->value('gh_ids');
  65. if(empty($gh_ids)){
  66. $gh_map = ['ghuser.gh_id' => '-1'];
  67. }else{
  68. $gh_map = ['ghuser.gh_id' => ['IN',$gh_ids]];
  69. }
  70. if($gh_ids == '*'){
  71. $gh_map = [];
  72. }
  73. $list = $this->model
  74. ->with(['gonghui'])
  75. ->where($where)
  76. ->where($gh_map)
  77. ->order($sort, $order)
  78. // ->select(false);dump($list);exit;
  79. ->paginate($limit);
  80. //循环
  81. foreach ($list as $row) {
  82. $row->getRelation('gonghui')->visible(['name']);
  83. }
  84. //追加字段//统计每个人的所有收益
  85. $list2 = collection($list->items())->toArray();
  86. //收益type
  87. $profit_type = [21,22,23,52,54,56,58,60,65,67,68,82,91];
  88. foreach ($list2 as $key => $row) {
  89. //累计收益
  90. $map = [
  91. 'log_type' => ['IN',$profit_type],
  92. 'user_id' => $row['id'],
  93. ];
  94. $row['profit'] = Db::name('user_money_log')->where($map)->sum('change_value');
  95. $list2[$key] = $row;
  96. }
  97. $result = array("total" => $list->total(), "rows" => $list2);
  98. return json($result);
  99. }
  100. return $this->view->fetch();
  101. }
  102. }