IndexController.php 121 KB

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