IndexController.php 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062
  1. <?php
  2. namespace App\Http\Controllers\Web\Recruit;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Models\RecruitAppointLog;
  5. use App\Models\RecruitTicket;
  6. use App\Validators\RecruitValidatorRequest;
  7. use Illuminate\Http\Request;
  8. use App\Models\Recruit;
  9. use App\Services\Recruit\RecruitService;
  10. use App\Models\RecruitAppointBasic;
  11. use App\Models\RecruitSupplement;
  12. use App\Models\RecruitPost;
  13. use App\Models\RecruitAppointInfo;
  14. use think\Route;
  15. use Illuminate\Support\Facades\Validator;
  16. use Illuminate\Support\Facades\DB;
  17. use App\Models\RecruitAppointExpandSpecial;
  18. use App\Models\RecruitAppointDetail;
  19. use App\Models\RecruitArticle;
  20. use Illuminate\Support\Facades\Cache;
  21. use App\Services\Common\BaiduService;
  22. class IndexController extends WebBaseController
  23. {
  24. protected $recruitService,$baiduService;
  25. public function __construct(RecruitService $recruitService,BaiduService $baiduService)
  26. {
  27. $this->recruitService = $recruitService;
  28. $this->baiduService = $baiduService;
  29. }
  30. /**
  31. * 招考列表页
  32. * @param Request $request
  33. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  34. */
  35. public function index(Request $request)
  36. {
  37. $key = $request->input('key');
  38. $list = $this->recruitService->getRecruit($key, 10);
  39. $return_data = [
  40. 'list' => $list,
  41. 'key' => $key,
  42. ];
  43. return view('app.recruit.index', $return_data);
  44. }
  45. /**
  46. * 招考详情页
  47. * @param Request $request
  48. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  49. */
  50. public function show(Request $request)
  51. {
  52. $user = $this->getUser();
  53. if($user){
  54. $uid = $user->id;
  55. $utype = $user->utype;
  56. }else{
  57. $uid = 0;
  58. $utype = 0;
  59. }
  60. $id = $request->input('id', 0);
  61. if (empty($id)) {
  62. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  63. }
  64. $recruit = Recruit::find($id);
  65. if (empty($recruit)) {
  66. return redirect(route('/recruit/list'));
  67. }
  68. $info = Recruit::parse_info($recruit);
  69. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  70. if(!$info->isApply && $appoint_info){
  71. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  72. if($first_post){
  73. $info->isApply = 1;
  74. }
  75. }
  76. if($appoint_info){
  77. //笔试
  78. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  79. if($pen_ticket){
  80. $pen_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","pen")->where('h_status',1)->first();
  81. if(!$pen_health){
  82. $appoint_info->pen_ticket = -2;
  83. }else{
  84. $time = time();
  85. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  86. $appoint_info->pen_ticket = 1;
  87. }else{
  88. $appoint_info->pen_ticket = -1;
  89. }
  90. }
  91. }else{
  92. $appoint_info->pen_ticket = 0;
  93. }
  94. //考核测试
  95. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  96. if($check_ticket){
  97. $time = time();
  98. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  99. $appoint_info->check_ticket = 1;
  100. }else{
  101. $appoint_info->check_ticket = -1;
  102. }
  103. }else{
  104. $appoint_info->check_ticket = 0;
  105. }
  106. //面试
  107. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  108. if($face_ticket && $appoint_info->face_audit == -1){
  109. $appoint_info->face_ticket = 1;
  110. }else{
  111. $appoint_info->face_ticket = 0;
  112. }
  113. //复试
  114. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  115. if($reexamine_ticket && $appoint_info->reexamine_audit == -1){
  116. $appoint_info->reexamine_ticket = 1;
  117. }else{
  118. $appoint_info->reexamine_ticket = 0;
  119. }
  120. }else{
  121. $appoint_info = new \stdClass();
  122. $appoint_info->pen_audit = 0;
  123. $appoint_info->post_id = 0;
  124. $appoint_info->pen_ticket = 0;
  125. $appoint_info->computer_ticket = 0;
  126. $appoint_info->face_ticket = 0;
  127. $appoint_info->check_ticket = 0;
  128. $appoint_info->reexamine_ticket = 0;
  129. $appoint_info->realname = '';
  130. $appoint_info->card = '';
  131. $appoint_info->mobile = '';
  132. $appoint_info->sex = 0;
  133. }
  134. $notice = $request->input('notice',0);
  135. if($notice){
  136. $public_notice_switch = 0;
  137. $public_notice = RecruitArticle::where('id',$notice)->where('released_at','<',time())->first();
  138. if (!empty($info)) {
  139. $view_data = [
  140. 'recruit' => $recruit,
  141. 'info' => $info,
  142. 'uid' => $uid,
  143. 'utype' => $utype,
  144. 'public_notice' => $public_notice,
  145. 'public_notice_switch' => $public_notice_switch,
  146. 'appoint_info' => $appoint_info
  147. ];
  148. return view('app.recruit.show')->with($view_data);
  149. } else {
  150. return back();
  151. }
  152. }else{
  153. $list = RecruitArticle::where('recruit_id',$id)->orderBy('created_at','desc')->where('released_at','<',time())->get();
  154. $public_notice_switch = 1;//有补充公告的模式
  155. if (!empty($info)) {
  156. $view_data = [
  157. 'recruit' => $recruit,
  158. 'info' => $info,
  159. 'uid' => $uid,
  160. 'utype' => $utype,
  161. 'list' => $list,
  162. 'public_notice_switch' => $public_notice_switch,
  163. 'appoint_info' => $appoint_info
  164. ];
  165. return view('app.recruit.show')->with($view_data);
  166. } else {
  167. return back();
  168. }
  169. }
  170. }
  171. /**
  172. * 上传文件的方法
  173. * @param Request $request
  174. * @return \Illuminate\Http\JsonResponse
  175. */
  176. public function upload(Request $request)
  177. {
  178. $user = $this->getUser();
  179. if($user){
  180. $uid = $user->id;
  181. $utype = $user->utype;
  182. }else{
  183. $uid = 0;
  184. $utype = 0;
  185. }
  186. $file = $request->file('file');
  187. if ($file->isValid()) { //判断文件是否存在
  188. //获取文件的扩展名
  189. $ext = $file->getClientOriginalExtension();
  190. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  191. $res['status'] = 0;
  192. $res['msg'] = '文件格式不正确';
  193. } else {
  194. //获取文件的绝对路径
  195. $path = $file->getRealPath();
  196. $oldname = $file->getClientOriginalName();
  197. //定义文件名
  198. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  199. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  200. Storage::disk('public')->put($filename, file_get_contents($path));
  201. $res['status'] = 1;
  202. $res['filename'] = $oldname;
  203. $res['path'] = "/storage/" . $filename;
  204. $res['msg'] = '上传成功';
  205. }
  206. } else {
  207. $res['status'] = 0;
  208. $res['msg'] = '上传失败';
  209. }
  210. return response()->json($res);
  211. }
  212. /**
  213. * 查看报名人数统计
  214. * @param Request $request
  215. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  216. */
  217. public function sign_up_count(Request $request)
  218. {
  219. $user = $this->getUser();
  220. if($user){
  221. $uid = $user->id;
  222. $utype = $user->utype;
  223. }else{
  224. $uid = 0;
  225. $utype = 0;
  226. }
  227. $id = $request->input('id', 0);
  228. $refresh = $request->input('refresh', '');
  229. if (empty($id)) {
  230. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
  231. }
  232. $recruit = Recruit::find($id);
  233. if (empty($recruit)) {
  234. return redirect(route('/recruit/list'));
  235. }
  236. if(!$recruit->show_report){
  237. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.list'), true, '上一页', '2');
  238. }
  239. if(Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {
  240. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  241. $list = $cache_data['list'];
  242. $time = $cache_data['time'];
  243. }else{
  244. $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();
  245. if(!$list){
  246. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.list'), true, '上一页', '2');
  247. }
  248. foreach ($list as $k => $v){
  249. $res = RecruitAppointInfo::select(DB::raw("count(case audit when 1 then 1 end) as 'checking', count(case audit when 2 then 2 end) as 'fail',count(case audit when 3 then 3 end) as 'success'"))->where('recruit_id',$recruit->id)->where('post_id',$v->id)->first();
  250. $list[$k]['checking'] = $res->checking;
  251. $list[$k]['fail'] = $res->fail;
  252. $list[$k]['success'] = $res->success;
  253. }
  254. $time = date('Y-m-d H:i',time());
  255. $cache_data = [
  256. 'list' => $list,
  257. 'time' => $time
  258. ];
  259. Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);
  260. }
  261. $view_data = [
  262. 'list' => $list,
  263. 'time' => $time
  264. ];
  265. return view('app.recruit.sign_up_count')->with($view_data);
  266. }
  267. /**
  268. * 报名功能页
  269. * @param Request $request
  270. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  271. */
  272. public function sign_up(Request $request)
  273. {
  274. $user = $this->getUser();
  275. if (!empty($user)) {
  276. $uid = $user->id;
  277. } else {
  278. return redirect(route('login'));
  279. }
  280. //招考id
  281. $id = $request->input('id', 0);
  282. if (!$id) {
  283. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  284. }
  285. //招考信息
  286. $recruit = Recruit::find($id);
  287. if(!$recruit['status'] && !$user->recruit_test){
  288. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  289. }
  290. if($recruit['current'] != 1){
  291. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  292. }
  293. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  294. $time = time();
  295. $formDisabled = 0;
  296. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  297. if(!in_array($uid,[161027,59041])){
  298. if(!$appoint_info){
  299. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  300. }
  301. if($appoint_info){
  302. //如果有报名记录,先查询首次报名是什么时候
  303. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('appoint_id',$appoint_info->id)->orderBy('created_at','asc')->first();
  304. if(!$first_post){//没有记录代表只是暂存
  305. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  306. }
  307. // $has_late_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('created_at','>',$recruit['apply_end'])->first();//查找在过了报名时间后,有报名记录,且仍是审核失败的报名记录,看其是否在报名时间后是否有再次提交的记录
  308. // if($has_late_post){
  309. // $formDisabled = 1;
  310. // }else{
  311. // $formDisabled = 0;
  312. // }
  313. }
  314. }
  315. }
  316. $view_data['module'] = $forms = explode(',', $recruit['forms']);
  317. //查询报名表是否已有记录
  318. if($appoint_info){
  319. if(in_array('internship',$forms)) {
  320. //如果已有该场次的报名记录,读取录入的数据集合
  321. $user_info = $appoint_info;
  322. $user_info['sex'] = (string)$user_info['sex'];
  323. $user_info['adjust'] = (string)$user_info['adjust'];
  324. $user_info['edu_type'] = (string)$user_info['edu_type'];
  325. $user_info['family'] = json_decode($user_info['family']);
  326. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  327. if($detail){
  328. $user_info['detail'] = $detail->toArray();
  329. }else{
  330. $user_info['detail'] = [
  331. 'rewards_and_punishments' => '',
  332. 'introduce' => ''
  333. ];
  334. }
  335. if(json_decode($user_info['identification'])){
  336. $identification = json_decode($user_info['identification'],true);
  337. foreach ($identification as $k => $v){
  338. if(array_key_exists('response',$v)){
  339. $identification[$k]['url'] = $v['response']['path'];
  340. }
  341. }
  342. }else{
  343. $identification = [];
  344. }
  345. $user_info['identification'] = $identification;
  346. if(json_decode($user_info['education_certification'])){
  347. $education_certification = json_decode($user_info['education_certification'],true);
  348. foreach ($education_certification as $k => $v){
  349. if(array_key_exists('response',$v)){
  350. $education_certification[$k]['url'] = $v['response']['path'];
  351. }
  352. }
  353. }else{
  354. $education_certification = [];
  355. }
  356. $user_info['education_certification'] = $education_certification;
  357. if(json_decode($user_info['other_certification'])){
  358. $other_certification = json_decode($user_info['other_certification'],true);
  359. foreach ($other_certification as $k => $v){
  360. if(array_key_exists('response',$v)){
  361. $other_certification[$k]['url'] = $v['response']['path'];
  362. }
  363. }
  364. }else{
  365. $other_certification = [];
  366. }
  367. $user_info['other_certification'] = $other_certification;
  368. //获取最新的报名审核信息
  369. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  370. if($logs){
  371. $user_info['audit_log'] = $logs->log;
  372. }else{
  373. $user_info['audit_log'] = '';
  374. }
  375. }else{
  376. //如果已有该场次的报名记录,读取录入的数据集合
  377. $user_info = $appoint_info;
  378. $user_info['sex'] = (string)$user_info['sex'];
  379. $user_info['edu_type'] = (string)$user_info['edu_type'];
  380. $user_info['family'] = json_decode($user_info['family']);
  381. if(in_array('expand_special',$forms)){
  382. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$user_info['id'])->first();
  383. if(json_decode($special['material'])){
  384. $material = json_decode($special['material'],true);
  385. foreach ($material as $k => $v){
  386. if(array_key_exists('response',$v)){
  387. if(array_key_exists('path',$v['response'])){
  388. $material[$k]['url'] = $v['response']['path'];}
  389. }
  390. }
  391. }else{
  392. $material = [];
  393. }
  394. $user_info['special'] = [
  395. 'point_apply' => (string)$special['point_apply'],
  396. 'condition' => $special['condition'],
  397. 'material' => $material
  398. ];
  399. }
  400. if(in_array('detail',$forms)){
  401. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  402. if($detail){
  403. $user_info['detail'] = $detail->toArray();
  404. }else{
  405. $user_info['detail'] = [
  406. 'train' => '',
  407. 'rewards_and_punishments' => '',
  408. 'introduce' => ''
  409. ];
  410. }
  411. }
  412. //如果有身份证明模块
  413. if(in_array('identification',$forms)){
  414. if(json_decode($user_info['identification'])){
  415. $identification = json_decode($user_info['identification'],true);
  416. foreach ($identification as $k => $v){
  417. if(array_key_exists('response',$v)){
  418. if(array_key_exists('path',$v['response'])){
  419. $identification[$k]['url'] = $v['response']['path'];
  420. }
  421. }
  422. }
  423. }else{
  424. $identification = [];
  425. }
  426. $user_info['identification'] = $identification;
  427. }
  428. //如果有教育证明模块
  429. if(in_array('education_certification',$forms)){
  430. if(json_decode($user_info['education_certification'])){
  431. $education_certification = json_decode($user_info['education_certification'],true);
  432. foreach ($education_certification as $k => $v){
  433. if(array_key_exists('response',$v)){
  434. if(array_key_exists('path',$v['response'])){
  435. $education_certification[$k]['url'] = $v['response']['path'];
  436. }
  437. }
  438. }
  439. }else{
  440. $education_certification = [];
  441. }
  442. $user_info['education_certification'] = $education_certification;
  443. }
  444. //如果有其他证明模块
  445. if(in_array('other_certification',$forms)){
  446. if(json_decode($user_info['other_certification'])){
  447. $other_certification = json_decode($user_info['other_certification'],true);
  448. foreach ($other_certification as $k => $v){
  449. if(array_key_exists('response',$v)){
  450. if(array_key_exists('path',$v['response'])){
  451. $other_certification[$k]['url'] = $v['response']['path'];
  452. }
  453. }
  454. }
  455. }else{
  456. $other_certification = [];
  457. }
  458. $user_info['other_certification'] = $other_certification;
  459. }
  460. //获取最新的报名审核信息
  461. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  462. if($logs){
  463. $user_info['audit_log'] = $logs->log;
  464. }else{
  465. $user_info['audit_log'] = '';
  466. }
  467. //获取提交报名的次数
  468. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  469. // $post_number = $number+1;//todo
  470. }
  471. }
  472. else{
  473. //实习专场
  474. if(in_array('internship',$forms)){
  475. $user_info = json_encode([
  476. 'recruit_id' => $id,
  477. 'operation' => 1,
  478. 'realname' => '',
  479. 'sex' => '1',
  480. 'birthday' => '',
  481. 'card' => '',
  482. 'nation' => '',
  483. 'native_place' => '',
  484. 'political_affiliation' => '',
  485. 'join_time' => '',
  486. 'house_register' => '',
  487. 'education' => '',
  488. 'school' => '',
  489. 'pro' => '',
  490. 'adjust' => '',
  491. 'mobile' => '',
  492. 'email' => '',
  493. 'address' => '',
  494. 'post_id' => '',
  495. 'concat_name' => '',
  496. 'concat_mobile' => '',
  497. 'resume' => '',
  498. 'avatar' => '',
  499. 'family' => [
  500. [
  501. 'relation' => '',
  502. 'realname' => '',
  503. 'birthday' => '',
  504. 'political_affiliation' => '',
  505. 'work' => ''
  506. ]
  507. ],
  508. 'detail' => [
  509. 'rewards_and_punishments' => '',
  510. 'introduce' => ''
  511. ],
  512. 'identification' => [],
  513. 'education_certification' => [],
  514. 'other_certification' => []
  515. ]);
  516. }else{
  517. //如果没有,结合基础数据及模块表单信息,制作数据对象
  518. $user_info = RecruitAppointBasic::where('uid',$uid)->first();
  519. if(!$user_info){
  520. //没有基础信息跳转完善route('person.recruitInfo')
  521. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');
  522. }
  523. $user_info['sex'] = (string)$user_info['sex'];
  524. $user_info['edu_type'] = (string)$user_info['edu_type'];
  525. $user_info['family'] = json_decode($user_info['family']);
  526. if(in_array('expand_special',$forms)){
  527. $user_info['special'] = [
  528. 'point_apply' => '0',
  529. 'condition' => '',
  530. 'material' => []
  531. ];
  532. }
  533. if(in_array('detail',$forms)){
  534. $user_info['detail'] = [
  535. 'train' => '',
  536. 'rewards_and_punishments' => '',
  537. 'introduce' => ''
  538. ];
  539. }
  540. if(in_array('identification',$forms)){
  541. $user_info['identification'] = [];
  542. }
  543. if(in_array('education_certification',$forms)){
  544. $user_info['education_certification'] = [];
  545. }
  546. if(in_array('other_certification',$forms)){
  547. $user_info['other_certification'] = [];
  548. }
  549. $user_info['recruit_id'] = $id;
  550. $user_info['operation'] = 1;
  551. }
  552. }
  553. //招考岗位
  554. $where_post[] = ['recruit_id', '=', $id];
  555. $where_post[] = ['status', '=', 1];
  556. $recruit_post = RecruitPost::where($where_post)->get();
  557. $post = [];
  558. $post_limit = [];
  559. foreach ($recruit_post as $value){
  560. $item = [
  561. 'value' => $value['id'],
  562. 'label' => $value['code'] . " " . $value['name']
  563. ];
  564. $post_limit[$value['id']] = json_decode($value['limit']);
  565. array_push($post,$item);
  566. }
  567. $view_data['appoint_info'] = $user_info;
  568. $view_data['post'] = json_encode($post);
  569. // $view_data['post_number'] = $post_number;
  570. // $view_data['post_times'] = $recruit['post_times'];
  571. $view_data['post_limit'] = json_encode($post_limit);
  572. $view_data['formDisable'] = $formDisabled;
  573. $view_data['title'] = $recruit->company;
  574. return view('app.recruit.sign_up',$view_data);
  575. }
  576. public function preview(Request $request)
  577. {
  578. $modules = $request->input('modules');
  579. $view_data['module'] = $forms = explode(',', $modules);
  580. return view('app.recruit.preview',$view_data);
  581. }
  582. /**
  583. * 提交报名的处理程序
  584. * @param Request $request
  585. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  586. */
  587. public function saveSignUp(Request $request)
  588. {
  589. $user = $this->getUser();
  590. if (!empty($user)) {
  591. $uid = $user->id;
  592. } else {
  593. return redirect(route('login'));
  594. }
  595. $recruit_id = $request->input('recruit_id', 0);
  596. if (!$recruit_id) {
  597. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  598. }
  599. $recruit = Recruit::find($recruit_id);
  600. if(!$recruit['status']){
  601. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  602. }
  603. if($recruit['current'] != 1){
  604. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  605. }
  606. $time = time();
  607. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  608. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  609. if($appoint_info){
  610. //如果有报名记录,先查询首次报名是什么时候
  611. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  612. if(!$first_post){//没有记录代表只是暂存
  613. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  614. }
  615. }
  616. if(!$appoint_info){
  617. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  618. }
  619. }
  620. //基础信息的检查
  621. $rules = [
  622. 'realname' => 'required',
  623. 'sex' => 'required',
  624. 'birthday' => 'required',
  625. 'avatar' => 'required',
  626. 'nation' => 'required',
  627. 'native_place' => 'required',
  628. 'political_affiliation' => 'required',
  629. 'post_id' => 'required',
  630. 'house_register' => 'required',
  631. //'edu_type' => 'required',
  632. 'education' => 'required',
  633. 'school' => 'required',
  634. 'address' => 'required',
  635. 'mobile' => 'required',
  636. 'email' => 'required',
  637. 'card' => 'required',
  638. 'concat_name' => 'required',
  639. 'concat_mobile' => 'required',
  640. 'resume' => 'required'
  641. ];
  642. $messages = [
  643. 'realname.required' => '请填写姓名',
  644. 'sex.required' => '请填写性别',
  645. 'birthday.required' => '请填写出生日期',
  646. 'avatar.required' => '请上传彩色免冠照',
  647. 'nation.required' => '请填写民族',
  648. 'native_place.required' => '请填写籍贯',
  649. 'political_affiliation.required' => '请选择政治面貌',
  650. 'post_id.required' => '请选择报名岗位',
  651. 'house_register.required' => '请填写户籍所在地',
  652. //'edu_type.required' => '请选择教育类型',
  653. 'education.required' => '请输入学历',
  654. 'school.required' => '请输入毕业院校',
  655. 'address.required' => '请填写通信地址',
  656. 'mobile.required' => '请填写手机号码',
  657. 'email.required' => '请填写电子邮箱',
  658. 'card.required' => '请填写身份证号码',
  659. 'resume.required' => '请填写个人简历',
  660. 'concat_name.required' => '请填写联系人姓名',
  661. 'concat_mobile.required' => '请填写联系人手机号码'
  662. ];
  663. $create_data = $request->all();
  664. $validator = Validator::make($create_data,$rules,$messages);
  665. if ($validator->fails()) {
  666. $msg = $validator->errors()->all();
  667. return response()->json(['status' => 0,'msg' => $msg[0]]);
  668. }else{
  669. $data = $request->only('realname','sex','birthday','avatar','nation','native_place','political_affiliation','titles','join_time','work','house_register','education','school','degree','pro','address','card','mobile','email','concat_name','concat_mobile','resume','post_id','adjust','remark');
  670. //身份证判断出生日期和性别
  671. $year = substr($data['card'],6,4);
  672. $month = substr($data['card'],10,2);
  673. $day = substr($data['card'],12,2);
  674. if($year.'-'.$month.'-'.$day != $data['birthday']){
  675. $data['birthday'] = $year.'-'.$month.'-'.$day;
  676. }
  677. if(intval(substr($data['card'],16,1)) % 2 == 0){
  678. $data['sex'] = 0;
  679. }else{
  680. $data['sex'] = 1;
  681. }
  682. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  683. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  684. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  685. }
  686. //获取操作符,是暂存还是提交
  687. $operation = $request->input('operation');
  688. if($operation == 1){
  689. $data['audit'] = 0;//暂存
  690. }else{
  691. $data['audit'] = 1;//提交
  692. }
  693. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  694. //岗位限制条件的判断
  695. $post_limit = json_decode($post_info['limit'],true);
  696. if(is_array($post_limit)){
  697. foreach($post_limit as $k => $v){
  698. if($k == 'birthday'){
  699. $value = str_replace('-','',$data[$k]);
  700. }else{
  701. $value = $data[$k];
  702. }
  703. switch ($v['op']){
  704. case '=':
  705. if($value != $v['value']){
  706. return response()->json(['status' => 0,'msg' => $v['msg']]);
  707. }
  708. break;
  709. case '>':
  710. if($value <= $v['value']){
  711. return response()->json(['status' => 0,'msg' => $v['msg']]);
  712. }
  713. break;
  714. case '>=':
  715. if($value < $v['value']){
  716. return response()->json(['status' => 0,'msg' => $v['msg']]);
  717. }
  718. break;
  719. case '<':
  720. if($value >= $v['value']){
  721. return response()->json(['status' => 0,'msg' => $v['msg']]);
  722. }
  723. break;
  724. case '<=':
  725. if($value > $v['value']){
  726. return response()->json(['status' => 0,'msg' => $v['msg']]);
  727. }
  728. break;
  729. case '!=':
  730. if($value == $v['value']){
  731. return response()->json(['status' => 0,'msg' => $v['msg']]);
  732. }
  733. break;
  734. case 'like':
  735. if(strpos($value,$v['value']) === false){
  736. return response()->json(['status' => 0,'msg' => $v['msg']]);
  737. }
  738. break;
  739. case 'in':
  740. if(strpos($v['value'],$value) === false){
  741. return response()->json(['status' => 0,'msg' => $v['msg']]);
  742. }
  743. break;
  744. }
  745. }
  746. }
  747. }
  748. //前置审核 判断完成,先将数据入报名信息基础表
  749. //解析家庭成员数据
  750. $familys = $request->input('family');
  751. $family = [];
  752. if(is_array($familys)){
  753. foreach ($familys as $value){
  754. $item = [
  755. 'relation' => $value['relation'],
  756. 'realname' => $value['realname'],
  757. 'birthday' => $value['birthday'],
  758. 'political_affiliation' => $value['political_affiliation'],
  759. 'work' => $value['work']
  760. ];
  761. array_push($family,$item);
  762. }
  763. }
  764. $data['family'] = json_encode($family);
  765. if($appoint_info){
  766. //如果已有报名记录,进入修改阶段的处理流程
  767. DB::beginTransaction();
  768. try{
  769. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  770. //分模块解析数据
  771. $forms = explode(',', $recruit['forms']);
  772. //如果有加分模块
  773. if(in_array('expand_special',$forms)){
  774. $special = $request->input('special');
  775. if($special['point_apply']){
  776. //删除掉没有成功返回路径的图片
  777. if(is_array($special['material'])){
  778. foreach ($special['material'] as $k => $v){
  779. if(!array_key_exists('response',$v)){
  780. unset($special['material'][$k]);
  781. }
  782. }
  783. }
  784. $special['material'] = json_encode($special['material']);
  785. }else{
  786. $special['condition'] = '';
  787. $special['material'] = json_encode([]);
  788. }
  789. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  790. if($hasRecord){
  791. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  792. }else{
  793. $special['recruit_appoint_id'] = $appoint_info->id;
  794. RecruitAppointExpandSpecial::create($special);
  795. }
  796. }
  797. //如果有详情模块
  798. if(in_array('detail',$forms) || in_array('internship',$forms)){
  799. $detail = $request->input('detail');
  800. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  801. if($hasRecord){
  802. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  803. }else{
  804. $detail['recruit_appoint_id'] = $appoint_info->id;
  805. RecruitAppointDetail::create($detail);
  806. }
  807. }
  808. //如果有身份证明模块
  809. if(in_array('identification',$forms) || in_array('internship',$forms)){
  810. $identification = $request->input('identification');
  811. if(is_array($identification)){
  812. //删除掉没有成功返回路径的图片
  813. foreach ($identification as $k => $v){
  814. if(!array_key_exists('response',$v)){
  815. unset($identification[$k]);
  816. }
  817. }
  818. }
  819. $appoint_info->identification = json_encode($identification);
  820. $appoint_info->save();
  821. }
  822. //如果有教育证明模块
  823. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  824. $education_certification = $request->input('education_certification');
  825. if(is_array($education_certification)){
  826. //删除掉没有成功返回路径的图片
  827. foreach ($education_certification as $k => $v){
  828. if(!array_key_exists('response',$v)){
  829. unset($education_certification[$k]);
  830. }
  831. }
  832. }
  833. $appoint_info->education_certification = json_encode($education_certification);
  834. $appoint_info->save();
  835. }
  836. //如果有其他证明模块
  837. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  838. $other_certification = $request->input('other_certification');
  839. if(is_array($other_certification)){
  840. //删除掉没有成功返回路径的图片
  841. foreach ($other_certification as $k => $v){
  842. if(!array_key_exists('response',$v)){
  843. unset($other_certification[$k]);
  844. }
  845. }
  846. }
  847. if($other_certification){
  848. $appoint_info->other_certification = json_encode($other_certification);
  849. $appoint_info->save();
  850. }
  851. }
  852. DB::commit();
  853. if($operation == 2){
  854. $log = [
  855. 'type' => 3,
  856. 'appoint_id'=> $appoint_info->id,
  857. 'uid' => $uid,
  858. 'log' => '用户提交报名'
  859. ];
  860. RecruitAppointLog::create($log);
  861. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  862. }else{
  863. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  864. }
  865. } catch (\Exception $e){
  866. DB::rollback();
  867. return ['status' => 0, 'msg' => $e->getMessage()];
  868. }
  869. }else{
  870. //没有报名记录,进入增加阶段的处理流程
  871. DB::beginTransaction();
  872. try{
  873. //20220726增加地区undefined选项处理
  874. if($index = stripos($data['native_place'],',undefined')){
  875. $data['native_place'] = substr($data['native_place'],0,$index);
  876. }
  877. if($index = stripos($data['house_register'],',undefined')){
  878. $data['house_register'] = substr($data['house_register'],0,$index);
  879. }
  880. $data['uid'] = $uid;
  881. $data['recruit_id'] = $recruit_id;
  882. $result = RecruitAppointInfo::create($data);
  883. //分模块解析数据
  884. $forms = explode(',', $recruit['forms']);
  885. //如果有加分模块
  886. if(in_array('expand_special',$forms)){
  887. $special = $request->input('special');
  888. if($special['point_apply']){
  889. if(is_array($special['material'])){
  890. //删除掉没有成功返回路径的图片
  891. foreach ($special['material'] as $k => $v){
  892. if(!array_key_exists('response',$v)){
  893. unset($special['material'][$k]);
  894. }
  895. }
  896. }
  897. $special['material'] = json_encode($special['material']);
  898. }
  899. $special['recruit_appoint_id'] = $result->id;
  900. RecruitAppointExpandSpecial::create($special);
  901. }
  902. //如果有详情模块
  903. if(in_array('detail',$forms) || in_array('internship',$forms)){
  904. $detail = $request->input('detail');
  905. $detail['recruit_appoint_id'] = $result->id;
  906. RecruitAppointDetail::create($detail);
  907. }
  908. //如果有身份证明模块
  909. if(in_array('identification',$forms) || in_array('internship',$forms)){
  910. $identification = $request->input('identification');
  911. if(is_array($identification)){
  912. //删除掉没有成功返回路径的图片
  913. foreach ($identification as $k => $v){
  914. if(!array_key_exists('response',$v)){
  915. unset($identification[$k]);
  916. }
  917. }
  918. }
  919. $result->identification = json_encode($identification);
  920. $result->save();
  921. }
  922. //如果有教育证明模块
  923. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  924. $education_certification = $request->input('education_certification');
  925. if(is_array($education_certification)){
  926. //删除掉没有成功返回路径的图片
  927. foreach ($education_certification as $k => $v){
  928. if(!array_key_exists('response',$v)){
  929. unset($education_certification[$k]);
  930. }
  931. }
  932. }
  933. $result->education_certification = json_encode($education_certification);
  934. $result->save();
  935. }
  936. //如果有其他证明模块
  937. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  938. $other_certification = $request->input('other_certification');
  939. if($other_certification){
  940. if(is_array($other_certification)){
  941. //删除掉没有成功返回路径的图片
  942. foreach ($other_certification as $k => $v){
  943. if(!array_key_exists('response',$v)){
  944. unset($other_certification[$k]);
  945. }
  946. }
  947. }
  948. $result->other_certification = json_encode($other_certification);
  949. $result->save();
  950. }
  951. }
  952. DB::commit();
  953. if($operation == 2){
  954. $log = [
  955. 'type' => 3,
  956. 'appoint_id'=> $result->id,
  957. 'uid' => $uid,
  958. 'log' => '用户首次提交报名'
  959. ];
  960. RecruitAppointLog::create($log);
  961. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  962. }else{
  963. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  964. }
  965. } catch (\Exception $e){
  966. DB::rollback();
  967. return ['status' => 0, 'msg' => $e->getMessage()];
  968. }
  969. }
  970. }
  971. }
  972. /**
  973. * 获得当前登录的用户
  974. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  975. */
  976. public function getUser()
  977. {
  978. if (auth('web-member')->check()) {
  979. $user = auth('web-member')->user();
  980. } else {
  981. $user = null;
  982. }
  983. return $user;
  984. }
  985. /**
  986. * 检查用户基本信息
  987. * @return array
  988. */
  989. public function checkUserBasicInfo()
  990. {
  991. $user = $this->getUser();
  992. if (!empty($user)) {
  993. $uid = $user->id;
  994. } else {
  995. $arr = ['status' => 401, 'msg'=>'请登录!'];
  996. return $arr;
  997. }
  998. $info = RecruitAppointBasic::where('uid',$uid)->first();
  999. if (empty($info)){
  1000. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  1001. return $arr;
  1002. }
  1003. return ['status' => 200, 'msg' => ''];
  1004. }
  1005. /**
  1006. * 个人中心招考页面
  1007. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1008. */
  1009. public function person_recruit()
  1010. {
  1011. $user = auth('web-member')->user();
  1012. $list = RecruitAppointInfo::where('uid',$user->id)
  1013. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1014. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1015. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  1016. ->get();
  1017. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  1018. }
  1019. /**
  1020. * 招考信息基础页
  1021. * @param Request $request
  1022. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1023. */
  1024. public function recruit_info(Request $request)
  1025. {
  1026. $user = auth('web-member')->user();
  1027. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  1028. if(!$info){
  1029. $info = [
  1030. 'realname' => '',
  1031. 'sex' => '0',
  1032. 'birthday' => '',
  1033. 'avatar' => '',
  1034. 'nation' => '',
  1035. 'native_place' => '',
  1036. 'political_affiliation' => '',
  1037. 'titles' => '',
  1038. 'work' => '',
  1039. 'house_register' => '',
  1040. 'join_time' => '',
  1041. 'edu_type' => '',
  1042. 'education' => '',
  1043. 'school' => '',
  1044. 'degree' => '',
  1045. 'pro' => '',
  1046. 'address' => '',
  1047. 'card' => '',
  1048. 'mobile' => '',
  1049. 'email' => '',
  1050. 'concat_name' => '',
  1051. 'concat_mobile' => '',
  1052. 'resume' => '',
  1053. 'family' => [
  1054. [
  1055. 'relation' => '',
  1056. 'realname' => '',
  1057. 'birthday' => '',
  1058. 'political_affiliation' => '',
  1059. 'work' => ''
  1060. ]
  1061. ],
  1062. 'is_push' => '1'
  1063. ];
  1064. }else{
  1065. $info->sex = (string)$info->sex;
  1066. $info->edu_type = (string)$info->edu_type;
  1067. $info->is_push = (string)$info->is_push;
  1068. $info->family = empty($info->family) ? [[
  1069. 'relation' => '',
  1070. 'realname' => '',
  1071. 'birthday' => '',
  1072. 'political_affiliation' => '',
  1073. 'work' => ''
  1074. ]] : json_decode($info->family);
  1075. }
  1076. $recruit_id = $request->input('recruit_id',0);
  1077. return view('app.person.recruit_info',[
  1078. 'info' => json_encode($info),
  1079. 'recruit_id'=> $recruit_id
  1080. ]);
  1081. }
  1082. /**
  1083. * 保存招考信息
  1084. * @param RecruitValidatorRequest $request
  1085. * @return \Illuminate\Http\JsonResponse
  1086. */
  1087. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1088. {
  1089. $user = auth('web-member')->user();
  1090. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1091. $data = $request->only('realname','sex','birthday','avatar','nation','native_place','political_affiliation','titles','work','house_register','join_time','education','school','degree','pro','address','card','mobile','email','concat_name','concat_mobile','resume','family','is_push');
  1092. if(count($data['family']) > 0){
  1093. $data['family'] = json_encode($data['family']);
  1094. }
  1095. if($basic){
  1096. //更新基础信息
  1097. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1098. if (!$res) {
  1099. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1100. }else{
  1101. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1102. }
  1103. }else{
  1104. //新增基础信息
  1105. $data['uid'] = $user->id;
  1106. $res = RecruitAppointBasic::create($data);
  1107. if (!$res) {
  1108. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1109. }else{
  1110. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1111. }
  1112. }
  1113. }
  1114. /**
  1115. * 笔试准考证
  1116. * @param Request $request
  1117. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1118. */
  1119. public function pen_ticket(Request $request)
  1120. {
  1121. $user = $this->getUser();
  1122. if (!empty($user)) {
  1123. $uid = $user->id;
  1124. } else {
  1125. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1126. }
  1127. $recruit_id = $request->input('recruit_id');
  1128. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1129. if($appoint_info){
  1130. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1131. if($pen_ticket){
  1132. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1133. if(!$health || $health->h_status == 0){
  1134. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1135. }
  1136. $time = time();
  1137. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1138. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1139. $recruit = Recruit::where('id',$recruit_id)->first();
  1140. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1141. $name = $recruit->name_en;
  1142. $date = date("Y-m-d",strtotime($recruit->created_at));
  1143. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1144. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '_create.pdf';
  1145. if(file_exists($file)){
  1146. header('Content-Description: File Transfer');
  1147. header('Content-Type: application/octet-stream');
  1148. header('Content-Disposition: attachment; filename='.basename($file));
  1149. header('Content-Transfer-Encoding: binary');
  1150. header('Expires: 0');
  1151. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1152. header('Pragma: public');
  1153. header('Content-Length: ' . filesize($file));
  1154. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1155. flush();
  1156. readfile($file);
  1157. }
  1158. }else{
  1159. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1160. }
  1161. }else{
  1162. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1163. }
  1164. }else{
  1165. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1166. }
  1167. }
  1168. /**
  1169. * 审核准考证
  1170. * @param Request $request
  1171. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1172. */
  1173. public function check_ticket(Request $request)
  1174. {
  1175. $user = $this->getUser();
  1176. if (!empty($user)) {
  1177. $uid = $user->id;
  1178. } else {
  1179. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1180. }
  1181. $recruit_id = $request->input('recruit_id');
  1182. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1183. if($appoint_info){
  1184. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1185. if($check_ticket){
  1186. $time = time();
  1187. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1188. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1189. $recruit = Recruit::where('id',$recruit_id)->first();
  1190. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1191. $name = $recruit->name_en;
  1192. $date = date("Y-m-d",strtotime($recruit->created_at));
  1193. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1194. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1195. if(file_exists($file)){
  1196. header('Content-Description: File Transfer');
  1197. header('Content-Type: application/octet-stream');
  1198. header('Content-Disposition: attachment; filename='.basename($file));
  1199. header('Content-Transfer-Encoding: binary');
  1200. header('Expires: 0');
  1201. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1202. header('Pragma: public');
  1203. header('Content-Length: ' . filesize($file));
  1204. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1205. flush();
  1206. readfile($file);
  1207. }
  1208. }else{
  1209. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1210. }
  1211. }else{
  1212. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1213. }
  1214. }else{
  1215. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1216. }
  1217. }
  1218. /**
  1219. * 面试准考证
  1220. * @param Request $request
  1221. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1222. */
  1223. public function face_ticket(Request $request)
  1224. {
  1225. $user = $this->getUser();
  1226. if (!empty($user)) {
  1227. $uid = $user->id;
  1228. } else {
  1229. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1230. }
  1231. $recruit_id = $request->input('recruit_id');
  1232. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1233. if($appoint_info){
  1234. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1235. if($face_ticket){
  1236. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1237. if(!$health || $health->h_status == 0){
  1238. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1239. }
  1240. $time = time();
  1241. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1242. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1243. $recruit = Recruit::where('id',$recruit_id)->first();
  1244. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1245. $name = $recruit->name_en;
  1246. $date = date("Y-m-d",strtotime($recruit->created_at));
  1247. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1248. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1249. if(file_exists($file)){
  1250. header('Content-Description: File Transfer');
  1251. header('Content-Type: application/octet-stream');
  1252. header('Content-Disposition: attachment; filename='.basename($file));
  1253. header('Content-Transfer-Encoding: binary');
  1254. header('Expires: 0');
  1255. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1256. header('Pragma: public');
  1257. header('Content-Length: ' . filesize($file));
  1258. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1259. flush();
  1260. readfile($file);
  1261. }
  1262. }else{
  1263. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1264. }
  1265. }else{
  1266. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1267. }
  1268. }else{
  1269. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1270. }
  1271. }
  1272. /**
  1273. * 复试准考证
  1274. * @param Request $request
  1275. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1276. */
  1277. public function reexamine_ticket(Request $request)
  1278. {
  1279. $user = $this->getUser();
  1280. if (!empty($user)) {
  1281. $uid = $user->id;
  1282. } else {
  1283. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1284. }
  1285. $recruit_id = $request->input('recruit_id');
  1286. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1287. if($appoint_info){
  1288. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1289. if($reexamine_ticket){
  1290. $time = time();
  1291. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1292. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1293. $recruit = Recruit::where('id',$recruit_id)->first();
  1294. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1295. $name = $recruit->name_en;
  1296. $date = date("Y-m-d",strtotime($recruit->created_at));
  1297. $filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id].'_create';
  1298. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1299. if(file_exists($file)){
  1300. header('Content-Description: File Transfer');
  1301. header('Content-Type: application/octet-stream');
  1302. header('Content-Disposition: attachment; filename='.basename($file));
  1303. header('Content-Transfer-Encoding: binary');
  1304. header('Expires: 0');
  1305. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1306. header('Pragma: public');
  1307. header('Content-Length: ' . filesize($file));
  1308. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1309. flush();
  1310. readfile($file);
  1311. }
  1312. }else{
  1313. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1314. }
  1315. }else{
  1316. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1317. }
  1318. }else{
  1319. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1320. }
  1321. }
  1322. /**
  1323. * 材料补登
  1324. * @param Request $request
  1325. */
  1326. public function material_supplement(Request $request)
  1327. {
  1328. $user = $this->getUser();
  1329. if (!empty($user)) {
  1330. $uid = $user->id;
  1331. } else {
  1332. return redirect(route('login'));
  1333. }
  1334. //招考id
  1335. $id = $request->input('id', 0);
  1336. if (!$id) {
  1337. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1338. }
  1339. $recruit = Recruit::find($id);
  1340. if(!$recruit['status'] && !$user->recruit_test){
  1341. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1342. }
  1343. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1344. if(!$appoint_info){
  1345. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1346. }
  1347. if($appoint_info->pen_audit != 1){
  1348. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1349. }
  1350. $uids = array (
  1351. 0 => '175624',
  1352. 1 => '175637',
  1353. 2 => '173543',
  1354. 3 => '175663',
  1355. 4 => '175628',
  1356. 5 => '159629',
  1357. 6 => '170066',
  1358. 7 => '175826',
  1359. 8 => '175629',
  1360. 9 => '175620',
  1361. 10 => '175738',
  1362. 11 => '175854',
  1363. 12 => '164974',
  1364. 13 => '167931',
  1365. 14 => '175757',
  1366. 15 => '175951',
  1367. 16 => '175893',
  1368. 17 => '175995',
  1369. 18 => '176024',
  1370. 19 => '176044',
  1371. 20 => '169828',
  1372. 21 => '152230',
  1373. 22 => '176147',
  1374. 23 => '176144',
  1375. 24 => '176189',
  1376. 25 => '169518',
  1377. 26 => '175925',
  1378. 27 => '176327',
  1379. 28 => '176347',
  1380. 29 => '176349',
  1381. 30 => '176407',
  1382. 31 => '170378',
  1383. 32 => '176463',
  1384. 33 => '176457',
  1385. 34 => '169219',
  1386. 35 => '169285',
  1387. 36 => '163039',
  1388. 37 => '176545',
  1389. 38 => '176551',
  1390. 39 => '169814',
  1391. 40 => '175847',
  1392. 41 => '175755',
  1393. 42 => '169240',
  1394. 43 => '176669',
  1395. 44 => '176605',
  1396. 45 => '176807',
  1397. 46 => '169917',
  1398. 47 => '176888',
  1399. 48 => '176578',
  1400. 49 => '176681',
  1401. 50 => '148287',
  1402. 51 => '176511',
  1403. 52 => '176946',
  1404. 53 => '176922',
  1405. 54 => '176955',
  1406. 55 => '167385',
  1407. 56 => '176971',
  1408. 57 => '176969',
  1409. 58 => '176984',
  1410. 59 => '169932',
  1411. 60 => '176250',
  1412. 61 => '149243',
  1413. 62 => '177026',
  1414. 63 => '169607',
  1415. 64 => '150162',
  1416. 65 => '177055',
  1417. 66 => '177061',
  1418. 67 => '177056',
  1419. 68 => '169761',
  1420. 69 => '177096',
  1421. 70 => '177118',
  1422. 71 => '177102',
  1423. 72 => '159073',
  1424. 73 => '177119',
  1425. 74 => '169641',
  1426. 75 => '177158',
  1427. 76 => '177128',
  1428. 77 => '170175',
  1429. 78 => '170822',
  1430. 79 => '177193',
  1431. 80 => '177234',
  1432. 81 => '177251',
  1433. 82 => '168964',
  1434. 83 => '176034',
  1435. 84 => '150532',
  1436. 85 => '168487',
  1437. 86 => '177304',
  1438. 87 => '170441',
  1439. 88 => '177262',
  1440. 89 => '177342',
  1441. 90 => '177356',
  1442. 91 => '170376',
  1443. 92 => '177316',
  1444. 93 => '177361',
  1445. 94 => '177170',
  1446. 95 => '171720',
  1447. 96 => '176736',
  1448. );
  1449. $limit_time = 1654078200;
  1450. if(in_array($uid,$uids)){
  1451. $limit_time = 1654164000;
  1452. }
  1453. $time = time();
  1454. if( $time > $limit_time){
  1455. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1456. }
  1457. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1458. if(!$info){
  1459. $info = [
  1460. 'appoint_id' => $appoint_info->id,
  1461. 'identification' => '',
  1462. 'household_register' => '',
  1463. 'education_certification' => '',
  1464. //'family_planning' => '',
  1465. 'manage' => '',
  1466. 'status' => 3
  1467. ];
  1468. }else{
  1469. $info = $info->toArray();
  1470. if(json_decode($info['identification'])){
  1471. $identification = json_decode($info['identification'],true);
  1472. foreach ($identification as $k => $v){
  1473. if(array_key_exists('response',$v)){
  1474. $identification[$k]['url'] = $v['response']['path'];
  1475. }
  1476. }
  1477. }else{
  1478. $identification = [];
  1479. }
  1480. $info['identification'] = $identification;
  1481. if(json_decode($info['household_register'])){
  1482. $household_register = json_decode($info['household_register'],true);
  1483. foreach ($household_register as $k => $v){
  1484. if(array_key_exists('response',$v)){
  1485. $household_register[$k]['url'] = $v['response']['path'];
  1486. }
  1487. }
  1488. }else{
  1489. $household_register = [];
  1490. }
  1491. $info['household_register'] = $household_register;
  1492. if(json_decode($info['education_certification'])){
  1493. $education_certification = json_decode($info['education_certification'],true);
  1494. foreach ($education_certification as $k => $v){
  1495. if(array_key_exists('response',$v)){
  1496. $education_certification[$k]['url'] = $v['response']['path'];
  1497. }
  1498. }
  1499. }else{
  1500. $education_certification = [];
  1501. }
  1502. $info['education_certification'] = $education_certification;
  1503. if(json_decode($info['family_planning'])){
  1504. $family_planning = json_decode($info['family_planning'],true);
  1505. foreach ($family_planning as $k => $v){
  1506. if(array_key_exists('response',$v)){
  1507. $family_planning[$k]['url'] = $v['response']['path'];
  1508. }
  1509. }
  1510. }else{
  1511. $family_planning = [];
  1512. }
  1513. $info['family_planning'] = $family_planning;
  1514. if(json_decode($info['manage'])){
  1515. $manage = json_decode($info['manage'],true);
  1516. foreach ($manage as $k => $v){
  1517. if(array_key_exists('response',$v)){
  1518. $manage[$k]['url'] = $v['response']['path'];
  1519. }
  1520. }
  1521. }else{
  1522. $manage = [];
  1523. }
  1524. $info['manage'] = $manage;
  1525. }
  1526. $view_data['info'] = json_encode($info);
  1527. $view_data['title'] = $recruit->company;
  1528. return view('app.recruit.supplement',$view_data);
  1529. }
  1530. /**
  1531. * 健康信息登记
  1532. * @param Request $request
  1533. */
  1534. public function health_info(Request $request)
  1535. {
  1536. $user = $this->getUser();
  1537. if (!empty($user)) {
  1538. $uid = $user->id;
  1539. } else {
  1540. return redirect(route('login'));
  1541. }
  1542. //招考id
  1543. $id = $request->input('id', 0);
  1544. if (!$id) {
  1545. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1546. }
  1547. $recruit = Recruit::find($id);
  1548. if(!$recruit['status'] && !$user->recruit_test){
  1549. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1550. }
  1551. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1552. if(!$appoint_info){
  1553. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1554. }
  1555. if($appoint_info->audit != 3){
  1556. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1557. }
  1558. $time = time();
  1559. $type = $request->input('type',null);
  1560. $where = [];
  1561. if($type){
  1562. switch ($type){
  1563. case 'pen':
  1564. $start = strtotime($recruit->pen_health_start);
  1565. $end = strtotime($recruit->pen_health_end);
  1566. break;
  1567. case 'computer':
  1568. $start = strtotime($recruit->computer_health_start);
  1569. $end = strtotime($recruit->computer_health_end);
  1570. break;
  1571. case 'face':
  1572. $start = strtotime($recruit->face_health_start);
  1573. $end = strtotime($recruit->face_health_end);
  1574. break;
  1575. default:
  1576. $start = strtotime($recruit->supplement_start);
  1577. $end = strtotime($recruit->supplement_end);
  1578. break;
  1579. }
  1580. $where[] = ['type', '=', $type];
  1581. }else{
  1582. $start = strtotime($recruit->supplement_start);
  1583. $end = strtotime($recruit->supplement_end);
  1584. }
  1585. if($time > $end || $time < $start){
  1586. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1587. }
  1588. $where[] = ['appoint_id', '=', $appoint_info->id];
  1589. $info = RecruitSupplement::where($where)->first();
  1590. if(!$info){
  1591. $info = [
  1592. 'appoint_id' => $appoint_info->id,
  1593. 'health_code' => '',
  1594. 'trip_code' => '',
  1595. 'type' => $type
  1596. ];
  1597. }else{
  1598. $info = $info->toArray();
  1599. if(json_decode($info['health_code'])){
  1600. $health_code = json_decode($info['health_code'],true);
  1601. foreach ($health_code as $k => $v){
  1602. if(array_key_exists('response',$v)){
  1603. $health_code[$k]['url'] = $v['response']['path'];
  1604. }
  1605. }
  1606. }else{
  1607. $health_code = [];
  1608. }
  1609. $info['health_code'] = $health_code;
  1610. if(json_decode($info['trip_code'])){
  1611. $trip_code = json_decode($info['trip_code'],true);
  1612. foreach ($trip_code as $k => $v){
  1613. if(array_key_exists('response',$v)){
  1614. $trip_code[$k]['url'] = $v['response']['path'];
  1615. }
  1616. }
  1617. }else{
  1618. $trip_code = [];
  1619. }
  1620. $info['trip_code'] = $trip_code;
  1621. }
  1622. $view_data['info'] = json_encode($info);
  1623. $view_data['title'] = $recruit->company;
  1624. return view('app.recruit.health',$view_data);
  1625. }
  1626. public function save_supplement(Request $request)
  1627. {
  1628. $user = $this->getUser();
  1629. if (!empty($user)) {
  1630. $uid = $user->id;
  1631. } else {
  1632. return redirect(route('login'));
  1633. }
  1634. $appoint_id = $request->input('appoint_id');
  1635. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',16)->where('id',$appoint_id)->first();
  1636. if(!$appoint_info){
  1637. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1638. }
  1639. $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
  1640. if($info){
  1641. if($info->status == 1){
  1642. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1643. }
  1644. if($info->status == 0){
  1645. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1646. }
  1647. //身份证明
  1648. $identification = $request->input('identification');
  1649. if(is_array($identification)){
  1650. //删除掉没有成功返回路径的图片
  1651. foreach ($identification as $k => $v){
  1652. if(!array_key_exists('response',$v)){
  1653. unset($identification[$k]);
  1654. }
  1655. }
  1656. }
  1657. $info->identification = json_encode($identification);
  1658. //户口簿
  1659. $household_register = $request->input('household_register');
  1660. if(is_array($household_register)){
  1661. //删除掉没有成功返回路径的图片
  1662. foreach ($household_register as $k => $v){
  1663. if(!array_key_exists('response',$v)){
  1664. unset($household_register[$k]);
  1665. }
  1666. }
  1667. }
  1668. $info->household_register = json_encode($household_register);
  1669. //学信网
  1670. $education_certification = $request->input('education_certification');
  1671. if(is_array($education_certification)){
  1672. //删除掉没有成功返回路径的图片
  1673. foreach ($education_certification as $k => $v){
  1674. if(!array_key_exists('response',$v)){
  1675. unset($education_certification[$k]);
  1676. }
  1677. }
  1678. }
  1679. $info->education_certification = json_encode($education_certification);
  1680. //计生
  1681. // $family_planning = $request->input('family_planning');
  1682. // if(is_array($family_planning)){
  1683. // //删除掉没有成功返回路径的图片
  1684. // foreach ($family_planning as $k => $v){
  1685. // if(!array_key_exists('response',$v)){
  1686. // unset($family_planning[$k]);
  1687. // }
  1688. // }
  1689. // }
  1690. // $info->family_planning = json_encode($family_planning);
  1691. //综治
  1692. $manage = $request->input('manage');
  1693. if(is_array($manage)){
  1694. //删除掉没有成功返回路径的图片
  1695. foreach ($manage as $k => $v){
  1696. if(!array_key_exists('response',$v)){
  1697. unset($manage[$k]);
  1698. }
  1699. }
  1700. }
  1701. $info->manage = json_encode($manage);
  1702. $info->status = 0;
  1703. $info->save();
  1704. $appoint_info->political_audit = 4;
  1705. $appoint_info->save();
  1706. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1707. }else{
  1708. $data['appoint_id'] = $appoint_id;
  1709. //身份证明
  1710. $identification = $request->input('identification');
  1711. if(is_array($identification)){
  1712. //删除掉没有成功返回路径的图片
  1713. foreach ($identification as $k => $v){
  1714. if(!array_key_exists('response',$v)){
  1715. unset($identification[$k]);
  1716. }
  1717. }
  1718. }
  1719. $data['identification'] = json_encode($identification);
  1720. //户口簿
  1721. $household_register = $request->input('household_register');
  1722. if(is_array($household_register)){
  1723. //删除掉没有成功返回路径的图片
  1724. foreach ($household_register as $k => $v){
  1725. if(!array_key_exists('response',$v)){
  1726. unset($household_register[$k]);
  1727. }
  1728. }
  1729. }
  1730. $data['household_register'] = json_encode($household_register);
  1731. //学信网
  1732. $education_certification = $request->input('education_certification');
  1733. if(is_array($education_certification)){
  1734. //删除掉没有成功返回路径的图片
  1735. foreach ($education_certification as $k => $v){
  1736. if(!array_key_exists('response',$v)){
  1737. unset($education_certification[$k]);
  1738. }
  1739. }
  1740. }
  1741. $data['education_certification'] = json_encode($education_certification);
  1742. //计生
  1743. // $family_planning = $request->input('family_planning');
  1744. // if(is_array($family_planning)){sp
  1745. // //删除掉没有成功返回路径的图片
  1746. // foreach ($family_planning as $k => $v){
  1747. // if(!array_key_exists('response',$v)){
  1748. // unset($family_planning[$k]);
  1749. // }
  1750. // }
  1751. // }
  1752. // $data['family_planning'] = json_encode($family_planning);
  1753. //综治
  1754. $manage = $request->input('manage');
  1755. if(is_array($manage)){
  1756. //删除掉没有成功返回路径的图片
  1757. foreach ($manage as $k => $v){
  1758. if(!array_key_exists('response',$v)){
  1759. unset($manage[$k]);
  1760. }
  1761. }
  1762. }
  1763. $data['manage'] = json_encode($manage);
  1764. $data['status'] = 0;
  1765. $result = RecruitSupplement::create($data);
  1766. $appoint_info->political_audit = 4;
  1767. $appoint_info->save();
  1768. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1769. }
  1770. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1771. }
  1772. public function save_healthinfo(Request $request)
  1773. {
  1774. $user = $this->getUser();
  1775. if (!empty($user)) {
  1776. $uid = $user->id;
  1777. } else {
  1778. return redirect(route('login'));
  1779. }
  1780. $appoint_id = $request->input('appoint_id');
  1781. $type = $request->input('type');
  1782. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1783. $recruit = Recruit::where('id',$appoint_info->recruit_id)->first();
  1784. if(!$appoint_info){
  1785. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1786. }
  1787. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();
  1788. if($info){
  1789. if($info->h_status == 1){
  1790. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1791. }
  1792. if($info->h_status == 0){
  1793. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1794. }
  1795. $health_code = $request->input('health_code');
  1796. if(is_array($health_code)){
  1797. //删除掉没有成功返回路径的图片
  1798. foreach ($health_code as $k => $v){
  1799. if(!array_key_exists('response',$v)){
  1800. unset($health_code[$k]);
  1801. }
  1802. }
  1803. }
  1804. $info->health_code = json_encode($health_code);
  1805. $trip_code = $request->input('trip_code');
  1806. if(is_array($trip_code)){
  1807. //删除掉没有成功返回路径的图片
  1808. foreach ($trip_code as $k => $v){
  1809. if(!array_key_exists('response',$v)){
  1810. unset($trip_code[$k]);
  1811. }
  1812. }
  1813. }
  1814. $info->trip_code = json_encode($trip_code);
  1815. $info->save();
  1816. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1817. }else{
  1818. $data['appoint_id'] = $appoint_id;
  1819. $data['type'] = $type;
  1820. $data['h_status'] = 0;
  1821. $appoint_info->health_audit = 4;
  1822. $health_code = $request->input('health_code');
  1823. if(is_array($health_code)){
  1824. //删除掉没有成功返回路径的图片
  1825. foreach ($health_code as $k => $v){
  1826. if(!array_key_exists('response',$v)){
  1827. unset($health_code[$k]);
  1828. }
  1829. }
  1830. }
  1831. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  1832. if(!array_key_exists('error_msg',$health_result) && !array_key_exists('error_code',$health_result)){
  1833. if(array_key_exists('姓名',$health_result)){
  1834. if($health_result['姓名'][0]['word'] != $appoint_info->realname){
  1835. return ['status' => 0, 'msg' => '抱歉,请上传您本人的健康码!'];
  1836. }
  1837. }else{
  1838. return ['status' => 0, 'msg' => '健康码错误,识别不到姓名!'];
  1839. }
  1840. if(array_key_exists('状态',$health_result)){
  1841. if($health_result['状态'][0]['word'] != '绿码'){
  1842. return ['status' => 0, 'msg' => '抱歉,您的健康码非绿码!'];
  1843. }
  1844. }else{
  1845. return ['status' => 0, 'msg' => '健康码错误,识别不到状态!'];
  1846. }
  1847. if(array_key_exists('更新时间',$health_result)){
  1848. $time = strtotime($health_result['更新时间'][0]['word']);
  1849. if($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)){
  1850. return ['status' => 0, 'msg' => "抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!"];
  1851. }
  1852. }else{
  1853. return ['status' => 0, 'msg' => '健康码错误,识别不到时间!'];
  1854. }
  1855. $data['h_status'] = 1;
  1856. $data['h_msg'] = '健康码自动审核通过';
  1857. $appoint_info->health_audit = 1;
  1858. $data['health_code'] = json_encode($health_code);
  1859. }
  1860. $data['health_result'] = json_encode($health_result);
  1861. $trip_code = $request->input('trip_code');
  1862. if(is_array($trip_code)){
  1863. //删除掉没有成功返回路径的图片
  1864. foreach ($trip_code as $k => $v){
  1865. if(!array_key_exists('response',$v)){
  1866. unset($trip_code[$k]);
  1867. }
  1868. }
  1869. }
  1870. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  1871. if(!array_key_exists('error_msg',$trip_result) && !array_key_exists('error_code',$trip_result)){
  1872. if(array_key_exists('途经地',$trip_result['result'])){
  1873. $fangyi_area = explode("\r\n",config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  1874. $result = array_intersect($fangyi_area,$trip_result['result']['途经地'][0]['word']);
  1875. if(count($result) > 0){
  1876. return ['status' => 0, 'msg' => '抱歉,您的行程中包含系统设置中高风险地区!'];
  1877. }
  1878. }
  1879. if(array_key_exists('风险性',$trip_result['result']) && $trip_result['result']['风险性']){
  1880. return ['status' => 0, 'msg' => '抱歉,您的行程可能含有风险!'];
  1881. }
  1882. if(array_key_exists('更新时间',$trip_result['result'])){
  1883. $time = strtotime($health_result['更新时间'][0]['word'][0]);
  1884. if($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)){
  1885. return ['status' => 0, 'msg' => "抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!"];
  1886. }
  1887. }
  1888. $data['h_msg'] .= '行程码审核通过';
  1889. }
  1890. $data['trip_result'] = json_encode($trip_result);
  1891. $data['trip_code'] = json_encode($trip_code);
  1892. RecruitSupplement::create($data);
  1893. $appoint_info->save();
  1894. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1895. }
  1896. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1897. }
  1898. public function interviewer_random(Request $request)
  1899. {
  1900. $model = $request->input('model',1);
  1901. $number1 = $request->input('number1',5);//考官人数
  1902. $number2 = $request->input('number2',1);//替补人数
  1903. $where[] = ['id','>',0];
  1904. switch ($model){
  1905. case '0':
  1906. $list = DB::table('recruit_interviewer')->get()->toArray();
  1907. shuffle($list);
  1908. $result = array_slice($list, 0, $number1+$number2);
  1909. break;
  1910. case '1':
  1911. $list = DB::table('recruit_interviewer')->get()->toArray();
  1912. shuffle($list);
  1913. $count = $number1;
  1914. for ($i = 0; $i < $count; $i++){
  1915. if(!$list[$i]->status){
  1916. $list[] = $list[$i];
  1917. unset($list[$i]);
  1918. $count++;
  1919. }
  1920. }
  1921. $result = array_slice($list, 0, $number1+$number2);
  1922. break;
  1923. case '2':
  1924. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  1925. shuffle($list);
  1926. $result = array_slice($list, 0, $number1+$number2);
  1927. break;
  1928. default:
  1929. $list = DB::table('recruit_interviewer')->get()->toArray();
  1930. shuffle($list);
  1931. for ($i = 0; $i < $number1; $i++){
  1932. dd($list[$i]);
  1933. if(!$list[$i]->status){
  1934. $list[] = $list[$i];
  1935. unset($list[$i]);
  1936. }
  1937. }
  1938. $result = array_slice($list, 0, $number1+$number2);
  1939. break;
  1940. }
  1941. $return_data = [
  1942. 'list' => $result,
  1943. 'number1' => $number1,
  1944. 'number2' => $number2
  1945. ];
  1946. return view('app.recruit.interviewer', $return_data);
  1947. }
  1948. }