IndexController.php 146 KB

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