dataList(1); /** * 渲染模板 */ return $this->render('index', $params); } /** * 查询数据列表 */ protected function dataList($type = '') { $request = Yii::$app->request; $createTime = $request->get('createTime'); $endTime = $request->get('endTime'); $mobile = $request->get('mobile'); $name = $request->get('name'); $status = $request->get('status'); $gets = [ 'createTime' => $createTime, 'endTime' => $endTime, 'mobile' => $mobile, 'name' => $name, 'status' => $status, ]; $where = ['and']; if ($createTime) { $createTime = strtotime($createTime); $where[] = ['>=', 'user.created_at', $createTime]; } if ($endTime) { $endTime = strtotime($endTime) + 86400; $where[] = ['<=', 'user.created_at', $endTime]; } if ($mobile) { $where[] = ['like', 'user.mobile', $mobile]; } if ($name) { $where[] = ['like', 'user.name', $name]; } if ($status) { $where[] = ['=', 'user.status', $status]; } if ($type == 0) { $pageList = UserRepository::getAdminUserList(0, 0, $where); $pages = null; } else { $pageSize = 20; $pages = new Pagination(['totalCount' => UserRepository::getAdminUserListCount($where), 'pageSize' => $pageSize]); $pageList = UserRepository::getAdminUserList($pages->offset, $pages->limit, $where); } /** * 数据整理 */ return [ 'listdata' => $pageList, 'pages' => $pages, 'gets' => $gets, 'statusList' => User::getStatusLabels(), ]; } /** * 导出订单数据 * @return string */ public function actionExportDa() { $data = $this->dataList(0); return $this->renderPartial("exportDa", $data); } /** * @return string */ public function actionInfo() { $id = $this->request->get('id'); $userModel = UserRepository::findOne(['id' => $id]); if (empty($userModel)) { $params = []; return $this->render('info', $params); } $userProfile = $userModel->profile; $user = [ 'id' => $userModel->id, 'uuid' => $userModel->uuid, 'mobile' => $userModel->mobile, 'username' => $userModel->user_name, 'name' => $userModel->name, 'status' => $userModel->status, 'status_label' => User::getStatusLabels($userModel->status), 'emergencyContact' => $userProfile->emergency_contact, 'emergencyPerson' => $userProfile->emergency_person, 'licensePic' => ImageManager::getUrl($userProfile->license_pic), 'licensePicMin' => ImageManager::getUrl($userProfile->license_pic, 'min'), 'factoryHeadPic' => ImageManager::getUrl($userProfile->factory_head_pic), 'factoryHeadPicMin' => ImageManager::getUrl($userProfile->factory_head_pic, 'min'), 'techChargePic' => ImageManager::getUrl($userProfile->tech_charge_pic), 'techChargePicMin' => ImageManager::getUrl($userProfile->tech_charge_pic, 'min'), 'qaChargePic' => ImageManager::getUrl($userProfile->qa_charge_pic), 'qaChargePicMin' => ImageManager::getUrl($userProfile->qa_charge_pic, 'min'), 'created_at' => $userModel->created_at ]; $params['user'] = $user; return $this->render('info', $params); } /** * @return string * @throws \yii\db\Exception */ public function actionApprove() { $e = new stdClass(); $e->success = false; $e->message = ''; $uuid = $this->request->post('id'); $userModel = UserRepository::findOne(['uuid' => $uuid]); if (empty($userModel)) { $e->message = '找不到该维修厂'; return $this->renderJson($e); } if (User::STATUS_APPROVE == $userModel->status) { $e->message = '改维修厂已经审核通过了,无需再次审核'; return $this->renderJson($e); } $tran = Yii::$app->db->beginTransaction(); try { $userModel->status = User::STATUS_APPROVE; $userModel->save(); $userProfile = $userModel->profile; $userProfile->approve_at = time(); $userProfile->save(); $tran->commit(); $e->success = true; $e->message = '审核成功'; } catch(Exception $ex) { $tran->rollBack(); $e->message = '审核失败'; } return $this->renderJson($e); } }