articleService = $articleService; } /** * 登录 */ public function login() { $user_id = auth('web-member')->id(); $return_data = ['user_id' => $user_id ?: 0, 'apply' => '[]']; //房源 $house = TalentHouse::orderBy('updated_at', 'desc')->orderByRaw(DB::raw("FIELD(status,2,1,3)"))->limit(8)->get(); foreach ($house as $v) { $v['declare_time_text'] = date('Y-m-d', strtotime($v['declare_time'])); $v['status_text'] = $this->house_status[$v['status']]; $v['status_tag'] = $this->tag_status[$v['status']]; $v['url'] = route('buyhouse.list', ['id' => $v['id']]); } $return_data['house'] = $house; //新闻 $news = Article::where('type_id', 56)->where('is_display', 1)->select(['id', 'title', 'updated_at'])->orderBy('list_order', 'desc')->limit(10)->get(); foreach ($news as $v) { $v['updated_at_text'] = date('Y-m-d', strtotime($v['updated_at'])); $v['url'] = route('news.show', ['id' => $v['id']]); } $return_data['news'] = $news; //我的申报 if ($user_id > 0) { $apply = TalentHouseApply::with('house') ->select(['id', 'house_id', 'status']) ->where('is_draft', 2) ->where('user_id', $user_id) ->get(); foreach ($apply as $v) { $v['status_text'] = $this->apply_status[$v['status']]; $v['status_tag'] = $this->tag_status[$v['status']]; $v['url'] = route('buyhouse.list', ['id' => $v['house_id']]); } $return_data['apply'] = $apply; } return view('app.content.buyhouse.login', $return_data); } /** * 房源信息 */ public function house(Request $request) { $lists = TalentHouse::orderByRaw(DB::raw("FIELD(status,2,1,3)"))->paginate(10); foreach ($lists as $v) { $v['status_text'] = $this->house_status[$v['status']]; $v['status_tag'] = $this->tag_status[$v['status']]; } $return_data = [ 'articles' => $lists, 'now_cate' => '房源信息', ]; return view('app.content.buyhouse.house', $return_data); } /** * 公告 */ public function news() { $lists = $this->articleService->list('', 56, '10'); $return_data = [ 'articles' => $lists, 'now_cate' => '公告', ]; return view('app.content.buyhouse.news', $return_data); } /** * 报名列表 */ public function list(Request $request) { $login = $this->checkLogin(); if ($login) { return $login; } $user_id = auth('web-member')->id(); $id = $request->get('id'); if (empty($id)) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3'); } //房源信息 $house = TalentHouse::where('id', $id)->first(); if (empty($house)) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3'); } $house['declare_time_text'] = date('Y-m-d', strtotime($house['declare_time'])); $house['status_text'] = $this->house_status[$house['status']]; $house['status_tag'] = $this->tag_status[$house['status']]; $house['apply_time'] = date('Y-m-d', strtotime($house['apply_time_start'])) . ' - ' . date('Y-m-d', strtotime($house['apply_time_end'])); //报名信息 $apply = TalentHouseApply::where('house_id', $id)->where('user_id', $user_id)->first(); $check = []; if ($apply) { if ($house['status'] != 2 && $apply['is_draft'] == 1) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('该房源未在申报时间', $back_url, true, '上一页', '3'); } //审核状态 if ($apply['is_draft'] == 2) { if ($apply['rs_check_status'] != 2) { $check['status_text'] = '人社局' . $this->apply_status[$apply['rs_check_status']]; $check['comment'] = $apply['rs_check_status'] == 1 ? '' : $apply['rs_check_comment']; $check['type'] = $this->check_type[$apply['rs_check_status']]; } elseif ($apply['zj_check_status'] != 2) { $check['status_text'] = '住建局' . $this->apply_status[$apply['zj_check_status']]; $check['comment'] = $apply['zj_check_status'] == 1 ? '' : $apply['zj_check_comment']; $check['type'] = $this->check_type[$apply['zj_check_status']]; } else { $check['title'] = ''; $check['status_text'] = $this->apply_status[$apply['zj_check_status']]; $check['comment'] = ''; $check['type'] = 'success'; } } } else { if ($house['status'] != 2) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('该房源未在申报时间', $back_url, true, '上一页', '3'); } $time = time(); $resume = Resume::where('uid', $user_id)->where('def', 1)->first(); if (empty($resume)) { $back_url = route('person.resume'); return $this->showMessage('请先填写一份简历', $back_url, true, '上一页', '3'); } $infos = MemberInfo::where('uid', $user_id)->first(); if (empty($infos['id_card'])) { $back_url = route('person.resume'); return $this->showMessage('请先填写身份证号', $back_url, true, '上一页', '3'); } $request_post = [ 'idCards' => [$infos['id_card']], 'sign' => mb_strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")), 'timeStr' => (string)$time, ]; $res = https_request('https://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards', json_encode($request_post), ['Content-Type:application/json']); $talent = json_decode($res, true); if (empty($talent['obj'])) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('您还未认定人才,暂无申报资格', $back_url, true, '上一页', '3'); } $talent = $talent['obj'][0]; if ($talent['talentArrange'] > 5) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('目前仅支持一到五层次人才申报', $back_url, true, '上一页', '3'); } $add = [ 'user_id' => $user_id, 'house_id' => $id, 'type' => $talent['type'], 'name' => $talent['name'], 'mobile' => $talent['phone'], 'native' => $talent['nativePlace'], 'email' => $talent['email'], 'talent_level' => $this->talent_level[$talent['talentArrange']], 'talent_card_validity' => $talent['activeDate'], 'talent_tags' => $talent['talentType'], 'talent_condition' => $talent['identifyCondition'], 'family' => json_encode([['relation' => '', 'realname' => '', 'idcard' => '']]), 'certificates' => '[]', 'marry_prove' => '[]', 'household_register' => '[]', 'work_prove' => '[]', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), ]; $id = TalentHouseApply::insertGetId($add); $apply = TalentHouseApply::find($id); } $apply['family'] = json_decode($apply['family'], true); $apply['certificates'] = json_decode($apply['certificates'], true); $apply['marry_prove'] = json_decode($apply['marry_prove'], true); $apply['household_register'] = json_decode($apply['household_register'], true); $apply['work_prove'] = json_decode($apply['work_prove'], true); $apply['checked'] = true; //是否可填表格 $formDisable = 'true'; if ($house['status'] == 2) { if ($apply['is_draft'] == 1) { $formDisable = 'false'; } } if ($apply['rs_check_status'] == 3 || $apply['zj_check_status'] == 3) { $formDisable = 'false'; } $return_data = [ 'formDisable' => $formDisable, 'check' => $check, 'apply' => json_encode($apply), 'house' => json_encode($house), 'module' => ['identification'], ]; return view('app.content.buyhouse.list', $return_data); } public function listPost(Request $request) { //数据校验 $data = $request->only(['id', 'certificates', 'marry', 'marry_prove', 'household_register', 'family', 'work_prove', 'street', 'house_condition', 'house_policy']); $rules = [ 'certificates' => 'required', 'marry' => 'required', 'household_register' => 'required', 'work_prove' => 'required', 'street' => 'required', 'house_condition' => 'required', 'house_policy' => 'required', ]; $messages = [ 'certificates.required' => '请上传证件信息', 'marry.required' => '请选择婚姻状况', 'household_register.required' => '请上传户口本', 'work_prove.required' => '请上传人才工作单位', 'street.required' => '请填写所属街道', 'house_condition.required' => '请填写家庭成员在晋江市行政区域内住房情况', 'house_policy.required' => '请填写在晋享受政策性住房或相关优惠情况', ]; $validator = Validator::make($data, $rules, $messages); if ($validator->fails()) { $msg = $validator->errors()->all(); return response()->json(['status' => 0, 'msg' => $msg[0]]); } if ($data['marry'] > 1 && empty($data['marry_prove'])) { return response()->json(['status' => 0, 'msg' => '请上传婚姻证明']); } //报名信息 $info = TalentHouseApply::find($data['id']); if (empty($info)) { return response()->json(['status' => 0, 'msg' => '提交格式有误']); } //图片 $images = ['certificates', 'household_register', 'marry_prove', 'work_prove']; foreach ($images as $image) { if (is_array($data[$image])) { //删除掉没有成功返回路径的图片 foreach ($data[$image] as $k => $v) { if (!array_key_exists('response', $v)) { unset($data[$image][$k]); } } $data[$image] = array_values($data[$image]); } } //更新数据 $info->certificates = json_encode($data['certificates']); $info->marry = $data['marry']; if ($data['marry'] > 1) { $info->marry_prove = json_encode($data['marry_prove']); } $info->household_register = json_encode($data['household_register']); $info->family = json_encode($data['family']); $info->work_prove = json_encode($data['work_prove']); $info->street = $data['street']; $info->house_condition = $data['house_condition']; $info->house_policy = $data['house_policy']; $info->status = 1; //审核状态 if ($info->rs_check_status == 3) { $info->rs_check_status = 1; } if ($info->zj_check_status == 3) { $info->zj_check_status = 1; } if ($info->is_draft == 1) { $info->is_draft = 2; } $info->save(); return response()->json(['status' => 1]); } public function upload(Request $request) { header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE'); header('Access-Control-Allow-Headers:Origin, Content-Type, Cookie, Accept, X-CSRF-TOKEN'); header('Access-Control-Allow-Credentials:true'); $file = $request->file('file'); if ($file->isValid()) { //判断文件是否存在 //获取文件的扩展名 $ext = $file->getClientOriginalExtension(); if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) { $res['status'] = 0; $res['msg'] = '文件格式不正确'; } else { //获取文件的绝对路径 $path = $file->getRealPath(); $oldname = $file->getClientOriginalName(); //定义文件名 $filename = 'storage/buyhouse/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext; //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置 Storage::disk('public')->put($filename, file_get_contents($path)); $res['status'] = 1; $res['filename'] = $oldname; $res['path'] = "/storage/" . $filename; $res['msg'] = '上传成功'; } } else { $res['status'] = 0; $res['msg'] = '上传失败'; } return response()->json($res); } /** * 登录状态 */ private function checkLogin() { $user_id = auth('web-member')->id(); if (empty($user_id)) { return redirect(route('buyhouse.login')); } return false; } }