scene('create')->check($this->request->post())) { $this->error($validate->getError()); } $data = [ 'name' => $this->request->post('name', '', 'trim'), 'phone' => $this->request->post('phone', '', 'trim'), 'province_adcode' => $this->request->post('province_adcode', '', 'trim'), 'city_adcode' => $this->request->post('city_adcode', '', 'trim'), 'district_adcode' => $this->request->post('district_adcode', '', 'trim'), 'address' => $this->request->post('address', '', 'trim'), 'id_card_front' => $this->request->post('id_card_front', '', 'trim'), 'id_card_back' => $this->request->post('id_card_back', '', 'trim'), ]; $application = InspectionService::createApplication($this->auth->id, $data); $this->success('申请提交成功,请耐心等待审核', [ 'id' => $application->id, 'audit_status' => $application->audit_status, 'audit_status_text' => $application->audit_status_text ]); } /** * 获取申请详情 */ public function detail() { // 验证请求参数 $validate = new \app\api\validate\Inspection(); $applicationId = $this->request->get('id/d'); $params = ['id' => $applicationId]; if (!$validate->scene('detail')->check($params)) { $this->error($validate->getError()); } $application = InspectionService::getApplicationDetail($applicationId, $this->auth->id); if($application){ $application->append(['audit_status_text', 'apply_time_text', 'audit_time_text', 'province_name', 'city_name', 'district_name']); $application->hidden(['createtime', 'updatetime', 'deletetime']); } $this->success('获取成功', $application); } /** * 获取申请列表 */ public function index() { $list = InspectionService::getApplicationList($this->auth->id); foreach ($list as $item) { $item->append(['audit_status_text', 'apply_time_text']); $item->visible(['id', 'name', 'phone', 'audit_status', 'audit_status_text', 'apply_time', 'apply_time_text', 'reject_reason']); } $this->success('获取成功', $list); } /** * 修改申请(仅审核中状态可修改) */ public function update() { // 验证请求参数 $validate = new \app\api\validate\Inspection(); if (!$validate->scene('update')->check($this->request->post())) { $this->error($validate->getError()); } $applicationId = $this->request->post('id/d'); $data = [ 'name' => $this->request->post('name', '', 'trim'), 'phone' => $this->request->post('phone', '', 'trim'), 'province_adcode' => $this->request->post('province_adcode', '', 'trim'), 'city_adcode' => $this->request->post('city_adcode', '', 'trim'), 'district_adcode' => $this->request->post('district_adcode', '', 'trim'), 'address' => $this->request->post('address', '', 'trim'), 'id_card_front' => $this->request->post('id_card_front', '', 'trim'), 'id_card_back' => $this->request->post('id_card_back', '', 'trim'), ]; $application = InspectionService::updateApplication($applicationId, $this->auth->id, $data); $this->success('修改成功', [ 'id' => $application->id, 'audit_status' => $application->audit_status, 'audit_status_text' => $application->audit_status_text ]); } /** * 检查申请资格 */ public function checkEligibility() { $result = InspectionService::checkEligibility($this->auth->id); $this->success('检查成功', $result); } }