IndexController.php 97 KB

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