IndexController.php 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100
  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. //dd($list);
  41. $return_data = [
  42. 'list' => $list,
  43. 'key' => $key,
  44. ];
  45. return view('app.recruit.index', $return_data);
  46. }
  47. /**
  48. * 招考详情页
  49. * @param Request $request
  50. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  51. */
  52. public function show(Request $request)
  53. {
  54. $user = $this->getUser();
  55. if ($user) {
  56. $uid = $user->id;
  57. $utype = $user->utype;
  58. } else {
  59. $uid = 0;
  60. $utype = 0;
  61. }
  62. $id = $request->input('id', 0);
  63. if (empty($id)) {
  64. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.index.list'), true, '上一页', '2');
  65. }
  66. $recruit = Recruit::where('status',1)->find($id);
  67. if (empty($recruit)) {
  68. return redirect(route('/recruit/list'));
  69. }
  70. $info = Recruit::parse_info($recruit);
  71. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  72. if ($info->isApply && $appoint_info) {
  73. $first_post = RecruitAppointLog::where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  74. if ($first_post) {
  75. $info->isApply = 1;
  76. }
  77. }
  78. if ($appoint_info) {
  79. //20221115增加确认笔试功能
  80. if ($recruit->pen_comfirm) {
  81. if ($appoint_info->audit != 3) {//审核未通过,无需确认
  82. $appoint_info->pen_comfirm = 0;
  83. } else {
  84. $time = time();
  85. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  86. $appoint_info->pen_comfirm = -1; //确认未开始
  87. } else {
  88. if ($appoint_info->pen_audit != -2) {
  89. $appoint_info->pen_comfirm = -2;//已确认无需再次确认
  90. } else {
  91. $appoint_info->pen_comfirm = 1;
  92. }
  93. }
  94. }
  95. } else {
  96. $appoint_info->pen_comfirm = 0;//无需确认
  97. }
  98. //笔试
  99. $pen_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 1)->first();
  100. if ($pen_ticket) {
  101. $pen_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "pen")->where('h_status', 1)->first();
  102. if (!$pen_health && $recruit->pen_epidemic) {
  103. $appoint_info->pen_ticket = -2;
  104. } else {
  105. $time = time();
  106. if (strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time) {
  107. $appoint_info->pen_ticket = 1;
  108. } else {
  109. $appoint_info->pen_ticket = -1;
  110. }
  111. }
  112. } else {
  113. $appoint_info->pen_ticket = 0;
  114. }
  115. //考核测试
  116. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  117. if ($check_ticket) {
  118. $time = time();
  119. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  120. $appoint_info->check_ticket = 1;
  121. } else {
  122. $appoint_info->check_ticket = -1;
  123. }
  124. } else {
  125. $appoint_info->check_ticket = 0;
  126. }
  127. //面试
  128. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  129. if ($face_ticket && $appoint_info->face_audit == -1) {
  130. $face_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "face")->where('h_status', 1)->first();
  131. if (!$face_health && $recruit->face_epidemic) {
  132. $appoint_info->face_ticket = -2;
  133. $time = time();
  134. if (strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time) {
  135. $appoint_info->face_ticket = -2;
  136. } else {
  137. $appoint_info->face_ticket = -3;
  138. }
  139. } else {
  140. $time = time();
  141. if (strtotime($recruit->face_health_start) < $time && strtotime($recruit->face_health_end) > $time) {
  142. $appoint_info->face_ticket = 1;
  143. } else {
  144. $appoint_info->face_ticket = -1;
  145. }
  146. }
  147. } else {
  148. $appoint_info->face_ticket = 0;
  149. }
  150. //复试
  151. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  152. if ($reexamine_ticket && $appoint_info->reexamine_audit == -1) {
  153. $reexamine_health = RecruitSupplement::where("appoint_id", $appoint_info->id)->where("type", "reexamine")->where('h_status', 1)->first();
  154. if (!$reexamine_health && $recruit->reexamine_epidemic) {
  155. $appoint_info->face_ticket = -2;
  156. $time = time();
  157. if (strtotime($recruit->reexamine_health_start) < $time && strtotime($recruit->reexamine_health_end) > $time) {
  158. $appoint_info->reexamine_ticket = -2;
  159. } else {
  160. $appoint_info->reexamine_ticket = -3;
  161. }
  162. } else {
  163. $time = time();
  164. if (strtotime($recruit->reexamine_health_start) < $time && strtotime($recruit->reexamine_health_end) > $time) {
  165. $appoint_info->reexamine_ticket = 1;
  166. } else {
  167. $appoint_info->reexamine_ticket = -1;
  168. }
  169. }
  170. } else {
  171. $appoint_info->reexamine_ticket = 0;
  172. }
  173. } else {
  174. $appoint_info = new \stdClass();
  175. $appoint_info->pen_comfirm = 0;
  176. $appoint_info->pen_audit = 0;
  177. $appoint_info->post_id = 0;
  178. $appoint_info->pen_ticket = 0;
  179. $appoint_info->computer_ticket = 0;
  180. $appoint_info->face_ticket = 0;
  181. $appoint_info->check_ticket = 0;
  182. $appoint_info->reexamine_ticket = 0;
  183. $appoint_info->realname = '';
  184. $appoint_info->card = '';
  185. $appoint_info->mobile = '';
  186. $appoint_info->sex = 0;
  187. $appoint_info->adjust = 0;
  188. $appoint_info->adjust_limit = 0;
  189. }
  190. $notice = $request->input('notice', 0);
  191. if ($notice) {
  192. $public_notice_switch = 0;
  193. $public_notice = RecruitArticle::where('id', $notice)->where('released_at', '<', time())->first();
  194. if (!empty($info)) {
  195. $view_data = [
  196. 'recruit' => $recruit,
  197. 'info' => $info,
  198. 'uid' => $uid,
  199. 'utype' => $utype,
  200. 'public_notice' => $public_notice,
  201. 'public_notice_switch' => $public_notice_switch,
  202. 'appoint_info' => $appoint_info,
  203. ];
  204. return view('app.recruit.show')->with($view_data);
  205. } else {
  206. return back();
  207. }
  208. } else {
  209. $list = RecruitArticle::where('recruit_id', $id)->where('is_display', 1)->orderBy('created_at', 'desc')->where('released_at', '<', time())->get();
  210. $public_notice_switch = 1;//有补充公告的模式
  211. if (!empty($info)) {
  212. $view_data = [
  213. 'recruit' => $recruit,
  214. 'info' => $info,
  215. 'uid' => $uid,
  216. 'utype' => $utype,
  217. 'list' => $list,
  218. 'public_notice_switch' => $public_notice_switch,
  219. 'appoint_info' => $appoint_info,
  220. ];
  221. return view('app.recruit.show')->with($view_data);
  222. } else {
  223. return back();
  224. }
  225. }
  226. }
  227. /**
  228. * 上传文件的方法
  229. * @param Request $request
  230. * @return \Illuminate\Http\JsonResponse
  231. */
  232. public function upload(Request $request)
  233. {
  234. $user = $this->getUser();
  235. if ($user) {
  236. $uid = $user->id;
  237. $utype = $user->utype;
  238. } else {
  239. $uid = 0;
  240. $utype = 0;
  241. }
  242. $file = $request->file('file');
  243. if ($file->isValid()) { //判断文件是否存在
  244. //获取文件的扩展名
  245. $ext = $file->getClientOriginalExtension();
  246. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  247. $res['status'] = 0;
  248. $res['msg'] = '文件格式不正确';
  249. } else {
  250. //获取文件的绝对路径
  251. $path = $file->getRealPath();
  252. $oldname = $file->getClientOriginalName();
  253. //定义文件名
  254. $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  255. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  256. Storage::disk('public')->put($filename, file_get_contents($path));
  257. $res['status'] = 1;
  258. $res['filename'] = $oldname;
  259. $res['path'] = "/storage/" . $filename;
  260. $res['msg'] = '上传成功';
  261. }
  262. } else {
  263. $res['status'] = 0;
  264. $res['msg'] = '上传失败';
  265. }
  266. return response()->json($res);
  267. }
  268. /**
  269. * 查看报名人数统计
  270. * @param Request $request
  271. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
  272. */
  273. public function sign_up_count(Request $request)
  274. {
  275. $user = $this->getUser();
  276. if ($user) {
  277. $uid = $user->id;
  278. $utype = $user->utype;
  279. } else {
  280. $uid = 0;
  281. $utype = 0;
  282. }
  283. $id = $request->input('id', 0);
  284. $refresh = $request->input('refresh', '');
  285. if (empty($id)) {
  286. return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.index.list'), true, '上一页', '2');
  287. }
  288. $recruit = Recruit::find($id);
  289. if (empty($recruit)) {
  290. return redirect(route('/recruit/list'));
  291. }
  292. if (!$recruit->show_report) {
  293. return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.index.list'), true, '上一页', '2');
  294. }
  295. if (Cache::has("sign_up_count_{$recruit->id}") && $refresh != 'jjhc2019') {
  296. $cache_data = Cache::get("sign_up_count_{$recruit->id}");
  297. $list = $cache_data['list'];
  298. $time = $cache_data['time'];
  299. } else {
  300. $list = RecruitPost::where('recruit_id', $recruit->id)->where('status', 1)->get();
  301. if (!$list) {
  302. return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.index.list'), true, '上一页', '2');
  303. }
  304. foreach ($list as $k => $v) {
  305. $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();
  306. $list[$k]['checking'] = $res->checking;
  307. $list[$k]['fail'] = $res->fail;
  308. $list[$k]['success'] = $res->success;
  309. }
  310. $time = date('Y-m-d H:i', time());
  311. $cache_data = [
  312. 'list' => $list,
  313. 'time' => $time,
  314. ];
  315. Cache::put("sign_up_count_{$recruit->id}", $cache_data, 60);
  316. }
  317. $view_data = [
  318. 'list' => $list,
  319. 'time' => $time,
  320. 'title' => $recruit->company,
  321. ];
  322. return view('app.recruit.sign_up_count')->with($view_data);
  323. }
  324. /**
  325. * 报名功能页
  326. * @param Request $request
  327. * @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
  328. */
  329. public function sign_up(Request $request)
  330. {
  331. $user = $this->getUser();
  332. if (!empty($user)) {
  333. $uid = $user->id;
  334. } else {
  335. return redirect(route('login'));
  336. }
  337. //招考id
  338. $id = $request->input('id', 0);
  339. if (!$id) {
  340. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  341. }
  342. //招考信息
  343. $recruit = Recruit::find($id);
  344. if (!$recruit['status'] && !$user->recruit_test) {
  345. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  346. }
  347. if ($recruit['current'] != 1 && $recruit['current'] != 2) {
  348. return $this->showMessage('抱歉,该项目报名通道已关闭,如有疑问,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  349. }
  350. if($recruit['limit_times'] == 1){
  351. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  352. }else{
  353. $appoint_info_id = $request->input('appoint_info_id', 0);
  354. $appoint_info = null;
  355. if($appoint_info_id > 0){
  356. $appoint_info = RecruitAppointInfo::where('id', $appoint_info_id)->first();
  357. }
  358. }
  359. $time = time();
  360. $formDisabled = 0;
  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['hj_certification'])) {
  414. $hj_certification = json_decode($user_info['hj_certification'], true);
  415. foreach ($hj_certification as $k => $v) {
  416. if (array_key_exists('response', $v)) {
  417. $hj_certification[$k]['url'] = $v['response']['path'];
  418. }
  419. }
  420. } else {
  421. $hj_certification = [];
  422. }
  423. $user_info['hj_certification'] = $hj_certification;
  424. if (json_decode($user_info['chengnuoshu'])) {
  425. $chengnuoshu = json_decode($user_info['chengnuoshu'], true);
  426. foreach ($chengnuoshu as $k => $v) {
  427. if (array_key_exists('response', $v)) {
  428. $chengnuoshu[$k]['url'] = $v['response']['path'];
  429. }
  430. }
  431. } else {
  432. $chengnuoshu = [];
  433. }
  434. $user_info['chengnuoshu'] = $chengnuoshu;
  435. if (json_decode($user_info['shixin'])) {
  436. $shixin = json_decode($user_info['shixin'], true);
  437. foreach ($shixin as $k => $v) {
  438. if (array_key_exists('response', $v)) {
  439. $shixin[$k]['url'] = $v['response']['path'];
  440. }
  441. }
  442. } else {
  443. $shixin = [];
  444. }
  445. $user_info['shixin'] = $shixin;
  446. if (json_decode($user_info['baokaoshengming'])) {
  447. $baokaoshengming = json_decode($user_info['baokaoshengming'], true);
  448. foreach ($baokaoshengming as $k => $v) {
  449. if (array_key_exists('response', $v)) {
  450. $baokaoshengming[$k]['url'] = $v['response']['path'];
  451. }
  452. }
  453. } else {
  454. $baokaoshengming = [];
  455. }
  456. $user_info['baokaoshengming'] = $baokaoshengming;
  457. //获取最新的报名审核信息
  458. $logs = RecruitAppointLog::where('appoint_id', $user_info->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  459. if ($logs) {
  460. $user_info['audit_log'] = $logs->log;
  461. } else {
  462. $user_info['audit_log'] = '';
  463. }
  464. } else {
  465. //如果已有该场次的报名记录,读取录入的数据集合
  466. $user_info = $appoint_info;
  467. $user_info['sex'] = (string)$user_info['sex'];
  468. $user_info['edu_type'] = (string)$user_info['edu_type'];
  469. $user_info['family'] = json_decode($user_info['family']);
  470. if (in_array('expand_special', $forms)) {
  471. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id', $user_info['id'])->first();
  472. if ($special) {
  473. if (strpos($special['condition'], ',') !== false) {
  474. $special['condition'] = explode(',', $special['condition']);
  475. }
  476. $material = json_decode($special['material'], true);
  477. if (is_array($material)) {
  478. foreach ($material as $k => $v) {
  479. if (array_key_exists('response', $v)) {
  480. if (array_key_exists('path', $v['response'])) {
  481. $material[$k]['url'] = $v['response']['path'];
  482. }
  483. }
  484. }
  485. }
  486. } else {
  487. $material = [];
  488. $special = [
  489. 'point_apply' => '0',
  490. 'condition' => '',
  491. ];
  492. }
  493. $user_info['special'] = [
  494. 'point_apply' => (string)$special['point_apply'],
  495. 'condition' => $special['condition'],
  496. 'material' => $material,
  497. ];
  498. }
  499. if (in_array('detail', $forms)) {
  500. $detail = RecruitAppointDetail::where('recruit_appoint_id', $user_info['id'])->first();
  501. if ($detail) {
  502. $user_info['detail'] = $detail->toArray();
  503. } else {
  504. $user_info['detail'] = [
  505. 'train' => '',
  506. 'rewards_and_punishments' => '',
  507. 'introduce' => '',
  508. ];
  509. }
  510. }
  511. //如果有身份证明模块
  512. if (in_array('identification', $forms)) {
  513. if (json_decode($user_info['identification'])) {
  514. $identification = json_decode($user_info['identification'], true);
  515. foreach ($identification as $k => $v) {
  516. if (array_key_exists('response', $v)) {
  517. if (array_key_exists('path', $v['response'])) {
  518. $identification[$k]['url'] = $v['response']['path'];
  519. }
  520. }
  521. }
  522. } else {
  523. $identification = [];
  524. }
  525. $user_info['identification'] = $identification;
  526. }
  527. //如果有教育证明模块
  528. if (in_array('education_certification', $forms)) {
  529. if (json_decode($user_info['education_certification'])) {
  530. $education_certification = json_decode($user_info['education_certification'], true);
  531. foreach ($education_certification as $k => $v) {
  532. if (array_key_exists('response', $v)) {
  533. if (array_key_exists('path', $v['response'])) {
  534. $education_certification[$k]['url'] = $v['response']['path'];
  535. }
  536. }
  537. }
  538. } else {
  539. $education_certification = [];
  540. }
  541. $user_info['education_certification'] = $education_certification;
  542. }
  543. //如果有其他证明模块
  544. if (in_array('other_certification', $forms)) {
  545. if (json_decode($user_info['other_certification'])) {
  546. $other_certification = json_decode($user_info['other_certification'], true);
  547. foreach ($other_certification as $k => $v) {
  548. if (array_key_exists('response', $v)) {
  549. if (array_key_exists('path', $v['response'])) {
  550. $other_certification[$k]['url'] = $v['response']['path'];
  551. }
  552. }
  553. }
  554. } else {
  555. $other_certification = [];
  556. }
  557. $user_info['other_certification'] = $other_certification;
  558. }
  559. //如果有户籍证明模块
  560. if (in_array('hj_certification', $forms)) {
  561. if (json_decode($user_info['hj_certification'])) {
  562. $hj_certification = json_decode($user_info['hj_certification'], true);
  563. foreach ($hj_certification as $k => $v) {
  564. if (array_key_exists('response', $v)) {
  565. if (array_key_exists('path', $v['response'])) {
  566. $hj_certification[$k]['url'] = $v['response']['path'];
  567. }
  568. }
  569. }
  570. } else {
  571. $hj_certification = [];
  572. }
  573. $user_info['hj_certification'] = $hj_certification;
  574. }
  575. //如果有承诺书模块
  576. if (in_array('chengnuoshu', $forms)) {
  577. if (json_decode($user_info['chengnuoshu'])) {
  578. $chengnuoshu = json_decode($user_info['chengnuoshu'], true);
  579. foreach ($chengnuoshu as $k => $v) {
  580. if (array_key_exists('response', $v)) {
  581. if (array_key_exists('path', $v['response'])) {
  582. $chengnuoshu[$k]['url'] = $v['response']['path'];
  583. }
  584. }
  585. }
  586. } else {
  587. $chengnuoshu = [];
  588. }
  589. $user_info['chengnuoshu'] = $chengnuoshu;
  590. }
  591. //如果有失信被执行人模块
  592. if (in_array('shixin', $forms)) {
  593. if (json_decode($user_info['shixin'])) {
  594. $shixin = json_decode($user_info['shixin'], true);
  595. foreach ($shixin as $k => $v) {
  596. if (array_key_exists('response', $v)) {
  597. if (array_key_exists('path', $v['response'])) {
  598. $shixin[$k]['url'] = $v['response']['path'];
  599. }
  600. }
  601. }
  602. } else {
  603. $shixin = [];
  604. }
  605. $user_info['shixin'] = $shixin;
  606. }
  607. //如果有声明书模块
  608. if (in_array('baokaoshengming', $forms)) {
  609. if (json_decode($user_info['baokaoshengming'])) {
  610. $baokaoshengming = json_decode($user_info['baokaoshengming'], true);
  611. foreach ($baokaoshengming as $k => $v) {
  612. if (array_key_exists('response', $v)) {
  613. if (array_key_exists('path', $v['response'])) {
  614. $baokaoshengming[$k]['url'] = $v['response']['path'];
  615. }
  616. }
  617. }
  618. } else {
  619. $baokaoshengming = [];
  620. }
  621. $user_info['baokaoshengming'] = $baokaoshengming;
  622. }
  623. //获取最新的报名审核信息
  624. $logs = RecruitAppointLog::where('appoint_id', $user_info->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  625. if ($logs) {
  626. $user_info['audit_log'] = $logs->log;
  627. } else {
  628. $user_info['audit_log'] = '';
  629. }
  630. //获取提交报名的次数
  631. // $number = RecruitAppointLog::where('appoint_id',$user_info->id)->where('step',1)->where('type',3)->count();
  632. // $post_number = $number+1;//todo
  633. }
  634. $appoint_info_id = $appoint_info->id;
  635. } else {
  636. //实习专场
  637. if (in_array('internship', $forms)) {
  638. $user_info = json_encode([
  639. 'id' => 0,
  640. 'recruit_id' => $id,
  641. 'operation' => 1,
  642. 'realname' => '',
  643. 'sex' => '1',
  644. 'birthday' => '',
  645. 'card' => '',
  646. 'nation' => '',
  647. 'native_place' => '',
  648. 'political_affiliation' => '',
  649. 'join_time' => '',
  650. 'house_register' => '',
  651. 'education' => '',
  652. 'school' => '',
  653. 'pro' => '',
  654. 'adjust' => '',
  655. 'mobile' => '',
  656. 'email' => '',
  657. 'address' => '',
  658. 'post_id' => '',
  659. 'concat_name' => '',
  660. 'concat_mobile' => '',
  661. 'resume' => '',
  662. 'avatar' => '',
  663. 'family' => [
  664. [
  665. 'relation' => '',
  666. 'realname' => '',
  667. 'birthday' => '',
  668. 'political_affiliation' => '',
  669. 'work' => '',
  670. ],
  671. ],
  672. 'detail' => [
  673. 'rewards_and_punishments' => '',
  674. 'introduce' => '',
  675. ],
  676. 'identification' => [],
  677. 'education_certification' => [],
  678. 'other_certification' => [],
  679. 'hj_certification' => [],
  680. 'chengnuoshu' => [],
  681. 'baokaoshengming' => [],
  682. 'shixin' => [],
  683. ]);
  684. } else {
  685. //如果没有,结合基础数据及模块表单信息,制作数据对象
  686. $user_info = RecruitAppointBasic::where('uid', $uid)->first();
  687. if (!$user_info) {
  688. //没有基础信息跳转完善route('person.recruitInfo')
  689. return $this->showMessage('请先完善招考基础信息!', route('recruit.recruitInfo', ['recruit_id', $id]), true, '上一页', '3');
  690. }
  691. $user_info['sex'] = (string)$user_info['sex'];
  692. $user_info['edu_type'] = (string)$user_info['edu_type'];
  693. $user_info['family'] = json_decode($user_info['family']);
  694. if (in_array('expand_special', $forms)) {
  695. $user_info['special'] = [
  696. 'point_apply' => '0',
  697. 'condition' => '',
  698. 'material' => [],
  699. ];
  700. }
  701. if (in_array('detail', $forms)) {
  702. $user_info['detail'] = [
  703. 'train' => '',
  704. 'rewards_and_punishments' => '',
  705. 'introduce' => '',
  706. ];
  707. }
  708. if (in_array('identification', $forms)) {
  709. $user_info['identification'] = [];
  710. }
  711. if (in_array('education_certification', $forms)) {
  712. $user_info['education_certification'] = [];
  713. }
  714. if (in_array('other_certification', $forms)) {
  715. $user_info['other_certification'] = [];
  716. }
  717. if (in_array('hj_certification', $forms)) {
  718. $user_info['hj_certification'] = [];
  719. }
  720. if (in_array('chengnuoshu', $forms)) {
  721. $user_info['chengnuoshu'] = [];
  722. }
  723. if (in_array('shixin', $forms)) {
  724. $user_info['shixin'] = [];
  725. }
  726. if (in_array('baokaoshengming', $forms)) {
  727. $user_info['baokaoshengming'] = [];
  728. }
  729. $user_info['recruit_id'] = $id;
  730. $user_info['operation'] = 1;
  731. }
  732. $appoint_info_id = 0;
  733. }
  734. //招考岗位
  735. $where_post[] = ['recruit_id', '=', $id];
  736. //$where_post[] = ['status', '=', 1];
  737. $recruit_post = RecruitPost::where($where_post)->get();
  738. $post = [];
  739. $post_limit = [];
  740. $post_special = [];
  741. foreach ($recruit_post as $value) {
  742. $item = [
  743. 'value' => $value['id'],
  744. 'label' => $value['code'] . " " . $value['name'],
  745. 'disabled' => $value['status'] == 1 ? false : true,
  746. ];
  747. $post_limit[$value['id']] = json_decode($value['limit']);
  748. $post_special[$value['id']] = json_decode($value['special']);
  749. array_push($post, $item);
  750. }
  751. $view_data['id'] = $id;
  752. $view_data['appoint_info'] = $user_info;
  753. $view_data['post'] = json_encode($post);
  754. // $view_data['post_number'] = $post_number;
  755. // $view_data['post_times'] = $recruit['post_times'];
  756. $view_data['post_limit'] = json_encode($post_limit);
  757. $view_data['post_special'] = json_encode($post_special);
  758. $view_data['formDisable'] = $formDisabled;
  759. $view_data['title'] = $recruit->company;
  760. $view_data['special_condition_type'] = $recruit->special_condition_type;
  761. $view_data['special_condition_value'] = json_decode($recruit->special_condition_value, true);
  762. return view('app.recruit.sign_up', $view_data);
  763. }
  764. public function preview(Request $request)
  765. {
  766. $modules = $request->input('modules');
  767. $view_data['module'] = $forms = explode(',', $modules);
  768. return view('app.recruit.preview', $view_data);
  769. }
  770. /**
  771. * 提交报名的处理程序
  772. * @param Request $request
  773. * @return array|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect|void
  774. */
  775. public function saveSignUp(Request $request)
  776. {
  777. $user = $this->getUser();
  778. if (!empty($user)) {
  779. $uid = $user->id;
  780. } else {
  781. return redirect(route('login'));
  782. }
  783. $recruit_id = $request->input('recruit_id', 0);
  784. if (!$recruit_id) {
  785. return response()->json(['status' => 0, 'msg' => '请选择项目!']);
  786. }
  787. $recruit = Recruit::find($recruit_id);
  788. // if(!$recruit['status']){
  789. // return response()->json(['status' => 0,'msg' => '抱歉,该项目状态不正确,请联系客服!']);
  790. // }
  791. if ($recruit['current'] != 1 && $recruit['current'] != 2) {
  792. return response()->json(['status' => 0, 'msg' => '抱歉,该项目报名通道已关闭,如有疑问,请联系客服!']);
  793. }
  794. $card = $request->input('card');
  795. $appointinfo_exist = RecruitAppointInfo::where('card', $card)->where('uid', '<>', $uid)->where('recruit_id', $recruit_id)->first();
  796. //兆丰建设两场公告二而一例外
  797. if ($recruit_id == 25 || $recruit_id == 26) {
  798. $special = RecruitAppointInfo::where('card', $card)->where('uid', '<>', $uid)->whereIn('recruit_id', [25, 26])->first();
  799. $appointinfo_exist = $appointinfo_exist & $special;
  800. }
  801. if ($appointinfo_exist) {
  802. return response()->json(['status' => 0, 'msg' => '您的证件已有其他账号的报名记录,请检查!']);
  803. }
  804. if($recruit['limit_times'] == 1){
  805. $time = time();
  806. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  807. if (($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)) {//过了招考时间
  808. if (!$appoint_info) {
  809. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  810. }
  811. if (($time < strtotime($recruit['audit_start']) || strtotime($recruit['audit_end']) < $time)) {//过了审核时间
  812. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过审核时间,无法继续报名!']);
  813. }
  814. //如果有报名记录,先查询首次报名是什么时候
  815. $first_post = RecruitAppointLog::where('appoint_id',$appoint_info->id)->where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  816. if (!$first_post) {//没有记录代表只是暂存
  817. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间1!']);
  818. }
  819. }
  820. }else{
  821. $time = time();
  822. $id = $request->input('id');
  823. if($id > 0){
  824. $appoint_info = RecruitAppointInfo::where('id', $id)->first();
  825. }else{
  826. $post_id = $request->input('post_id');
  827. $appoint_info_post = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->where('post_id',$post_id)->first();
  828. if($appoint_info_post){
  829. return response()->json(['status' => 0, 'msg' => '相同岗位已存在报名记录,请检查 !']);
  830. }
  831. $appoint_info_count = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->count();
  832. if($appoint_info_count >= $recruit['limit_times']){
  833. return response()->json(['status' => 0, 'msg' => '超过报名次数上限!']);
  834. }
  835. $appoint_info = null;
  836. }
  837. if (($time < strtotime($recruit['apply_start']) || strtotime($recruit['apply_end']) < $time)) {//过了招考时间
  838. if($id == 0){
  839. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  840. }
  841. $first_post = RecruitAppointLog::where('appoint_id',$id)->where('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  842. if (!$first_post) {//没有记录代表只是暂存
  843. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  844. }
  845. }
  846. }
  847. $data = $request->only('realname', 'sex', 'birthday', 'avatar', 'nation', 'native_place', 'political_affiliation', 'titles', 'join_time', 'work', 'house_register', 'education', 'school', 'degree', 'pro', 'address', 'card_type', 'card', 'mobile', 'email', 'concat_name', 'concat_mobile', 'resume', 'post_id', 'adjust', 'remark', 'graduation');
  848. if (!array_key_exists('post_id', $data)) {
  849. return response()->json(['status' => 0, 'msg' => '请选择报考岗位']);
  850. }
  851. $post_info = RecruitPost::where('id', $data['post_id'])->where('recruit_id', $recruit_id)->first();
  852. if (!$post_info['status'] || $post_info['deleted_at'] != null) {
  853. return response()->json(['status' => 0, 'msg' => '该岗位已失效']);
  854. }
  855. //获取操作符,是暂存还是提交
  856. $operation = $request->input('operation');
  857. if ($operation == 1) {
  858. $data['audit'] = 0;//暂存
  859. } else {
  860. //基础信息的检查
  861. $rules = [
  862. 'realname' => 'required',
  863. 'sex' => 'required',
  864. 'birthday' => 'required',
  865. 'avatar' => 'required',
  866. 'nation' => 'required',
  867. 'native_place' => 'required',
  868. 'political_affiliation' => 'required',
  869. 'post_id' => 'required',
  870. 'house_register' => 'required',
  871. //'edu_type' => 'required',
  872. 'education' => 'required',
  873. 'school' => 'required',
  874. 'graduation' => 'required',
  875. 'address' => 'required',
  876. 'mobile' => 'required',
  877. 'email' => 'required',
  878. 'card_type' => 'required',
  879. 'card' => 'required',
  880. 'concat_name' => 'required',
  881. 'concat_mobile' => 'required',
  882. 'resume' => 'required',
  883. ];
  884. $messages = [
  885. 'realname.required' => '请填写姓名',
  886. 'sex.required' => '请填写性别',
  887. 'birthday.required' => '请填写出生日期',
  888. 'avatar.required' => '请上传彩色免冠照',
  889. 'nation.required' => '请填写民族',
  890. 'native_place.required' => '请填写籍贯',
  891. 'political_affiliation.required' => '请选择政治面貌',
  892. 'post_id.required' => '请选择报名岗位',
  893. 'house_register.required' => '请填写户籍所在地',
  894. //'edu_type.required' => '请选择教育类型',
  895. 'education.required' => '请输入学历',
  896. 'school.required' => '请输入毕业院校',
  897. 'graduation.required' => '请填写毕业时间',
  898. 'address.required' => '请填写通信地址',
  899. 'mobile.required' => '请填写手机号码',
  900. 'email.required' => '请填写电子邮箱',
  901. 'card_type.required' => '请选择证件类型',
  902. 'card.required' => '请填写身份证号码',
  903. 'resume.required' => '请填写个人简历',
  904. 'concat_name.required' => '请填写联系人姓名',
  905. 'concat_mobile.required' => '请填写联系人手机号码',
  906. ];
  907. $create_data = $request->all();
  908. $validator = Validator::make($create_data, $rules, $messages);
  909. if ($validator->fails()) {
  910. $msg = $validator->errors()->all();
  911. return response()->json(['status' => 0, 'msg' => $msg[0]]);
  912. }
  913. $data['audit'] = 1;//提交
  914. }
  915. if (strlen($data['card']) == 18) {
  916. //身份证判断出生日期和性别
  917. $year = substr($data['card'], 6, 4);
  918. $month = substr($data['card'], 10, 2);
  919. $day = substr($data['card'], 12, 2);
  920. if ($year . '-' . $month . '-' . $day != $data['birthday']) {
  921. $data['birthday'] = $year . '-' . $month . '-' . $day;
  922. }
  923. if (intval(substr($data['card'], 16, 1)) % 2 == 0) {
  924. $data['sex'] = 0;
  925. } else {
  926. $data['sex'] = 1;
  927. }
  928. }
  929. try {
  930. if (!empty($post_info['limit']) && json_decode($post_info['limit'])) {
  931. //岗位限制条件的判断
  932. $post_limit = json_decode($post_info['limit'], true);
  933. if (is_array($post_limit)) {
  934. foreach ($post_limit as $k => $v) {
  935. if ($k == 'birthday') {
  936. $value = str_replace('-', '', $data[$k]);
  937. } else {
  938. $value = $data[$k];
  939. }
  940. switch ($v['op']) {
  941. case '=':
  942. if ($value != $v['value']) {
  943. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  944. }
  945. break;
  946. case '>':
  947. if ($value <= $v['value']) {
  948. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  949. }
  950. break;
  951. case '>=':
  952. if ($value < $v['value']) {
  953. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  954. }
  955. break;
  956. case '<':
  957. if ($value >= $v['value']) {
  958. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  959. }
  960. break;
  961. case '<=':
  962. if ($value > $v['value']) {
  963. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  964. }
  965. break;
  966. case '!=':
  967. if ($value == $v['value']) {
  968. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  969. }
  970. break;
  971. case 'like':
  972. if (strpos($value, $v['value']) === false) {
  973. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  974. }
  975. break;
  976. case 'in':
  977. if (strpos($v['value'], $value) === false) {
  978. return response()->json(['status' => 0, 'msg' => $v['msg']]);
  979. }
  980. break;
  981. }
  982. }
  983. }
  984. }
  985. } catch (\Exception $e) {
  986. error_log(serialize($data), 3, '/data/wwwroot/jucai/sms');
  987. return ['status' => 0, 'msg' => '数据有误,请联系客服'];
  988. }
  989. //前置审核 判断完成,先将数据入报名信息基础表
  990. //解析家庭成员数据
  991. $familys = $request->input('family');
  992. $family = [];
  993. if (is_array($familys)) {
  994. foreach ($familys as $value) {
  995. if (!array_key_exists('relation', $value) || !array_key_exists('realname', $value) || !array_key_exists('birthday', $value) || !array_key_exists('political_affiliation', $value) || !array_key_exists('work', $value)) {
  996. return ['status' => 0, 'msg' => '请填写完整的家庭成员信息'];
  997. }
  998. $item = [
  999. 'relation' => $value['relation'],
  1000. 'realname' => $value['realname'],
  1001. 'birthday' => $value['birthday'],
  1002. 'political_affiliation' => $value['political_affiliation'],
  1003. 'work' => $value['work'],
  1004. ];
  1005. array_push($family, $item);
  1006. }
  1007. }
  1008. $forms = explode(',', $recruit['forms']);
  1009. if (in_array('expand_special', $forms)) {
  1010. $special = $request->input('special');
  1011. if ($special['point_apply'] && is_array($special['condition']) && count($special['condition']) == 0) {
  1012. return response()->json(['status' => 0, 'msg' => '加分条件不能为空']);
  1013. }
  1014. if ($special['point_apply'] && ($special['condition'] == '')) {
  1015. return response()->json(['status' => 0, 'msg' => '加分条件不能为空']);
  1016. }
  1017. }
  1018. $data['family'] = json_encode($family);
  1019. if ($appoint_info) {
  1020. //如果已有报名记录,进入修改阶段的处理流程
  1021. DB::beginTransaction();
  1022. try {
  1023. RecruitAppointInfo::where('id', $appoint_info->id)->update($data);
  1024. //分模块解析数据
  1025. //如果有加分模块
  1026. if (in_array('expand_special', $forms)) {
  1027. $special = $request->input('special');
  1028. if ($special['point_apply']) {//如果申请加分
  1029. if (!array_key_exists('material', $special)) {
  1030. return response()->json(['status' => 0, 'msg' => '加分佐证材料不能为空!']);
  1031. }
  1032. //删除掉没有成功返回路径的图片
  1033. if (is_array($special['material'])) {
  1034. foreach ($special['material'] as $k => $v) {
  1035. if (!array_key_exists('response', $v)) {
  1036. unset($special['material'][$k]);
  1037. }
  1038. }
  1039. }
  1040. switch ($recruit->special_condition_type) {
  1041. case 0:
  1042. $special['point'] = 0;
  1043. break;
  1044. case 1:
  1045. $special_rule = json_decode($recruit->special_condition_value, true);
  1046. $conditions = array_column($special_rule['list'], 'condition');
  1047. $special['point'] = 0;
  1048. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1049. foreach ($special['condition'] as $v) {
  1050. $key = array_search($v, $conditions);
  1051. $rule_info = $special_rule['list'][$key];
  1052. $special['point'] += $rule_info['value'];
  1053. }
  1054. } else {
  1055. $key = array_search($special['condition'], $conditions);
  1056. $rule_info = $special_rule['list'][$key];
  1057. $special['point'] += $rule_info['value'];
  1058. }
  1059. break;
  1060. case 2:
  1061. $special_rule = json_decode($post_info['special'], true);
  1062. $conditions = array_column($special_rule['list'], 'condition');
  1063. $special['point'] = 0;
  1064. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1065. foreach ($special['condition'] as $v) {
  1066. $key = array_search($v, $conditions);
  1067. $rule_info = $special_rule['list'][$key];
  1068. $special['point'] += $rule_info['value'];
  1069. }
  1070. } else {
  1071. $key = array_search($special['condition'], $conditions);
  1072. $rule_info = $special_rule['list'][$key];
  1073. $special['point'] += $rule_info['value'];
  1074. }
  1075. break;
  1076. }
  1077. if (is_array($special['condition'])) {
  1078. $special['condition'] = implode(',', $special['condition']);
  1079. }
  1080. $special['material'] = json_encode($special['material']);
  1081. $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->first();
  1082. if ($hasRecord) {
  1083. RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->update($special);
  1084. } else {
  1085. $special['recruit_appoint_id'] = $appoint_info->id;
  1086. RecruitAppointExpandSpecial::create($special);
  1087. }
  1088. } else {
  1089. RecruitAppointExpandSpecial::where('recruit_appoint_id', $appoint_info->id)->update(['point_apply' => 0, 'condition' => '', 'point' => 0, 'material' => null]);
  1090. }
  1091. }
  1092. //如果有详情模块
  1093. if (in_array('detail', $forms) || in_array('internship', $forms)) {
  1094. $detail = $request->input('detail');
  1095. $hasRecord = RecruitAppointDetail::where('recruit_appoint_id', $appoint_info->id)->first();
  1096. if ($hasRecord) {
  1097. RecruitAppointDetail::where('recruit_appoint_id', $appoint_info->id)->update($detail);
  1098. } else {
  1099. $detail['recruit_appoint_id'] = $appoint_info->id;
  1100. RecruitAppointDetail::create($detail);
  1101. }
  1102. }
  1103. //如果有身份证明模块
  1104. if (in_array('identification', $forms) || in_array('internship', $forms)) {
  1105. $identification = $request->input('identification');
  1106. if (is_array($identification)) {
  1107. //删除掉没有成功返回路径的图片
  1108. foreach ($identification as $k => $v) {
  1109. if (!array_key_exists('response', $v)) {
  1110. unset($identification[$k]);
  1111. }
  1112. }
  1113. }
  1114. $appoint_info->identification = json_encode($identification);
  1115. $appoint_info->save();
  1116. }
  1117. //如果有教育证明模块
  1118. if (in_array('education_certification', $forms) || in_array('internship', $forms)) {
  1119. $education_certification = $request->input('education_certification');
  1120. if (is_array($education_certification)) {
  1121. //删除掉没有成功返回路径的图片
  1122. foreach ($education_certification as $k => $v) {
  1123. if (!array_key_exists('response', $v)) {
  1124. unset($education_certification[$k]);
  1125. }
  1126. }
  1127. }
  1128. $appoint_info->education_certification = json_encode($education_certification);
  1129. $appoint_info->save();
  1130. }
  1131. //如果有其他证明模块
  1132. if (in_array('other_certification', $forms) || in_array('internship', $forms)) {
  1133. $other_certification = $request->input('other_certification');
  1134. if (is_array($other_certification)) {
  1135. //删除掉没有成功返回路径的图片
  1136. foreach ($other_certification as $k => $v) {
  1137. if (!array_key_exists('response', $v)) {
  1138. unset($other_certification[$k]);
  1139. }
  1140. }
  1141. }
  1142. if ($other_certification) {
  1143. $appoint_info->other_certification = json_encode($other_certification);
  1144. $appoint_info->save();
  1145. }
  1146. }
  1147. //如果有其他证明模块
  1148. if (in_array('hj_certification', $forms)) {
  1149. $hj_certification = $request->input('hj_certification');
  1150. if (is_array($hj_certification)) {
  1151. //删除掉没有成功返回路径的图片
  1152. foreach ($hj_certification as $k => $v) {
  1153. if (!array_key_exists('response', $v)) {
  1154. unset($hj_certification[$k]);
  1155. }
  1156. }
  1157. }
  1158. if ($hj_certification) {
  1159. $appoint_info->hj_certification = json_encode($hj_certification);
  1160. $appoint_info->save();
  1161. }
  1162. }
  1163. //如果有承诺书模块
  1164. if (in_array('chengnuoshu', $forms)) {
  1165. $chengnuoshu = $request->input('chengnuoshu');
  1166. if (is_array($chengnuoshu)) {
  1167. //删除掉没有成功返回路径的图片
  1168. foreach ($chengnuoshu as $k => $v) {
  1169. if (!array_key_exists('response', $v)) {
  1170. unset($chengnuoshu[$k]);
  1171. }
  1172. }
  1173. }
  1174. if ($chengnuoshu) {
  1175. $appoint_info->chengnuoshu = json_encode($chengnuoshu);
  1176. $appoint_info->save();
  1177. }
  1178. }
  1179. //如果有失信被执行人模块
  1180. if (in_array('shixin', $forms)) {
  1181. $shixin = $request->input('shixin');
  1182. if (is_array($shixin)) {
  1183. //删除掉没有成功返回路径的图片
  1184. foreach ($shixin as $k => $v) {
  1185. if (!array_key_exists('response', $v)) {
  1186. unset($shixin[$k]);
  1187. }
  1188. }
  1189. }
  1190. if ($shixin) {
  1191. $appoint_info->shixin = json_encode($shixin);
  1192. $appoint_info->save();
  1193. }
  1194. }
  1195. //如果有声明书模块
  1196. if (in_array('baokaoshengming', $forms)) {
  1197. $baokaoshengming = $request->input('baokaoshengming');
  1198. if (is_array($baokaoshengming)) {
  1199. //删除掉没有成功返回路径的图片
  1200. foreach ($baokaoshengming as $k => $v) {
  1201. if (!array_key_exists('response', $v)) {
  1202. unset($baokaoshengming[$k]);
  1203. }
  1204. }
  1205. }
  1206. if ($baokaoshengming) {
  1207. $appoint_info->baokaoshengming = json_encode($baokaoshengming);
  1208. $appoint_info->save();
  1209. }
  1210. }
  1211. DB::commit();
  1212. if ($operation == 2) {
  1213. $log = [
  1214. 'type' => 3,
  1215. 'appoint_id' => $appoint_info->id,
  1216. 'uid' => $uid,
  1217. 'log' => '用户提交报名',
  1218. ];
  1219. RecruitAppointLog::create($log);
  1220. if (empty($recruit->qr_code)) {
  1221. return ['status' => 1, 'msg' => '提交成功', 'data' => $appoint_info->id, 'is_html' => 0];
  1222. } else {
  1223. return ['status' => 1, 'msg' => "<h3 style='text-align: center'>提交成功,添加工作人员企业微信了解后续信息</h3><p style='text-align: center'><img src='{$recruit->qr_code}' width='240' height='240' /></p>", 'data' => $appoint_info->id, 'is_html' => 1];
  1224. }
  1225. } else {
  1226. $log = [
  1227. 'type' => 4,
  1228. 'appoint_id' => $appoint_info->id,
  1229. 'uid' => $uid,
  1230. 'log' => '用户修改资料',
  1231. ];
  1232. RecruitAppointLog::create($log);
  1233. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  1234. }
  1235. } catch (\Exception $e) {
  1236. DB::rollback();
  1237. return ['status' => 0, 'msg' => $e->getMessage()];
  1238. }
  1239. } else {
  1240. //没有报名记录,进入增加阶段的处理流程
  1241. DB::beginTransaction();
  1242. try {
  1243. //20220726增加地区undefined选项处理
  1244. if ($index = stripos($data['native_place'], ',undefined')) {
  1245. $data['native_place'] = substr($data['native_place'], 0, $index);
  1246. }
  1247. if ($index = stripos($data['house_register'], ',undefined')) {
  1248. $data['house_register'] = substr($data['house_register'], 0, $index);
  1249. }
  1250. $data['uid'] = $uid;
  1251. $data['recruit_id'] = $recruit_id;
  1252. $result = RecruitAppointInfo::create($data);
  1253. //分模块解析数据
  1254. $forms = explode(',', $recruit['forms']);
  1255. //如果有加分模块
  1256. if (in_array('expand_special', $forms)) {
  1257. $special = $request->input('special');
  1258. if ($special['point_apply']) {
  1259. if (is_array($special['material'])) {
  1260. //删除掉没有成功返回路径的图片
  1261. foreach ($special['material'] as $k => $v) {
  1262. if (!array_key_exists('response', $v)) {
  1263. unset($special['material'][$k]);
  1264. }
  1265. }
  1266. }
  1267. switch ($recruit->special_condition_type) {
  1268. case 0:
  1269. $special['point'] = 0;
  1270. break;
  1271. case 1:
  1272. $special_rule = json_decode($recruit->special_condition_value, true);
  1273. $conditions = array_column($special_rule['list'], 'condition');
  1274. $special['point'] = 0;
  1275. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1276. foreach ($special['condition'] as $v) {
  1277. $key = array_search($v, $conditions);
  1278. $rule_info = $special_rule['list'][$key];
  1279. $special['point'] += $rule_info['value'];
  1280. }
  1281. } else {
  1282. $key = array_search($special['condition'], $conditions);
  1283. $rule_info = $special_rule['list'][$key];
  1284. $special['point'] += $rule_info['value'];
  1285. }
  1286. break;
  1287. case 2:
  1288. $special_rule = json_decode($post_info['special'], true);
  1289. $conditions = array_column($special_rule['list'], 'condition');
  1290. $special['point'] = 0;
  1291. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1292. foreach ($special['condition'] as $v) {
  1293. $key = array_search($v, $conditions);
  1294. $rule_info = $special_rule['list'][$key];
  1295. $special['point'] += $rule_info['value'];
  1296. }
  1297. } else {
  1298. $key = array_search($special['condition'], $conditions);
  1299. $rule_info = $special_rule['list'][$key];
  1300. $special['point'] += $rule_info['value'];
  1301. }
  1302. break;
  1303. }
  1304. if (is_array($special['condition'])) {
  1305. $special['condition'] = implode(',', $special['condition']);
  1306. }
  1307. $special['material'] = json_encode($special['material']);
  1308. $special['recruit_appoint_id'] = $result->id;
  1309. RecruitAppointExpandSpecial::create($special);
  1310. }
  1311. }
  1312. //如果有详情模块
  1313. if (in_array('detail', $forms) || in_array('internship', $forms)) {
  1314. $detail = $request->input('detail');
  1315. $detail['recruit_appoint_id'] = $result->id;
  1316. RecruitAppointDetail::create($detail);
  1317. }
  1318. //如果有身份证明模块
  1319. if (in_array('identification', $forms) || in_array('internship', $forms)) {
  1320. $identification = $request->input('identification');
  1321. if (is_array($identification)) {
  1322. //删除掉没有成功返回路径的图片
  1323. foreach ($identification as $k => $v) {
  1324. if (!array_key_exists('response', $v)) {
  1325. unset($identification[$k]);
  1326. }
  1327. }
  1328. }
  1329. $result->identification = json_encode($identification);
  1330. $result->save();
  1331. }
  1332. //如果有教育证明模块
  1333. if (in_array('education_certification', $forms) || in_array('internship', $forms)) {
  1334. $education_certification = $request->input('education_certification');
  1335. if (is_array($education_certification)) {
  1336. //删除掉没有成功返回路径的图片
  1337. foreach ($education_certification as $k => $v) {
  1338. if (!array_key_exists('response', $v)) {
  1339. unset($education_certification[$k]);
  1340. }
  1341. }
  1342. }
  1343. $result->education_certification = json_encode($education_certification);
  1344. $result->save();
  1345. }
  1346. //如果有其他证明模块
  1347. if (in_array('other_certification', $forms) || in_array('internship', $forms)) {
  1348. $other_certification = $request->input('other_certification');
  1349. if ($other_certification) {
  1350. if (is_array($other_certification)) {
  1351. //删除掉没有成功返回路径的图片
  1352. foreach ($other_certification as $k => $v) {
  1353. if (!array_key_exists('response', $v)) {
  1354. unset($other_certification[$k]);
  1355. }
  1356. }
  1357. }
  1358. $result->other_certification = json_encode($other_certification);
  1359. $result->save();
  1360. }
  1361. }
  1362. //如果有户籍证明模块
  1363. if (in_array('hj_certification', $forms)) {
  1364. $hj_certification = $request->input('hj_certification');
  1365. if ($hj_certification) {
  1366. if (is_array($hj_certification)) {
  1367. //删除掉没有成功返回路径的图片
  1368. foreach ($hj_certification as $k => $v) {
  1369. if (!array_key_exists('response', $v)) {
  1370. unset($hj_certification[$k]);
  1371. }
  1372. }
  1373. }
  1374. $result->hj_certification = json_encode($hj_certification);
  1375. $result->save();
  1376. }
  1377. }
  1378. //如果有承诺书模块
  1379. if (in_array('chengnuoshu', $forms)) {
  1380. $chengnuoshu = $request->input('chengnuoshu');
  1381. if ($chengnuoshu) {
  1382. if (is_array($chengnuoshu)) {
  1383. //删除掉没有成功返回路径的图片
  1384. foreach ($chengnuoshu as $k => $v) {
  1385. if (!array_key_exists('response', $v)) {
  1386. unset($chengnuoshu[$k]);
  1387. }
  1388. }
  1389. }
  1390. $result->chengnuoshu = json_encode($chengnuoshu);
  1391. $result->save();
  1392. }
  1393. }
  1394. //如果有失信被执行人模块
  1395. if (in_array('shixin', $forms)) {
  1396. $shixin = $request->input('shixin');
  1397. if ($shixin) {
  1398. if (is_array($shixin)) {
  1399. //删除掉没有成功返回路径的图片
  1400. foreach ($shixin as $k => $v) {
  1401. if (!array_key_exists('response', $v)) {
  1402. unset($shixin[$k]);
  1403. }
  1404. }
  1405. }
  1406. $result->shixin = json_encode($shixin);
  1407. $result->save();
  1408. }
  1409. }
  1410. //如果有声明书模块
  1411. if (in_array('baokaoshengming', $forms)) {
  1412. $baokaoshengming = $request->input('baokaoshengming');
  1413. if ($baokaoshengming) {
  1414. if (is_array($baokaoshengming)) {
  1415. //删除掉没有成功返回路径的图片
  1416. foreach ($baokaoshengming as $k => $v) {
  1417. if (!array_key_exists('response', $v)) {
  1418. unset($baokaoshengming[$k]);
  1419. }
  1420. }
  1421. }
  1422. $result->baokaoshengming = json_encode($baokaoshengming);
  1423. $result->save();
  1424. }
  1425. }
  1426. DB::commit();
  1427. if ($operation == 2) {
  1428. $log = [
  1429. 'type' => 3,
  1430. 'appoint_id' => $result->id,
  1431. 'uid' => $uid,
  1432. 'log' => '用户首次提交报名',
  1433. ];
  1434. RecruitAppointLog::create($log);
  1435. if (empty($recruit->qr_code)) {
  1436. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id, 'is_html' => 0];
  1437. } else {
  1438. return ['status' => 1, 'msg' => "<h3 style='text-align: center'>提交成功,添加工作人员企业微信了解后续信息</h3><p><img src='/storage/{$recruit->qr_code}' width='240' height='240' /></p>", 'data' => $result->id, 'is_html' => 1];
  1439. }
  1440. //return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  1441. } else {
  1442. $log = [
  1443. 'type' => 4,
  1444. 'appoint_id' => $result->id,
  1445. 'uid' => $uid,
  1446. 'log' => '用户暂存资料',
  1447. ];
  1448. RecruitAppointLog::create($log);
  1449. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  1450. }
  1451. } catch (\Exception $e) {
  1452. DB::rollback();
  1453. return ['status' => 0, 'msg' => $e->getMessage()];
  1454. }
  1455. }
  1456. }
  1457. /**
  1458. * 获得当前登录的用户
  1459. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  1460. */
  1461. public function getUser()
  1462. {
  1463. if (auth('web-member')->check()) {
  1464. $user = auth('web-member')->user();
  1465. } else {
  1466. $user = null;
  1467. }
  1468. return $user;
  1469. }
  1470. /**
  1471. * 检查用户基本信息
  1472. * @return array
  1473. */
  1474. public function checkUserBasicInfo()
  1475. {
  1476. $user = $this->getUser();
  1477. if (!empty($user)) {
  1478. $uid = $user->id;
  1479. } else {
  1480. $arr = ['status' => 401, 'msg' => '请登录!'];
  1481. return $arr;
  1482. }
  1483. $info = RecruitAppointBasic::where('uid', $uid)->first();
  1484. if (empty($info)) {
  1485. $arr = ['status' => 401, 'msg' => '请先完善招考基本信息', 'url' => route('recruit.recruitInfo')];
  1486. return $arr;
  1487. }
  1488. return ['status' => 200, 'msg' => ''];
  1489. }
  1490. /**
  1491. * 个人中心招考页面
  1492. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1493. */
  1494. public function person_recruit()
  1495. {
  1496. $user = auth('web-member')->user();
  1497. $list = RecruitAppointInfo::where('uid', $user->id)
  1498. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1499. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1500. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  1501. ->get();
  1502. return view('app.person.recruit')->with(['list' => $list, 'total' => count($list)]);
  1503. }
  1504. /**
  1505. * 招考信息基础页
  1506. * @param Request $request
  1507. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1508. */
  1509. public function recruit_info(Request $request)
  1510. {
  1511. $user = auth('web-member')->user();
  1512. if (!empty($user)) {
  1513. $uid = $user->id;
  1514. } else {
  1515. return redirect(route('login'));
  1516. }
  1517. $info = RecruitAppointBasic::where('uid', $user->id)->first();
  1518. if (!$info) {
  1519. $info = [
  1520. 'realname' => '',
  1521. 'sex' => '0',
  1522. 'birthday' => '',
  1523. 'avatar' => '',
  1524. 'nation' => '',
  1525. 'native_place' => '',
  1526. 'political_affiliation' => '',
  1527. 'titles' => '',
  1528. 'work' => '',
  1529. 'house_register' => '',
  1530. 'join_time' => '',
  1531. 'edu_type' => '',
  1532. 'education' => '',
  1533. 'school' => '',
  1534. 'degree' => '',
  1535. 'pro' => '',
  1536. 'address' => '',
  1537. 'card' => '',
  1538. 'mobile' => '',
  1539. 'email' => '',
  1540. 'concat_name' => '',
  1541. 'concat_mobile' => '',
  1542. 'resume' => '',
  1543. 'family' => [
  1544. [
  1545. 'relation' => '',
  1546. 'realname' => '',
  1547. 'birthday' => '',
  1548. 'political_affiliation' => '',
  1549. 'work' => '',
  1550. ],
  1551. ],
  1552. 'is_push' => '1',
  1553. ];
  1554. } else {
  1555. $info->sex = (string)$info->sex;
  1556. $info->edu_type = (string)$info->edu_type;
  1557. $info->is_push = (string)$info->is_push;
  1558. $info->family = empty($info->family) ? [[
  1559. 'relation' => '',
  1560. 'realname' => '',
  1561. 'birthday' => '',
  1562. 'political_affiliation' => '',
  1563. 'work' => '',
  1564. ]] : json_decode($info->family);
  1565. }
  1566. $recruit_id = $request->input('recruit_id', 0);
  1567. return view('app.person.recruit_info', [
  1568. 'info' => json_encode($info),
  1569. 'recruit_id' => $recruit_id,
  1570. ]);
  1571. }
  1572. /**
  1573. * 保存招考信息
  1574. * @param RecruitValidatorRequest $request
  1575. * @return \Illuminate\Http\JsonResponse
  1576. */
  1577. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1578. {
  1579. $user = auth('web-member')->user();
  1580. $basic = RecruitAppointBasic::where('uid', $user->id)->first();
  1581. $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');
  1582. if (count($data['family']) > 0) {
  1583. $data['family'] = json_encode($data['family']);
  1584. }
  1585. if ($basic) {
  1586. //更新基础信息
  1587. $res = RecruitAppointBasic::where('uid', $user->id)->update($data);
  1588. if (!$res) {
  1589. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1590. } else {
  1591. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1592. }
  1593. } else {
  1594. //新增基础信息
  1595. $data['uid'] = $user->id;
  1596. $res = RecruitAppointBasic::create($data);
  1597. if (!$res) {
  1598. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1599. } else {
  1600. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1601. }
  1602. }
  1603. }
  1604. /**
  1605. * 笔试准考证
  1606. * @param Request $request
  1607. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1608. */
  1609. public function pen_ticket(Request $request)
  1610. {
  1611. $user = $this->getUser();
  1612. if (!empty($user)) {
  1613. $uid = $user->id;
  1614. } else {
  1615. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1616. }
  1617. $recruit_id = $request->input('recruit_id');
  1618. $recruit = Recruit::where('id', $recruit_id)->first();
  1619. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1620. if ($appoint_info) {
  1621. $pen_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 1)->first();
  1622. if ($pen_ticket) {
  1623. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1624. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1625. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1626. }
  1627. $time = time();
  1628. if (strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time) {
  1629. RecruitTicket::where('appoint_id', $appoint_info->id)->update(['ex_status' => 1]);
  1630. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1631. $name = $recruit->name_en;
  1632. $date = date("Y-m-d", strtotime($recruit->created_at));
  1633. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1634. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1635. // return view('app.recruit.recruit_ticket', [
  1636. // 'title' => "{$filename}.docx",
  1637. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/pen/{$filename}.docx",
  1638. // ]);
  1639. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1640. if (file_exists($file)) {
  1641. header('Content-Description: File Transfer');
  1642. header('Content-Type: application/octet-stream');
  1643. header('Content-Disposition: attachment; filename=' . basename($file));
  1644. header('Content-Transfer-Encoding: binary');
  1645. header('Expires: 0');
  1646. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1647. header('Pragma: public');
  1648. header('Content-Length: ' . filesize($file));
  1649. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1650. flush();
  1651. readfile($file);
  1652. } else {
  1653. return $this->showMessage('准考证不存在,请联系管理员!', route('home'), true, '上一页', '3');
  1654. }
  1655. } else {
  1656. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1657. }
  1658. } else {
  1659. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1660. }
  1661. } else {
  1662. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1663. }
  1664. }
  1665. /**
  1666. * 审核准考证
  1667. * @param Request $request
  1668. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1669. */
  1670. public function check_ticket(Request $request)
  1671. {
  1672. $user = $this->getUser();
  1673. if (!empty($user)) {
  1674. $uid = $user->id;
  1675. } else {
  1676. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1677. }
  1678. $recruit_id = $request->input('recruit_id');
  1679. $recruit = Recruit::where('id', $recruit_id)->first();
  1680. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1681. if ($appoint_info) {
  1682. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  1683. if ($check_ticket) {
  1684. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1685. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1686. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1687. }
  1688. $time = time();
  1689. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  1690. RecruitTicket::where('id', $check_ticket->id)->update(['ex_status' => 1]);
  1691. $recruit = Recruit::where('id', $recruit_id)->first();
  1692. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1693. $name = $recruit->name_en;
  1694. $date = date("Y-m-d", strtotime($recruit->created_at));
  1695. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1696. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1697. // return view('app.recruit.recruit_ticket', [
  1698. // 'title' => "{$filename}.docx",
  1699. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/computer/{$filename}.docx",
  1700. // ]);
  1701. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/computer/" . $filename . '.pdf';
  1702. if (file_exists($file)) {
  1703. header('Content-Description: File Transfer');
  1704. header('Content-Type: application/octet-stream');
  1705. header('Content-Disposition: attachment; filename=' . basename($file));
  1706. header('Content-Transfer-Encoding: binary');
  1707. header('Expires: 0');
  1708. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1709. header('Pragma: public');
  1710. header('Content-Length: ' . filesize($file));
  1711. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1712. flush();
  1713. readfile($file);
  1714. }
  1715. } else {
  1716. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1717. }
  1718. } else {
  1719. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1720. }
  1721. } else {
  1722. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1723. }
  1724. }
  1725. /**
  1726. * 面试准考证
  1727. * @param Request $request
  1728. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1729. */
  1730. public function face_ticket(Request $request)
  1731. {
  1732. $user = $this->getUser();
  1733. if (!empty($user)) {
  1734. $uid = $user->id;
  1735. } else {
  1736. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1737. }
  1738. $recruit_id = $request->input('recruit_id');
  1739. $recruit = Recruit::where('id', $recruit_id)->first();
  1740. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->orderBy('id','desc')->first();
  1741. if ($appoint_info) {
  1742. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  1743. if ($face_ticket) {
  1744. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1745. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1746. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1747. }
  1748. $time = time();
  1749. if (strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time) {
  1750. RecruitTicket::where('id', $face_ticket->id)->update(['ex_status' => 1]);
  1751. $recruit = Recruit::where('id', $recruit_id)->first();
  1752. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1753. $name = $recruit->name_en;
  1754. $date = date("Y-m-d", strtotime($recruit->created_at));
  1755. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1756. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1757. // return view('app.recruit.recruit_ticket', [
  1758. // 'title' => "{$filename}.docx",
  1759. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/face/{$filename}.docx",
  1760. // ]);
  1761. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1762. if (file_exists($file)) {
  1763. header('Content-Description: File Transfer');
  1764. header('Content-Type: application/octet-stream');
  1765. header('Content-Disposition: attachment; filename=' . basename($file));
  1766. header('Content-Transfer-Encoding: binary');
  1767. header('Expires: 0');
  1768. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1769. header('Pragma: public');
  1770. header('Content-Length: ' . filesize($file));
  1771. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1772. flush();
  1773. readfile($file);
  1774. }
  1775. } else {
  1776. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1777. }
  1778. } else {
  1779. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1780. }
  1781. } else {
  1782. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1783. }
  1784. }
  1785. /**
  1786. * 复试准考证
  1787. * @param Request $request
  1788. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1789. */
  1790. public function reexamine_ticket(Request $request)
  1791. {
  1792. $user = $this->getUser();
  1793. if (!empty($user)) {
  1794. $uid = $user->id;
  1795. } else {
  1796. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1797. }
  1798. $recruit_id = $request->input('recruit_id');
  1799. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1800. if ($appoint_info) {
  1801. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  1802. if ($reexamine_ticket) {
  1803. $time = time();
  1804. if (strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time) {
  1805. RecruitTicket::where('id', $reexamine_ticket->id)->update(['ex_status' => 1]);
  1806. $recruit = Recruit::where('id', $recruit_id)->first();
  1807. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1808. $name = $recruit->name_en;
  1809. $date = date("Y-m-d", strtotime($recruit->created_at));
  1810. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1811. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1812. if (file_exists($file)) {
  1813. header('Content-Description: File Transfer');
  1814. header('Content-Type: application/octet-stream');
  1815. header('Content-Disposition: attachment; filename=' . basename($file));
  1816. header('Content-Transfer-Encoding: binary');
  1817. header('Expires: 0');
  1818. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1819. header('Pragma: public');
  1820. header('Content-Length: ' . filesize($file));
  1821. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1822. flush();
  1823. readfile($file);
  1824. }
  1825. } else {
  1826. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1827. }
  1828. } else {
  1829. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1830. }
  1831. } else {
  1832. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1833. }
  1834. }
  1835. /**
  1836. * 材料补登
  1837. * @param Request $request
  1838. */
  1839. public function material_supplement(Request $request)
  1840. {
  1841. $user = $this->getUser();
  1842. if (!empty($user)) {
  1843. $uid = $user->id;
  1844. } else {
  1845. return redirect(route('login'));
  1846. }
  1847. //招考id
  1848. $id = $request->input('id', 0);
  1849. if (!$id) {
  1850. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1851. }
  1852. $recruit = Recruit::find($id);
  1853. if (!$recruit['status'] && !$user->recruit_test) {
  1854. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1855. }
  1856. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1857. if (!$appoint_info) {
  1858. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1859. }
  1860. if ($appoint_info->pen_audit != 1) {
  1861. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1862. }
  1863. $limit_time = 1726824600;
  1864. $time = time();
  1865. if ($time > $limit_time) {
  1866. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1867. }
  1868. $info = RecruitSupplement::where('appoint_id', $appoint_info->id)->where('type', 'supplement')->first();
  1869. if (!$info) {
  1870. $info = [
  1871. 'appoint_id' => $appoint_info->id,
  1872. 'identification' => '',
  1873. //'household_register' => '',
  1874. //'education_certification' => '',
  1875. //'family_planning' => '',
  1876. 'chengxin' => '',
  1877. 'manage' => '',
  1878. 'status' => 3,
  1879. ];
  1880. } else {
  1881. $info = $info->toArray();
  1882. if (json_decode($info['identification'])) {
  1883. $identification = json_decode($info['identification'], true);
  1884. foreach ($identification as $k => $v) {
  1885. if (array_key_exists('response', $v)) {
  1886. $identification[$k]['url'] = $v['response']['path'];
  1887. }
  1888. }
  1889. } else {
  1890. $identification = [];
  1891. }
  1892. $info['identification'] = $identification;
  1893. if (json_decode($info['household_register'])) {
  1894. $household_register = json_decode($info['household_register'], true);
  1895. foreach ($household_register as $k => $v) {
  1896. if (array_key_exists('response', $v)) {
  1897. $household_register[$k]['url'] = $v['response']['path'];
  1898. }
  1899. }
  1900. } else {
  1901. $household_register = [];
  1902. }
  1903. $info['household_register'] = $household_register;
  1904. if (json_decode($info['education_certification'])) {
  1905. $education_certification = json_decode($info['education_certification'], true);
  1906. foreach ($education_certification as $k => $v) {
  1907. if (array_key_exists('response', $v)) {
  1908. $education_certification[$k]['url'] = $v['response']['path'];
  1909. }
  1910. }
  1911. } else {
  1912. $education_certification = [];
  1913. }
  1914. $info['education_certification'] = $education_certification;
  1915. if (json_decode($info['family_planning'])) {
  1916. $family_planning = json_decode($info['family_planning'], true);
  1917. foreach ($family_planning as $k => $v) {
  1918. if (array_key_exists('response', $v)) {
  1919. $family_planning[$k]['url'] = $v['response']['path'];
  1920. }
  1921. }
  1922. } else {
  1923. $family_planning = [];
  1924. }
  1925. $info['family_planning'] = $family_planning;
  1926. if (json_decode($info['chengxin'])) {
  1927. $chengxin = json_decode($info['chengxin'], true);
  1928. foreach ($chengxin as $k => $v) {
  1929. if (array_key_exists('response', $v)) {
  1930. $chengxin[$k]['url'] = $v['response']['path'];
  1931. }
  1932. }
  1933. } else {
  1934. $chengxin = [];
  1935. }
  1936. $info['chengxin'] = $chengxin;
  1937. if (json_decode($info['manage'])) {
  1938. $manage = json_decode($info['manage'], true);
  1939. foreach ($manage as $k => $v) {
  1940. if (array_key_exists('response', $v)) {
  1941. $manage[$k]['url'] = $v['response']['path'];
  1942. }
  1943. }
  1944. } else {
  1945. $manage = [];
  1946. }
  1947. $info['manage'] = $manage;
  1948. }
  1949. $view_data['info'] = json_encode($info);
  1950. $view_data['title'] = $recruit->company;
  1951. return view('app.recruit.supplement', $view_data);
  1952. }
  1953. /**
  1954. * 健康信息登记
  1955. * @param Request $request
  1956. */
  1957. public function health_info(Request $request)
  1958. {
  1959. $user = $this->getUser();
  1960. if (!empty($user)) {
  1961. $uid = $user->id;
  1962. } else {
  1963. return redirect(route('login'));
  1964. }
  1965. //招考id
  1966. $id = $request->input('id', 0);
  1967. if (!$id) {
  1968. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1969. }
  1970. $recruit = Recruit::find($id);
  1971. if (!$recruit['status'] && !$user->recruit_test) {
  1972. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1973. }
  1974. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1975. if (!$appoint_info) {
  1976. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1977. }
  1978. if ($appoint_info->audit != 3) {
  1979. return $this->showMessage('抱歉,您无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1980. }
  1981. $time = time();
  1982. $type = $request->input('type', null);
  1983. $where = [];
  1984. if ($type) {
  1985. switch ($type) {
  1986. case 'pen':
  1987. $start = strtotime($recruit->pen_health_start);
  1988. $end = strtotime($recruit->pen_health_end);
  1989. break;
  1990. case 'computer':
  1991. $start = strtotime($recruit->computer_health_start);
  1992. $end = strtotime($recruit->computer_health_end);
  1993. break;
  1994. case 'face':
  1995. $start = strtotime($recruit->face_health_start);
  1996. $end = strtotime($recruit->face_health_end);
  1997. break;
  1998. case 'reexamine':
  1999. $start = strtotime($recruit->reexamine_health_start);
  2000. $end = strtotime($recruit->reexamine_health_end);
  2001. break;
  2002. default:
  2003. $start = strtotime($recruit->supplement_start);
  2004. $end = strtotime($recruit->supplement_end);
  2005. break;
  2006. }
  2007. $where[] = ['type', '=', $type];
  2008. } else {
  2009. $start = strtotime($recruit->supplement_start);
  2010. $end = strtotime($recruit->supplement_end);
  2011. }
  2012. if ($time > $end || $time < $start) {
  2013. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2014. }
  2015. $where[] = ['appoint_id', '=', $appoint_info->id];
  2016. $info = RecruitSupplement::where($where)->first();
  2017. if (!$info) {
  2018. $info = [
  2019. 'appoint_id' => $appoint_info->id,
  2020. 'health_code' => '',
  2021. 'trip_code' => '',
  2022. 'type' => $type,
  2023. ];
  2024. } else {
  2025. $info = $info->toArray();
  2026. if (json_decode($info['health_code'])) {
  2027. $health_code = json_decode($info['health_code'], true);
  2028. foreach ($health_code as $k => $v) {
  2029. if (array_key_exists('response', $v)) {
  2030. $health_code[$k]['url'] = $v['response']['path'];
  2031. }
  2032. }
  2033. } else {
  2034. $health_code = [];
  2035. }
  2036. $info['health_code'] = $health_code;
  2037. if (json_decode($info['trip_code'])) {
  2038. $trip_code = json_decode($info['trip_code'], true);
  2039. foreach ($trip_code as $k => $v) {
  2040. if (array_key_exists('response', $v)) {
  2041. $trip_code[$k]['url'] = $v['response']['path'];
  2042. }
  2043. }
  2044. } else {
  2045. $trip_code = [];
  2046. }
  2047. $info['trip_code'] = $trip_code;
  2048. }
  2049. $view_data['info'] = json_encode($info);
  2050. $view_data['title'] = $recruit->company;
  2051. return view('app.recruit.health', $view_data);
  2052. }
  2053. public function save_supplement(Request $request)
  2054. {
  2055. $user = $this->getUser();
  2056. if (!empty($user)) {
  2057. $uid = $user->id;
  2058. } else {
  2059. return redirect(route('login'));
  2060. }
  2061. $limit_time = 1726824600;
  2062. $time = time();
  2063. if ($time > $limit_time) {
  2064. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', 38]), true, '上一页', '3');
  2065. }
  2066. $appoint_id = $request->input('appoint_id');
  2067. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', 68)->where('id', $appoint_id)->first();
  2068. if (!$appoint_info) {
  2069. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  2070. }
  2071. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', 'supplement')->first();
  2072. if ($info) {
  2073. if ($info->status == 1) {
  2074. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2075. }
  2076. if ($info->status == 0) {
  2077. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2078. }
  2079. //身份证明
  2080. $identification = $request->input('identification');
  2081. if (is_array($identification)) {
  2082. //删除掉没有成功返回路径的图片
  2083. foreach ($identification as $k => $v) {
  2084. if (!array_key_exists('response', $v)) {
  2085. unset($identification[$k]);
  2086. }
  2087. }
  2088. }
  2089. $info->identification = json_encode($identification);
  2090. //户口簿
  2091. $household_register = $request->input('household_register');
  2092. if (is_array($household_register)) {
  2093. //删除掉没有成功返回路径的图片
  2094. foreach ($household_register as $k => $v) {
  2095. if (!array_key_exists('response', $v)) {
  2096. unset($household_register[$k]);
  2097. }
  2098. }
  2099. }
  2100. $info->household_register = json_encode($household_register);
  2101. //学信网
  2102. $education_certification = $request->input('education_certification');
  2103. if (is_array($education_certification)) {
  2104. //删除掉没有成功返回路径的图片
  2105. foreach ($education_certification as $k => $v) {
  2106. if (!array_key_exists('response', $v)) {
  2107. unset($education_certification[$k]);
  2108. }
  2109. }
  2110. }
  2111. $info->education_certification = json_encode($education_certification);
  2112. //计生
  2113. // $family_planning = $request->input('family_planning');
  2114. // if(is_array($family_planning)){
  2115. // //删除掉没有成功返回路径的图片
  2116. // foreach ($family_planning as $k => $v){
  2117. // if(!array_key_exists('response',$v)){
  2118. // unset($family_planning[$k]);
  2119. // }
  2120. // }
  2121. // }
  2122. // $info->family_planning = json_encode($family_planning);
  2123. //失信查询 情况
  2124. $chengxin = $request->input('chengxin');
  2125. if (is_array($chengxin)) {
  2126. //删除掉没有成功返回路径的图片
  2127. foreach ($chengxin as $k => $v) {
  2128. if (!array_key_exists('response', $v)) {
  2129. unset($chengxin[$k]);
  2130. }
  2131. }
  2132. }
  2133. $info->chengxin = json_encode($chengxin);
  2134. //综治
  2135. $manage = $request->input('manage');
  2136. if (is_array($manage)) {
  2137. //删除掉没有成功返回路径的图片
  2138. foreach ($manage as $k => $v) {
  2139. if (!array_key_exists('response', $v)) {
  2140. unset($manage[$k]);
  2141. }
  2142. }
  2143. }
  2144. $info->manage = json_encode($manage);
  2145. $info->status = 0;
  2146. $info->save();
  2147. $appoint_info->political_audit = 4;
  2148. $appoint_info->save();
  2149. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2150. } else {
  2151. $data['appoint_id'] = $appoint_id;
  2152. //身份证明
  2153. $identification = $request->input('identification');
  2154. if (is_array($identification)) {
  2155. //删除掉没有成功返回路径的图片
  2156. foreach ($identification as $k => $v) {
  2157. if (!array_key_exists('response', $v)) {
  2158. unset($identification[$k]);
  2159. }
  2160. }
  2161. }
  2162. $data['identification'] = json_encode($identification);
  2163. //户口簿
  2164. $household_register = $request->input('household_register');
  2165. if (is_array($household_register)) {
  2166. //删除掉没有成功返回路径的图片
  2167. foreach ($household_register as $k => $v) {
  2168. if (!array_key_exists('response', $v)) {
  2169. unset($household_register[$k]);
  2170. }
  2171. }
  2172. }
  2173. $data['household_register'] = json_encode($household_register);
  2174. //学信网
  2175. $education_certification = $request->input('education_certification');
  2176. if (is_array($education_certification)) {
  2177. //删除掉没有成功返回路径的图片
  2178. foreach ($education_certification as $k => $v) {
  2179. if (!array_key_exists('response', $v)) {
  2180. unset($education_certification[$k]);
  2181. }
  2182. }
  2183. }
  2184. $data['education_certification'] = json_encode($education_certification);
  2185. //计生
  2186. // $family_planning = $request->input('family_planning');
  2187. // if(is_array($family_planning)){sp
  2188. // //删除掉没有成功返回路径的图片
  2189. // foreach ($family_planning as $k => $v){
  2190. // if(!array_key_exists('response',$v)){
  2191. // unset($family_planning[$k]);
  2192. // }
  2193. // }
  2194. // }
  2195. // $data['family_planning'] = json_encode($family_planning);
  2196. //失信查询 情况
  2197. $chengxin = $request->input('chengxin');
  2198. if (is_array($chengxin)) {
  2199. //删除掉没有成功返回路径的图片
  2200. foreach ($chengxin as $k => $v) {
  2201. if (!array_key_exists('response', $v)) {
  2202. unset($chengxin[$k]);
  2203. }
  2204. }
  2205. }
  2206. $data['chengxin'] = json_encode($chengxin);
  2207. //综治
  2208. $manage = $request->input('manage');
  2209. if (is_array($manage)) {
  2210. //删除掉没有成功返回路径的图片
  2211. foreach ($manage as $k => $v) {
  2212. if (!array_key_exists('response', $v)) {
  2213. unset($manage[$k]);
  2214. }
  2215. }
  2216. }
  2217. $data['manage'] = json_encode($manage);
  2218. $data['status'] = 0;
  2219. $data['type'] = 'supplement';
  2220. $result = RecruitSupplement::create($data);
  2221. $appoint_info->political_audit = 4;
  2222. $appoint_info->save();
  2223. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2224. }
  2225. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2226. }
  2227. public function save_healthinfo(Request $request)
  2228. {
  2229. $user = $this->getUser();
  2230. if (!empty($user)) {
  2231. $uid = $user->id;
  2232. } else {
  2233. return redirect(route('login'));
  2234. }
  2235. $appoint_id = $request->input('appoint_id');
  2236. $type = $request->input('type');
  2237. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('id', $appoint_id)->first();
  2238. if (!$appoint_info) {
  2239. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  2240. }
  2241. $recruit = Recruit::where('id', $appoint_info->recruit_id)->first();
  2242. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', $type)->first();
  2243. if ($info) {
  2244. if ($info->h_status == 1) {
  2245. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2246. }
  2247. if ($info->h_status == 0) {
  2248. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2249. }
  2250. $health_code = $request->input('health_code');
  2251. if (is_array($health_code)) {
  2252. //删除掉没有成功返回路径的图片
  2253. foreach ($health_code as $k => $v) {
  2254. if (!array_key_exists('response', $v)) {
  2255. unset($health_code[$k]);
  2256. }
  2257. }
  2258. }
  2259. $info->health_code = json_encode($health_code);
  2260. $trip_code = $request->input('trip_code');
  2261. if (is_array($trip_code)) {
  2262. //删除掉没有成功返回路径的图片
  2263. foreach ($trip_code as $k => $v) {
  2264. if (!array_key_exists('response', $v)) {
  2265. unset($trip_code[$k]);
  2266. }
  2267. }
  2268. }
  2269. $info->trip_code = json_encode($trip_code);
  2270. $info->h_status = 0;
  2271. $appoint_info->health_audit = 4;
  2272. $appoint_info->save();
  2273. $info->save();
  2274. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2275. } else {
  2276. $data['appoint_id'] = $appoint_id;
  2277. $data['type'] = $type;
  2278. $data['h_status'] = 0;
  2279. $appoint_info->health_audit = 4;
  2280. $health_code = $request->input('health_code');
  2281. if (is_array($health_code)) {
  2282. //删除掉没有成功返回路径的图片
  2283. foreach ($health_code as $k => $v) {
  2284. if (!array_key_exists('response', $v)) {
  2285. unset($health_code[$k]);
  2286. }
  2287. }
  2288. }
  2289. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  2290. $health_msg = ['健康码自动审核通过'];
  2291. //$h_status = 1;
  2292. //$appoint_info->health_audit = 1;
  2293. if (!array_key_exists('error_msg', $health_result) && !array_key_exists('error_code', $health_result)) {
  2294. if (array_key_exists('姓名', $health_result)) {
  2295. if (stripos($health_result['姓名'][0]['word'], '*') > 0) {
  2296. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  2297. }
  2298. if ($health_result['姓名'][0]['word'] != $appoint_info->realname) {
  2299. array_push($health_msg, '抱歉,请上传您本人的健康码!');
  2300. }
  2301. } else {
  2302. array_push($health_msg, '健康码错误,识别不到姓名!');
  2303. }
  2304. if (array_key_exists('状态', $health_result)) {
  2305. if ($health_result['状态'][0]['word'] != '绿码') {
  2306. array_push($health_msg, '抱歉,您的健康码非绿码!');
  2307. }
  2308. } else {
  2309. array_push($health_msg, '健康码错误,识别不到状态!');
  2310. }
  2311. if (array_key_exists('更新时间', $health_result)) {
  2312. $time = strtotime($health_result['更新时间'][0]['word']);
  2313. if ($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)) {
  2314. array_push($health_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  2315. }
  2316. } else {
  2317. array_push($health_msg, '健康码错误,识别不到时间!');
  2318. }
  2319. //$data['h_status'] = $h_status;
  2320. $data['h_msg'] = implode(';', $health_msg);
  2321. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  2322. $data['health_code'] = json_encode($health_code);
  2323. }
  2324. $data['health_result'] = json_encode($health_result);
  2325. $trip_code = $request->input('trip_code');
  2326. if (is_array($trip_code)) {
  2327. //删除掉没有成功返回路径的图片
  2328. foreach ($trip_code as $k => $v) {
  2329. if (!array_key_exists('response', $v)) {
  2330. unset($trip_code[$k]);
  2331. }
  2332. }
  2333. }
  2334. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  2335. $trip_msg = [];
  2336. $trip_status = 0;
  2337. if (!array_key_exists('error_msg', $trip_result) && !array_key_exists('error_code', $trip_result)) {
  2338. if (array_key_exists('途经地', $trip_result['result'])) {
  2339. $fangyi_area = explode("\r\n", config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  2340. $result = array_intersect($fangyi_area, $trip_result['result']['途经地'][0]['word']);
  2341. if (count($result) > 0) {
  2342. array_push($trip_msg, '抱歉,您的行程中包含系统设置中高风险地区!');
  2343. $trip_status = 0;
  2344. }
  2345. }
  2346. if (array_key_exists('风险性', $trip_result['result']) && $trip_result['result']['风险性']) {
  2347. array_push($trip_msg, '抱歉,您的行程可能含有风险!');
  2348. $trip_status = 0;
  2349. }
  2350. if (array_key_exists('更新时间', $trip_result['result'])) {
  2351. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2352. if ($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)) {
  2353. array_push($trip_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2354. $trip_status = 0;
  2355. }
  2356. }
  2357. $data['h_msg'] .= implode(';', $trip_msg);
  2358. }
  2359. $data['trip_result'] = json_encode($trip_result);
  2360. $data['trip_code'] = json_encode($trip_code);
  2361. $data['h_status'] = 0;
  2362. $appoint_info->health_audit = 4;
  2363. RecruitSupplement::create($data);
  2364. $appoint_info->save();
  2365. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2366. }
  2367. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2368. }
  2369. public function post_select(Request $request)
  2370. {
  2371. $user = $this->getUser();
  2372. if (!empty($user)) {
  2373. $uid = $user->id;
  2374. } else {
  2375. return redirect(route('login'));
  2376. }
  2377. $recruit_id = $request->input('recruit_id');
  2378. //$appoint_id = $request->input('appoint_id');
  2379. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  2380. if (!$info) {
  2381. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2382. }
  2383. //手动设置择岗时间段
  2384. $time = time();
  2385. if ($time > 1727150400 || $time < 1727053200) {
  2386. //if($time > 1694491200){
  2387. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2388. }
  2389. $option_list = [
  2390. [
  2391. 'id' => 1,
  2392. 'name' => '陈埭镇',
  2393. ],
  2394. [
  2395. 'id' => 2,
  2396. 'name' => '金井镇',
  2397. ],
  2398. [
  2399. 'id' => 3,
  2400. 'name' => '深沪镇'
  2401. ]
  2402. ];
  2403. $select_list = [];
  2404. if ($info->result) {
  2405. $result = json_decode($info->result, true);
  2406. foreach ($result as $v) {
  2407. $item['name'] = $v;
  2408. array_push($select_list, $item);
  2409. }
  2410. }
  2411. // $recruit_id = $request->input('recruit_id');
  2412. // $appoint_id = $request->input('appoint_id');
  2413. // $uid = $request->input('uid');
  2414. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2415. // if(!$info){
  2416. // $info = new \stdClass();
  2417. // $info->status = 0;
  2418. // $info->recruit_id = 8;
  2419. // $info->appoint_id = rand(0,999999);
  2420. // $info->uid = rand(0,999999);
  2421. // }else{
  2422. // $result = json_decode($info->result,true);
  2423. // foreach ($option_list as $k => $v){
  2424. // if(in_array($v['name'],$result)){
  2425. // $select_list[$k] = $v;
  2426. // unset($option_list[$k]);
  2427. // }
  2428. // }
  2429. // }
  2430. $view_data = ['info' => $info, 'options_list' => json_encode($option_list), 'select_list' => json_encode($select_list)];
  2431. return view('app.recruit.post_select', $view_data);
  2432. }
  2433. /**
  2434. * 放弃择岗
  2435. */
  2436. public function give_up_post(Request $request)
  2437. {
  2438. //以下为测试环境
  2439. // $recruit_id = $request->input('recruit_id');
  2440. // $appoint_id = $request->input('appoint_id');
  2441. // $uid = $request->input('uid');
  2442. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2443. // if($info){
  2444. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2445. // }
  2446. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2447. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2448. //以下为正式环境再放开
  2449. $user = $this->getUser();
  2450. if (!empty($user)) {
  2451. $uid = $user->id;
  2452. } else {
  2453. return redirect(route('login'));
  2454. }
  2455. $recruit_id = $request->input('recruit_id');
  2456. $appoint_id = $request->input('appoint_id');
  2457. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2458. if ($info == null) {
  2459. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2460. }
  2461. if ($info->status != 0) {
  2462. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2463. }
  2464. $info->status = -1;
  2465. $info->save();
  2466. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2467. }
  2468. public function comfirm_post(Request $request)
  2469. {
  2470. $user = $this->getUser();
  2471. if (!empty($user)) {
  2472. $uid = $user->id;
  2473. } else {
  2474. return redirect(route('login'));
  2475. }
  2476. $recruit_id = $request->input('recruit_id');
  2477. $appoint_id = $request->input('appoint_id');
  2478. $time = time();
  2479. if ($time > 1727150400 || $time < 1727053200) {
  2480. return ['status' => 0, 'msg' => "抱歉,未到择岗时间!"];
  2481. }
  2482. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2483. if ($info->result) {
  2484. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2485. }
  2486. // $data = [
  2487. // 'recruit_id' => $recruit_id,
  2488. // 'appoint_id' => $recruit_id,
  2489. // 'uid' => $uid,
  2490. // 'status' => 1
  2491. // ];
  2492. $result = [];
  2493. $select = $request->input('select');
  2494. if (is_array($select) && count($select) > 0) {
  2495. foreach ($select as $v) {
  2496. array_push($result, $v['name']);
  2497. }
  2498. }
  2499. $info->result = json_encode($result);
  2500. $info->status = 1;
  2501. $info->save();
  2502. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2503. }
  2504. public function select_result(Request $request)
  2505. {
  2506. $redis = Cache::getRedis();
  2507. $redis->set('recruit_quota_batch5', '');
  2508. return view('app.recruit.select_result');
  2509. }
  2510. public function get_select_result(Request $request)
  2511. {
  2512. $redis = Cache::getRedis();
  2513. $quot_batch5 = $redis->get('recruit_quota_batch5');
  2514. if (!$quot_batch5) {
  2515. $quot_batch5 = [
  2516. [
  2517. 'name' => '陈埭镇',
  2518. 'value' => 21,
  2519. ],
  2520. [
  2521. 'name' => '金井镇',
  2522. 'value' => 3
  2523. ],
  2524. [
  2525. 'name' => '深沪镇',
  2526. 'value' => 2
  2527. ]
  2528. ];
  2529. $redis->set('recruit_quotaA', json_encode($quot_batch5));
  2530. } else {
  2531. $quot_batch5 = json_decode($quot_batch5, true);
  2532. }
  2533. $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=5 and a.result is not null')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id', 'a.record', 'a.record2', 'a.record3'])->orderBy('record', 'desc')->orderBy('record2', 'desc')->orderBy('record3', 'desc')->limit(2)->get()->toArray();
  2534. $return_data = [
  2535. 'list' => [],
  2536. ];
  2537. $array_column = array_column($quot_batch5, 'name');
  2538. if (count($list) > 1) {
  2539. $current = $list[0];
  2540. $next = $list[1];
  2541. } else {
  2542. $current = $list[0];
  2543. $next = false;
  2544. }
  2545. $person_select_result = json_decode($current->result, true);
  2546. $flag = 0;//是否择岗成功
  2547. foreach ($person_select_result as $val) {
  2548. //寻找下标
  2549. $index = array_search($val, $array_column);
  2550. if ($quot_batch5[$index]['value']) {
  2551. if ($next && $current->record == $next->record && $current->record2 == $next->record2 && $current->record3 == $next->record3 && $quot_batch5[$index]['value'] == 1) {
  2552. //如果当前处理人员不是最后一个,且分数与下一名人员三个维度完全一样的话并且该人员欲择的岗位仅剩一位,则特殊处理
  2553. //查找同样分数人同样志愿
  2554. $next_select_result = json_decode($next->result, true);
  2555. //寻找下标
  2556. $current_index = array_search($val, $person_select_result);
  2557. $next_index = array_search($val, $next_select_result);
  2558. if ($current_index > $next_index) {
  2559. //如果当前人员对当前镇街的意向排序大于下一人,调换两个指针,先排序下一个人
  2560. $current = $next;
  2561. }
  2562. }
  2563. $quota_data = [
  2564. 'index' => $index,
  2565. 'old_value' => $quot_batch5[$index]['value'],
  2566. ];
  2567. //有名额允许择岗
  2568. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => $val, 'status' => 1]);
  2569. $current->select_result = $val;
  2570. $quot_batch5[$index]['value']--;
  2571. $quota_data['new_value'] = $quot_batch5[$index]['value'];
  2572. $redis->set('recruit_quota_batch4', json_encode($quot_batch5));
  2573. $flag = 1;
  2574. break;
  2575. }
  2576. }
  2577. if (!$flag) {
  2578. $quota_data = [
  2579. 'index' => $index,
  2580. 'old_value' => $quot_batch5[$index]['value'],
  2581. ];
  2582. $current->select_result = '未匹配到志愿,本轮择岗不成功!';
  2583. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => '未匹配到志愿,本轮择岗不成功!', 'status' => -2]);
  2584. }
  2585. $return_data['quota'] = $quota_data;
  2586. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2587. }
  2588. public function select_init(Request $request)
  2589. {
  2590. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 5 and type = 1 and result is not null')->count();
  2591. $redis = Cache::getRedis();
  2592. $quot_batch5 = $redis->get('recruit_quota_batch4');
  2593. if (!$quot_batch5) {
  2594. $quot_batch5 = [
  2595. [
  2596. 'name' => '陈埭镇',
  2597. 'value' => 21,
  2598. ],
  2599. [
  2600. 'name' => '金井镇',
  2601. 'value' => 3
  2602. ],
  2603. [
  2604. 'name' => '深沪镇',
  2605. 'value' => 2
  2606. ]
  2607. ];
  2608. $redis->set('recruit_quota_batch5', json_encode($quot_batch5));
  2609. }
  2610. $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=5 and type = 1')->select(['b.realname', 'c.ex_number', 'a.result', 'a.select_result', 'a.id'])->orderBy('record', 'desc')->get();
  2611. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quot_batch5, 'list' => $list]];
  2612. }
  2613. public function interviewer_random(Request $request)
  2614. {
  2615. $model = $request->input('model', 1);
  2616. $number1 = $request->input('number1', 5);//考官人数
  2617. $number2 = $request->input('number2', 1);//替补人数
  2618. $where[] = ['id', '>', 0];
  2619. switch ($model) {
  2620. case '0':
  2621. $list = DB::table('recruit_interviewer')->get()->toArray();
  2622. shuffle($list);
  2623. $result = array_slice($list, 0, $number1 + $number2);
  2624. break;
  2625. case '1':
  2626. $list = DB::table('recruit_interviewer')->get()->toArray();
  2627. shuffle($list);
  2628. $count = $number1;
  2629. for ($i = 0; $i < $count; $i++) {
  2630. if (!$list[$i]->status) {
  2631. $list[] = $list[$i];
  2632. unset($list[$i]);
  2633. $count++;
  2634. }
  2635. }
  2636. $result = array_slice($list, 0, $number1 + $number2);
  2637. break;
  2638. case '2':
  2639. $list = DB::table('recruit_interviewer')->where('status', 1)->get()->toArray();
  2640. shuffle($list);
  2641. $result = array_slice($list, 0, $number1 + $number2);
  2642. break;
  2643. default:
  2644. $list = DB::table('recruit_interviewer')->get()->toArray();
  2645. shuffle($list);
  2646. for ($i = 0; $i < $number1; $i++) {
  2647. dd($list[$i]);
  2648. if (!$list[$i]->status) {
  2649. $list[] = $list[$i];
  2650. unset($list[$i]);
  2651. }
  2652. }
  2653. $result = array_slice($list, 0, $number1 + $number2);
  2654. break;
  2655. }
  2656. $return_data = [
  2657. 'list' => $result,
  2658. 'number1' => $number1,
  2659. 'number2' => $number2,
  2660. ];
  2661. return view('app.recruit.interviewer', $return_data);
  2662. }
  2663. public function supplement_info(Request $request)
  2664. {
  2665. $user = $this->getUser();
  2666. if (!empty($user)) {
  2667. $uid = $user->id;
  2668. } else {
  2669. return redirect(route('login'));
  2670. }
  2671. //招考id
  2672. $id = $request->input('id', 0);
  2673. if (!$id) {
  2674. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2675. }
  2676. $recruit = Recruit::find($id);
  2677. if (!$recruit['status']) {
  2678. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2679. }
  2680. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2681. if (!$appoint_info) {
  2682. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2683. }
  2684. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid', $uid)->where('appoint_id', $appoint_info->id)->first();
  2685. if ($supplement_info) {
  2686. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2687. }
  2688. $uids = [167780,168696,56609,168696,164951,169813,161935,169412,169307,169628,169331,170471,161935,170718,175771,175856,169628,56609,168696,176871,169412,169813,177014,161935,152626,176994,176703,176432,170471,177272,179103,179206,179165,179873,179863,179715,180131,161935,180616,170718,180766,175856,180810,169412,177272,167988,181121,181175,168696,182354,56609,184859,161935,176994,169813,169412,187369,159298,169628,181175,187450,167988,187572,187578,187573,179863,187753,187577,152626,187875,187815,149975,187821,180131,187934,176871,168696,186519,170718,188160,176994,169813,161935,180616,188342,188411,177014,188455,188450,177272,184859,168696,181121,189428,189446,189410,182354,182354,184859,184859,187572,190509,161935,170718,184859,182354,191077,187450,191077,169813,191538,191954,191396,152626,182354,192121,189446,192223,192271,170718,170718,192769,192798,192674,192774,192800,180131,179863,169412,192560,186519,56609,170471,188160,168696,159298,187572,192868,169628,192874,192775,192892,181175,167988,192914,192922,192925,159772,192930,192945,192752,192652,188411,192958,179715,192959,192834,192987,192739,192392,152626,188450,193038,192542,192452,193055,192788,187369,193072,176703,193079,193069,193084,192803,192668,187875,193103,187578,191396,175771,193113,193135,193132,191077,193151,191954,187381,193130,193169,188035,179103,176432,182354,180766,189410,192855,179165,175642,193202,193141,193248,193239,193244,193252,192978,192888,187753,185725,143917,177272,187821,193326,193334,193331,187573,180616,193350,192813,193357,192926,193212,187815,193361,193158,193150,176994,193389,184118,176896,193408,192811,189446,193416,193423,170718,187934,192955,169307,180810,193428,149975,187577,186473,192720,175856,161935,187935,159058,193526,187450,192271,169813,193570,193578,193225,193594,193606,181121,169331,193616,184859,190509,193640,192751,193574,167780,193695,192133,193714,192523,193718,193717,193720,189428,179873,177014,188342,193742,188455,176871,191538,193787,192223,193789,185725,182354,186519,193135];//写死用户
  2689. if (!in_array($uid, $uids)) {
  2690. return $this->showMessage('您无需登记信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2691. }
  2692. // $limit_time = 1661961599;
  2693. // $time = time();
  2694. // if( $time > $limit_time){
  2695. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2696. // }
  2697. $view_data = [];
  2698. //$view_data['info'] = json_encode($info);
  2699. $view_data['title'] = $recruit->company;
  2700. $view_data['id'] = $id;
  2701. return view('app.recruit.supplement_info', $view_data);
  2702. }
  2703. public function save_supplement_info(Request $request)
  2704. {
  2705. $user = $this->getUser();
  2706. if (!empty($user)) {
  2707. $uid = $user->id;
  2708. } else {
  2709. return redirect(route('login'));
  2710. }
  2711. //招考id
  2712. $id = $request->input('recruit_id', 0);
  2713. if (!$id) {
  2714. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2715. }
  2716. $recruit = Recruit::find($id);
  2717. if (!$recruit['status']) {
  2718. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2719. }
  2720. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2721. if (!$appoint_info) {
  2722. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2723. }
  2724. if ($request->input('marriage') == '已婚') {
  2725. if ($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == '') {
  2726. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2727. }
  2728. }
  2729. $data = [
  2730. 'uid' => $uid,
  2731. 'appoint_id' => $appoint_info->id,
  2732. 'street' => $request->input('street'),
  2733. 'realname' => $request->input('realname'),
  2734. 'sex' => $request->input('sex'),
  2735. 'house' => $request->input('house'),
  2736. 'nation' => $request->input('nation'),
  2737. 'native' => $request->input('native'),
  2738. 'marriage' => $request->input('marriage'),
  2739. 'spouse_card_type' => $request->input('spouse_card_type'),
  2740. 'spouse_card' => $request->input('spouse_card'),
  2741. 'spouse_realname' => $request->input('spouse_realname'),
  2742. 'spouse_mobile' => $request->input('spouse_mobile'),
  2743. 'political' => $request->input('political'),
  2744. 'bank_card' => $request->input('bank_card'),
  2745. 'bank_open' => $request->input('bank_open'),
  2746. 'card' => $request->input('card'),
  2747. 'card_endtime' => $request->input('card_endtime'),
  2748. 'mobile' => $request->input('mobile'),
  2749. 'edu' => $request->input('education'),
  2750. 'pro' => $request->input('pro'),
  2751. 'address' => $request->input('address'),
  2752. 'funds' => $request->input('funds'),
  2753. ];
  2754. DB::table('recruit_supplement_cunwu')->insert($data);
  2755. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2756. }
  2757. public function comfirm_pen(Request $request)
  2758. {
  2759. $user = $this->getUser();
  2760. if (!empty($user)) {
  2761. $uid = $user->id;
  2762. } else {
  2763. return redirect(route('login'));
  2764. }
  2765. //招考id
  2766. $id = $request->input('recruit_id', 0);
  2767. if (!$id) {
  2768. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2769. }
  2770. $recruit = Recruit::find($id);
  2771. if (!$recruit['status']) {
  2772. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2773. }
  2774. if (!$recruit->pen_comfirm) {
  2775. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2776. }
  2777. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2778. if (!$appoint_info) {
  2779. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2780. }
  2781. if ($appoint_info->audit != 3) {
  2782. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2783. }
  2784. $time = time();
  2785. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  2786. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2787. }
  2788. if ($appoint_info->pen_audit != -2) {
  2789. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2790. }
  2791. $appoint_info->update(['pen_audit' => -1]);
  2792. $log = [
  2793. 'type' => 3,
  2794. 'appoint_id' => $appoint_info->id,
  2795. 'uid' => $uid,
  2796. 'log' => '用户确认参加笔试',
  2797. ];
  2798. RecruitAppointLog::create($log);
  2799. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2800. }
  2801. public function supplementary_entry(Request $request)
  2802. {
  2803. $user = $this->getUser();
  2804. if (!empty($user)) {
  2805. $uid = $user->id;
  2806. } else {
  2807. return redirect(route('login'));
  2808. }
  2809. //招考id
  2810. $id = $request->input('recruit_id', 0);
  2811. if (!$id) {
  2812. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2813. }
  2814. $recruit = Recruit::find($id);
  2815. if (!$recruit['status']) {
  2816. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2817. }
  2818. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2819. if (!$appoint_info) {
  2820. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2821. }
  2822. $time = time();
  2823. if ($time > 1680969600) {
  2824. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2825. }
  2826. if ($appoint_info->adjust_limit) {
  2827. $appoint_info->update(['adjust' => 1]);
  2828. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2829. } else {
  2830. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2831. }
  2832. }
  2833. public function show_sign_limit(Request $request){
  2834. $user = $this->getUser();
  2835. if (!empty($user)) {
  2836. $uid = $user->id;
  2837. } else {
  2838. return redirect(route('login'));
  2839. }
  2840. //招考id
  2841. $id = $request->input('recruit_id', 0);
  2842. if (!$id) {
  2843. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2844. }
  2845. $recruit = Recruit::find($id);
  2846. if (!$recruit['status']) {
  2847. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2848. }
  2849. $list = RecruitAppointInfo::where('uid', $user->id)
  2850. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  2851. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  2852. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  2853. ->where('recruit_appoint_info.recruit_id','=',$id)
  2854. ->get();
  2855. $html = view('app.recruit.show_sign_limit')->with(['list' => $list , 'total' => count($list)])->render();
  2856. return response()->json(['code' => 1, 'data' => $html]);
  2857. }
  2858. }