model = new \app\admin\model\Ghuser; $this->view->assign("realStatusList", $this->model->getRealStatusList()); $this->view->assign("genderList", $this->model->getGenderList()); $this->view->assign("idcardStatusList", $this->model->getIdcardStatusList()); $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("openMatchVideoList", $this->model->getOpenMatchVideoList()); $this->view->assign("openMatchAudioList", $this->model->getOpenMatchAudioList()); $this->view->assign("openMatchTypingList", $this->model->getOpenMatchTypingList()); $this->view->assign("freeVideoList", $this->model->getFreeVideoList()); $this->view->assign("freeAudioList", $this->model->getFreeAudioList()); $this->view->assign("freeTypingList", $this->model->getFreeTypingList()); $this->view->assign("hideIsFinishinfoList", $this->model->getHideIsFinishinfoList()); $this->view->assign("isGuildList", $this->model->getIsGuildList()); $this->view->assign("isOnlineList", $this->model->getIsOnlineList()); $this->view->assign("isLivebcList", $this->model->getIsLivebcList()); $this->view->assign("isActiveList", $this->model->getIsActiveList()); $this->view->assign("secretvideoStatusList", $this->model->getSecretvideoStatusList()); } public function import() { parent::import(); } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ /** * 查看 */ public function index() { //当前是否为关联查询 $this->relationSearch = true; //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); //公会分权限 $gh_map = []; $gh_ids = db('admin')->where('id',$this->auth->id)->value('gh_ids'); if(empty($gh_ids)){ $gh_map = ['ghuser.gh_id' => '-1']; }else{ $gh_map = ['ghuser.gh_id' => ['IN',$gh_ids]]; } if($gh_ids == '*'){ $gh_map = []; } $list = $this->model ->with(['gonghui']) ->where($where) ->where($gh_map) ->order($sort, $order) // ->select(false);dump($list);exit; ->paginate($limit); //循环 foreach ($list as $row) { $row->getRelation('gonghui')->visible(['name']); } //追加字段//统计每个人的所有收益 $list2 = collection($list->items())->toArray(); //收益type $profit_type = [21,22,23,52,54,56,58,60,65,67,68,82,91]; foreach ($list2 as $key => $row) { //累计收益 $map = [ 'log_type' => ['IN',$profit_type], 'user_id' => $row['id'], ]; $row['profit'] = Db::name('user_money_log')->where($map)->sum('change_value'); $list2[$key] = $row; } $result = array("total" => $list->total(), "rows" => $list2); return json($result); } return $this->view->fetch(); } }