IndexController.php 142 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085
  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('type', 3)->where('uid', $uid)->orderBy('created_at', 'asc')->first();
  816. if (!$first_post) {//没有记录代表只是暂存
  817. return response()->json(['status' => 0, 'msg' => '抱歉,该项目已过报名时间!']);
  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. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $appoint_info->id];
  1227. }
  1228. } catch (\Exception $e) {
  1229. DB::rollback();
  1230. return ['status' => 0, 'msg' => $e->getMessage()];
  1231. }
  1232. } else {
  1233. //没有报名记录,进入增加阶段的处理流程
  1234. DB::beginTransaction();
  1235. try {
  1236. //20220726增加地区undefined选项处理
  1237. if ($index = stripos($data['native_place'], ',undefined')) {
  1238. $data['native_place'] = substr($data['native_place'], 0, $index);
  1239. }
  1240. if ($index = stripos($data['house_register'], ',undefined')) {
  1241. $data['house_register'] = substr($data['house_register'], 0, $index);
  1242. }
  1243. $data['uid'] = $uid;
  1244. $data['recruit_id'] = $recruit_id;
  1245. $result = RecruitAppointInfo::create($data);
  1246. //分模块解析数据
  1247. $forms = explode(',', $recruit['forms']);
  1248. //如果有加分模块
  1249. if (in_array('expand_special', $forms)) {
  1250. $special = $request->input('special');
  1251. if ($special['point_apply']) {
  1252. if (is_array($special['material'])) {
  1253. //删除掉没有成功返回路径的图片
  1254. foreach ($special['material'] as $k => $v) {
  1255. if (!array_key_exists('response', $v)) {
  1256. unset($special['material'][$k]);
  1257. }
  1258. }
  1259. }
  1260. switch ($recruit->special_condition_type) {
  1261. case 0:
  1262. $special['point'] = 0;
  1263. break;
  1264. case 1:
  1265. $special_rule = json_decode($recruit->special_condition_value, true);
  1266. $conditions = array_column($special_rule['list'], 'condition');
  1267. $special['point'] = 0;
  1268. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1269. foreach ($special['condition'] as $v) {
  1270. $key = array_search($v, $conditions);
  1271. $rule_info = $special_rule['list'][$key];
  1272. $special['point'] += $rule_info['value'];
  1273. }
  1274. } else {
  1275. $key = array_search($special['condition'], $conditions);
  1276. $rule_info = $special_rule['list'][$key];
  1277. $special['point'] += $rule_info['value'];
  1278. }
  1279. break;
  1280. case 2:
  1281. $special_rule = json_decode($post_info['special'], true);
  1282. $conditions = array_column($special_rule['list'], 'condition');
  1283. $special['point'] = 0;
  1284. if (array_key_exists('multi', $special_rule) && $special_rule['multi'] && is_array($special['condition'])) {
  1285. foreach ($special['condition'] as $v) {
  1286. $key = array_search($v, $conditions);
  1287. $rule_info = $special_rule['list'][$key];
  1288. $special['point'] += $rule_info['value'];
  1289. }
  1290. } else {
  1291. $key = array_search($special['condition'], $conditions);
  1292. $rule_info = $special_rule['list'][$key];
  1293. $special['point'] += $rule_info['value'];
  1294. }
  1295. break;
  1296. }
  1297. if (is_array($special['condition'])) {
  1298. $special['condition'] = implode(',', $special['condition']);
  1299. }
  1300. $special['material'] = json_encode($special['material']);
  1301. $special['recruit_appoint_id'] = $result->id;
  1302. RecruitAppointExpandSpecial::create($special);
  1303. }
  1304. }
  1305. //如果有详情模块
  1306. if (in_array('detail', $forms) || in_array('internship', $forms)) {
  1307. $detail = $request->input('detail');
  1308. $detail['recruit_appoint_id'] = $result->id;
  1309. RecruitAppointDetail::create($detail);
  1310. }
  1311. //如果有身份证明模块
  1312. if (in_array('identification', $forms) || in_array('internship', $forms)) {
  1313. $identification = $request->input('identification');
  1314. if (is_array($identification)) {
  1315. //删除掉没有成功返回路径的图片
  1316. foreach ($identification as $k => $v) {
  1317. if (!array_key_exists('response', $v)) {
  1318. unset($identification[$k]);
  1319. }
  1320. }
  1321. }
  1322. $result->identification = json_encode($identification);
  1323. $result->save();
  1324. }
  1325. //如果有教育证明模块
  1326. if (in_array('education_certification', $forms) || in_array('internship', $forms)) {
  1327. $education_certification = $request->input('education_certification');
  1328. if (is_array($education_certification)) {
  1329. //删除掉没有成功返回路径的图片
  1330. foreach ($education_certification as $k => $v) {
  1331. if (!array_key_exists('response', $v)) {
  1332. unset($education_certification[$k]);
  1333. }
  1334. }
  1335. }
  1336. $result->education_certification = json_encode($education_certification);
  1337. $result->save();
  1338. }
  1339. //如果有其他证明模块
  1340. if (in_array('other_certification', $forms) || in_array('internship', $forms)) {
  1341. $other_certification = $request->input('other_certification');
  1342. if ($other_certification) {
  1343. if (is_array($other_certification)) {
  1344. //删除掉没有成功返回路径的图片
  1345. foreach ($other_certification as $k => $v) {
  1346. if (!array_key_exists('response', $v)) {
  1347. unset($other_certification[$k]);
  1348. }
  1349. }
  1350. }
  1351. $result->other_certification = json_encode($other_certification);
  1352. $result->save();
  1353. }
  1354. }
  1355. //如果有户籍证明模块
  1356. if (in_array('hj_certification', $forms)) {
  1357. $hj_certification = $request->input('hj_certification');
  1358. if ($hj_certification) {
  1359. if (is_array($hj_certification)) {
  1360. //删除掉没有成功返回路径的图片
  1361. foreach ($hj_certification as $k => $v) {
  1362. if (!array_key_exists('response', $v)) {
  1363. unset($hj_certification[$k]);
  1364. }
  1365. }
  1366. }
  1367. $result->hj_certification = json_encode($hj_certification);
  1368. $result->save();
  1369. }
  1370. }
  1371. //如果有承诺书模块
  1372. if (in_array('chengnuoshu', $forms)) {
  1373. $chengnuoshu = $request->input('chengnuoshu');
  1374. if ($chengnuoshu) {
  1375. if (is_array($chengnuoshu)) {
  1376. //删除掉没有成功返回路径的图片
  1377. foreach ($chengnuoshu as $k => $v) {
  1378. if (!array_key_exists('response', $v)) {
  1379. unset($chengnuoshu[$k]);
  1380. }
  1381. }
  1382. }
  1383. $result->chengnuoshu = json_encode($chengnuoshu);
  1384. $result->save();
  1385. }
  1386. }
  1387. //如果有失信被执行人模块
  1388. if (in_array('shixin', $forms)) {
  1389. $shixin = $request->input('shixin');
  1390. if ($shixin) {
  1391. if (is_array($shixin)) {
  1392. //删除掉没有成功返回路径的图片
  1393. foreach ($shixin as $k => $v) {
  1394. if (!array_key_exists('response', $v)) {
  1395. unset($shixin[$k]);
  1396. }
  1397. }
  1398. }
  1399. $result->shixin = json_encode($shixin);
  1400. $result->save();
  1401. }
  1402. }
  1403. //如果有声明书模块
  1404. if (in_array('baokaoshengming', $forms)) {
  1405. $baokaoshengming = $request->input('baokaoshengming');
  1406. if ($baokaoshengming) {
  1407. if (is_array($baokaoshengming)) {
  1408. //删除掉没有成功返回路径的图片
  1409. foreach ($baokaoshengming as $k => $v) {
  1410. if (!array_key_exists('response', $v)) {
  1411. unset($baokaoshengming[$k]);
  1412. }
  1413. }
  1414. }
  1415. $result->baokaoshengming = json_encode($baokaoshengming);
  1416. $result->save();
  1417. }
  1418. }
  1419. DB::commit();
  1420. if ($operation == 2) {
  1421. $log = [
  1422. 'type' => 3,
  1423. 'appoint_id' => $result->id,
  1424. 'uid' => $uid,
  1425. 'log' => '用户首次提交报名',
  1426. ];
  1427. RecruitAppointLog::create($log);
  1428. if (empty($recruit->qr_code)) {
  1429. return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id, 'is_html' => 0];
  1430. } else {
  1431. 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];
  1432. }
  1433. //return ['status' => 1, 'msg' => '提交成功', 'data' => $result->id];
  1434. } else {
  1435. return ['status' => 1, 'msg' => '资料保存成功,请尽快完善并提交', 'data' => $result->id];
  1436. }
  1437. } catch (\Exception $e) {
  1438. DB::rollback();
  1439. return ['status' => 0, 'msg' => $e->getMessage()];
  1440. }
  1441. }
  1442. }
  1443. /**
  1444. * 获得当前登录的用户
  1445. * @return \Illuminate\Contracts\Auth\Authenticatable|null
  1446. */
  1447. public function getUser()
  1448. {
  1449. if (auth('web-member')->check()) {
  1450. $user = auth('web-member')->user();
  1451. } else {
  1452. $user = null;
  1453. }
  1454. return $user;
  1455. }
  1456. /**
  1457. * 检查用户基本信息
  1458. * @return array
  1459. */
  1460. public function checkUserBasicInfo()
  1461. {
  1462. $user = $this->getUser();
  1463. if (!empty($user)) {
  1464. $uid = $user->id;
  1465. } else {
  1466. $arr = ['status' => 401, 'msg' => '请登录!'];
  1467. return $arr;
  1468. }
  1469. $info = RecruitAppointBasic::where('uid', $uid)->first();
  1470. if (empty($info)) {
  1471. $arr = ['status' => 401, 'msg' => '请先完善招考基本信息', 'url' => route('recruit.recruitInfo')];
  1472. return $arr;
  1473. }
  1474. return ['status' => 200, 'msg' => ''];
  1475. }
  1476. /**
  1477. * 个人中心招考页面
  1478. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1479. */
  1480. public function person_recruit()
  1481. {
  1482. $user = auth('web-member')->user();
  1483. $list = RecruitAppointInfo::where('uid', $user->id)
  1484. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  1485. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  1486. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  1487. ->get();
  1488. return view('app.person.recruit')->with(['list' => $list, 'total' => count($list)]);
  1489. }
  1490. /**
  1491. * 招考信息基础页
  1492. * @param Request $request
  1493. * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|\think\response\View
  1494. */
  1495. public function recruit_info(Request $request)
  1496. {
  1497. $user = auth('web-member')->user();
  1498. if (!empty($user)) {
  1499. $uid = $user->id;
  1500. } else {
  1501. return redirect(route('login'));
  1502. }
  1503. $info = RecruitAppointBasic::where('uid', $user->id)->first();
  1504. if (!$info) {
  1505. $info = [
  1506. 'realname' => '',
  1507. 'sex' => '0',
  1508. 'birthday' => '',
  1509. 'avatar' => '',
  1510. 'nation' => '',
  1511. 'native_place' => '',
  1512. 'political_affiliation' => '',
  1513. 'titles' => '',
  1514. 'work' => '',
  1515. 'house_register' => '',
  1516. 'join_time' => '',
  1517. 'edu_type' => '',
  1518. 'education' => '',
  1519. 'school' => '',
  1520. 'degree' => '',
  1521. 'pro' => '',
  1522. 'address' => '',
  1523. 'card' => '',
  1524. 'mobile' => '',
  1525. 'email' => '',
  1526. 'concat_name' => '',
  1527. 'concat_mobile' => '',
  1528. 'resume' => '',
  1529. 'family' => [
  1530. [
  1531. 'relation' => '',
  1532. 'realname' => '',
  1533. 'birthday' => '',
  1534. 'political_affiliation' => '',
  1535. 'work' => '',
  1536. ],
  1537. ],
  1538. 'is_push' => '1',
  1539. ];
  1540. } else {
  1541. $info->sex = (string)$info->sex;
  1542. $info->edu_type = (string)$info->edu_type;
  1543. $info->is_push = (string)$info->is_push;
  1544. $info->family = empty($info->family) ? [[
  1545. 'relation' => '',
  1546. 'realname' => '',
  1547. 'birthday' => '',
  1548. 'political_affiliation' => '',
  1549. 'work' => '',
  1550. ]] : json_decode($info->family);
  1551. }
  1552. $recruit_id = $request->input('recruit_id', 0);
  1553. return view('app.person.recruit_info', [
  1554. 'info' => json_encode($info),
  1555. 'recruit_id' => $recruit_id,
  1556. ]);
  1557. }
  1558. /**
  1559. * 保存招考信息
  1560. * @param RecruitValidatorRequest $request
  1561. * @return \Illuminate\Http\JsonResponse
  1562. */
  1563. public function saveRecruitInfo(RecruitValidatorRequest $request)
  1564. {
  1565. $user = auth('web-member')->user();
  1566. $basic = RecruitAppointBasic::where('uid', $user->id)->first();
  1567. $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');
  1568. if (count($data['family']) > 0) {
  1569. $data['family'] = json_encode($data['family']);
  1570. }
  1571. if ($basic) {
  1572. //更新基础信息
  1573. $res = RecruitAppointBasic::where('uid', $user->id)->update($data);
  1574. if (!$res) {
  1575. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1576. } else {
  1577. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1578. }
  1579. } else {
  1580. //新增基础信息
  1581. $data['uid'] = $user->id;
  1582. $res = RecruitAppointBasic::create($data);
  1583. if (!$res) {
  1584. return response()->json(['status' => 0, 'msg' => '保存失败,请联系客服']);
  1585. } else {
  1586. return response()->json(['status' => 1, 'msg' => '个人基础信息保存成功,快去报名吧!']);
  1587. }
  1588. }
  1589. }
  1590. /**
  1591. * 笔试准考证
  1592. * @param Request $request
  1593. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1594. */
  1595. public function pen_ticket(Request $request)
  1596. {
  1597. $user = $this->getUser();
  1598. if (!empty($user)) {
  1599. $uid = $user->id;
  1600. } else {
  1601. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1602. }
  1603. $recruit_id = $request->input('recruit_id');
  1604. $recruit = Recruit::where('id', $recruit_id)->first();
  1605. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1606. if ($appoint_info) {
  1607. $pen_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 1)->first();
  1608. if ($pen_ticket) {
  1609. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1610. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1611. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1612. }
  1613. $time = time();
  1614. if (strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time) {
  1615. RecruitTicket::where('appoint_id', $appoint_info->id)->update(['ex_status' => 1]);
  1616. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1617. $name = $recruit->name_en;
  1618. $date = date("Y-m-d", strtotime($recruit->created_at));
  1619. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1620. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1621. // return view('app.recruit.recruit_ticket', [
  1622. // 'title' => "{$filename}.docx",
  1623. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/pen/{$filename}.docx",
  1624. // ]);
  1625. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/pen/" . $filename . '.pdf';
  1626. if (file_exists($file)) {
  1627. header('Content-Description: File Transfer');
  1628. header('Content-Type: application/octet-stream');
  1629. header('Content-Disposition: attachment; filename=' . basename($file));
  1630. header('Content-Transfer-Encoding: binary');
  1631. header('Expires: 0');
  1632. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1633. header('Pragma: public');
  1634. header('Content-Length: ' . filesize($file));
  1635. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1636. flush();
  1637. readfile($file);
  1638. } else {
  1639. return $this->showMessage('准考证不存在,请联系管理员!', route('home'), true, '上一页', '3');
  1640. }
  1641. } else {
  1642. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1643. }
  1644. } else {
  1645. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1646. }
  1647. } else {
  1648. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1649. }
  1650. }
  1651. /**
  1652. * 审核准考证
  1653. * @param Request $request
  1654. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1655. */
  1656. public function check_ticket(Request $request)
  1657. {
  1658. $user = $this->getUser();
  1659. if (!empty($user)) {
  1660. $uid = $user->id;
  1661. } else {
  1662. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1663. }
  1664. $recruit_id = $request->input('recruit_id');
  1665. $recruit = Recruit::where('id', $recruit_id)->first();
  1666. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1667. if ($appoint_info) {
  1668. $check_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 2)->first();
  1669. if ($check_ticket) {
  1670. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1671. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1672. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1673. }
  1674. $time = time();
  1675. if (strtotime($check_ticket->ex_start) < $time && strtotime($check_ticket->ex_end) > $time) {
  1676. RecruitTicket::where('id', $check_ticket->id)->update(['ex_status' => 1]);
  1677. $recruit = Recruit::where('id', $recruit_id)->first();
  1678. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1679. $name = $recruit->name_en;
  1680. $date = date("Y-m-d", strtotime($recruit->created_at));
  1681. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1682. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1683. // return view('app.recruit.recruit_ticket', [
  1684. // 'title' => "{$filename}.docx",
  1685. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/computer/{$filename}.docx",
  1686. // ]);
  1687. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/computer/" . $filename . '.pdf';
  1688. if (file_exists($file)) {
  1689. header('Content-Description: File Transfer');
  1690. header('Content-Type: application/octet-stream');
  1691. header('Content-Disposition: attachment; filename=' . basename($file));
  1692. header('Content-Transfer-Encoding: binary');
  1693. header('Expires: 0');
  1694. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1695. header('Pragma: public');
  1696. header('Content-Length: ' . filesize($file));
  1697. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1698. flush();
  1699. readfile($file);
  1700. }
  1701. } else {
  1702. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1703. }
  1704. } else {
  1705. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1706. }
  1707. } else {
  1708. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1709. }
  1710. }
  1711. /**
  1712. * 面试准考证
  1713. * @param Request $request
  1714. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1715. */
  1716. public function face_ticket(Request $request)
  1717. {
  1718. $user = $this->getUser();
  1719. if (!empty($user)) {
  1720. $uid = $user->id;
  1721. } else {
  1722. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1723. }
  1724. $recruit_id = $request->input('recruit_id');
  1725. $recruit = Recruit::where('id', $recruit_id)->first();
  1726. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->orderBy('id','desc')->first();
  1727. if ($appoint_info) {
  1728. $face_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 3)->first();
  1729. if ($face_ticket) {
  1730. $health = RecruitSupplement::where('appoint_id', $appoint_info->id)->first();
  1731. if ((!$health || $health->h_status == 0) && $recruit->pen_epidemic) {
  1732. return $this->showMessage('健康审核信息未通过!', route('home'), true, '上一页', '3');
  1733. }
  1734. $time = time();
  1735. if (strtotime($face_ticket->ex_start) < $time && strtotime($face_ticket->ex_end) > $time) {
  1736. RecruitTicket::where('id', $face_ticket->id)->update(['ex_status' => 1]);
  1737. $recruit = Recruit::where('id', $recruit_id)->first();
  1738. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1739. $name = $recruit->name_en;
  1740. $date = date("Y-m-d", strtotime($recruit->created_at));
  1741. //$filename = $date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id];
  1742. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1743. // return view('app.recruit.recruit_ticket', [
  1744. // 'title' => "{$filename}.docx",
  1745. // 'url' => "https://www.jucai.gov.cn/storage/recruit/ticket/word/{$date}/{$name}/face/{$filename}.docx",
  1746. // ]);
  1747. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/face/" . $filename . '.pdf';
  1748. if (file_exists($file)) {
  1749. header('Content-Description: File Transfer');
  1750. header('Content-Type: application/octet-stream');
  1751. header('Content-Disposition: attachment; filename=' . basename($file));
  1752. header('Content-Transfer-Encoding: binary');
  1753. header('Expires: 0');
  1754. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1755. header('Pragma: public');
  1756. header('Content-Length: ' . filesize($file));
  1757. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1758. flush();
  1759. readfile($file);
  1760. }
  1761. } else {
  1762. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1763. }
  1764. } else {
  1765. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1766. }
  1767. } else {
  1768. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1769. }
  1770. }
  1771. /**
  1772. * 复试准考证
  1773. * @param Request $request
  1774. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1775. */
  1776. public function reexamine_ticket(Request $request)
  1777. {
  1778. $user = $this->getUser();
  1779. if (!empty($user)) {
  1780. $uid = $user->id;
  1781. } else {
  1782. return $this->showMessage('请登录!', route('home'), true, '上一页', '3');
  1783. }
  1784. $recruit_id = $request->input('recruit_id');
  1785. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  1786. if ($appoint_info) {
  1787. $reexamine_ticket = RecruitTicket::where('appoint_id', $appoint_info->id)->where('ex_type', 4)->first();
  1788. if ($reexamine_ticket) {
  1789. $time = time();
  1790. if (strtotime($reexamine_ticket->ex_start) < $time && strtotime($reexamine_ticket->ex_end) > $time) {
  1791. RecruitTicket::where('id', $reexamine_ticket->id)->update(['ex_status' => 1]);
  1792. $recruit = Recruit::where('id', $recruit_id)->first();
  1793. $post_data = RecruitPost::where('recruit_id', $recruit_id)->where('status', 1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1794. $name = $recruit->name_en;
  1795. $date = date("Y-m-d", strtotime($recruit->created_at));
  1796. $filename = sha1($date . '_' . $appoint_info->realname . '_' . $appoint_info->card . '_' . $post_data[$appoint_info->post_id]);
  1797. $file = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/reexamine/" . $filename . '.pdf';
  1798. if (file_exists($file)) {
  1799. header('Content-Description: File Transfer');
  1800. header('Content-Type: application/octet-stream');
  1801. header('Content-Disposition: attachment; filename=' . basename($file));
  1802. header('Content-Transfer-Encoding: binary');
  1803. header('Expires: 0');
  1804. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  1805. header('Pragma: public');
  1806. header('Content-Length: ' . filesize($file));
  1807. ob_clean(); //重要的就是这个函数的调用, 清空但不关闭输出缓存, 否则下载的文件头两个字符会是0a
  1808. flush();
  1809. readfile($file);
  1810. }
  1811. } else {
  1812. return $this->showMessage('非打印时间!', route('home'), true, '上一页', '3');
  1813. }
  1814. } else {
  1815. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1816. }
  1817. } else {
  1818. return $this->showMessage('暂无准考证可以打印!', route('home'), true, '上一页', '3');
  1819. }
  1820. }
  1821. /**
  1822. * 材料补登
  1823. * @param Request $request
  1824. */
  1825. public function material_supplement(Request $request)
  1826. {
  1827. $user = $this->getUser();
  1828. if (!empty($user)) {
  1829. $uid = $user->id;
  1830. } else {
  1831. return redirect(route('login'));
  1832. }
  1833. //招考id
  1834. $id = $request->input('id', 0);
  1835. if (!$id) {
  1836. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1837. }
  1838. $recruit = Recruit::find($id);
  1839. if (!$recruit['status'] && !$user->recruit_test) {
  1840. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1841. }
  1842. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1843. if (!$appoint_info) {
  1844. return $this->showMessage('抱歉,您没有报名,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1845. }
  1846. if ($appoint_info->pen_audit != 1) {
  1847. return $this->showMessage('抱歉,您未入闱,无需考察审核!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1848. }
  1849. $limit_time = 1726824600;
  1850. $time = time();
  1851. if ($time > $limit_time) {
  1852. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1853. }
  1854. $info = RecruitSupplement::where('appoint_id', $appoint_info->id)->where('type', 'supplement')->first();
  1855. if (!$info) {
  1856. $info = [
  1857. 'appoint_id' => $appoint_info->id,
  1858. 'identification' => '',
  1859. //'household_register' => '',
  1860. //'education_certification' => '',
  1861. //'family_planning' => '',
  1862. 'chengxin' => '',
  1863. 'manage' => '',
  1864. 'status' => 3,
  1865. ];
  1866. } else {
  1867. $info = $info->toArray();
  1868. if (json_decode($info['identification'])) {
  1869. $identification = json_decode($info['identification'], true);
  1870. foreach ($identification as $k => $v) {
  1871. if (array_key_exists('response', $v)) {
  1872. $identification[$k]['url'] = $v['response']['path'];
  1873. }
  1874. }
  1875. } else {
  1876. $identification = [];
  1877. }
  1878. $info['identification'] = $identification;
  1879. if (json_decode($info['household_register'])) {
  1880. $household_register = json_decode($info['household_register'], true);
  1881. foreach ($household_register as $k => $v) {
  1882. if (array_key_exists('response', $v)) {
  1883. $household_register[$k]['url'] = $v['response']['path'];
  1884. }
  1885. }
  1886. } else {
  1887. $household_register = [];
  1888. }
  1889. $info['household_register'] = $household_register;
  1890. if (json_decode($info['education_certification'])) {
  1891. $education_certification = json_decode($info['education_certification'], true);
  1892. foreach ($education_certification as $k => $v) {
  1893. if (array_key_exists('response', $v)) {
  1894. $education_certification[$k]['url'] = $v['response']['path'];
  1895. }
  1896. }
  1897. } else {
  1898. $education_certification = [];
  1899. }
  1900. $info['education_certification'] = $education_certification;
  1901. if (json_decode($info['family_planning'])) {
  1902. $family_planning = json_decode($info['family_planning'], true);
  1903. foreach ($family_planning as $k => $v) {
  1904. if (array_key_exists('response', $v)) {
  1905. $family_planning[$k]['url'] = $v['response']['path'];
  1906. }
  1907. }
  1908. } else {
  1909. $family_planning = [];
  1910. }
  1911. $info['family_planning'] = $family_planning;
  1912. if (json_decode($info['chengxin'])) {
  1913. $chengxin = json_decode($info['chengxin'], true);
  1914. foreach ($chengxin as $k => $v) {
  1915. if (array_key_exists('response', $v)) {
  1916. $chengxin[$k]['url'] = $v['response']['path'];
  1917. }
  1918. }
  1919. } else {
  1920. $chengxin = [];
  1921. }
  1922. $info['chengxin'] = $chengxin;
  1923. if (json_decode($info['manage'])) {
  1924. $manage = json_decode($info['manage'], true);
  1925. foreach ($manage as $k => $v) {
  1926. if (array_key_exists('response', $v)) {
  1927. $manage[$k]['url'] = $v['response']['path'];
  1928. }
  1929. }
  1930. } else {
  1931. $manage = [];
  1932. }
  1933. $info['manage'] = $manage;
  1934. }
  1935. $view_data['info'] = json_encode($info);
  1936. $view_data['title'] = $recruit->company;
  1937. return view('app.recruit.supplement', $view_data);
  1938. }
  1939. /**
  1940. * 健康信息登记
  1941. * @param Request $request
  1942. */
  1943. public function health_info(Request $request)
  1944. {
  1945. $user = $this->getUser();
  1946. if (!empty($user)) {
  1947. $uid = $user->id;
  1948. } else {
  1949. return redirect(route('login'));
  1950. }
  1951. //招考id
  1952. $id = $request->input('id', 0);
  1953. if (!$id) {
  1954. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  1955. }
  1956. $recruit = Recruit::find($id);
  1957. if (!$recruit['status'] && !$user->recruit_test) {
  1958. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1959. }
  1960. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  1961. if (!$appoint_info) {
  1962. return $this->showMessage('抱歉,您没有报名,无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1963. }
  1964. if ($appoint_info->audit != 3) {
  1965. return $this->showMessage('抱歉,您无需登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  1966. }
  1967. $time = time();
  1968. $type = $request->input('type', null);
  1969. $where = [];
  1970. if ($type) {
  1971. switch ($type) {
  1972. case 'pen':
  1973. $start = strtotime($recruit->pen_health_start);
  1974. $end = strtotime($recruit->pen_health_end);
  1975. break;
  1976. case 'computer':
  1977. $start = strtotime($recruit->computer_health_start);
  1978. $end = strtotime($recruit->computer_health_end);
  1979. break;
  1980. case 'face':
  1981. $start = strtotime($recruit->face_health_start);
  1982. $end = strtotime($recruit->face_health_end);
  1983. break;
  1984. case 'reexamine':
  1985. $start = strtotime($recruit->reexamine_health_start);
  1986. $end = strtotime($recruit->reexamine_health_end);
  1987. break;
  1988. default:
  1989. $start = strtotime($recruit->supplement_start);
  1990. $end = strtotime($recruit->supplement_end);
  1991. break;
  1992. }
  1993. $where[] = ['type', '=', $type];
  1994. } else {
  1995. $start = strtotime($recruit->supplement_start);
  1996. $end = strtotime($recruit->supplement_end);
  1997. }
  1998. if ($time > $end || $time < $start) {
  1999. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2000. }
  2001. $where[] = ['appoint_id', '=', $appoint_info->id];
  2002. $info = RecruitSupplement::where($where)->first();
  2003. if (!$info) {
  2004. $info = [
  2005. 'appoint_id' => $appoint_info->id,
  2006. 'health_code' => '',
  2007. 'trip_code' => '',
  2008. 'type' => $type,
  2009. ];
  2010. } else {
  2011. $info = $info->toArray();
  2012. if (json_decode($info['health_code'])) {
  2013. $health_code = json_decode($info['health_code'], true);
  2014. foreach ($health_code as $k => $v) {
  2015. if (array_key_exists('response', $v)) {
  2016. $health_code[$k]['url'] = $v['response']['path'];
  2017. }
  2018. }
  2019. } else {
  2020. $health_code = [];
  2021. }
  2022. $info['health_code'] = $health_code;
  2023. if (json_decode($info['trip_code'])) {
  2024. $trip_code = json_decode($info['trip_code'], true);
  2025. foreach ($trip_code as $k => $v) {
  2026. if (array_key_exists('response', $v)) {
  2027. $trip_code[$k]['url'] = $v['response']['path'];
  2028. }
  2029. }
  2030. } else {
  2031. $trip_code = [];
  2032. }
  2033. $info['trip_code'] = $trip_code;
  2034. }
  2035. $view_data['info'] = json_encode($info);
  2036. $view_data['title'] = $recruit->company;
  2037. return view('app.recruit.health', $view_data);
  2038. }
  2039. public function save_supplement(Request $request)
  2040. {
  2041. $user = $this->getUser();
  2042. if (!empty($user)) {
  2043. $uid = $user->id;
  2044. } else {
  2045. return redirect(route('login'));
  2046. }
  2047. $limit_time = 1726824600;
  2048. $time = time();
  2049. if ($time > $limit_time) {
  2050. return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show', ['id', 38]), true, '上一页', '3');
  2051. }
  2052. $appoint_id = $request->input('appoint_id');
  2053. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', 68)->where('id', $appoint_id)->first();
  2054. if (!$appoint_info) {
  2055. return ['status' => 0, 'msg' => '抱歉,找不到您要补登的报名记录!'];
  2056. }
  2057. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', 'supplement')->first();
  2058. if ($info) {
  2059. if ($info->status == 1) {
  2060. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2061. }
  2062. if ($info->status == 0) {
  2063. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2064. }
  2065. //身份证明
  2066. $identification = $request->input('identification');
  2067. if (is_array($identification)) {
  2068. //删除掉没有成功返回路径的图片
  2069. foreach ($identification as $k => $v) {
  2070. if (!array_key_exists('response', $v)) {
  2071. unset($identification[$k]);
  2072. }
  2073. }
  2074. }
  2075. $info->identification = json_encode($identification);
  2076. //户口簿
  2077. $household_register = $request->input('household_register');
  2078. if (is_array($household_register)) {
  2079. //删除掉没有成功返回路径的图片
  2080. foreach ($household_register as $k => $v) {
  2081. if (!array_key_exists('response', $v)) {
  2082. unset($household_register[$k]);
  2083. }
  2084. }
  2085. }
  2086. $info->household_register = json_encode($household_register);
  2087. //学信网
  2088. $education_certification = $request->input('education_certification');
  2089. if (is_array($education_certification)) {
  2090. //删除掉没有成功返回路径的图片
  2091. foreach ($education_certification as $k => $v) {
  2092. if (!array_key_exists('response', $v)) {
  2093. unset($education_certification[$k]);
  2094. }
  2095. }
  2096. }
  2097. $info->education_certification = json_encode($education_certification);
  2098. //计生
  2099. // $family_planning = $request->input('family_planning');
  2100. // if(is_array($family_planning)){
  2101. // //删除掉没有成功返回路径的图片
  2102. // foreach ($family_planning as $k => $v){
  2103. // if(!array_key_exists('response',$v)){
  2104. // unset($family_planning[$k]);
  2105. // }
  2106. // }
  2107. // }
  2108. // $info->family_planning = json_encode($family_planning);
  2109. //失信查询 情况
  2110. $chengxin = $request->input('chengxin');
  2111. if (is_array($chengxin)) {
  2112. //删除掉没有成功返回路径的图片
  2113. foreach ($chengxin as $k => $v) {
  2114. if (!array_key_exists('response', $v)) {
  2115. unset($chengxin[$k]);
  2116. }
  2117. }
  2118. }
  2119. $info->chengxin = json_encode($chengxin);
  2120. //综治
  2121. $manage = $request->input('manage');
  2122. if (is_array($manage)) {
  2123. //删除掉没有成功返回路径的图片
  2124. foreach ($manage as $k => $v) {
  2125. if (!array_key_exists('response', $v)) {
  2126. unset($manage[$k]);
  2127. }
  2128. }
  2129. }
  2130. $info->manage = json_encode($manage);
  2131. $info->status = 0;
  2132. $info->save();
  2133. $appoint_info->political_audit = 4;
  2134. $appoint_info->save();
  2135. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2136. } else {
  2137. $data['appoint_id'] = $appoint_id;
  2138. //身份证明
  2139. $identification = $request->input('identification');
  2140. if (is_array($identification)) {
  2141. //删除掉没有成功返回路径的图片
  2142. foreach ($identification as $k => $v) {
  2143. if (!array_key_exists('response', $v)) {
  2144. unset($identification[$k]);
  2145. }
  2146. }
  2147. }
  2148. $data['identification'] = json_encode($identification);
  2149. //户口簿
  2150. $household_register = $request->input('household_register');
  2151. if (is_array($household_register)) {
  2152. //删除掉没有成功返回路径的图片
  2153. foreach ($household_register as $k => $v) {
  2154. if (!array_key_exists('response', $v)) {
  2155. unset($household_register[$k]);
  2156. }
  2157. }
  2158. }
  2159. $data['household_register'] = json_encode($household_register);
  2160. //学信网
  2161. $education_certification = $request->input('education_certification');
  2162. if (is_array($education_certification)) {
  2163. //删除掉没有成功返回路径的图片
  2164. foreach ($education_certification as $k => $v) {
  2165. if (!array_key_exists('response', $v)) {
  2166. unset($education_certification[$k]);
  2167. }
  2168. }
  2169. }
  2170. $data['education_certification'] = json_encode($education_certification);
  2171. //计生
  2172. // $family_planning = $request->input('family_planning');
  2173. // if(is_array($family_planning)){sp
  2174. // //删除掉没有成功返回路径的图片
  2175. // foreach ($family_planning as $k => $v){
  2176. // if(!array_key_exists('response',$v)){
  2177. // unset($family_planning[$k]);
  2178. // }
  2179. // }
  2180. // }
  2181. // $data['family_planning'] = json_encode($family_planning);
  2182. //失信查询 情况
  2183. $chengxin = $request->input('chengxin');
  2184. if (is_array($chengxin)) {
  2185. //删除掉没有成功返回路径的图片
  2186. foreach ($chengxin as $k => $v) {
  2187. if (!array_key_exists('response', $v)) {
  2188. unset($chengxin[$k]);
  2189. }
  2190. }
  2191. }
  2192. $data['chengxin'] = json_encode($chengxin);
  2193. //综治
  2194. $manage = $request->input('manage');
  2195. if (is_array($manage)) {
  2196. //删除掉没有成功返回路径的图片
  2197. foreach ($manage as $k => $v) {
  2198. if (!array_key_exists('response', $v)) {
  2199. unset($manage[$k]);
  2200. }
  2201. }
  2202. }
  2203. $data['manage'] = json_encode($manage);
  2204. $data['status'] = 0;
  2205. $data['type'] = 'supplement';
  2206. $result = RecruitSupplement::create($data);
  2207. $appoint_info->political_audit = 4;
  2208. $appoint_info->save();
  2209. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2210. }
  2211. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2212. }
  2213. public function save_healthinfo(Request $request)
  2214. {
  2215. $user = $this->getUser();
  2216. if (!empty($user)) {
  2217. $uid = $user->id;
  2218. } else {
  2219. return redirect(route('login'));
  2220. }
  2221. $appoint_id = $request->input('appoint_id');
  2222. $type = $request->input('type');
  2223. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('id', $appoint_id)->first();
  2224. if (!$appoint_info) {
  2225. return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
  2226. }
  2227. $recruit = Recruit::where('id', $appoint_info->recruit_id)->first();
  2228. $info = RecruitSupplement::where('appoint_id', $appoint_id)->where('type', $type)->first();
  2229. if ($info) {
  2230. if ($info->h_status == 1) {
  2231. return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
  2232. }
  2233. if ($info->h_status == 0) {
  2234. return ['status' => 0, 'msg' => '材料审核中,不允许修改'];
  2235. }
  2236. $health_code = $request->input('health_code');
  2237. if (is_array($health_code)) {
  2238. //删除掉没有成功返回路径的图片
  2239. foreach ($health_code as $k => $v) {
  2240. if (!array_key_exists('response', $v)) {
  2241. unset($health_code[$k]);
  2242. }
  2243. }
  2244. }
  2245. $info->health_code = json_encode($health_code);
  2246. $trip_code = $request->input('trip_code');
  2247. if (is_array($trip_code)) {
  2248. //删除掉没有成功返回路径的图片
  2249. foreach ($trip_code as $k => $v) {
  2250. if (!array_key_exists('response', $v)) {
  2251. unset($trip_code[$k]);
  2252. }
  2253. }
  2254. }
  2255. $info->trip_code = json_encode($trip_code);
  2256. $info->h_status = 0;
  2257. $appoint_info->health_audit = 4;
  2258. $appoint_info->save();
  2259. $info->save();
  2260. return ['status' => 1, 'msg' => '提交成功', 'data' => ''];
  2261. } else {
  2262. $data['appoint_id'] = $appoint_id;
  2263. $data['type'] = $type;
  2264. $data['h_status'] = 0;
  2265. $appoint_info->health_audit = 4;
  2266. $health_code = $request->input('health_code');
  2267. if (is_array($health_code)) {
  2268. //删除掉没有成功返回路径的图片
  2269. foreach ($health_code as $k => $v) {
  2270. if (!array_key_exists('response', $v)) {
  2271. unset($health_code[$k]);
  2272. }
  2273. }
  2274. }
  2275. $health_result = $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
  2276. $health_msg = ['健康码自动审核通过'];
  2277. //$h_status = 1;
  2278. //$appoint_info->health_audit = 1;
  2279. if (!array_key_exists('error_msg', $health_result) && !array_key_exists('error_code', $health_result)) {
  2280. if (array_key_exists('姓名', $health_result)) {
  2281. if (stripos($health_result['姓名'][0]['word'], '*') > 0) {
  2282. return ['status' => 0, 'msg' => '请打开健康码的“眼睛开关”,显示完整个人信息'];
  2283. }
  2284. if ($health_result['姓名'][0]['word'] != $appoint_info->realname) {
  2285. array_push($health_msg, '抱歉,请上传您本人的健康码!');
  2286. }
  2287. } else {
  2288. array_push($health_msg, '健康码错误,识别不到姓名!');
  2289. }
  2290. if (array_key_exists('状态', $health_result)) {
  2291. if ($health_result['状态'][0]['word'] != '绿码') {
  2292. array_push($health_msg, '抱歉,您的健康码非绿码!');
  2293. }
  2294. } else {
  2295. array_push($health_msg, '健康码错误,识别不到状态!');
  2296. }
  2297. if (array_key_exists('更新时间', $health_result)) {
  2298. $time = strtotime($health_result['更新时间'][0]['word']);
  2299. if ($time < strtotime($recruit->pen_health_start) || $time > strtotime($recruit->pen_health_end)) {
  2300. array_push($health_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的健康码!');
  2301. }
  2302. } else {
  2303. array_push($health_msg, '健康码错误,识别不到时间!');
  2304. }
  2305. //$data['h_status'] = $h_status;
  2306. $data['h_msg'] = implode(';', $health_msg);
  2307. //$appoint_info->health_audit = $h_status == 1 ? 1 : 4;
  2308. $data['health_code'] = json_encode($health_code);
  2309. }
  2310. $data['health_result'] = json_encode($health_result);
  2311. $trip_code = $request->input('trip_code');
  2312. if (is_array($trip_code)) {
  2313. //删除掉没有成功返回路径的图片
  2314. foreach ($trip_code as $k => $v) {
  2315. if (!array_key_exists('response', $v)) {
  2316. unset($trip_code[$k]);
  2317. }
  2318. }
  2319. }
  2320. $trip_result = $this->baiduService->trip_code(file_get_contents(base_path() . "/public" . $trip_code[0]['response']['path']));
  2321. $trip_msg = [];
  2322. $trip_status = 0;
  2323. if (!array_key_exists('error_msg', $trip_result) && !array_key_exists('error_code', $trip_result)) {
  2324. if (array_key_exists('途经地', $trip_result['result'])) {
  2325. $fangyi_area = explode("\r\n", config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.risk_area'));
  2326. $result = array_intersect($fangyi_area, $trip_result['result']['途经地'][0]['word']);
  2327. if (count($result) > 0) {
  2328. array_push($trip_msg, '抱歉,您的行程中包含系统设置中高风险地区!');
  2329. $trip_status = 0;
  2330. }
  2331. }
  2332. if (array_key_exists('风险性', $trip_result['result']) && $trip_result['result']['风险性']) {
  2333. array_push($trip_msg, '抱歉,您的行程可能含有风险!');
  2334. $trip_status = 0;
  2335. }
  2336. if (array_key_exists('更新时间', $trip_result['result'])) {
  2337. $time = strtotime($trip_result['result']['更新时间'][0]['word'][0]);
  2338. if ($time > strtotime($recruit->pen_health_start) || $recruit < ($recruit->pen_health_end)) {
  2339. array_push($trip_msg, '抱歉,请上传{$recruit->pen_health_start}至{$recruit->pen_health_end}之间的行程码!');
  2340. $trip_status = 0;
  2341. }
  2342. }
  2343. $data['h_msg'] .= implode(';', $trip_msg);
  2344. }
  2345. $data['trip_result'] = json_encode($trip_result);
  2346. $data['trip_code'] = json_encode($trip_code);
  2347. $data['h_status'] = 0;
  2348. $appoint_info->health_audit = 4;
  2349. RecruitSupplement::create($data);
  2350. $appoint_info->save();
  2351. return ['status' => 1, 'msg' => '提交成功,请刷新查看审核结果', 'data' => ''];
  2352. }
  2353. return ['status' => 0, 'msg' => 'test', 'data' => ''];
  2354. }
  2355. public function post_select(Request $request)
  2356. {
  2357. $user = $this->getUser();
  2358. if (!empty($user)) {
  2359. $uid = $user->id;
  2360. } else {
  2361. return redirect(route('login'));
  2362. }
  2363. $recruit_id = $request->input('recruit_id');
  2364. //$appoint_id = $request->input('appoint_id');
  2365. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->first();
  2366. if (!$info) {
  2367. return $this->showMessage('抱歉,您无需择岗!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2368. }
  2369. //手动设置择岗时间段
  2370. $time = time();
  2371. if ($time > 1727150400 || $time < 1727053200) {
  2372. //if($time > 1694491200){
  2373. return $this->showMessage('抱歉,未到择岗时间!', route('recruit.show', ['id', $recruit_id]), true, '上一页', '2');
  2374. }
  2375. $option_list = [
  2376. [
  2377. 'id' => 1,
  2378. 'name' => '陈埭镇',
  2379. ],
  2380. [
  2381. 'id' => 2,
  2382. 'name' => '金井镇',
  2383. ],
  2384. [
  2385. 'id' => 3,
  2386. 'name' => '深沪镇'
  2387. ]
  2388. ];
  2389. $select_list = [];
  2390. if ($info->result) {
  2391. $result = json_decode($info->result, true);
  2392. foreach ($result as $v) {
  2393. $item['name'] = $v;
  2394. array_push($select_list, $item);
  2395. }
  2396. }
  2397. // $recruit_id = $request->input('recruit_id');
  2398. // $appoint_id = $request->input('appoint_id');
  2399. // $uid = $request->input('uid');
  2400. // $info = RecruitAppointSelect::where('uid',$uid)->first();
  2401. // if(!$info){
  2402. // $info = new \stdClass();
  2403. // $info->status = 0;
  2404. // $info->recruit_id = 8;
  2405. // $info->appoint_id = rand(0,999999);
  2406. // $info->uid = rand(0,999999);
  2407. // }else{
  2408. // $result = json_decode($info->result,true);
  2409. // foreach ($option_list as $k => $v){
  2410. // if(in_array($v['name'],$result)){
  2411. // $select_list[$k] = $v;
  2412. // unset($option_list[$k]);
  2413. // }
  2414. // }
  2415. // }
  2416. $view_data = ['info' => $info, 'options_list' => json_encode($option_list), 'select_list' => json_encode($select_list)];
  2417. return view('app.recruit.post_select', $view_data);
  2418. }
  2419. /**
  2420. * 放弃择岗
  2421. */
  2422. public function give_up_post(Request $request)
  2423. {
  2424. //以下为测试环境
  2425. // $recruit_id = $request->input('recruit_id');
  2426. // $appoint_id = $request->input('appoint_id');
  2427. // $uid = $request->input('uid');
  2428. // $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  2429. // if($info){
  2430. // return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  2431. // }
  2432. // RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
  2433. // return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2434. //以下为正式环境再放开
  2435. $user = $this->getUser();
  2436. if (!empty($user)) {
  2437. $uid = $user->id;
  2438. } else {
  2439. return redirect(route('login'));
  2440. }
  2441. $recruit_id = $request->input('recruit_id');
  2442. $appoint_id = $request->input('appoint_id');
  2443. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2444. if ($info == null) {
  2445. return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
  2446. }
  2447. if ($info->status != 0) {
  2448. return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
  2449. }
  2450. $info->status = -1;
  2451. $info->save();
  2452. return ['status' => 1, 'msg' => "放弃择岗成功!"];
  2453. }
  2454. public function comfirm_post(Request $request)
  2455. {
  2456. $user = $this->getUser();
  2457. if (!empty($user)) {
  2458. $uid = $user->id;
  2459. } else {
  2460. return redirect(route('login'));
  2461. }
  2462. $recruit_id = $request->input('recruit_id');
  2463. $appoint_id = $request->input('appoint_id');
  2464. $time = time();
  2465. if ($time > 1727150400 || $time < 1727053200) {
  2466. return ['status' => 0, 'msg' => "抱歉,未到择岗时间!"];
  2467. }
  2468. $info = RecruitAppointSelect::where('uid', $uid)->where('recruit_id', $recruit_id)->where('appoint_id', $appoint_id)->first();
  2469. if ($info->result) {
  2470. return ['status' => 0, 'msg' => "择岗数据已提交!"];
  2471. }
  2472. // $data = [
  2473. // 'recruit_id' => $recruit_id,
  2474. // 'appoint_id' => $recruit_id,
  2475. // 'uid' => $uid,
  2476. // 'status' => 1
  2477. // ];
  2478. $result = [];
  2479. $select = $request->input('select');
  2480. if (is_array($select) && count($select) > 0) {
  2481. foreach ($select as $v) {
  2482. array_push($result, $v['name']);
  2483. }
  2484. }
  2485. $info->result = json_encode($result);
  2486. $info->status = 1;
  2487. $info->save();
  2488. return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
  2489. }
  2490. public function select_result(Request $request)
  2491. {
  2492. $redis = Cache::getRedis();
  2493. $redis->set('recruit_quota_batch5', '');
  2494. return view('app.recruit.select_result');
  2495. }
  2496. public function get_select_result(Request $request)
  2497. {
  2498. $redis = Cache::getRedis();
  2499. $quot_batch5 = $redis->get('recruit_quota_batch5');
  2500. if (!$quot_batch5) {
  2501. $quot_batch5 = [
  2502. [
  2503. 'name' => '陈埭镇',
  2504. 'value' => 21,
  2505. ],
  2506. [
  2507. 'name' => '金井镇',
  2508. 'value' => 3
  2509. ],
  2510. [
  2511. 'name' => '深沪镇',
  2512. 'value' => 2
  2513. ]
  2514. ];
  2515. $redis->set('recruit_quotaA', json_encode($quot_batch5));
  2516. } else {
  2517. $quot_batch5 = json_decode($quot_batch5, true);
  2518. }
  2519. $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();
  2520. $return_data = [
  2521. 'list' => [],
  2522. ];
  2523. $array_column = array_column($quot_batch5, 'name');
  2524. if (count($list) > 1) {
  2525. $current = $list[0];
  2526. $next = $list[1];
  2527. } else {
  2528. $current = $list[0];
  2529. $next = false;
  2530. }
  2531. $person_select_result = json_decode($current->result, true);
  2532. $flag = 0;//是否择岗成功
  2533. foreach ($person_select_result as $val) {
  2534. //寻找下标
  2535. $index = array_search($val, $array_column);
  2536. if ($quot_batch5[$index]['value']) {
  2537. if ($next && $current->record == $next->record && $current->record2 == $next->record2 && $current->record3 == $next->record3 && $quot_batch5[$index]['value'] == 1) {
  2538. //如果当前处理人员不是最后一个,且分数与下一名人员三个维度完全一样的话并且该人员欲择的岗位仅剩一位,则特殊处理
  2539. //查找同样分数人同样志愿
  2540. $next_select_result = json_decode($next->result, true);
  2541. //寻找下标
  2542. $current_index = array_search($val, $person_select_result);
  2543. $next_index = array_search($val, $next_select_result);
  2544. if ($current_index > $next_index) {
  2545. //如果当前人员对当前镇街的意向排序大于下一人,调换两个指针,先排序下一个人
  2546. $current = $next;
  2547. }
  2548. }
  2549. $quota_data = [
  2550. 'index' => $index,
  2551. 'old_value' => $quot_batch5[$index]['value'],
  2552. ];
  2553. //有名额允许择岗
  2554. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => $val, 'status' => 1]);
  2555. $current->select_result = $val;
  2556. $quot_batch5[$index]['value']--;
  2557. $quota_data['new_value'] = $quot_batch5[$index]['value'];
  2558. $redis->set('recruit_quota_batch4', json_encode($quot_batch5));
  2559. $flag = 1;
  2560. break;
  2561. }
  2562. }
  2563. if (!$flag) {
  2564. $quota_data = [
  2565. 'index' => $index,
  2566. 'old_value' => $quot_batch5[$index]['value'],
  2567. ];
  2568. $current->select_result = '未匹配到志愿,本轮择岗不成功!';
  2569. DB::table('recruit_appoint_select')->where('id', $current->id)->update(['select_result' => '未匹配到志愿,本轮择岗不成功!', 'status' => -2]);
  2570. }
  2571. $return_data['quota'] = $quota_data;
  2572. return ['status' => 1, 'msg' => '择岗排序成功', 'data' => $return_data];
  2573. }
  2574. public function select_init(Request $request)
  2575. {
  2576. $count = DB::table('recruit_appoint_select')->whereRaw('select_result is null and batch = 5 and type = 1 and result is not null')->count();
  2577. $redis = Cache::getRedis();
  2578. $quot_batch5 = $redis->get('recruit_quota_batch4');
  2579. if (!$quot_batch5) {
  2580. $quot_batch5 = [
  2581. [
  2582. 'name' => '陈埭镇',
  2583. 'value' => 21,
  2584. ],
  2585. [
  2586. 'name' => '金井镇',
  2587. 'value' => 3
  2588. ],
  2589. [
  2590. 'name' => '深沪镇',
  2591. 'value' => 2
  2592. ]
  2593. ];
  2594. $redis->set('recruit_quota_batch5', json_encode($quot_batch5));
  2595. }
  2596. $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();
  2597. return ['status' => 1, 'msg' => '获取初始化信息成功', 'data' => ['count' => $count, 'quota' => $quot_batch5, 'list' => $list]];
  2598. }
  2599. public function interviewer_random(Request $request)
  2600. {
  2601. $model = $request->input('model', 1);
  2602. $number1 = $request->input('number1', 5);//考官人数
  2603. $number2 = $request->input('number2', 1);//替补人数
  2604. $where[] = ['id', '>', 0];
  2605. switch ($model) {
  2606. case '0':
  2607. $list = DB::table('recruit_interviewer')->get()->toArray();
  2608. shuffle($list);
  2609. $result = array_slice($list, 0, $number1 + $number2);
  2610. break;
  2611. case '1':
  2612. $list = DB::table('recruit_interviewer')->get()->toArray();
  2613. shuffle($list);
  2614. $count = $number1;
  2615. for ($i = 0; $i < $count; $i++) {
  2616. if (!$list[$i]->status) {
  2617. $list[] = $list[$i];
  2618. unset($list[$i]);
  2619. $count++;
  2620. }
  2621. }
  2622. $result = array_slice($list, 0, $number1 + $number2);
  2623. break;
  2624. case '2':
  2625. $list = DB::table('recruit_interviewer')->where('status', 1)->get()->toArray();
  2626. shuffle($list);
  2627. $result = array_slice($list, 0, $number1 + $number2);
  2628. break;
  2629. default:
  2630. $list = DB::table('recruit_interviewer')->get()->toArray();
  2631. shuffle($list);
  2632. for ($i = 0; $i < $number1; $i++) {
  2633. dd($list[$i]);
  2634. if (!$list[$i]->status) {
  2635. $list[] = $list[$i];
  2636. unset($list[$i]);
  2637. }
  2638. }
  2639. $result = array_slice($list, 0, $number1 + $number2);
  2640. break;
  2641. }
  2642. $return_data = [
  2643. 'list' => $result,
  2644. 'number1' => $number1,
  2645. 'number2' => $number2,
  2646. ];
  2647. return view('app.recruit.interviewer', $return_data);
  2648. }
  2649. public function supplement_info(Request $request)
  2650. {
  2651. $user = $this->getUser();
  2652. if (!empty($user)) {
  2653. $uid = $user->id;
  2654. } else {
  2655. return redirect(route('login'));
  2656. }
  2657. //招考id
  2658. $id = $request->input('id', 0);
  2659. if (!$id) {
  2660. return $this->showMessage('请选择报名项目!', route('home'), true, '上一页', '3');
  2661. }
  2662. $recruit = Recruit::find($id);
  2663. if (!$recruit['status']) {
  2664. return $this->showMessage('抱歉,该项目状态不正确,请联系客服!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2665. }
  2666. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2667. if (!$appoint_info) {
  2668. return $this->showMessage('抱歉,您没有报名,无需补充信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2669. }
  2670. $supplement_info = DB::table("recruit_supplement_cunwu")->where('uid', $uid)->where('appoint_id', $appoint_info->id)->first();
  2671. if ($supplement_info) {
  2672. return $this->showMessage('您已登记信息,无需再次登记!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2673. }
  2674. $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];//写死用户
  2675. if (!in_array($uid, $uids)) {
  2676. return $this->showMessage('您无需登记信息!', route('recruit.show', ['id', $recruit['id']]), true, '上一页', '3');
  2677. }
  2678. // $limit_time = 1661961599;
  2679. // $time = time();
  2680. // if( $time > $limit_time){
  2681. // return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
  2682. // }
  2683. $view_data = [];
  2684. //$view_data['info'] = json_encode($info);
  2685. $view_data['title'] = $recruit->company;
  2686. $view_data['id'] = $id;
  2687. return view('app.recruit.supplement_info', $view_data);
  2688. }
  2689. public function save_supplement_info(Request $request)
  2690. {
  2691. $user = $this->getUser();
  2692. if (!empty($user)) {
  2693. $uid = $user->id;
  2694. } else {
  2695. return redirect(route('login'));
  2696. }
  2697. //招考id
  2698. $id = $request->input('recruit_id', 0);
  2699. if (!$id) {
  2700. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2701. }
  2702. $recruit = Recruit::find($id);
  2703. if (!$recruit['status']) {
  2704. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2705. }
  2706. $appoint_info = RecruitAppointInfo::where('uid', $uid)->where('recruit_id', $id)->first();
  2707. if (!$appoint_info) {
  2708. return ['status' => 0, 'msg' => '抱歉,您没有报名,无需补充信息!', 'data' => ''];
  2709. }
  2710. if ($request->input('marriage') == '已婚') {
  2711. if ($request->input('spouse_card_type') == '' || $request->input('spouse_card') == '' || $request->input('spouse_realname') == '' || $request->input('spouse_mobile') == '') {
  2712. return ['status' => 0, 'msg' => '请完善配偶信息!', 'data' => ''];
  2713. }
  2714. }
  2715. $data = [
  2716. 'uid' => $uid,
  2717. 'appoint_id' => $appoint_info->id,
  2718. 'street' => $request->input('street'),
  2719. 'realname' => $request->input('realname'),
  2720. 'sex' => $request->input('sex'),
  2721. 'house' => $request->input('house'),
  2722. 'nation' => $request->input('nation'),
  2723. 'native' => $request->input('native'),
  2724. 'marriage' => $request->input('marriage'),
  2725. 'spouse_card_type' => $request->input('spouse_card_type'),
  2726. 'spouse_card' => $request->input('spouse_card'),
  2727. 'spouse_realname' => $request->input('spouse_realname'),
  2728. 'spouse_mobile' => $request->input('spouse_mobile'),
  2729. 'political' => $request->input('political'),
  2730. 'bank_card' => $request->input('bank_card'),
  2731. 'bank_open' => $request->input('bank_open'),
  2732. 'card' => $request->input('card'),
  2733. 'card_endtime' => $request->input('card_endtime'),
  2734. 'mobile' => $request->input('mobile'),
  2735. 'edu' => $request->input('education'),
  2736. 'pro' => $request->input('pro'),
  2737. 'address' => $request->input('address'),
  2738. 'funds' => $request->input('funds'),
  2739. ];
  2740. DB::table('recruit_supplement_cunwu')->insert($data);
  2741. return ['status' => 1, 'msg' => '提交成功!', 'data' => ''];
  2742. }
  2743. public function comfirm_pen(Request $request)
  2744. {
  2745. $user = $this->getUser();
  2746. if (!empty($user)) {
  2747. $uid = $user->id;
  2748. } else {
  2749. return redirect(route('login'));
  2750. }
  2751. //招考id
  2752. $id = $request->input('recruit_id', 0);
  2753. if (!$id) {
  2754. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2755. }
  2756. $recruit = Recruit::find($id);
  2757. if (!$recruit['status']) {
  2758. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2759. }
  2760. if (!$recruit->pen_comfirm) {
  2761. return ['status' => 0, 'msg' => '该项目无须确认笔试考试!', 'data' => ''];
  2762. }
  2763. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2764. if (!$appoint_info) {
  2765. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2766. }
  2767. if ($appoint_info->audit != 3) {
  2768. return ['status' => 0, 'msg' => '您的报名未审核通过,无需确认!', 'data' => ''];
  2769. }
  2770. $time = time();
  2771. if (strtotime($recruit->pen_comfirm_start) > $time || strtotime($recruit->pen_comfirm_end) < $time) {
  2772. return ['status' => 0, 'msg' => '未在笔试确认时间段!', 'data' => ''];
  2773. }
  2774. if ($appoint_info->pen_audit != -2) {
  2775. return ['status' => 0, 'msg' => '您已确认参加笔试,无需再次确认!', 'data' => ''];
  2776. }
  2777. $appoint_info->update(['pen_audit' => -1]);
  2778. $log = [
  2779. 'type' => 3,
  2780. 'appoint_id' => $appoint_info->id,
  2781. 'uid' => $uid,
  2782. 'log' => '用户确认参加笔试',
  2783. ];
  2784. RecruitAppointLog::create($log);
  2785. return ['status' => 1, 'msg' => '确认成功', 'data' => $appoint_info->id];
  2786. }
  2787. public function supplementary_entry(Request $request)
  2788. {
  2789. $user = $this->getUser();
  2790. if (!empty($user)) {
  2791. $uid = $user->id;
  2792. } else {
  2793. return redirect(route('login'));
  2794. }
  2795. //招考id
  2796. $id = $request->input('recruit_id', 0);
  2797. if (!$id) {
  2798. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2799. }
  2800. $recruit = Recruit::find($id);
  2801. if (!$recruit['status']) {
  2802. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2803. }
  2804. $appoint_info = RecruitAppointInfo::where('recruit_id', $id)->where('uid', $uid)->first();
  2805. if (!$appoint_info) {
  2806. return ['status' => 0, 'msg' => '找不到您的报名记录,请检查!', 'data' => ''];
  2807. }
  2808. $time = time();
  2809. if ($time > 1680969600) {
  2810. return ['status' => 0, 'msg' => '已停止补充报名!', 'data' => ''];
  2811. }
  2812. if ($appoint_info->adjust_limit) {
  2813. $appoint_info->update(['adjust' => 1]);
  2814. return ['status' => 1, 'msg' => '补充报名成功!', 'data' => ''];
  2815. } else {
  2816. return ['status' => 0, 'msg' => '您无需补充报名!', 'data' => ''];
  2817. }
  2818. }
  2819. public function show_sign_limit(Request $request){
  2820. $user = $this->getUser();
  2821. if (!empty($user)) {
  2822. $uid = $user->id;
  2823. } else {
  2824. return redirect(route('login'));
  2825. }
  2826. //招考id
  2827. $id = $request->input('recruit_id', 0);
  2828. if (!$id) {
  2829. return ['status' => 0, 'msg' => '请选择报名项目!', 'data' => ''];
  2830. }
  2831. $recruit = Recruit::find($id);
  2832. if (!$recruit['status']) {
  2833. return ['status' => 0, 'msg' => '抱歉,该项目状态不正确,请联系客服!', 'data' => ''];
  2834. }
  2835. $list = RecruitAppointInfo::where('uid', $user->id)
  2836. ->join('recruit', 'recruit.id', '=', 'recruit_appoint_info.recruit_id', 'left')
  2837. ->join('recruit_post', 'recruit_post.id', '=', 'recruit_appoint_info.post_id', 'left')
  2838. ->select('recruit.name as recruit_name', 'recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  2839. ->where('recruit_appoint_info.recruit_id','=',$id)
  2840. ->get();
  2841. $html = view('app.recruit.show_sign_limit')->with(['list' => $list , 'total' => count($list)])->render();
  2842. return response()->json(['code' => 1, 'data' => $html]);
  2843. }
  2844. }