/** * 用户列表 */ public function listAction() { $this->setLeftNav('list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $columns = ['user_id', 'user_account', 'user_nickname', 'user_cover', 'user_gender', 'user_expert', 'user_birthday', 'user_realname', 'user_district', 'FULL_NAME district', 'user_state', 'user_addtime', 'persional_sign']; $filterName = $req->getQuery('filterName', null, ''); $filterMobile = $req->getQuery('filterMobile', null, ''); $filterState = intval($req->getQuery('filterState', null, -10000)); $filterGender = intval($req->getQuery('filterGender', null, -10000)); $filterExpert = intval($req->getQuery('filterExpert', null, -10000)); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $where = []; $bind = []; if (!!$filterName) { $where[] = 'user_nickname LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } if (!!$filterMobile) { $where[] = 'user_account = :mobile:'; $bind['mobile'] = $filterMobile; } if ($filterState > -10000) { $where[] = 'user_state = :state:'; $bind['state'] = $filterState; } if ($filterGender > -10000) { $where[] = 'user_gender = :gender:'; $bind['gender'] = $filterGender; } if ($filterExpert > -10000) { $where[] = 'user_expert = :expert:'; $bind['expert'] = $filterExpert; } // 地区 $districts = []; if ($filterDistrict > -10000) { $where[] = 'user_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($districts) > 0) { $where[] = 'user_district IN(' . implode(', ', $districts) . ')'; } $whereStr = count($where) > 0 ? implode(' AND ', $where) : ''; $query = UserBase::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=user_district', 'area'); if (count($where) > 0) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $data = $query->orderBy('user_id DESC')->limit($limit, $offset)->execute(); $total = UserBase::count(['conditions' => $whereStr, 'bind' => $bind]); $this->view->setVars(['filterName' => $filterName, 'filterMobile' => $filterMobile, 'filterState' => $filterState, 'filterGender' => $filterGender, 'filterExpert' => $filterExpert, 'filterProvince' => $filterProvince, 'filterCity' => $filterCity, 'filterDistrict' => $filterDistrict]); $this->view->setVars(['page' => $page, 'limit' => $limit, 'total' => $total]); $this->view->setVar('data', $data); }
/** * 添加关联1.0 */ public function questionUserAddAction() { $req = $this->request; if (!$req->isPost()) { $this->view->setVar('opList', BackendOperator::find('operator_group = 2')); return; } $response = new ResponseResult(); $response->callback = $req->getPost('callback', null, 'parent.setFormResult'); $response->callbackJavascriptTag = true; $opId = intval($req->getPost('op_id', null, 0)); $userId = intval($req->getPost('user_id', null, 0)); if ($opId < 1 || $userId < 1) { $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!'); return $response; } // 操作员是否存在 if (BackendOperator::count('operator_id = ' . $opId) == 0) { $response->sendError(ResponseResultStatus::BUSINESS, '操作员不存在!'); return $response; } // 用户是否存在 if (UserBase::count('user_id = ' . $userId) == 0) { $response->sendError(ResponseResultStatus::BUSINESS, '用户不存在!'); return $response; } $info = new OmQuestionAnswerUser(); $info->op_id = $opId; $info->user_id = $userId; if ($info->save() == false) { $this->databaseErrorLog($info); $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!'); } else { $response->sendResult($info->qau_id); } return $response; }