IndexController.php 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782
  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.index.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. //20221115增加确认笔试功能
  79. if($recruit->pen_comfirm){
  80. if($appoint_info->audit != 3){//审核未通过,无需确认
  81. $appoint_info->pen_comfirm = 0;
  82. }else{
  83. $time = time();
  84. if(strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time){
  85. $appoint_info->pen_comfirm = -1; //确认未开始
  86. }else{
  87. if($appoint_info->pen_audit != -2){
  88. $appoint_info->pen_comfirm = -2;//已确认无需再次确认
  89. }else{
  90. $appoint_info->pen_comfirm = 1;
  91. }
  92. }
  93. }
  94. }else{
  95. $appoint_info->pen_comfirm = 0;//无需确认
  96. }
  97. //笔试
  98. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  99. if($pen_ticket){
  100. $pen_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","pen")->where('h_status',1)->first();
  101. if(!$pen_health && $recruit->pen_epidemic){
  102. $appoint_info->pen_ticket = -2;
  103. }else{
  104. $time = time();
  105. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  106. $appoint_info->pen_ticket = 1;
  107. }else{
  108. $appoint_info->pen_ticket = -1;
  109. }
  110. }
  111. }else{
  112. $appoint_info->pen_ticket = 0;
  113. }
  114. //考核测试
  115. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  116. if($check_ticket){
  117. $time = time();
  118. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  119. $appoint_info->check_ticket = 1;
  120. }else{
  121. $appoint_info->check_ticket = -1;
  122. }
  123. }else{
  124. $appoint_info->check_ticket = 0;
  125. }
  126. //面试
  127. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  128. if($face_ticket && $appoint_info->face_audit == -1){
  129. $face_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","face")->where('h_status',1)->first();
  130. if(!$face_health && $recruit->face_epidemic){
  131. $appoint_info->face_ticket = -2;
  132. $time = time();
  133. if(strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time){
  134. $appoint_info->face_ticket = -2;
  135. }else{
  136. $appoint_info->face_ticket = -3;
  137. }
  138. }else{
  139. $time = time();
  140. if(strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time){
  141. $appoint_info->face_ticket = 1;
  142. }else{
  143. $appoint_info->face_ticket = -1;
  144. }
  145. }
  146. }else{
  147. $appoint_info->face_ticket = 0;
  148. }
  149. //复试
  150. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  151. if($reexamine_ticket && $appoint_info->reexamine_audit == -1){
  152. $reexamine_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","reexamine")->where('h_status',1)->first();
  153. if(!$reexamine_health){
  154. $appoint_info->reexamine_ticket = -2;
  155. }else{
  156. $appoint_info->reexamine_ticket = 1;
  157. }
  158. }else{
  159. $appoint_info->reexamine_ticket = 0;
  160. }
  161. }else{
  162. $appoint_info = new \stdClass();
  163. $appoint_info->pen_comfirm = 0;
  164. $appoint_info->pen_audit = 0;
  165. $appoint_info->post_id = 0;
  166. $appoint_info->pen_ticket = 0;
  167. $appoint_info->computer_ticket = 0;
  168. $appoint_info->face_ticket = 0;
  169. $appoint_info->check_ticket = 0;
  170. $appoint_info->reexamine_ticket = 0;
  171. $appoint_info->realname = '';
  172. $appoint_info->card = '';
  173. $appoint_info->mobile = '';
  174. $appoint_info->sex = 0;
  175. $appoint_info->adjust = 0;
  176. $appoint_info->adjust_limit = 0;
  177. }
  178. $notice = $request->input('notice',0);
  179. if($notice){
  180. $public_notice_switch = 0;
  181. $public_notice = RecruitArticle::where('id',$notice)->where('released_at','<',time())->first();
  182. if (!empty($info)) {
  183. $view_data = [
  184. 'recruit' => $recruit,
  185. 'info' => $info,
  186. 'uid' => $uid,
  187. 'utype' => $utype,
  188. 'public_notice' => $public_notice,
  189. 'public_notice_switch' => $public_notice_switch,
  190. 'appoint_info' => $appoint_info
  191. ];
  192. return view('app.recruit.show')->with($view_data);
  193. } else {
  194. return back();
  195. }
  196. }else{
  197. $list = RecruitArticle::where('recruit_id',$id)->orderBy('created_at','desc')->where('released_at','<',time())->get();
  198. $public_notice_switch = 1;//有补充公告的模式
  199. if (!empty($info)) {
  200. $view_data = [
  201. 'recruit' => $recruit,
  202. 'info' => $info,
  203. 'uid' => $uid,
  204. 'utype' => $utype,
  205. 'list' => $list,
  206. 'public_notice_switch' => $public_notice_switch,
  207. 'appoint_info' => $appoint_info
  208. ];
  209. return view('app.recruit.show')->with($view_data);
  210. } else {
  211. return back();
  212. }
  213. }
  214. }
  215. /**
  216. * 上传文件的方法
  217. * @param Request $request
  218. * @return \Illuminate\Http\JsonResponse
  219. */
  220. public function upload(Request $request)
  221. {
  222. $user = $this->getUser();
  223. if($user){
  224. $uid = $user->id;
  225. $utype = $user->utype;
  226. }else{
  227. $uid = 0;
  228. $utype = 0;
  229. }
  230. $file = $request->file('file');
  231. if ($file->isValid()) { //判断文件是否存在
  232. //获取文件的扩展名
  233. $ext = $file->getClientOriginalExtension();
  234. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  235. $res['status'] = 0;
  236. $res['msg'] = '文件格式不正确';
  237. } else {
  238. //获取文件的绝对路径
  239. $path = $file->getRealPath();
  240. $oldname = $file->getClientOriginalName();
  241. //定义文件名
  242. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  243. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  244. Storage::disk('public')->put($filename, file_get_contents($path));
  245. $res['status'] = 1;
  246. $res['filename'] = $oldname;
  247. $res['path'] = "/storage/" . $filename;
  248. $res['msg'] = '上传成功';
  249. }
  250. } else {
  251. $res['status'] = 0;
  252. $res['msg'] = '上传失败';
  253. }
  254. return response()->json($res);
  255. }
  256. /**
  257. * 查看报名人数统计
  258. * @param Request $request
  259. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  260. */
  261. public function sign_up_count(Request $request)
  262. {
  263. $user = $this->getUser();
  264. if($user){
  265. $uid = $user->id;
  266. $utype = $user->utype;
  267. }else{
  268. $uid = 0;
  269. $utype = 0;
  270. }
  271. $id = $request->input('id', 0);
  272. $refresh = $request->input('refresh', '');
  273. if (empty($id)) {
  274. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.index.list'), true, '上一页', '2');
  275. }
  276. $recruit = Recruit::find($id);
  277. if (empty($recruit)) {
  278. return redirect(route('/recruit/list'));
  279. }
  280. if(!$recruit->show_report){
  281. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.index.list'), true, '上一页', '2');
  282. }
  283. if(Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {
  284. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  285. $list = $cache_data['list'];
  286. $time = $cache_data['time'];
  287. }else{
  288. $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();
  289. if(!$list){
  290. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.index.list'), true, '上一页', '2');
  291. }
  292. foreach ($list as $k => $v){
  293. $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();
  294. $list[$k]['checking'] = $res->checking;
  295. $list[$k]['fail'] = $res->fail;
  296. $list[$k]['success'] = $res->success;
  297. }
  298. $time = date('Y-m-d H:i',time());
  299. $cache_data = [
  300. 'list' => $list,
  301. 'time' => $time
  302. ];
  303. Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);
  304. }
  305. $view_data = [
  306. 'list' => $list,
  307. 'time' => $time,
  308. 'title' => $recruit->company
  309. ];
  310. return view('app.recruit.sign_up_count')->with($view_data);
  311. }
  312. /**
  313. * 报名功能页
  314. * @param Request $request
  315. * @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
  316. */
  317. public function sign_up(Request $request)
  318. {
  319. $user = $this->getUser();
  320. if (!empty($user)) {
  321. $uid = $user->id;
  322. } else {
  323. return redirect(route('login'));
  324. }
  325. //招考id
  326. $id = $request->input('id', 0);
  327. if (!$id) {
  328. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  329. }
  330. //招考信息
  331. $recruit = Recruit::find($id);
  332. if(!$recruit['status'] && !$user->recruit_test){
  333. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  334. }
  335. if($recruit['current'] != 1 && $recruit['current'] != 2){
  336. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  337. }
  338. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  339. $time = time();
  340. $formDisabled = 0;
  341. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  342. if(!in_array($uid,[161027,59041])){
  343. if(!$appoint_info){
  344. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  345. }
  346. if($appoint_info){
  347. //如果有报名记录,先查询首次报名是什么时候
  348. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('appoint_id',$appoint_info->id)->orderBy('created_at','asc')->first();
  349. if(!$first_post){//没有记录代表只是暂存
  350. return $this->showMessage('抱歉,该项目已过报名时间或尚未开始!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  351. }
  352. // $has_late_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->where('created_at','>',$recruit['apply_end'])->first();//查找在过了报名时间后,有报名记录,且仍是审核失败的报名记录,看其是否在报名时间后是否有再次提交的记录
  353. // if($has_late_post){
  354. // $formDisabled = 1;
  355. // }else{
  356. // $formDisabled = 0;
  357. // }
  358. }
  359. }
  360. }
  361. $view_data['module'] = $forms = explode(',', $recruit['forms']);
  362. //查询报名表是否已有记录
  363. if($appoint_info){
  364. if(in_array('internship',$forms)) {
  365. //如果已有该场次的报名记录,读取录入的数据集合
  366. $user_info = $appoint_info;
  367. $user_info['sex'] = (string)$user_info['sex'];
  368. $user_info['adjust'] = (string)$user_info['adjust'];
  369. $user_info['edu_type'] = (string)$user_info['edu_type'];
  370. $user_info['family'] = json_decode($user_info['family']);
  371. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  372. if($detail){
  373. $user_info['detail'] = $detail->toArray();
  374. }else{
  375. $user_info['detail'] = [
  376. 'rewards_and_punishments' => '',
  377. 'introduce' => ''
  378. ];
  379. }
  380. if(json_decode($user_info['identification'])){
  381. $identification = json_decode($user_info['identification'],true);
  382. foreach ($identification as $k => $v){
  383. if(array_key_exists('response',$v)){
  384. $identification[$k]['url'] = $v['response']['path'];
  385. }
  386. }
  387. }else{
  388. $identification = [];
  389. }
  390. $user_info['identification'] = $identification;
  391. if(json_decode($user_info['education_certification'])){
  392. $education_certification = json_decode($user_info['education_certification'],true);
  393. foreach ($education_certification as $k => $v){
  394. if(array_key_exists('response',$v)){
  395. $education_certification[$k]['url'] = $v['response']['path'];
  396. }
  397. }
  398. }else{
  399. $education_certification = [];
  400. }
  401. $user_info['education_certification'] = $education_certification;
  402. if(json_decode($user_info['other_certification'])){
  403. $other_certification = json_decode($user_info['other_certification'],true);
  404. foreach ($other_certification as $k => $v){
  405. if(array_key_exists('response',$v)){
  406. $other_certification[$k]['url'] = $v['response']['path'];
  407. }
  408. }
  409. }else{
  410. $other_certification = [];
  411. }
  412. $user_info['other_certification'] = $other_certification;
  413. if(json_decode($user_info['chengnuoshu'])){
  414. $chengnuoshu = json_decode($user_info['chengnuoshu'],true);
  415. foreach ($chengnuoshu as $k => $v){
  416. if(array_key_exists('response',$v)){
  417. $chengnuoshu[$k]['url'] = $v['response']['path'];
  418. }
  419. }
  420. }else{
  421. $chengnuoshu = [];
  422. }
  423. $user_info['chengnuoshu'] = $chengnuoshu;
  424. if(json_decode($user_info['shixin'])){
  425. $shixin = json_decode($user_info['shixin'],true);
  426. foreach ($shixin as $k => $v){
  427. if(array_key_exists('response',$v)){
  428. $shixin[$k]['url'] = $v['response']['path'];
  429. }
  430. }
  431. }else{
  432. $shixin = [];
  433. }
  434. $user_info['shixin'] = $shixin;
  435. //获取最新的报名审核信息
  436. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  437. if($logs){
  438. $user_info['audit_log'] = $logs->log;
  439. }else{
  440. $user_info['audit_log'] = '';
  441. }
  442. }else{
  443. //如果已有该场次的报名记录,读取录入的数据集合
  444. $user_info = $appoint_info;
  445. $user_info['sex'] = (string)$user_info['sex'];
  446. $user_info['edu_type'] = (string)$user_info['edu_type'];
  447. $user_info['family'] = json_decode($user_info['family']);
  448. if(in_array('expand_special',$forms)){
  449. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$user_info['id'])->first();
  450. if($special){
  451. $material = json_decode($special['material'],true);
  452. if(is_array($material)){
  453. foreach ($material as $k => $v){
  454. if(array_key_exists('response',$v)){
  455. if(array_key_exists('path',$v['response'])){
  456. $material[$k]['url'] = $v['response']['path'];
  457. }
  458. }
  459. }
  460. }
  461. }else{
  462. $material = [];
  463. $special = [
  464. 'point_apply' => '0',
  465. 'condition' => ''
  466. ];
  467. }
  468. $user_info['special'] = [
  469. 'point_apply' => (string)$special['point_apply'],
  470. 'condition' => $special['condition'],
  471. 'material' => $material
  472. ];
  473. }
  474. if(in_array('detail',$forms)){
  475. $detail = RecruitAppointDetail::where('recruit_appoint_id',$user_info['id'])->first();
  476. if($detail){
  477. $user_info['detail'] = $detail->toArray();
  478. }else{
  479. $user_info['detail'] = [
  480. 'train' => '',
  481. 'rewards_and_punishments' => '',
  482. 'introduce' => ''
  483. ];
  484. }
  485. }
  486. //如果有身份证明模块
  487. if(in_array('identification',$forms)){
  488. if(json_decode($user_info['identification'])){
  489. $identification = json_decode($user_info['identification'],true);
  490. foreach ($identification as $k => $v){
  491. if(array_key_exists('response',$v)){
  492. if(array_key_exists('path',$v['response'])){
  493. $identification[$k]['url'] = $v['response']['path'];
  494. }
  495. }
  496. }
  497. }else{
  498. $identification = [];
  499. }
  500. $user_info['identification'] = $identification;
  501. }
  502. //如果有教育证明模块
  503. if(in_array('education_certification',$forms)){
  504. if(json_decode($user_info['education_certification'])){
  505. $education_certification = json_decode($user_info['education_certification'],true);
  506. foreach ($education_certification as $k => $v){
  507. if(array_key_exists('response',$v)){
  508. if(array_key_exists('path',$v['response'])){
  509. $education_certification[$k]['url'] = $v['response']['path'];
  510. }
  511. }
  512. }
  513. }else{
  514. $education_certification = [];
  515. }
  516. $user_info['education_certification'] = $education_certification;
  517. }
  518. //如果有其他证明模块
  519. if(in_array('other_certification',$forms)){
  520. if(json_decode($user_info['other_certification'])){
  521. $other_certification = json_decode($user_info['other_certification'],true);
  522. foreach ($other_certification as $k => $v){
  523. if(array_key_exists('response',$v)){
  524. if(array_key_exists('path',$v['response'])){
  525. $other_certification[$k]['url'] = $v['response']['path'];
  526. }
  527. }
  528. }
  529. }else{
  530. $other_certification = [];
  531. }
  532. $user_info['other_certification'] = $other_certification;
  533. }
  534. //如果有承诺书模块
  535. if(in_array('chengnuoshu',$forms)){
  536. if(json_decode($user_info['chengnuoshu'])){
  537. $chengnuoshu = json_decode($user_info['chengnuoshu'],true);
  538. foreach ($chengnuoshu as $k => $v){
  539. if(array_key_exists('response',$v)){
  540. if(array_key_exists('path',$v['response'])){
  541. $chengnuoshu[$k]['url'] = $v['response']['path'];
  542. }
  543. }
  544. }
  545. }else{
  546. $chengnuoshu = [];
  547. }
  548. $user_info['chengnuoshu'] = $chengnuoshu;
  549. }
  550. //如果有失信被执行人模块
  551. if(in_array('shixin',$forms)){
  552. if(json_decode($user_info['shixin'])){
  553. $shixin = json_decode($user_info['shixin'],true);
  554. foreach ($shixin as $k => $v){
  555. if(array_key_exists('response',$v)){
  556. if(array_key_exists('path',$v['response'])){
  557. $shixin[$k]['url'] = $v['response']['path'];
  558. }
  559. }
  560. }
  561. }else{
  562. $shixin = [];
  563. }
  564. $user_info['shixin'] = $shixin;
  565. }
  566. //获取最新的报名审核信息
  567. $logs = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',2)->orderBy('created_at','desc')->first();
  568. if($logs){
  569. $user_info['audit_log'] = $logs->log;
  570. }else{
  571. $user_info['audit_log'] = '';
  572. }
  573. //获取提交报名的次数
  574. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  575. // $post_number = $number+1;//todo
  576. }
  577. }
  578. else{
  579. //实习专场
  580. if(in_array('internship',$forms)){
  581. $user_info = json_encode([
  582. 'recruit_id' => $id,
  583. 'operation' => 1,
  584. 'realname' => '',
  585. 'sex' => '1',
  586. 'birthday' => '',
  587. 'card' => '',
  588. 'nation' => '',
  589. 'native_place' => '',
  590. 'political_affiliation' => '',
  591. 'join_time' => '',
  592. 'house_register' => '',
  593. 'education' => '',
  594. 'school' => '',
  595. 'pro' => '',
  596. 'adjust' => '',
  597. 'mobile' => '',
  598. 'email' => '',
  599. 'address' => '',
  600. 'post_id' => '',
  601. 'concat_name' => '',
  602. 'concat_mobile' => '',
  603. 'resume' => '',
  604. 'avatar' => '',
  605. 'family' => [
  606. [
  607. 'relation' => '',
  608. 'realname' => '',
  609. 'birthday' => '',
  610. 'political_affiliation' => '',
  611. 'work' => ''
  612. ]
  613. ],
  614. 'detail' => [
  615. 'rewards_and_punishments' => '',
  616. 'introduce' => ''
  617. ],
  618. 'identification' => [],
  619. 'education_certification' => [],
  620. 'other_certification' => [],
  621. 'chengnuoshu' => [],
  622. 'shixin' => []
  623. ]);
  624. }else{
  625. //如果没有,结合基础数据及模块表单信息,制作数据对象
  626. $user_info = RecruitAppointBasic::where('uid',$uid)->first();
  627. if(!$user_info){
  628. //没有基础信息跳转完善route('person.recruitInfo')
  629. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo',array('recruit_id',$id)), true, '上一页', '3');
  630. }
  631. $user_info['sex'] = (string)$user_info['sex'];
  632. $user_info['edu_type'] = (string)$user_info['edu_type'];
  633. $user_info['family'] = json_decode($user_info['family']);
  634. if(in_array('expand_special',$forms)){
  635. $user_info['special'] = [
  636. 'point_apply' => '0',
  637. 'condition' => '',
  638. 'material' => []
  639. ];
  640. }
  641. if(in_array('detail',$forms)){
  642. $user_info['detail'] = [
  643. 'train' => '',
  644. 'rewards_and_punishments' => '',
  645. 'introduce' => ''
  646. ];
  647. }
  648. if(in_array('identification',$forms)){
  649. $user_info['identification'] = [];
  650. }
  651. if(in_array('education_certification',$forms)){
  652. $user_info['education_certification'] = [];
  653. }
  654. if(in_array('other_certification',$forms)){
  655. $user_info['other_certification'] = [];
  656. }
  657. if(in_array('chengnuoshu',$forms)){
  658. $user_info['chengnuoshu'] = [];
  659. }
  660. if(in_array('shixin',$forms)){
  661. $user_info['shixin'] = [];
  662. }
  663. $user_info['recruit_id'] = $id;
  664. $user_info['operation'] = 1;
  665. }
  666. }
  667. //招考岗位
  668. $where_post[] = ['recruit_id', '=', $id];
  669. $where_post[] = ['status', '=', 1];
  670. $recruit_post = RecruitPost::where($where_post)->get();
  671. $post = [];
  672. $post_limit = [];
  673. foreach ($recruit_post as $value){
  674. $item = [
  675. 'value' => $value['id'],
  676. 'label' => $value['code'] . " " . $value['name']
  677. ];
  678. $post_limit[$value['id']] = json_decode($value['limit']);
  679. array_push($post,$item);
  680. }
  681. $view_data['appoint_info'] = $user_info;
  682. $view_data['post'] = json_encode($post);
  683. // $view_data['post_number'] = $post_number;
  684. // $view_data['post_times'] = $recruit['post_times'];
  685. $view_data['post_limit'] = json_encode($post_limit);
  686. $view_data['formDisable'] = $formDisabled;
  687. $view_data['title'] = $recruit->company;
  688. $view_data['special_condition_type'] = $recruit->special_condition_type;
  689. $view_data['special_condition_value'] = explode(',',$recruit->special_condition_value);
  690. return view('app.recruit.sign_up',$view_data);
  691. }
  692. public function preview(Request $request)
  693. {
  694. $modules = $request->input('modules');
  695. $view_data['module'] = $forms = explode(',', $modules);
  696. return view('app.recruit.preview',$view_data);
  697. }
  698. /**
  699. * 提交报名的处理程序
  700. * @param Request $request
  701. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  702. */
  703. public function saveSignUp(Request $request)
  704. {
  705. $user = $this->getUser();
  706. if (!empty($user)) {
  707. $uid = $user->id;
  708. } else {
  709. return redirect(route('login'));
  710. }
  711. $recruit_id = $request->input('recruit_id', 0);
  712. if (!$recruit_id) {
  713. return response()->json(['status' => 0,'msg' => '请选择项目!']);
  714. }
  715. $recruit = Recruit::find($recruit_id);
  716. if(!$recruit['status']){
  717. return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  718. }
  719. if($recruit['current'] != 1 && $recruit['current'] != 2){
  720. return response()->json(['status' => 0,'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  721. }
  722. $card = $request->input('card');
  723. $appointinfo_exist = RecruitAppointInfo::where('card',$card)->where('uid','<>',$uid)->where('recruit_id',$recruit_id)->first();
  724. //兆丰建设两场公告二而一例外
  725. if($recruit_id == 25 || $recruit_id == 26){
  726. $special = RecruitAppointInfo::where('card',$card)->where('uid','<>',$uid)->whereIn('recruit_id',[25,26])->first();
  727. $appointinfo_exist = $appointinfo_exist & $special;
  728. }
  729. if($appointinfo_exist){
  730. return response()->json(['status' => 0,'msg' => '您的证件已有其他账号的报名记录,请检查!']);
  731. }
  732. $time = time();
  733. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  734. if(($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)){//过了招考时间
  735. if(!$appoint_info){
  736. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  737. }
  738. if(($time < strtotime($recruit['audit_start']) || strtotime($recruit['audit_end']) < $time)){//过了审核时间
  739. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过审核时间,无法继续报名!']);
  740. }
  741. //如果有报名记录,先查询首次报名是什么时候
  742. $first_post = RecruitAppointLog::where('type',3)->where('uid',$uid)->orderBy('created_at','asc')->first();
  743. if(!$first_post){//没有记录代表只是暂存
  744. return response()->json(['status' => 0,'msg' => '抱歉,该项目已过报名时间!']);
  745. }
  746. }
  747. $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');
  748. $post_info = RecruitPost::where('id',$data['post_id'])->where('recruit_id',$recruit_id)->first();
  749. if(!$post_info['status'] || $post_info['deleted_at'] != null){
  750. return response()->json(['status' => 0,'msg' => '该岗位已失效']);
  751. }
  752. //获取操作符,是暂存还是提交
  753. $operation = $request->input('operation');
  754. if($operation == 1){
  755. $data['audit'] = 0;//暂存
  756. }else{
  757. //基础信息的检查
  758. $rules = [
  759. 'realname' => 'required',
  760. 'sex' => 'required',
  761. 'birthday' => 'required',
  762. 'avatar' => 'required',
  763. 'nation' => 'required',
  764. 'native_place' => 'required',
  765. 'political_affiliation' => 'required',
  766. 'post_id' => 'required',
  767. 'house_register' => 'required',
  768. //'edu_type' => 'required',
  769. 'education' => 'required',
  770. 'school' => 'required',
  771. 'address' => 'required',
  772. 'mobile' => 'required',
  773. 'email' => 'required',
  774. 'card' => 'required',
  775. 'concat_name' => 'required',
  776. 'concat_mobile' => 'required',
  777. 'resume' => 'required'
  778. ];
  779. $messages = [
  780. 'realname.required' => '请填写姓名',
  781. 'sex.required' => '请填写性别',
  782. 'birthday.required' => '请填写出生日期',
  783. 'avatar.required' => '请上传彩色免冠照',
  784. 'nation.required' => '请填写民族',
  785. 'native_place.required' => '请填写籍贯',
  786. 'political_affiliation.required' => '请选择政治面貌',
  787. 'post_id.required' => '请选择报名岗位',
  788. 'house_register.required' => '请填写户籍所在地',
  789. //'edu_type.required' => '请选择教育类型',
  790. 'education.required' => '请输入学历',
  791. 'school.required' => '请输入毕业院校',
  792. 'address.required' => '请填写通信地址',
  793. 'mobile.required' => '请填写手机号码',
  794. 'email.required' => '请填写电子邮箱',
  795. 'card.required' => '请填写身份证号码',
  796. 'resume.required' => '请填写个人简历',
  797. 'concat_name.required' => '请填写联系人姓名',
  798. 'concat_mobile.required' => '请填写联系人手机号码'
  799. ];
  800. $create_data = $request->all();
  801. $validator = Validator::make($create_data,$rules,$messages);
  802. if ($validator->fails()) {
  803. $msg = $validator->errors()->all();
  804. return response()->json(['status' => 0,'msg' => $msg[0]]);
  805. }
  806. $data['audit'] = 1;//提交
  807. }
  808. //身份证判断出生日期和性别
  809. $year = substr($data['card'],6,4);
  810. $month = substr($data['card'],10,2);
  811. $day = substr($data['card'],12,2);
  812. if($year.'-'.$month.'-'.$day != $data['birthday']){
  813. $data['birthday'] = $year.'-'.$month.'-'.$day;
  814. }
  815. if(intval(substr($data['card'],16,1)) % 2 == 0){
  816. $data['sex'] = 0;
  817. }else{
  818. $data['sex'] = 1;
  819. }
  820. if(!empty($post_info['limit']) && json_decode($post_info['limit'])){
  821. //岗位限制条件的判断
  822. $post_limit = json_decode($post_info['limit'],true);
  823. if(is_array($post_limit)){
  824. foreach($post_limit as $k => $v){
  825. if($k == 'birthday'){
  826. $value = str_replace('-','',$data[$k]);
  827. }else{
  828. $value = $data[$k];
  829. }
  830. switch ($v['op']){
  831. case '=':
  832. if($value != $v['value']){
  833. return response()->json(['status' => 0,'msg' => $v['msg']]);
  834. }
  835. break;
  836. case '>':
  837. if($value <= $v['value']){
  838. return response()->json(['status' => 0,'msg' => $v['msg']]);
  839. }
  840. break;
  841. case '>=':
  842. if($value < $v['value']){
  843. return response()->json(['status' => 0,'msg' => $v['msg']]);
  844. }
  845. break;
  846. case '<':
  847. if($value >= $v['value']){
  848. return response()->json(['status' => 0,'msg' => $v['msg']]);
  849. }
  850. break;
  851. case '<=':
  852. if($value > $v['value']){
  853. return response()->json(['status' => 0,'msg' => $v['msg']]);
  854. }
  855. break;
  856. case '!=':
  857. if($value == $v['value']){
  858. return response()->json(['status' => 0,'msg' => $v['msg']]);
  859. }
  860. break;
  861. case 'like':
  862. if(strpos($value,$v['value']) === false){
  863. return response()->json(['status' => 0,'msg' => $v['msg']]);
  864. }
  865. break;
  866. case 'in':
  867. if(strpos($v['value'],$value) === false){
  868. return response()->json(['status' => 0,'msg' => $v['msg']]);
  869. }
  870. break;
  871. }
  872. }
  873. }
  874. }
  875. //前置审核 判断完成,先将数据入报名信息基础表
  876. //解析家庭成员数据
  877. $familys = $request->input('family');
  878. $family = [];
  879. if(is_array($familys)){
  880. foreach ($familys as $value){
  881. $item = [
  882. 'relation' => $value['relation'],
  883. 'realname' => $value['realname'],
  884. 'birthday' => $value['birthday'],
  885. 'political_affiliation' => $value['political_affiliation'],
  886. 'work' => $value['work']
  887. ];
  888. array_push($family,$item);
  889. }
  890. }
  891. $data['family'] = json_encode($family);
  892. if($appoint_info){
  893. //如果已有报名记录,进入修改阶段的处理流程
  894. DB::beginTransaction();
  895. try{
  896. RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->update($data);
  897. //分模块解析数据
  898. $forms = explode(',', $recruit['forms']);
  899. //如果有加分模块
  900. if(in_array('expand_special',$forms)){
  901. $special = $request->input('special');
  902. if($special['point_apply']){
  903. //删除掉没有成功返回路径的图片
  904. if(is_array($special['material'])){
  905. foreach ($special['material'] as $k => $v){
  906. if(!array_key_exists('response',$v)){
  907. unset($special['material'][$k]);
  908. }
  909. }
  910. }
  911. $special['material'] = json_encode($special['material']);
  912. }else{
  913. $special['condition'] = '';
  914. $special['material'] = json_encode([]);
  915. }
  916. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
  917. if($hasRecord){
  918. RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->update($special);
  919. }else{
  920. $special['recruit_appoint_id'] = $appoint_info->id;
  921. RecruitAppointExpandSpecial::create($special);
  922. }
  923. }
  924. //如果有详情模块
  925. if(in_array('detail',$forms) || in_array('internship',$forms)){
  926. $detail = $request->input('detail');
  927. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->first();
  928. if($hasRecord){
  929. RecruitAppointDetail::where('recruit_appoint_id',$appoint_info->id)->update($detail);
  930. }else{
  931. $detail['recruit_appoint_id'] = $appoint_info->id;
  932. RecruitAppointDetail::create($detail);
  933. }
  934. }
  935. //如果有身份证明模块
  936. if(in_array('identification',$forms) || in_array('internship',$forms)){
  937. $identification = $request->input('identification');
  938. if(is_array($identification)){
  939. //删除掉没有成功返回路径的图片
  940. foreach ($identification as $k => $v){
  941. if(!array_key_exists('response',$v)){
  942. unset($identification[$k]);
  943. }
  944. }
  945. }
  946. $appoint_info->identification = json_encode($identification);
  947. $appoint_info->save();
  948. }
  949. //如果有教育证明模块
  950. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  951. $education_certification = $request->input('education_certification');
  952. if(is_array($education_certification)){
  953. //删除掉没有成功返回路径的图片
  954. foreach ($education_certification as $k => $v){
  955. if(!array_key_exists('response',$v)){
  956. unset($education_certification[$k]);
  957. }
  958. }
  959. }
  960. $appoint_info->education_certification = json_encode($education_certification);
  961. $appoint_info->save();
  962. }
  963. //如果有其他证明模块
  964. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  965. $other_certification = $request->input('other_certification');
  966. if(is_array($other_certification)){
  967. //删除掉没有成功返回路径的图片
  968. foreach ($other_certification as $k => $v){
  969. if(!array_key_exists('response',$v)){
  970. unset($other_certification[$k]);
  971. }
  972. }
  973. }
  974. if($other_certification){
  975. $appoint_info->other_certification = json_encode($other_certification);
  976. $appoint_info->save();
  977. }
  978. }
  979. //如果有承诺书模块
  980. if(in_array('chengnuoshu',$forms)){
  981. $chengnuoshu = $request->input('chengnuoshu');
  982. if(is_array($chengnuoshu)){
  983. //删除掉没有成功返回路径的图片
  984. foreach ($chengnuoshu as $k => $v){
  985. if(!array_key_exists('response',$v)){
  986. unset($chengnuoshu[$k]);
  987. }
  988. }
  989. }
  990. if($chengnuoshu){
  991. $appoint_info->chengnuoshu = json_encode($chengnuoshu);
  992. $appoint_info->save();
  993. }
  994. }
  995. //如果有失信被执行人模块
  996. if(in_array('shixin',$forms)){
  997. $shixin = $request->input('shixin');
  998. if(is_array($shixin)){
  999. //删除掉没有成功返回路径的图片
  1000. foreach ($shixin as $k => $v){
  1001. if(!array_key_exists('response',$v)){
  1002. unset($shixin[$k]);
  1003. }
  1004. }
  1005. }
  1006. if($shixin){
  1007. $appoint_info->shixin = json_encode($shixin);
  1008. $appoint_info->save();
  1009. }
  1010. }
  1011. DB::commit();
  1012. if($operation == 2){
  1013. $log = [
  1014. 'type' => 3,
  1015. 'appoint_id'=> $appoint_info->id,
  1016. 'uid' => $uid,
  1017. 'log' => '用户提交报名'
  1018. ];
  1019. RecruitAppointLog::create($log);
  1020. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id];
  1021. }else{
  1022. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  1023. }
  1024. } catch (\Exception $e){
  1025. DB::rollback();
  1026. return ['status' => 0, 'msg' => $e->getMessage()];
  1027. }
  1028. }else{
  1029. //没有报名记录,进入增加阶段的处理流程
  1030. DB::beginTransaction();
  1031. try{
  1032. //20220726增加地区undefined选项处理
  1033. if($index = stripos($data['native_place'],',undefined')){
  1034. $data['native_place'] = substr($data['native_place'],0,$index);
  1035. }
  1036. if($index = stripos($data['house_register'],',undefined')){
  1037. $data['house_register'] = substr($data['house_register'],0,$index);
  1038. }
  1039. $data['uid'] = $uid;
  1040. $data['recruit_id'] = $recruit_id;
  1041. $result = RecruitAppointInfo::create($data);
  1042. //分模块解析数据
  1043. $forms = explode(',', $recruit['forms']);
  1044. //如果有加分模块
  1045. if(in_array('expand_special',$forms)){
  1046. $special = $request->input('special');
  1047. if($special['point_apply']){
  1048. if(is_array($special['material'])){
  1049. //删除掉没有成功返回路径的图片
  1050. foreach ($special['material'] as $k => $v){
  1051. if(!array_key_exists('response',$v)){
  1052. unset($special['material'][$k]);
  1053. }
  1054. }
  1055. }
  1056. $special['material'] = json_encode($special['material']);
  1057. }
  1058. $special['recruit_appoint_id'] = $result->id;
  1059. RecruitAppointExpandSpecial::create($special);
  1060. }
  1061. //如果有详情模块
  1062. if(in_array('detail',$forms) || in_array('internship',$forms)){
  1063. $detail = $request->input('detail');
  1064. $detail['recruit_appoint_id'] = $result->id;
  1065. RecruitAppointDetail::create($detail);
  1066. }
  1067. //如果有身份证明模块
  1068. if(in_array('identification',$forms) || in_array('internship',$forms)){
  1069. $identification = $request->input('identification');
  1070. if(is_array($identification)){
  1071. //删除掉没有成功返回路径的图片
  1072. foreach ($identification as $k => $v){
  1073. if(!array_key_exists('response',$v)){
  1074. unset($identification[$k]);
  1075. }
  1076. }
  1077. }
  1078. $result->identification = json_encode($identification);
  1079. $result->save();
  1080. }
  1081. //如果有教育证明模块
  1082. if(in_array('education_certification',$forms) || in_array('internship',$forms)){
  1083. $education_certification = $request->input('education_certification');
  1084. if(is_array($education_certification)){
  1085. //删除掉没有成功返回路径的图片
  1086. foreach ($education_certification as $k => $v){
  1087. if(!array_key_exists('response',$v)){
  1088. unset($education_certification[$k]);
  1089. }
  1090. }
  1091. }
  1092. $result->education_certification = json_encode($education_certification);
  1093. $result->save();
  1094. }
  1095. //如果有其他证明模块
  1096. if(in_array('other_certification',$forms) || in_array('internship',$forms)){
  1097. $other_certification = $request->input('other_certification');
  1098. if($other_certification){
  1099. if(is_array($other_certification)){
  1100. //删除掉没有成功返回路径的图片
  1101. foreach ($other_certification as $k => $v){
  1102. if(!array_key_exists('response',$v)){
  1103. unset($other_certification[$k]);
  1104. }
  1105. }
  1106. }
  1107. $result->other_certification = json_encode($other_certification);
  1108. $result->save();
  1109. }
  1110. }
  1111. //如果有承诺书模块
  1112. if(in_array('chengnuoshu',$forms)){
  1113. $chengnuoshu = $request->input('chengnuoshu');
  1114. if($chengnuoshu){
  1115. if(is_array($chengnuoshu)){
  1116. //删除掉没有成功返回路径的图片
  1117. foreach ($chengnuoshu as $k => $v){
  1118. if(!array_key_exists('response',$v)){
  1119. unset($chengnuoshu[$k]);
  1120. }
  1121. }
  1122. }
  1123. $result->chengnuoshu = json_encode($chengnuoshu);
  1124. $result->save();
  1125. }
  1126. }
  1127. //如果有失信被执行人模块
  1128. if(in_array('shixin',$forms)){
  1129. $shixin = $request->input('shixin');
  1130. if($shixin){
  1131. if(is_array($shixin)){
  1132. //删除掉没有成功返回路径的图片
  1133. foreach ($shixin as $k => $v){
  1134. if(!array_key_exists('response',$v)){
  1135. unset($shixin[$k]);
  1136. }
  1137. }
  1138. }
  1139. $result->shixin = json_encode($shixin);
  1140. $result->save();
  1141. }
  1142. }
  1143. DB::commit();
  1144. if($operation == 2){
  1145. $log = [
  1146. 'type' => 3,
  1147. 'appoint_id'=> $result->id,
  1148. 'uid' => $uid,
  1149. 'log' => '用户首次提交报名'
  1150. ];
  1151. RecruitAppointLog::create($log);
  1152. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  1153. }else{
  1154. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  1155. }
  1156. } catch (\Exception $e){
  1157. DB::rollback();
  1158. return ['status' => 0, 'msg' => $e->getMessage()];
  1159. }
  1160. }
  1161. }
  1162. /**
  1163. * 获得当前登录的用户
  1164. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  1165. */
  1166. public function getUser()
  1167. {
  1168. if (auth('web-member')->check()) {
  1169. $user = auth('web-member')->user();
  1170. } else {
  1171. $user = null;
  1172. }
  1173. return $user;
  1174. }
  1175. /**
  1176. * 检查用户基本信息
  1177. * @return array
  1178. */
  1179. public function checkUserBasicInfo()
  1180. {
  1181. $user = $this->getUser();
  1182. if (!empty($user)) {
  1183. $uid = $user->id;
  1184. } else {
  1185. $arr = ['status' => 401, 'msg'=>'请登录!'];
  1186. return $arr;
  1187. }
  1188. $info = RecruitAppointBasic::where('uid',$uid)->first();
  1189. if (empty($info)){
  1190. $arr = ['status'=>401,'msg'=>'请先完善招考基本信息','url'=> route('recruit.recruitInfo')];
  1191. return $arr;
  1192. }
  1193. return ['status' => 200, 'msg' => ''];
  1194. }
  1195. /**
  1196. * 个人中心招考页面
  1197. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1198. */
  1199. public function person_recruit()
  1200. {
  1201. $user = auth('web-member')->user();
  1202. $list = RecruitAppointInfo::where('uid',$user->id)
  1203. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1204. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1205. ->select('recruit.name as recruit_name','recruit_appoint_info.*','recruit_post.code','recruit_post.name')
  1206. ->get();
  1207. return view('app.person.recruit')->with(['list' => $list,'total' => count($list)]);
  1208. }
  1209. /**
  1210. * 招考信息基础页
  1211. * @param Request $request
  1212. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1213. */
  1214. public function recruit_info(Request $request)
  1215. {
  1216. $user = auth('web-member')->user();
  1217. if (!empty($user)) {
  1218. $uid = $user->id;
  1219. } else {
  1220. return redirect(route('login'));
  1221. }
  1222. $info = RecruitAppointBasic::where('uid',$user->id)->first();
  1223. if(!$info){
  1224. $info = [
  1225. 'realname' => '',
  1226. 'sex' => '0',
  1227. 'birthday' => '',
  1228. 'avatar' => '',
  1229. 'nation' => '',
  1230. 'native_place' => '',
  1231. 'political_affiliation' => '',
  1232. 'titles' => '',
  1233. 'work' => '',
  1234. 'house_register' => '',
  1235. 'join_time' => '',
  1236. 'edu_type' => '',
  1237. 'education' => '',
  1238. 'school' => '',
  1239. 'degree' => '',
  1240. 'pro' => '',
  1241. 'address' => '',
  1242. 'card' => '',
  1243. 'mobile' => '',
  1244. 'email' => '',
  1245. 'concat_name' => '',
  1246. 'concat_mobile' => '',
  1247. 'resume' => '',
  1248. 'family' => [
  1249. [
  1250. 'relation' => '',
  1251. 'realname' => '',
  1252. 'birthday' => '',
  1253. 'political_affiliation' => '',
  1254. 'work' => ''
  1255. ]
  1256. ],
  1257. 'is_push' => '1'
  1258. ];
  1259. }else{
  1260. $info->sex = (string)$info->sex;
  1261. $info->edu_type = (string)$info->edu_type;
  1262. $info->is_push = (string)$info->is_push;
  1263. $info->family = empty($info->family) ? [[
  1264. 'relation' => '',
  1265. 'realname' => '',
  1266. 'birthday' => '',
  1267. 'political_affiliation' => '',
  1268. 'work' => ''
  1269. ]] : json_decode($info->family);
  1270. }
  1271. $recruit_id = $request->input('recruit_id',0);
  1272. return view('app.person.recruit_info',[
  1273. 'info' => json_encode($info),
  1274. 'recruit_id'=> $recruit_id
  1275. ]);
  1276. }
  1277. /**
  1278. * 保存招考信息
  1279. * @param RecruitValidatorRequest $request
  1280. * @return \Illuminate\Http\JsonResponse
  1281. */
  1282. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1283. {
  1284. $user = auth('web-member')->user();
  1285. $basic = RecruitAppointBasic::where('uid',$user->id)->first();
  1286. $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');
  1287. if(count($data['family']) > 0){
  1288. $data['family'] = json_encode($data['family']);
  1289. }
  1290. if($basic){
  1291. //更新基础信息
  1292. $res = RecruitAppointBasic::where('uid',$user->id)->update($data);
  1293. if (!$res) {
  1294. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1295. }else{
  1296. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1297. }
  1298. }else{
  1299. //新增基础信息
  1300. $data['uid'] = $user->id;
  1301. $res = RecruitAppointBasic::create($data);
  1302. if (!$res) {
  1303. return response()->json(['status'=>0,'msg'=>'保存失败,请联系客服']);
  1304. }else{
  1305. return response()->json(['status'=>1,'msg'=>'个人基础信息保存成功,快去报名吧!']);
  1306. }
  1307. }
  1308. }
  1309. /**
  1310. * 笔试准考证
  1311. * @param Request $request
  1312. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1313. */
  1314. public function pen_ticket(Request $request)
  1315. {
  1316. $user = $this->getUser();
  1317. if (!empty($user)) {
  1318. $uid = $user->id;
  1319. } else {
  1320. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1321. }
  1322. $recruit_id = $request->input('recruit_id');
  1323. $recruit = Recruit::where('id',$recruit_id)->first();
  1324. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1325. if($appoint_info){
  1326. $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
  1327. if($pen_ticket){
  1328. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1329. if((!$health || $health->h_status == 0) && $recruit->pen_epidemic){
  1330. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1331. }
  1332. $time = time();
  1333. if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
  1334. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1335. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1336. $name = $recruit->name_en;
  1337. $date = date("Y-m-d",strtotime($recruit->created_at));
  1338. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1339. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1340. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1341. if(file_exists($file)){
  1342. header('Content-Description: File Transfer');
  1343. header('Content-Type: application/octet-stream');
  1344. header('Content-Disposition: attachment; filename='.basename($file));
  1345. header('Content-Transfer-Encoding: binary');
  1346. header('Expires: 0');
  1347. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1348. header('Pragma: public');
  1349. header('Content-Length: ' . filesize($file));
  1350. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1351. flush();
  1352. readfile($file);
  1353. }
  1354. }else{
  1355. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1356. }
  1357. }else{
  1358. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1359. }
  1360. }else{
  1361. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1362. }
  1363. }
  1364. /**
  1365. * 审核准考证
  1366. * @param Request $request
  1367. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1368. */
  1369. public function check_ticket(Request $request)
  1370. {
  1371. $user = $this->getUser();
  1372. if (!empty($user)) {
  1373. $uid = $user->id;
  1374. } else {
  1375. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1376. }
  1377. $recruit_id = $request->input('recruit_id');
  1378. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1379. if($appoint_info){
  1380. $check_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',2)->first();
  1381. if($check_ticket){
  1382. $time = time();
  1383. if(strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time){
  1384. RecruitTicket::where('appoint_id',$appoint_info->id)->update(['ex_status' => 1]);
  1385. $recruit = Recruit::where('id',$recruit_id)->first();
  1386. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1387. $name = $recruit->name_en;
  1388. $date = date("Y-m-d",strtotime($recruit->created_at));
  1389. $filename = date("Y-m-18",time()) . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1390. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/check/" . $filename . '.pdf';
  1391. if(file_exists($file)){
  1392. header('Content-Description: File Transfer');
  1393. header('Content-Type: application/octet-stream');
  1394. header('Content-Disposition: attachment; filename='.basename($file));
  1395. header('Content-Transfer-Encoding: binary');
  1396. header('Expires: 0');
  1397. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1398. header('Pragma: public');
  1399. header('Content-Length: ' . filesize($file));
  1400. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1401. flush();
  1402. readfile($file);
  1403. }
  1404. }else{
  1405. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1406. }
  1407. }else{
  1408. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1409. }
  1410. }else{
  1411. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1412. }
  1413. }
  1414. /**
  1415. * 面试准考证
  1416. * @param Request $request
  1417. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1418. */
  1419. public function face_ticket(Request $request)
  1420. {
  1421. $user = $this->getUser();
  1422. if (!empty($user)) {
  1423. $uid = $user->id;
  1424. } else {
  1425. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1426. }
  1427. $recruit_id = $request->input('recruit_id');
  1428. $recruit = Recruit::where('id',$recruit_id)->first();
  1429. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1430. if($appoint_info){
  1431. $face_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',3)->first();
  1432. if($face_ticket){
  1433. $health = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
  1434. if((!$health || $health->h_status == 0) && $recruit->pen_epidemic){
  1435. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1436. }$time = time();
  1437. if(strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time){
  1438. RecruitTicket::where('id',$face_ticket->id)->update(['ex_status' => 1]);
  1439. $recruit = Recruit::where('id',$recruit_id)->first();
  1440. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1441. $name = $recruit->name_en;
  1442. $date = date("Y-m-d",strtotime($recruit->created_at));
  1443. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1444. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1445. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1446. if(file_exists($file)){
  1447. header('Content-Description: File Transfer');
  1448. header('Content-Type: application/octet-stream');
  1449. header('Content-Disposition: attachment; filename='.basename($file));
  1450. header('Content-Transfer-Encoding: binary');
  1451. header('Expires: 0');
  1452. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1453. header('Pragma: public');
  1454. header('Content-Length: ' . filesize($file));
  1455. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1456. flush();
  1457. readfile($file);
  1458. }
  1459. }else{
  1460. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1461. }
  1462. }else{
  1463. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1464. }
  1465. }else{
  1466. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1467. }
  1468. }
  1469. /**
  1470. * 复试准考证
  1471. * @param Request $request
  1472. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1473. */
  1474. public function reexamine_ticket(Request $request)
  1475. {
  1476. $user = $this->getUser();
  1477. if (!empty($user)) {
  1478. $uid = $user->id;
  1479. } else {
  1480. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1481. }
  1482. $recruit_id = $request->input('recruit_id');
  1483. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  1484. if($appoint_info){
  1485. $reexamine_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',4)->first();
  1486. if($reexamine_ticket){
  1487. $time = time();
  1488. if(strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time){
  1489. RecruitTicket::where('id',$reexamine_ticket->id)->update(['ex_status' => 1]);
  1490. $recruit = Recruit::where('id',$recruit_id)->first();
  1491. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1492. $name = $recruit->name_en;
  1493. $date = date("Y-m-d",strtotime($recruit->created_at));
  1494. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1495. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1496. if(file_exists($file)){
  1497. header('Content-Description: File Transfer');
  1498. header('Content-Type: application/octet-stream');
  1499. header('Content-Disposition: attachment; filename='.basename($file));
  1500. header('Content-Transfer-Encoding: binary');
  1501. header('Expires: 0');
  1502. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1503. header('Pragma: public');
  1504. header('Content-Length: ' . filesize($file));
  1505. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1506. flush();
  1507. readfile($file);
  1508. }
  1509. }else{
  1510. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1511. }
  1512. }else{
  1513. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1514. }
  1515. }else{
  1516. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1517. }
  1518. }
  1519. /**
  1520. * 材料补登
  1521. * @param Request $request
  1522. */
  1523. public function material_supplement(Request $request)
  1524. {
  1525. $user = $this->getUser();
  1526. if (!empty($user)) {
  1527. $uid = $user->id;
  1528. } else {
  1529. return redirect(route('login'));
  1530. }
  1531. //招考id
  1532. $id = $request->input('id', 0);
  1533. if (!$id) {
  1534. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1535. }
  1536. $recruit = Recruit::find($id);
  1537. if(!$recruit['status'] && !$user->recruit_test){
  1538. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1539. }
  1540. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1541. if(!$appoint_info){
  1542. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1543. }
  1544. if($appoint_info->pen_audit != 1){
  1545. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1546. }
  1547. $limit_time = 1662543000;
  1548. $time = time();
  1549. if( $time > $limit_time){
  1550. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1551. }
  1552. $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->where('type','supplement')->first();
  1553. if(!$info){
  1554. $info = [
  1555. 'appoint_id' => $appoint_info->id,
  1556. 'identification' => '',
  1557. 'household_register' => '',
  1558. 'education_certification' => '',
  1559. //'family_planning' => '',
  1560. 'manage' => '',
  1561. 'status' => 3
  1562. ];
  1563. }else{
  1564. $info = $info->toArray();
  1565. if(json_decode($info['identification'])){
  1566. $identification = json_decode($info['identification'],true);
  1567. foreach ($identification as $k => $v){
  1568. if(array_key_exists('response',$v)){
  1569. $identification[$k]['url'] = $v['response']['path'];
  1570. }
  1571. }
  1572. }else{
  1573. $identification = [];
  1574. }
  1575. $info['identification'] = $identification;
  1576. if(json_decode($info['household_register'])){
  1577. $household_register = json_decode($info['household_register'],true);
  1578. foreach ($household_register as $k => $v){
  1579. if(array_key_exists('response',$v)){
  1580. $household_register[$k]['url'] = $v['response']['path'];
  1581. }
  1582. }
  1583. }else{
  1584. $household_register = [];
  1585. }
  1586. $info['household_register'] = $household_register;
  1587. if(json_decode($info['education_certification'])){
  1588. $education_certification = json_decode($info['education_certification'],true);
  1589. foreach ($education_certification as $k => $v){
  1590. if(array_key_exists('response',$v)){
  1591. $education_certification[$k]['url'] = $v['response']['path'];
  1592. }
  1593. }
  1594. }else{
  1595. $education_certification = [];
  1596. }
  1597. $info['education_certification'] = $education_certification;
  1598. if(json_decode($info['family_planning'])){
  1599. $family_planning = json_decode($info['family_planning'],true);
  1600. foreach ($family_planning as $k => $v){
  1601. if(array_key_exists('response',$v)){
  1602. $family_planning[$k]['url'] = $v['response']['path'];
  1603. }
  1604. }
  1605. }else{
  1606. $family_planning = [];
  1607. }
  1608. $info['family_planning'] = $family_planning;
  1609. if(json_decode($info['manage'])){
  1610. $manage = json_decode($info['manage'],true);
  1611. foreach ($manage as $k => $v){
  1612. if(array_key_exists('response',$v)){
  1613. $manage[$k]['url'] = $v['response']['path'];
  1614. }
  1615. }
  1616. }else{
  1617. $manage = [];
  1618. }
  1619. $info['manage'] = $manage;
  1620. }
  1621. $view_data['info'] = json_encode($info);
  1622. $view_data['title'] = $recruit->company;
  1623. return view('app.recruit.supplement',$view_data);
  1624. }
  1625. /**
  1626. * 健康信息登记
  1627. * @param Request $request
  1628. */
  1629. public function health_info(Request $request)
  1630. {
  1631. $user = $this->getUser();
  1632. if (!empty($user)) {
  1633. $uid = $user->id;
  1634. } else {
  1635. return redirect(route('login'));
  1636. }
  1637. //招考id
  1638. $id = $request->input('id', 0);
  1639. if (!$id) {
  1640. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1641. }
  1642. $recruit = Recruit::find($id);
  1643. if(!$recruit['status'] && !$user->recruit_test){
  1644. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1645. }
  1646. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  1647. if(!$appoint_info){
  1648. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1649. }
  1650. if($appoint_info->audit != 3){
  1651. return $this->showMessage('抱歉,您无需登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1652. }
  1653. $time = time();
  1654. $type = $request->input('type',null);
  1655. $where = [];
  1656. if($type){
  1657. switch ($type){
  1658. case 'pen':
  1659. $start = strtotime($recruit->pen_health_start);
  1660. $end = strtotime($recruit->pen_health_end);
  1661. break;
  1662. case 'computer':
  1663. $start = strtotime($recruit->computer_health_start);
  1664. $end = strtotime($recruit->computer_health_end);
  1665. break;
  1666. case 'face':
  1667. $start = strtotime($recruit->face_health_start);
  1668. $end = strtotime($recruit->face_health_end);
  1669. break;
  1670. case 'reexamine':
  1671. $start = strtotime($recruit->reexamine_health_start);
  1672. $end = strtotime($recruit->reexamine_health_end);
  1673. break;
  1674. default:
  1675. $start = strtotime($recruit->supplement_start);
  1676. $end = strtotime($recruit->supplement_end);
  1677. break;
  1678. }
  1679. $where[] = ['type', '=', $type];
  1680. }else{
  1681. $start = strtotime($recruit->supplement_start);
  1682. $end = strtotime($recruit->supplement_end);
  1683. }
  1684. if($time > $end || $time < $start){
  1685. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  1686. }
  1687. $where[] = ['appoint_id', '=', $appoint_info->id];
  1688. $info = RecruitSupplement::where($where)->first();
  1689. if(!$info){
  1690. $info = [
  1691. 'appoint_id' => $appoint_info->id,
  1692. 'health_code' => '',
  1693. 'trip_code' => '',
  1694. 'type' => $type
  1695. ];
  1696. }else{
  1697. $info = $info->toArray();
  1698. if(json_decode($info['health_code'])){
  1699. $health_code = json_decode($info['health_code'],true);
  1700. foreach ($health_code as $k => $v){
  1701. if(array_key_exists('response',$v)){
  1702. $health_code[$k]['url'] = $v['response']['path'];
  1703. }
  1704. }
  1705. }else{
  1706. $health_code = [];
  1707. }
  1708. $info['health_code'] = $health_code;
  1709. if(json_decode($info['trip_code'])){
  1710. $trip_code = json_decode($info['trip_code'],true);
  1711. foreach ($trip_code as $k => $v){
  1712. if(array_key_exists('response',$v)){
  1713. $trip_code[$k]['url'] = $v['response']['path'];
  1714. }
  1715. }
  1716. }else{
  1717. $trip_code = [];
  1718. }
  1719. $info['trip_code'] = $trip_code;
  1720. }
  1721. $view_data['info'] = json_encode($info);
  1722. $view_data['title'] = $recruit->company;
  1723. return view('app.recruit.health',$view_data);
  1724. }
  1725. public function save_supplement(Request $request)
  1726. {
  1727. $user = $this->getUser();
  1728. if (!empty($user)) {
  1729. $uid = $user->id;
  1730. } else {
  1731. return redirect(route('login'));
  1732. }
  1733. $limit_time = 1662543000;
  1734. $time = time();
  1735. if( $time > $limit_time){
  1736. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',18)), true, '上一页', '3');
  1737. }
  1738. $appoint_id = $request->input('appoint_id');
  1739. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',18)->where('id',$appoint_id)->first();
  1740. if(!$appoint_info){
  1741. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  1742. }
  1743. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type','supplement')->first();
  1744. if($info){
  1745. if($info->status == 1){
  1746. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1747. }
  1748. if($info->status == 0){
  1749. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1750. }
  1751. //身份证明
  1752. $identification = $request->input('identification');
  1753. if(is_array($identification)){
  1754. //删除掉没有成功返回路径的图片
  1755. foreach ($identification as $k => $v){
  1756. if(!array_key_exists('response',$v)){
  1757. unset($identification[$k]);
  1758. }
  1759. }
  1760. }
  1761. $info->identification = json_encode($identification);
  1762. //户口簿
  1763. $household_register = $request->input('household_register');
  1764. if(is_array($household_register)){
  1765. //删除掉没有成功返回路径的图片
  1766. foreach ($household_register as $k => $v){
  1767. if(!array_key_exists('response',$v)){
  1768. unset($household_register[$k]);
  1769. }
  1770. }
  1771. }
  1772. $info->household_register = json_encode($household_register);
  1773. //学信网
  1774. $education_certification = $request->input('education_certification');
  1775. if(is_array($education_certification)){
  1776. //删除掉没有成功返回路径的图片
  1777. foreach ($education_certification as $k => $v){
  1778. if(!array_key_exists('response',$v)){
  1779. unset($education_certification[$k]);
  1780. }
  1781. }
  1782. }
  1783. $info->education_certification = json_encode($education_certification);
  1784. //计生
  1785. // $family_planning = $request->input('family_planning');
  1786. // if(is_array($family_planning)){
  1787. // //删除掉没有成功返回路径的图片
  1788. // foreach ($family_planning as $k => $v){
  1789. // if(!array_key_exists('response',$v)){
  1790. // unset($family_planning[$k]);
  1791. // }
  1792. // }
  1793. // }
  1794. // $info->family_planning = json_encode($family_planning);
  1795. //综治
  1796. $manage = $request->input('manage');
  1797. if(is_array($manage)){
  1798. //删除掉没有成功返回路径的图片
  1799. foreach ($manage as $k => $v){
  1800. if(!array_key_exists('response',$v)){
  1801. unset($manage[$k]);
  1802. }
  1803. }
  1804. }
  1805. $info->manage = json_encode($manage);
  1806. $info->status = 0;
  1807. $info->save();
  1808. $appoint_info->political_audit = 4;
  1809. $appoint_info->save();
  1810. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1811. }else{
  1812. $data['appoint_id'] = $appoint_id;
  1813. //身份证明
  1814. $identification = $request->input('identification');
  1815. if(is_array($identification)){
  1816. //删除掉没有成功返回路径的图片
  1817. foreach ($identification as $k => $v){
  1818. if(!array_key_exists('response',$v)){
  1819. unset($identification[$k]);
  1820. }
  1821. }
  1822. }
  1823. $data['identification'] = json_encode($identification);
  1824. //户口簿
  1825. $household_register = $request->input('household_register');
  1826. if(is_array($household_register)){
  1827. //删除掉没有成功返回路径的图片
  1828. foreach ($household_register as $k => $v){
  1829. if(!array_key_exists('response',$v)){
  1830. unset($household_register[$k]);
  1831. }
  1832. }
  1833. }
  1834. $data['household_register'] = json_encode($household_register);
  1835. //学信网
  1836. $education_certification = $request->input('education_certification');
  1837. if(is_array($education_certification)){
  1838. //删除掉没有成功返回路径的图片
  1839. foreach ($education_certification as $k => $v){
  1840. if(!array_key_exists('response',$v)){
  1841. unset($education_certification[$k]);
  1842. }
  1843. }
  1844. }
  1845. $data['education_certification'] = json_encode($education_certification);
  1846. //计生
  1847. // $family_planning = $request->input('family_planning');
  1848. // if(is_array($family_planning)){sp
  1849. // //删除掉没有成功返回路径的图片
  1850. // foreach ($family_planning as $k => $v){
  1851. // if(!array_key_exists('response',$v)){
  1852. // unset($family_planning[$k]);
  1853. // }
  1854. // }
  1855. // }
  1856. // $data['family_planning'] = json_encode($family_planning);
  1857. //综治
  1858. $manage = $request->input('manage');
  1859. if(is_array($manage)){
  1860. //删除掉没有成功返回路径的图片
  1861. foreach ($manage as $k => $v){
  1862. if(!array_key_exists('response',$v)){
  1863. unset($manage[$k]);
  1864. }
  1865. }
  1866. }
  1867. $data['manage'] = json_encode($manage);
  1868. $data['status'] = 0;
  1869. $data['type'] = 'supplement';
  1870. $result = RecruitSupplement::create($data);
  1871. $appoint_info->political_audit = 4;
  1872. $appoint_info->save();
  1873. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1874. }
  1875. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  1876. }
  1877. public function save_healthinfo(Request $request)
  1878. {
  1879. $user = $this->getUser();
  1880. if (!empty($user)) {
  1881. $uid = $user->id;
  1882. } else {
  1883. return redirect(route('login'));
  1884. }
  1885. $appoint_id = $request->input('appoint_id');
  1886. $type = $request->input('type');
  1887. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
  1888. if(!$appoint_info){
  1889. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  1890. }
  1891. $recruit = Recruit::where('id',$appoint_info->recruit_id)->first();
  1892. $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();
  1893. if($info){
  1894. if($info->h_status == 1){
  1895. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  1896. }
  1897. if($info->h_status == 0){
  1898. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  1899. }
  1900. $health_code = $request->input('health_code');
  1901. if(is_array($health_code)){
  1902. //删除掉没有成功返回路径的图片
  1903. foreach ($health_code as $k => $v){
  1904. if(!array_key_exists('response',$v)){
  1905. unset($health_code[$k]);
  1906. }
  1907. }
  1908. }
  1909. $info->health_code = json_encode($health_code);
  1910. $trip_code = $request->input('trip_code');
  1911. if(is_array($trip_code)){
  1912. //删除掉没有成功返回路径的图片
  1913. foreach ($trip_code as $k => $v){
  1914. if(!array_key_exists('response',$v)){
  1915. unset($trip_code[$k]);
  1916. }
  1917. }
  1918. }
  1919. $info->trip_code = json_encode($trip_code);
  1920. $info->h_status = 0;
  1921. $appoint_info->health_audit = 4;
  1922. $appoint_info->save();
  1923. $info->save();
  1924. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  1925. }else{
  1926. $data['appoint_id'] = $appoint_id;
  1927. $data['type'] = $type;
  1928. $data['h_status'] = 0;
  1929. $appoint_info->health_audit = 4;
  1930. $health_code = $request->input('health_code');
  1931. if(is_array($health_code)){
  1932. //删除掉没有成功返回路径的图片
  1933. foreach ($health_code as $k => $v){
  1934. if(!array_key_exists('response',$v)){
  1935. unset($health_code[$k]);
  1936. }
  1937. }
  1938. }
  1939. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  1940. $health_msg = ['健康码自动审核通过'];
  1941. //$h_status = 1;
  1942. //$appoint_info->health_audit = 1;
  1943. if(!array_key_exists('error_msg',$health_result) && !array_key_exists('error_code',$health_result)){
  1944. if(array_key_exists('姓名',$health_result)){
  1945. if(stripos($health_result['姓名'][0]['word'],'*')>0){
  1946. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  1947. }
  1948. if($health_result['姓名'][0]['word'] != $appoint_info->realname){
  1949. array_push($health_msg,'抱歉,请上传您本人的健康码!');
  1950. }
  1951. }else{
  1952. array_push($health_msg,'健康码错误,识别不到姓名!');
  1953. }
  1954. if(array_key_exists('状态',$health_result)){
  1955. if($health_result['状态'][0]['word'] != '绿码'){
  1956. array_push($health_msg,'抱歉,您的健康码非绿码!');
  1957. }
  1958. }else{
  1959. array_push($health_msg,'健康码错误,识别不到状态!');
  1960. }
  1961. if(array_key_exists('更新时间',$health_result)){
  1962. $time = strtotime($health_result['更新时间'][0]['word']);
  1963. if($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)){
  1964. array_push($health_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  1965. }
  1966. }else{
  1967. array_push($health_msg,'健康码错误,识别不到时间!');
  1968. }
  1969. //$data['h_status'] = $h_status;
  1970. $data['h_msg'] = implode(';',$health_msg);
  1971. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  1972. $data['health_code'] = json_encode($health_code);
  1973. }
  1974. $data['health_result'] = json_encode($health_result);
  1975. $trip_code = $request->input('trip_code');
  1976. if(is_array($trip_code)){
  1977. //删除掉没有成功返回路径的图片
  1978. foreach ($trip_code as $k => $v){
  1979. if(!array_key_exists('response',$v)){
  1980. unset($trip_code[$k]);
  1981. }
  1982. }
  1983. }
  1984. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  1985. $trip_msg = [];
  1986. $trip_status = 0;
  1987. if(!array_key_exists('error_msg',$trip_result) && !array_key_exists('error_code',$trip_result)){
  1988. if(array_key_exists('途经地',$trip_result['result'])){
  1989. $fangyi_area = explode("\r\n",config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  1990. $result = array_intersect($fangyi_area,$trip_result['result']['途经地'][0]['word']);
  1991. if(count($result) > 0){
  1992. array_push($trip_msg,'抱歉,您的行程中包含系统设置中高风险地区!');
  1993. $trip_status = 0;
  1994. }
  1995. }
  1996. if(array_key_exists('风险性',$trip_result['result']) && $trip_result['result']['风险性']){
  1997. array_push($trip_msg,'抱歉,您的行程可能含有风险!');
  1998. $trip_status = 0;
  1999. }
  2000. if(array_key_exists('更新时间',$trip_result['result'])){
  2001. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2002. if($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)){
  2003. array_push($trip_msg,'抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2004. $trip_status = 0;
  2005. }
  2006. }
  2007. $data['h_msg'] .= implode(';',$trip_msg);
  2008. }
  2009. $data['trip_result'] = json_encode($trip_result);
  2010. $data['trip_code'] = json_encode($trip_code);
  2011. $data['h_status'] = 0;
  2012. $appoint_info->health_audit = 4;
  2013. RecruitSupplement::create($data);
  2014. $appoint_info->save();
  2015. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2016. }
  2017. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2018. }
  2019. public function post_select(Request $request)
  2020. {
  2021. $user = $this->getUser();
  2022. if (!empty($user)) {
  2023. $uid = $user->id;
  2024. } else {
  2025. return redirect(route('login'));
  2026. }
  2027. $recruit_id = $request->input('recruit_id');
  2028. //$appoint_id = $request->input('appoint_id');
  2029. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->first();
  2030. if(!$info){
  2031. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2032. }
  2033. //手动设置择岗时间段
  2034. $time = time();
  2035. if($time > 1663300800 || $time < 1663200000){
  2036. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2037. }
  2038. $option_list = [
  2039. [
  2040. 'id' => 6,
  2041. 'name' => '新塘街道'
  2042. ],
  2043. [
  2044. 'id' => 7,
  2045. 'name' => '陈埭镇'
  2046. ],
  2047. [
  2048. 'id' => 8,
  2049. 'name' => '池店镇'
  2050. ],
  2051. [
  2052. 'id' => 9,
  2053. 'name' => '安海镇'
  2054. ],
  2055. [
  2056. 'id' => 10,
  2057. 'name' => '磁灶镇'
  2058. ],
  2059. [
  2060. 'id' => 11,
  2061. 'name' => '内坑镇'
  2062. ],
  2063. [
  2064. 'id' => 13,
  2065. 'name' => '东石镇'
  2066. ],
  2067. [
  2068. 'id' => 14,
  2069. 'name' => '永和镇'
  2070. ],
  2071. [
  2072. 'id' => 15,
  2073. 'name' => '英林镇'
  2074. ],
  2075. [
  2076. 'id' => 16,
  2077. 'name' => '金井镇'
  2078. ],
  2079. [
  2080. 'id' => 17,
  2081. 'name' => '龙湖镇'
  2082. ],
  2083. [
  2084. 'id' => 18,
  2085. 'name' => '深沪镇'
  2086. ],
  2087. [
  2088. 'id' => 19,
  2089. 'name' => '西滨镇'
  2090. ]
  2091. ];
  2092. $select_list = [];
  2093. if($info->result){
  2094. $result = json_decode($info->result,true);
  2095. foreach ($result as $v){
  2096. $item['name'] = $v;
  2097. array_push($select_list,$item);
  2098. }
  2099. }
  2100. // $recruit_id = $request->input('recruit_id');
  2101. // $appoint_id = $request->input('appoint_id');
  2102. // $uid = $request->input('uid');
  2103. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2104. // if(!$info){
  2105. // $info = new \stdClass();
  2106. // $info->status = 0;
  2107. // $info->recruit_id = 8;
  2108. // $info->appoint_id = rand(0,999999);
  2109. // $info->uid = rand(0,999999);
  2110. // }else{
  2111. // $result = json_decode($info->result,true);
  2112. // foreach ($option_list as $k => $v){
  2113. // if(in_array($v['name'],$result)){
  2114. // $select_list[$k] = $v;
  2115. // unset($option_list[$k]);
  2116. // }
  2117. // }
  2118. // }
  2119. $view_data = ['info' => $info,'options_list' => json_encode($option_list),'select_list' => json_encode($select_list)];
  2120. return view('app.recruit.post_select',$view_data);
  2121. }
  2122. /**
  2123. * 放弃择岗
  2124. */
  2125. public function give_up_post(Request $request)
  2126. {
  2127. //以下为测试环境
  2128. // $recruit_id = $request->input('recruit_id');
  2129. // $appoint_id = $request->input('appoint_id');
  2130. // $uid = $request->input('uid');
  2131. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2132. // if($info){
  2133. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2134. // }
  2135. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2136. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2137. //以下为正式环境再放开
  2138. $user = $this->getUser();
  2139. if (!empty($user)) {
  2140. $uid = $user->id;
  2141. } else {
  2142. return redirect(route('login'));
  2143. }
  2144. $recruit_id = $request->input('recruit_id');
  2145. $appoint_id = $request->input('appoint_id');
  2146. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2147. if($info == null){
  2148. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2149. }
  2150. if($info->status != 0){
  2151. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2152. }
  2153. $info->status = -1;
  2154. $info->save();
  2155. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2156. }
  2157. public function comfirm_post(Request $request)
  2158. {
  2159. $user = $this->getUser();
  2160. if (!empty($user)) {
  2161. $uid = $user->id;
  2162. } else {
  2163. return redirect(route('login'));
  2164. }
  2165. $recruit_id = $request->input('recruit_id');
  2166. $appoint_id = $request->input('appoint_id');
  2167. $time = time();
  2168. if($time > 1663300800 || $time < 1663200000){
  2169. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
  2170. }
  2171. $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2172. if($info->result){
  2173. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2174. }
  2175. // $data = [
  2176. // 'recruit_id' => $recruit_id,
  2177. // 'appoint_id' => $recruit_id,
  2178. // 'uid' => $uid,
  2179. // 'status' => 1
  2180. // ];
  2181. $result = [];
  2182. $select = $request->input('select');
  2183. if(is_array($select) && count($select) > 0){
  2184. foreach ($select as $v) {
  2185. array_push($result,$v['name']);
  2186. }
  2187. }
  2188. $info->result = json_encode($result);
  2189. $info->status = 1;
  2190. $info->save();
  2191. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2192. }
  2193. public function select_result(Request $request)
  2194. {
  2195. return view('app.recruit.select_result');
  2196. }
  2197. public function get_select_result(Request $request)
  2198. {
  2199. $redis = Cache::getRedis();
  2200. $quota = $redis->get('recruit_quota');
  2201. if(!$quota){
  2202. $quota = [
  2203. [
  2204. 'name' => '新塘街道',
  2205. 'value' => 13
  2206. ],
  2207. [
  2208. 'name' => '陈埭镇',
  2209. 'value' => 88
  2210. ],
  2211. [
  2212. 'name' => '池店镇',
  2213. 'value' => 10
  2214. ],
  2215. [
  2216. 'name' => '安海镇',
  2217. 'value' => 10
  2218. ],
  2219. [
  2220. 'name' => '磁灶镇',
  2221. 'value' => 21
  2222. ],
  2223. [
  2224. 'name' => '内坑镇',
  2225. 'value' => 22
  2226. ],
  2227. [
  2228. 'name' => '东石镇',
  2229. 'value' => 4
  2230. ],
  2231. [
  2232. 'name' => '永和镇',
  2233. 'value' => 27
  2234. ],
  2235. [
  2236. 'name' => '英林镇',
  2237. 'value' => 5
  2238. ],
  2239. [
  2240. 'name' => '金井镇',
  2241. 'value' => 13
  2242. ],
  2243. [
  2244. 'name' => '龙湖镇',
  2245. 'value' => 53
  2246. ],
  2247. [
  2248. 'name' => '深沪镇',
  2249. 'value' => 23
  2250. ],
  2251. [
  2252. 'name' => '西滨镇',
  2253. 'value' => 3
  2254. ]
  2255. ];
  2256. $redis->set('recruit_quota',json_encode($quota));
  2257. }else{
  2258. $quota = json_decode($quota,true);
  2259. }
  2260. $limit = $request->input('limit',1);
  2261. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b','a.appoint_id','=','b.id')->leftJoin('recruit_ticket as c','a.appoint_id','=','c.appoint_id')->whereRaw('a.select_result is null and a.batch=2 and a.status=1')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->limit($limit)->get();
  2262. $return_data = [
  2263. 'list' => []
  2264. ];
  2265. $array_column = array_column($quota,'name');
  2266. foreach ($list as $k => $v){
  2267. $person_select_result = json_decode($v->result,true);
  2268. $flag = 0;//是否择岗成功
  2269. foreach ($person_select_result as $val){
  2270. //寻找下标
  2271. $index = array_search($val,$array_column);
  2272. if($quota[$index]['value'] > 0){
  2273. $quota_data = [
  2274. 'index' => $index,
  2275. 'old_value' => $quota[$index]['value']
  2276. ];
  2277. //有名额允许择岗
  2278. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  2279. $v->select_result = $val;
  2280. $quota[$index]['value']--;
  2281. $quota_data['new_value'] = $quota[$index]['value'];
  2282. $redis->set('recruit_quota',json_encode($quota));
  2283. $flag = 1;
  2284. break;
  2285. }
  2286. }
  2287. if(!$flag){
  2288. $v->select_result = '未匹配到志愿,本轮择岗不成功!';
  2289. DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>'未匹配到志愿,本轮择岗不成功!','status' => -2]);
  2290. }
  2291. array_push($return_data['list'],$v);
  2292. }
  2293. $return_data['quota'] = $quota_data;
  2294. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2295. }
  2296. public function select_init(Request $request)
  2297. {
  2298. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 2')->count();
  2299. $redis = Cache::getRedis();
  2300. $quota = $redis->get('recruit_quota');
  2301. if(!$quota){
  2302. $quota = [
  2303. [
  2304. 'name' => '新塘街道',
  2305. 'value' => 13
  2306. ],
  2307. [
  2308. 'name' => '陈埭镇',
  2309. 'value' => 88
  2310. ],
  2311. [
  2312. 'name' => '池店镇',
  2313. 'value' => 10
  2314. ],
  2315. [
  2316. 'name' => '安海镇',
  2317. 'value' => 10
  2318. ],
  2319. [
  2320. 'name' => '磁灶镇',
  2321. 'value' => 21
  2322. ],
  2323. [
  2324. 'name' => '内坑镇',
  2325. 'value' => 22
  2326. ],
  2327. [
  2328. 'name' => '东石镇',
  2329. 'value' => 4
  2330. ],
  2331. [
  2332. 'name' => '永和镇',
  2333. 'value' => 27
  2334. ],
  2335. [
  2336. 'name' => '英林镇',
  2337. 'value' => 5
  2338. ],
  2339. [
  2340. 'name' => '金井镇',
  2341. 'value' => 13
  2342. ],
  2343. [
  2344. 'name' => '龙湖镇',
  2345. 'value' => 53
  2346. ],
  2347. [
  2348. 'name' => '深沪镇',
  2349. 'value' => 23
  2350. ],
  2351. [
  2352. 'name' => '西滨镇',
  2353. 'value' => 3
  2354. ]
  2355. ];
  2356. $redis->set('recruit_quota',json_encode($quota));
  2357. }
  2358. $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b','a.appoint_id','=','b.id')->leftJoin('recruit_ticket as c','a.appoint_id','=','c.appoint_id')->whereRaw('a.select_result is not null and a.batch=2')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->get();
  2359. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quota, 'list' => $list]];
  2360. }
  2361. public function interviewer_random(Request $request)
  2362. {
  2363. $model = $request->input('model',1);
  2364. $number1 = $request->input('number1',5);//考官人数
  2365. $number2 = $request->input('number2',1);//替补人数
  2366. $where[] = ['id','>',0];
  2367. switch ($model){
  2368. case '0':
  2369. $list = DB::table('recruit_interviewer')->get()->toArray();
  2370. shuffle($list);
  2371. $result = array_slice($list, 0, $number1+$number2);
  2372. break;
  2373. case '1':
  2374. $list = DB::table('recruit_interviewer')->get()->toArray();
  2375. shuffle($list);
  2376. $count = $number1;
  2377. for ($i = 0; $i < $count; $i++){
  2378. if(!$list[$i]->status){
  2379. $list[] = $list[$i];
  2380. unset($list[$i]);
  2381. $count++;
  2382. }
  2383. }
  2384. $result = array_slice($list, 0, $number1+$number2);
  2385. break;
  2386. case '2':
  2387. $list = DB::table('recruit_interviewer')->where('status',1)->get()->toArray();
  2388. shuffle($list);
  2389. $result = array_slice($list, 0, $number1+$number2);
  2390. break;
  2391. default:
  2392. $list = DB::table('recruit_interviewer')->get()->toArray();
  2393. shuffle($list);
  2394. for ($i = 0; $i < $number1; $i++){
  2395. dd($list[$i]);
  2396. if(!$list[$i]->status){
  2397. $list[] = $list[$i];
  2398. unset($list[$i]);
  2399. }
  2400. }
  2401. $result = array_slice($list, 0, $number1+$number2);
  2402. break;
  2403. }
  2404. $return_data = [
  2405. 'list' => $result,
  2406. 'number1' => $number1,
  2407. 'number2' => $number2
  2408. ];
  2409. return view('app.recruit.interviewer', $return_data);
  2410. }
  2411. public function supplement_info(Request $request)
  2412. {
  2413. $user = $this->getUser();
  2414. if (!empty($user)) {
  2415. $uid = $user->id;
  2416. } else {
  2417. return redirect(route('login'));
  2418. }
  2419. //招考id
  2420. $id = $request->input('id', 0);
  2421. if (!$id) {
  2422. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2423. }
  2424. $recruit = Recruit::find($id);
  2425. if(!$recruit['status']){
  2426. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2427. }
  2428. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2429. if(!$appoint_info){
  2430. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2431. }
  2432. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid',$uid)->where('appoint_id',$appoint_info->id)->first();
  2433. if($supplement_info){
  2434. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2435. }
  2436. $uids = [179049,179051,175896,177011,179015,179134,166830,179056,179110,179140,179040,179154,168701,149108,176405,176637,179182,179115,52845,179240,179036,170227,179286,179145,177121,169161,179282,179318,179173,179385,179287,175723,165156,179217,179085,179174,179441,179459,179448,179461,179476,170189,158658,162111,179504,177503,169950,173378,179571,179576,179548,175865,132228,168809,158464,150061,179594,169655,179311,168348,179131,179654,179664,179683,175855,179100,56968,179610,179146,179731,176717,179435,179669,175794,179487,176307,179806,179758,179555,179822,176249,179769,179815,179685,179856,179840,179828,179844,179376,169398,169530,170181,179799,179123,179652,179936,176102,179261,179957,179888,180033,180039,180050,180028,180064,180078,159819,180085,179987,177195,176790,175722,179933,176170,180122,176929,179872,180151,180123,176834,179547,179879,180196,170277,159623,179892,179904,180227,179952,180232,165930,179195,173624,180244,180277,180325,180321,180265,179871,179908,149297,179898,180407,180239,169158,175716,169910,180288,180452,162757,180309,180474,179266,164225,180465,169899,180098,175481,179306,180458,176454,180451,180507,180531,169591,180456,175467,180589,180587,180590,180601,179679,180597,180602,180604,175637,179830,165858,179835,180677,169304,180711,180234,180426,169691,176956,178303,170289,177028,179894,180311,176683,169720,150103,180705,176548,176655,180849,176101,180855,180808,180869,180348,180733,180889,180866,180399,180657,180920,180876,179701,152053,180208,175641,180831,169075,180980,180988,180991,180686,181016,181023,180974,152179,179284,181058,168483,177233,176619,181110,180809,180979,181122,180916,181142,180992,177427,181143,169886,147697,181173,181218,181041,181171,163107,180363,151296,169429,150164,181258,176891,56330,169740,181272,170078,177000,181317,180845,181303,180839,180983];//写死用户
  2437. if(!in_array($uid,$uids)){
  2438. return $this->showMessage('您无需登记信息!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2439. }
  2440. // $limit_time = 1661961599;
  2441. // $time = time();
  2442. // if( $time > $limit_time){
  2443. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2444. // }
  2445. $view_data = [];
  2446. //$view_data['info'] = json_encode($info);
  2447. $view_data['title'] = $recruit->company;
  2448. $view_data['id'] = $id;
  2449. return view('app.recruit.supplement_info',$view_data);
  2450. }
  2451. public function save_supplement_info(Request $request){
  2452. $user = $this->getUser();
  2453. if (!empty($user)) {
  2454. $uid = $user->id;
  2455. } else {
  2456. return redirect(route('login'));
  2457. }
  2458. //招考id
  2459. $id = $request->input('recruit_id', 0);
  2460. if (!$id) {
  2461. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2462. }
  2463. $recruit = Recruit::find($id);
  2464. if(!$recruit['status']){
  2465. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2466. }
  2467. $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('recruit_id',$id)->first();
  2468. if(!$appoint_info){
  2469. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2470. }
  2471. if($request->input('marriage') == '已婚'){
  2472. if($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == ''){
  2473. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2474. }
  2475. }
  2476. $data = [
  2477. 'uid' => $uid,
  2478. 'appoint_id' => $appoint_info->id,
  2479. 'street' => $request->input('street'),
  2480. 'realname' => $request->input('realname'),
  2481. 'sex' => $request->input('sex'),
  2482. 'house' => $request->input('house'),
  2483. 'nation' => $request->input('nation'),
  2484. 'native' => $request->input('native'),
  2485. 'marriage' => $request->input('marriage'),
  2486. 'spouse_card_type' => $request->input('spouse_card_type'),
  2487. 'spouse_card' => $request->input('spouse_card'),
  2488. 'spouse_realname' => $request->input('spouse_realname'),
  2489. 'spouse_mobile' => $request->input('spouse_mobile'),
  2490. 'political' => $request->input('political'),
  2491. 'bank_card' => $request->input('bank_card'),
  2492. 'bank_open' => $request->input('bank_open'),
  2493. 'card' => $request->input('card'),
  2494. 'card_endtime' => $request->input('card_endtime'),
  2495. 'mobile' => $request->input('mobile'),
  2496. 'edu' => $request->input('education'),
  2497. 'pro' => $request->input('pro'),
  2498. 'address' => $request->input('address'),
  2499. 'funds' => $request->input('funds')
  2500. ];
  2501. DB::table('recruit_supplement_cunwu')->insert($data);
  2502. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2503. }
  2504. public function comfirm_pen(Request $request){
  2505. $user = $this->getUser();
  2506. if (!empty($user)) {
  2507. $uid = $user->id;
  2508. } else {
  2509. return redirect(route('login'));
  2510. }
  2511. //招考id
  2512. $id = $request->input('recruit_id', 0);
  2513. if (!$id) {
  2514. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2515. }
  2516. $recruit = Recruit::find($id);
  2517. if(!$recruit['status']){
  2518. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2519. }
  2520. if(!$recruit->pen_comfirm){
  2521. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2522. }
  2523. $appoint_info = RecruitAppointInfo::where('recruit_id',$id)->where('uid',$uid)->first();
  2524. if(!$appoint_info){
  2525. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2526. }
  2527. if($appoint_info->audit != 3){
  2528. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2529. }
  2530. $time = time();
  2531. if(strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time){
  2532. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2533. }
  2534. if($appoint_info->pen_audit != -2){
  2535. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2536. }
  2537. $appoint_info->update(['pen_audit' => -1]);
  2538. $log = [
  2539. 'type' => 3,
  2540. 'appoint_id'=> $appoint_info->id,
  2541. 'uid' => $uid,
  2542. 'log' => '用户确认参加笔试'
  2543. ];
  2544. RecruitAppointLog::create($log);
  2545. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2546. }
  2547. public function supplementary_entry(Request $request){
  2548. $user = $this->getUser();
  2549. if (!empty($user)) {
  2550. $uid = $user->id;
  2551. } else {
  2552. return redirect(route('login'));
  2553. }
  2554. //招考id
  2555. $id = $request->input('recruit_id', 0);
  2556. if (!$id) {
  2557. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2558. }
  2559. $recruit = Recruit::find($id);
  2560. if(!$recruit['status']){
  2561. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2562. }
  2563. $appoint_info = RecruitAppointInfo::where('recruit_id',$id)->where('uid',$uid)->first();
  2564. if(!$appoint_info){
  2565. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2566. }
  2567. $time = time();
  2568. if($time > 1680969600){
  2569. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2570. }
  2571. if($appoint_info->adjust_limit){
  2572. $appoint_info->update(['adjust' => 1]);
  2573. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2574. }else{
  2575. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2576. }
  2577. }
  2578. }