IndexController.php 113 KB

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