SpecialController.php 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. <?php
  2. namespace App\Admin\Controllers\Recruit;
  3. use App\Admin\Extensions\Form\ValidateForm;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Admin\AdminUser;
  6. use App\Models\Member;
  7. use App\Models\Pms;
  8. use App\Models\Recruit;
  9. use App\Models\RecruitAppointInfo;
  10. use App\Models\RecruitAppointLog;
  11. use App\Models\RecruitPost;
  12. use App\Models\RecruitSubjoin;
  13. use App\Models\RecruitTicket;
  14. use App\Models\RecruitTicketField;
  15. use App\Services\Common\SmsService;
  16. use Encore\Admin\Auth\Permission;
  17. use Encore\Admin\Facades\Admin;
  18. use Encore\Admin\Form;
  19. use Encore\Admin\Grid;
  20. use Encore\Admin\Layout\Content;
  21. use Illuminate\Http\Request;
  22. use Illuminate\Support\Facades\DB;
  23. use Illuminate\Support\Facades\Storage;
  24. class SpecialController extends Controller
  25. {
  26. private $smsService;
  27. public function __construct(SmsService $smsService)
  28. {
  29. $this->smsService = $smsService;
  30. }
  31. /**
  32. * Show interface.
  33. *
  34. * @param mixed $id
  35. * @param Content $content
  36. * @return Content
  37. */
  38. public function show($id, Content $content)
  39. {
  40. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/special/index');
  41. }
  42. /**
  43. * 招考报名首页
  44. * @param Content $content
  45. * @return Content
  46. */
  47. public function index(Content $content)
  48. {
  49. return $content
  50. ->header('专场招考报名管理')
  51. ->description('')
  52. ->body($this->grid());
  53. }
  54. /**
  55. * Make a grid builder.
  56. *
  57. * @return Grid
  58. */
  59. protected function grid()
  60. {
  61. $grid = new Grid(new Recruit);
  62. $grid->model()->where('special',1);
  63. $grid->model()->orderBy('created_at', 'DESC');
  64. $grid->model()->paginate(20);
  65. if (Admin::user()->can('special_recruit_manager_create')) {
  66. $grid->disableCreateButton(false);
  67. }
  68. $grid->perPages([10, 20, 30, 40, 50, 100]);
  69. $grid->id('ID');
  70. $grid->name('招考场次名称');
  71. $grid->column('current','当前阶段')->display(function ($current) {
  72. switch ($current){
  73. case '1':
  74. return '报名';
  75. break;
  76. case '2':
  77. return '审核';
  78. break;
  79. case '3':
  80. return '笔试';
  81. break;
  82. case '4':
  83. return '上机测试';
  84. break;
  85. case '5':
  86. return '面试';
  87. break;
  88. case '6':
  89. return '复试';
  90. break;
  91. case '7':
  92. return '体检';
  93. break;
  94. case '8':
  95. return '政审';
  96. break;
  97. case '9':
  98. return '公示';
  99. break;
  100. case '0':
  101. return '已结束';
  102. break;
  103. }
  104. });
  105. $grid->column('status','状态')->display(function ($status) {
  106. return $status ? '显示' : '隐藏';
  107. });
  108. $grid->filter(function ($filter) {
  109. $filter->disableIdFilter();
  110. $filter->where(function ($query) {
  111. $query->where('simple', '=', "{$this->input}");
  112. }, '类型', 'simple')->radio([0 => '招考',1 => '招聘']);
  113. });
  114. $grid->created_at('创建时间');
  115. $grid->actions(function ($actions) {
  116. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/special/appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  117. $actions->disableEdit(false);
  118. $actions->disableDelete(false);
  119. $actions->disableView();
  120. });
  121. return $grid;
  122. }
  123. /**
  124. * 新增招考报名表单页.
  125. *
  126. * @param Content $content
  127. * @return Content
  128. */
  129. public function create(Content $content)
  130. {
  131. Permission::check('special_recruit_manager_create');
  132. return $content
  133. ->header('新增专场招聘场次')
  134. ->description('新增')
  135. ->body(view('admin.special.index')->with(['grid' => $this->form()->render(), 'id' => '0']));
  136. }
  137. /**
  138. * 更新报名场次信息
  139. * @param $id
  140. * @param Request $request
  141. */
  142. public function update($id, Request $request)
  143. {
  144. $verify = $this->Form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  145. $postCode = $request->input('postcode', []);
  146. $postName = $request->input('postname', []);
  147. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  148. return admin_toastr('请填写招考岗位', 'error');
  149. }
  150. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  151. return admin_toastr('请填写招考岗位名称', 'error');
  152. }
  153. $recruit_id = $id;
  154. $recruit = Recruit::find($id);
  155. if(!$recruit->special){
  156. $this->show();
  157. }
  158. $data = [];
  159. $data['name'] = $verify['name'];
  160. $data['company'] = $verify['company'];
  161. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  162. if(array_key_exists('small_img',$verify)){
  163. $data['small_img'] = $verify['small_img'];
  164. }else{
  165. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  166. }
  167. $data['status'] = $verify['status'];
  168. $data['show_report'] = $verify['show_report'];
  169. $data['current'] = $verify['current'];
  170. $data['step'] = implode(',',array_filter($verify['step']));
  171. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  172. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  173. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  174. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  175. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  176. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  177. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  178. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  179. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  180. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  181. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  182. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  183. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  184. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  185. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  186. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  187. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  188. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  189. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  190. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  191. $data['introduction'] = $verify['introduction'];
  192. $data['host_address'] = $verify['host_address'];
  193. $data['contact'] = $verify['contact'];
  194. $data['phone'] = $verify['phone'];
  195. $data['ordid'] = $verify['ordid'];
  196. $data['limit_times'] = $verify['limit_times'];
  197. $data['post_times'] = $verify['post_times'];
  198. $data['pay_switch'] = $verify['pay_switch'];
  199. $data['forms'] = implode(',',array_filter($verify['forms']));
  200. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  201. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  202. $data['pen_ticket_status'] = 0;
  203. $data['pen_ticket_field'] = implode(',',$verify['pen_ticket_field']);
  204. $data['pen_comfirm'] = $verify['pen_comfirm'];
  205. $data['pen_comfirm_start'] = $verify['pen_comfirm_start'] ? $verify['pen_comfirm_start'] : null;
  206. $data['pen_comfirm_end'] = $verify['pen_comfirm_end'] ? $verify['pen_comfirm_end'] : null;
  207. $data['pen_epidemic'] = $verify['pen_epidemic'];
  208. $data['pen_health'] = $verify['pen_health'];
  209. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  210. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  211. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  212. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  213. $data['computer_ticket_status'] = 0;
  214. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  215. $data['face_ticket_type'] = $verify['face_ticket_type'];
  216. $data['face_ticket_content'] = $verify['face_ticket_content'];
  217. $data['face_ticket_status'] = 0;
  218. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  219. $data['face_epidemic'] = $verify['face_epidemic'];
  220. $data['face_health'] = $verify['face_health'];
  221. $data['face_health_start'] = $verify['face_health_start'] ? $verify['face_health_start'] : null;
  222. $data['face_health_end'] = $verify['face_health_end'] ? $verify['face_health_end'] : null;
  223. $data['reexamine_ticket_type'] = $verify['reexamine_ticket_type'];
  224. $data['reexamine_ticket_content'] = $verify['reexamine_ticket_content'];
  225. $data['reexamine_ticket_status'] = 0;
  226. $data['reexamine_field'] = implode(',',$verify['reexamine_field']);
  227. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  228. $fileCharater = $request->input('addFile');
  229. $data['special'] = 0;
  230. DB::beginTransaction();//检查数据库事务
  231. try {
  232. $res = Recruit::where('id', $recruit_id)->update($data);
  233. $postcode_array = $request->postcode;
  234. $postname_array = $request->postname;
  235. $postnumber_array = $request->postnumber;
  236. $limit_array = $request->postlimit;
  237. $postid_arr = $request->postid_arr;
  238. $countnum = count($postcode_array);
  239. if ($countnum > 0) {
  240. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  241. if (count($postid_arr) == 0) {//没有提交岗位代表删除岗位
  242. RecruitPost::where('recruit_id', $recruit_id)->delete();
  243. } else {
  244. foreach ($ids as $key => $value) {
  245. if (!in_array($value, $postid_arr)) {
  246. $post_is_create = RecruitAppointInfo::where('post_id', $value)->first();
  247. if (empty($post_is_create)) {
  248. //有报名信息的岗位不能删除
  249. RecruitPost::destroy($value);
  250. }
  251. }
  252. }
  253. }
  254. for ($i = 0; $i < $countnum; $i++) {
  255. $data = array();
  256. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  257. if (isset($postid_arr[$i])) {
  258. $post_id = $postid_arr[$i];
  259. $data['code'] = $postcode_array[$i];
  260. $data['name'] = $postname_array[$i];
  261. $data['number'] = $postnumber_array[$i];
  262. $data['limit'] = $limit_array[$i];
  263. $data['recruit_id'] = $recruit_id;
  264. RecruitPost::where('id', $post_id)->update($data);
  265. } else {
  266. $data['code'] = $postcode_array[$i];
  267. $data['name'] = $postname_array[$i];
  268. $data['number'] = $postnumber_array[$i];
  269. $data['limit'] = $limit_array[$i];
  270. $data['recruit_id'] = $recruit_id;
  271. RecruitPost::create($data);
  272. }
  273. }
  274. }
  275. } else {
  276. RecruitPost::where('recruit_id', $recruit_id)->delete();
  277. }
  278. $fileCharater = $request->file('addFile');
  279. if (!empty($fileCharater)) {
  280. RecruitSubjoin::where('recruit_id', $recruit_id)->delete();
  281. foreach ($fileCharater as $f => $fv) {
  282. $picpath = 'zhaokaopic/' . date('Ymd', time()) . '/';
  283. //获取文件的扩展名
  284. $ext = $fv->getClientOriginalExtension();
  285. //获取文件的绝对路径
  286. $path = $fv->getRealPath();
  287. //定义文件名
  288. $filename = time() . rand(100, 999) . '.' . $ext;
  289. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  290. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  291. $data = $picpath . $filename;
  292. $create_arr = [
  293. 'recruit_id' => $recruit_id,
  294. 'subjoin_name' => $fv->getClientOriginalName(),
  295. 'subjoin_path' => $data,
  296. 'subjoin_addtime' => time()
  297. ];
  298. RecruitSubjoin::create($create_arr);
  299. }
  300. }
  301. DB::commit();
  302. return admin_toastr('操作成功!', 'success');
  303. } catch (\Exception $e) {
  304. DB::rollback();
  305. return admin_toastr($e->getMessage(), 'error');
  306. }
  307. }
  308. /**
  309. * 新增/修改招考场次的表单
  310. *
  311. * @return Form
  312. */
  313. protected function form()
  314. {
  315. $form = new ValidateForm(new Recruit);
  316. $form->tab('基础信息', function ($form) {
  317. $form->text('name', '招考场次名称')->rules('required|between:4,61', [
  318. 'required' => '请填写招考场次名称',
  319. 'between' => '招考场次名称长度为2~30个字符'
  320. ])->setWidth(5)->setMustMark();
  321. $form->text('company', '招聘主体')->rules('required|between:4,61', [
  322. 'required' => '请填写招聘主体',
  323. 'between' => '招聘主体长度为2~30个字符'
  324. ])->setWidth(5)->setMustMark();
  325. $form->text('name_en', '英文标识')->setWidth(5)->help('同一个招聘单位,发布的招聘场次若不在同一天,允许一样,若为空则自动生成');
  326. $form->image('small_img', '缩略图')->uniqueName()->setWidth(3);
  327. $form->radio('simple', '类型')->options([0 => '招聘', 1 => '招考'])->default(0)->setMustMark();
  328. $form->switch('status', '状态')->default(1)->setMustMark();
  329. $form->switch('show_report', '显示报名人数')->default(0)->setMustMark();
  330. $form->radio('current', '当前进展')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示',0 => '已结束'])->default(1)->setMustMark();
  331. $form->checkbox('step', '招考流程')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示'])->default([1, 2])->setMustMark();
  332. $form->datetimeRange('apply_start', 'apply_end', '报名日期')->rules('required', array('required' => '报名日期必须设置'))->setMustMark();
  333. $form->datetimeRange('audit_start', 'audit_end', '审核日期');
  334. $form->datetimeRange('preliminary_start', 'preliminary_end', '笔试时间');
  335. $form->datetimeRange('computer_start', 'computer_end', '上机时间');
  336. $form->datetimeRange('interview_start', 'interview_end', '面试时间');
  337. $form->datetimeRange('reexamine_start', 'reexamine_end', '复试时间');
  338. $form->datetimeRange('health_start', 'health_end', '体检时间');
  339. $form->datetimeRange('political_start', 'political_end', '政审时间');
  340. $form->datetimeRange('publicity_start', 'publicity_end', '公示时间');
  341. $form->editor('introduction', '招考正文')->rules('required', array('required' => '招考正文不能为空。'))->setMustMark();
  342. $form->text('contact', '联系人');
  343. $form->text('phone', '联系电话');
  344. $form->text('host_address', '联系地址');
  345. //$form->switch('predetermined_status', '是否允许报名')->states($display_option)->default(1)->setMustMark();
  346. $form->number('ordid', '排序')->default(0);
  347. $form->multipleFile('addFile', '附件')->move('storage/app/public/recruit/' . time());
  348. })->tab('报名表单与条件', function ($form) {
  349. $form->checkbox('forms', '报名表单模块')->options(['basic' => '基础信息模块','expand_special' => '扩展模块-加分','detail' => '详情介绍模块','identification' => '身份证明上传模块','education_certification' => '学历证明上传模块','other_certification' => '其他证明上传模块', 'remark' => '备注模块','chengnuoshu'=>'诚信承诺书','shixin'=>'失信被执行人查询信息页扫描件','internship' => '实习专场'])->default(['basic'])->setMustMark();
  350. $str = "let num = $(\"#forms\").find(\".checked\").length;
  351. if(num == 0){
  352. alert(\"未选中报名表单模块\");
  353. return false;
  354. }
  355. let modules = new Array();
  356. $.each($(\"#forms\").find(\".checked\"),function(index,item){
  357. modules.push($(item).children(\"input\").val())
  358. });
  359. window.open(\"https://www.jucai.gov.cn/recruit/preview?modules=\"+modules.join(','));
  360. return false;";
  361. $form->button('test','勾选对应模块后点击我')->on('click',$str);
  362. $form->text('limit_times', '报名次数限制')->rules('required|regex:/^\d+$/', [
  363. 'required' => '报名限制次数必须填写',
  364. 'regex' => '次数必须为数字'
  365. ])->default(1)->help('同一个场次允许同时报名几个岗位,直接输入数字即可');
  366. $form->text('post_times', '审核次数限制')->rules('required|regex:/^\d+$/', [
  367. 'required' => '审核限制次数必须填写',
  368. 'regex' => '次数必须为数字'
  369. ])->default(1)->help('允许提交审核的次数,直接输入数字即可');
  370. $form->datetimeRange('supplement_start', 'supplement_end', '材料补登时间');
  371. $form->radio('pay_switch', '缴费报名')->options([0 => '否', 1 => '是'])->default(0);
  372. $form->radio('special_condition_type', '加分条件样式')->options([0 => '手输', 1 => '下拉选择'])->default(0);
  373. $form->text('special_condition_value', '加分条件值')->default("")->help('下拉选择项请用英文,隔开');
  374. })->tab('笔试', function ($form) {
  375. $form->switch('pen_comfirm', '笔试确认')->help("打开后将会在设置时间段内开启笔试确认功能,有且仅当确认了才能打印准考证参加笔试")->default(0)->setMustMark();
  376. $form->datetimeRange('pen_comfirm_start', 'pen_comfirm_end', '确认笔试时间')->help("设置该时间后,仅在该时间段内才可以确认参加笔试");
  377. $form->radio('pen_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  378. $form->text('pen_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  379. $form->listbox('pen_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('pen'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  380. $form->switch('pen_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  381. $form->switch('pen_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  382. $form->datetimeRange('pen_health_start', 'pen_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  383. })->tab('上机', function ($form) {
  384. $form->radio('computer_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  385. $form->text('computer_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  386. $form->listbox('computer_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('computer'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  387. $form->switch('computer_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  388. $form->switch('computer_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  389. $form->datetimeRange('computer_health_start', 'computer_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  390. })->tab('面试', function ($form) {
  391. $form->radio('face_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  392. $form->text('face_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  393. $form->listbox('face_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('face'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  394. $form->switch('face_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  395. $form->switch('face_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  396. $form->datetimeRange('face_health_start', 'face_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  397. })->tab('复试', function ($form) {
  398. $form->radio('reexamine_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  399. $form->text('reexamine_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  400. $form->listbox('reexamine_field', '模板字段')->options(RecruitTicketField::ticketFieldData('reexamine'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  401. });
  402. return $form;
  403. }
  404. /**
  405. * Make a form builder.
  406. *
  407. * @return Form
  408. */
  409. public function store(Request $request)
  410. {
  411. $verify = $this->form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  412. $postCode = $request->input('postcode', []);
  413. $postName = $request->input('postname', []);
  414. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  415. return admin_toastr('请填写招考岗位', 'error');
  416. }
  417. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  418. return admin_toastr('请填写招考岗位名称', 'error');
  419. }
  420. $data = [];
  421. $data['name'] = $verify['name'];
  422. $data['company'] = $verify['company'];
  423. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  424. if(array_key_exists('small_img',$verify)){
  425. $data['small_img'] = $verify['small_img'];
  426. }else{
  427. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  428. }
  429. $data['status'] = $verify['status'];
  430. $data['show_report'] = $verify['show_report'];
  431. $data['current'] = $verify['current'];
  432. $data['step'] = implode(',',array_filter($verify['step']));
  433. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  434. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  435. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  436. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  437. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  438. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  439. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  440. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  441. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  442. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  443. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  444. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  445. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  446. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  447. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  448. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  449. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  450. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  451. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  452. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  453. $data['introduction'] = $verify['introduction'];
  454. $data['host_address'] = $verify['host_address'];
  455. $data['contact'] = $verify['contact'];
  456. $data['phone'] = $verify['phone'];
  457. $data['ordid'] = $verify['ordid'];
  458. $data['limit_times'] = $verify['limit_times'];
  459. $data['post_times'] = $verify['post_times'];
  460. $data['pay_switch'] = $verify['pay_switch'];
  461. $data['forms'] = implode(',',array_filter($verify['forms']));
  462. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  463. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  464. $data['pen_ticket_status'] = 0;
  465. $data['pen_comfirm'] = $verify['pen_comfirm'];
  466. $data['pen_comfirm_start'] = $verify['pen_comfirm_start'] ? $verify['pen_comfirm_start'] : null;
  467. $data['pen_comfirm_end'] = $verify['pen_comfirm_end'] ? $verify['pen_comfirm_end'] : null;
  468. $data['pen_epidemic'] = $verify['pen_epidemic'];
  469. $data['pen_health'] = $verify['pen_health'];
  470. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  471. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  472. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  473. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  474. $data['computer_ticket_status'] = 0;
  475. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  476. $data['face_ticket_type'] = $verify['face_ticket_type'];
  477. $data['face_ticket_content'] = $verify['face_ticket_content'];
  478. $data['face_ticket_status'] = 0;
  479. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  480. $data['face_epidemic'] = $verify['face_epidemic'];
  481. $data['face_health'] = $verify['face_health'];
  482. $data['face_health_start'] = $verify['face_health_start'] ? $verify['face_health_start'] : null;
  483. $data['face_health_end'] = $verify['face_health_end'] ? $verify['face_health_end'] : null;
  484. $data['reexamine_ticket_type'] = $verify['reexamine_ticket_type'];
  485. $data['reexamine_ticket_content'] = $verify['reexamine_ticket_content'];
  486. $data['reexamine_ticket_status'] = 0;
  487. $data['reexamine_field'] = implode(',',$verify['reexamine_field']);
  488. $data['special'] = 1;
  489. $fileCharater = $request->input('addFile');
  490. DB::beginTransaction();//检查数据库事务
  491. try {
  492. $recruit = Recruit::create($data);
  493. $recruit_id = $recruit->id;
  494. //添加招聘岗位
  495. $postcode_array = $request->postcode;
  496. $postname_array = $request->postname;
  497. $postnumber_array = $request->postnumber;
  498. $limit_array = $request->postlimit;
  499. $countnum = count($postcode_array);
  500. for ($i = 0; $i < $countnum; $i++) {
  501. $data = array();
  502. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  503. $data['code'] = $postcode_array[$i];
  504. $data['name'] = $postname_array[$i];
  505. $data['number'] = $postnumber_array[$i];
  506. $data['limit'] = $limit_array[$i];
  507. $data['status'] = 1;
  508. $data['recruit_id'] = $recruit_id;
  509. RecruitPost::create($data);
  510. }
  511. }
  512. if (!empty($fileCharater)) {
  513. foreach ($fileCharater as $f => $fv) {
  514. $picpath = 'recruit/' . date('Ymd', time()) . '/';
  515. //获取文件的扩展名
  516. $ext = $fv->getClientOriginalExtension();
  517. //获取文件的绝对路径
  518. $path = $fv->getRealPath();
  519. //定义文件名
  520. $filename = time() . rand(100, 999) . '.' . $ext;
  521. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  522. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  523. $data = $picpath . $filename;
  524. $create_arr = [
  525. 'recruit_id' => $recruit_id,
  526. 'subjoin_name' => $fv->getClientOriginalName(),
  527. 'subjoin_path' => $data,
  528. 'subjoin_addtime' => time()
  529. ];
  530. RecruitSubjoin::create($create_arr);
  531. }
  532. }
  533. DB::commit();//检查数据库事务
  534. } catch (\Exception $e) {
  535. dd($e->getMessage());
  536. DB::rollback();
  537. return admin_toastr($e->getMessage(), 'error');
  538. }
  539. }
  540. /**
  541. * Edit interface.
  542. *
  543. * @param mixed $id
  544. * @param Content $content
  545. * @return Content
  546. */
  547. public function edit($id, Content $content)
  548. {
  549. Permission::check('special_recruit_manager_edit');
  550. $recruit = Recruit::find($id);
  551. if(!$recruit->special){
  552. $this->show();
  553. }
  554. $grid = $this->form()->edit($id)->render();
  555. return $content
  556. ->header('招考管理')
  557. ->description('编辑')
  558. ->body(view('admin.special.index')->with(['grid' => $grid, 'id' => $id]));
  559. }
  560. /**
  561. * 删掉指定招考场次
  562. * @param $id
  563. */
  564. public function destroy($id)
  565. {
  566. Permission::check('special_recruit_manager_del');
  567. $info = Recruit::find($id);
  568. if($info){
  569. if(!$info->special){
  570. $this->show();
  571. }
  572. if($info->delete()){
  573. //RecruitAppointInfo::where('recruit_id', $id)->delete(); //todo保留
  574. return response()->json(['status' => 1, 'message' => '删除成功!'], '200');
  575. }else{
  576. return response()->json(['status' => 0, 'message' => '删除失败!'], '200');
  577. }
  578. }else{
  579. return response()->json(['status' => 0, 'message' => '找不到记录!'], '200');
  580. }
  581. }
  582. /**
  583. * 报名管理
  584. * @param Content $content
  585. * @param Request $request
  586. * @return Content|\Illuminate\Http\RedirectResponse
  587. */
  588. public function appointList(Content $content, Request $request)
  589. {
  590. Permission::check('special_recruit_appoint_list');
  591. $id = $request->id;
  592. $recruit = Recruit::find($id);
  593. if(!$recruit->special){
  594. $this->show();
  595. }
  596. if (empty($recruit)) {
  597. return back();
  598. }
  599. $search_data = $request->all();
  600. $where = [];
  601. $where[] = ['audit','>',0];
  602. if (isset($search_data['id']) || session('manage_search_data')['id']) {
  603. if (isset($search_data['page'])) {
  604. if (session('search_data')) {
  605. $where = session('managewhere');
  606. unset($search_data['page']);
  607. $search_data = session('manage_search_data');
  608. }
  609. }
  610. foreach ($search_data as $k => $v) {
  611. if ($k == 'realname') {
  612. $where[] = [$k, 'like', "%$v%"];
  613. } elseif ($k == 'id') {
  614. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  615. } elseif($k == 'print_bs'){
  616. $where[] = ['recruit_ticket.ex_type', '=', 1];
  617. $where[] = ['recruit_ticket.ex_status', '=', $v];
  618. } elseif($k == 'print_js'){
  619. $where[] = ['recruit_ticket.ex_type', '=', 2];
  620. $where[] = ['recruit_ticket.ex_status', '=', $v];
  621. } elseif($k == 'print_ms'){
  622. $where[] = ['recruit_ticket.ex_type', '=', 3];
  623. $where[] = ['recruit_ticket.ex_status', '=', $v];
  624. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  625. $where[] = [$k, '=', $v];
  626. }
  627. }
  628. session(['managewhere' => $where]);
  629. session(['manage_search_data' => $search_data]);
  630. session()->save();
  631. }
  632. $session_data = session('search_data');
  633. if(isset($session_data['perpage'])){
  634. $perpage = $session_data['perpage'];
  635. }else{
  636. $perpage = 20;
  637. }
  638. $list = RecruitAppointInfo::where($where)
  639. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  640. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  641. ->select('recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  642. ->orderBy('recruit_appoint_info.updated_at','desc')
  643. ->paginate($perpage);
  644. foreach ($list as $k => $v){
  645. if($v->sex == 0){
  646. $list[$k]['sex'] = '女';
  647. }else{
  648. $list[$k]['sex'] = '男';
  649. }
  650. switch ($v->political_affiliation){
  651. case '01':
  652. $list[$k]['political_affiliation'] = '中共党员';
  653. break;
  654. case '02':
  655. $list[$k]['political_affiliation'] = '中共预备党员';
  656. break;
  657. case '03':
  658. $list[$k]['political_affiliation'] = '共青团员';
  659. break;
  660. case '04':
  661. $list[$k]['political_affiliation'] = '民革党员';
  662. break;
  663. case '05':
  664. $list[$k]['political_affiliation'] = '民盟盟员';
  665. break;
  666. case '06':
  667. $list[$k]['political_affiliation'] = '民建会员';
  668. break;
  669. case '07':
  670. $list[$k]['political_affiliation'] = '民进会员';
  671. break;
  672. case '08':
  673. $list[$k]['political_affiliation'] = '农工党党员';
  674. break;
  675. case '09':
  676. $list[$k]['political_affiliation'] = '致公党党员';
  677. break;
  678. case '10':
  679. $list[$k]['political_affiliation'] = '九三学社社员';
  680. break;
  681. case '11':
  682. $list[$k]['political_affiliation'] = '台盟盟员';
  683. break;
  684. case '12':
  685. $list[$k]['political_affiliation'] = '无党派人士';
  686. break;
  687. case '13':
  688. $list[$k]['political_affiliation'] = '群众';
  689. break;
  690. }
  691. $list[$k]['pen_print'] = 0;
  692. $list[$k]['computer_print'] = 0;
  693. $list[$k]['face_print'] = 0;
  694. $list[$k]['reexamine_print'] = 0;
  695. $tickets = RecruitTicket::where('appoint_id',$v->id)->get();
  696. if($tickets){
  697. foreach ($tickets as $tk => $tv){
  698. if($tv->ex_type == 1){
  699. $list[$k]['pen_print'] = $tv->ex_status;
  700. }
  701. if($tv->ex_type == 2){
  702. $list[$k]['computer_print'] = $tv->ex_status;
  703. }
  704. if($tv->ex_type == 3){
  705. $list[$k]['face_print'] = $tv->ex_status;
  706. }
  707. if($tv->ex_type == 4){
  708. $list[$k]['reexamine_print'] = $tv->ex_status;
  709. }
  710. }
  711. }
  712. }
  713. $post_data = RecruitPost::where('recruit_id',$id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  714. return $content
  715. ->header('报名管理')
  716. ->description('招考人员信息列表')
  717. ->body(view('admin.special.appoint_list')->with([
  718. 'list' => $list,
  719. 'search_data' => $search_data,
  720. 'recruit' => $recruit,
  721. 'post' => $post_data
  722. ]));
  723. }
  724. /**
  725. * 查看审核日志
  726. * @param Request $request
  727. * @return \Illuminate\Http\JsonResponse
  728. */
  729. public function showLog(Request $request)
  730. {
  731. Permission::check('special_recruit_show_log');
  732. $id = $request->id;
  733. $logs = RecruitAppointLog::where('appoint_id', $id)->orderBy('created_at', 'desc')->get()->toArray();
  734. $str = "";
  735. if ($logs) {
  736. $str .= "<table class='table'><tr style='background:#F0F8FD'><td>审核时间</td><td>操作级别</td><td>记录类型</td><td>触发操作的人员</td><td>审核描述</td></tr>";
  737. foreach ($logs as $k => $v) {
  738. switch ($v['type']){
  739. case '1':
  740. $level = '系统级操作';
  741. $user = '系统';
  742. break;
  743. case '2':
  744. $level = '审核系列操作';
  745. $admin = AdminUser::where('id',$v['uid'])->first();
  746. $user = $admin->name;
  747. break;
  748. case '3':
  749. $level = '用户自行操作';
  750. $member = Member::where('id',$v['uid'])->first();
  751. $user = $member->username;
  752. break;
  753. }
  754. switch ($v['step']){
  755. case '1':
  756. $step = '报名及审核';
  757. break;
  758. case '2':
  759. $step = '笔试';
  760. break;
  761. case '3':
  762. $step = '面试';
  763. break;
  764. case '4':
  765. $step = '上机';
  766. break;
  767. case '5':
  768. $step = '复审';
  769. break;
  770. case '6':
  771. $step = '体检';
  772. break;
  773. case '7':
  774. $step = '政审';
  775. break;
  776. case '8':
  777. $step = '录用';
  778. break;
  779. }
  780. $str .= "<tr><td>" . $v['created_at'] . "</td><td>" . $level . "</td><td>" . $step . "</td><td>" . $user . "</td><td>" . $v['log'] . "</td></tr>\r\n";
  781. }
  782. $str .= "</table>";
  783. } else {
  784. $str = "抱歉,暂未有审核记录";
  785. }
  786. return response()->json(['code' => 1, 'data' => $str]);
  787. }
  788. /**
  789. * 查看报名详细信息
  790. * @param Request $request
  791. * @return \Illuminate\Http\JsonResponse
  792. * @throws \Throwable
  793. */
  794. public function getUserinfo(Request $request)
  795. {
  796. Permission::check('special_recruit_getUserinfo');
  797. $id = $request->id;
  798. $data = RecruitAppointInfo::where('recruit_appoint_info.id',$id)
  799. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  800. ->join('recruit_appoint_expand_special', 'recruit_appoint_info.id', '=', 'recruit_appoint_expand_special.recruit_appoint_id', 'left')
  801. ->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left')
  802. ->select('recruit_appoint_info.*', 'recruit_post.name', 'recruit_post.code', 'recruit_appoint_detail.train', 'recruit_appoint_detail.rewards_and_punishments', 'recruit_appoint_detail.introduce', 'recruit_appoint_expand_special.point_apply', 'recruit_appoint_expand_special.condition', 'recruit_appoint_expand_special.material')
  803. ->first();
  804. $recruit = Recruit::where('id',$data->recruit_id)->first();
  805. $recruit->forms = explode(',', $recruit->forms);
  806. $data->family = json_decode($data->family);
  807. if ($data->family) {
  808. foreach ($data->family as $k => $v) {
  809. $v->political_affiliation = RecruitAppointInfo::$political_affiliation[$v->political_affiliation];
  810. }
  811. }
  812. //layer相册层
  813. $photos = [
  814. 'material'=>[],
  815. 'identification'=>[],
  816. 'education_certification'=>[],
  817. 'other_certification'=>[],
  818. ];
  819. if(in_array('expand_special',$recruit->forms)){
  820. if(json_decode($data->material)){
  821. $data->material = json_decode($data->material);
  822. $photo_data = [];
  823. foreach ($data->material as $k => $v) {
  824. if($v->status){
  825. $photo_data[] = [
  826. 'alt' => $v->name,
  827. 'pid' => $v->uid,
  828. 'src' => $v->response->path,
  829. ];
  830. }
  831. }
  832. $photos['material'] = [
  833. 'title' => '申请加分佐证材料',
  834. 'id' => 1,
  835. 'start' => 0,
  836. 'data' =>$photo_data
  837. ];
  838. }else{
  839. $data->material = [];
  840. }
  841. }
  842. if(in_array('identification',$recruit->forms) || in_array('internship',$recruit->forms)){
  843. if(json_decode($data->identification)){
  844. $data->identification = json_decode($data->identification);
  845. $photo_data = [];
  846. foreach ($data->identification as $k => $v) {
  847. if($v->status){
  848. $photo_data[] = [
  849. 'alt' => $v->name,
  850. 'pid' => $v->uid,
  851. 'src' => $v->response->path,
  852. ];
  853. }
  854. }
  855. $photos['identification'] = [
  856. 'title' => '身份证明',
  857. 'id' => 1,
  858. 'start' => 0,
  859. 'data' =>$photo_data
  860. ];
  861. }else{
  862. $data->identification = [];
  863. }
  864. }
  865. if(in_array('education_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  866. if(json_decode($data->education_certification)){
  867. $data->education_certification = json_decode($data->education_certification);
  868. $photo_data = [];
  869. foreach ($data->education_certification as $k => $v) {
  870. if($v->status){
  871. $photo_data[] = [
  872. 'alt' => $v->name,
  873. 'pid' => $v->uid,
  874. 'src' => $v->response->path,
  875. ];
  876. }
  877. }
  878. $photos['education_certification'] = [
  879. 'title' => '学历证明',
  880. 'id' => 1,
  881. 'start' => 0,
  882. 'data' =>$photo_data
  883. ];
  884. }else{
  885. $data->education_certification = [];
  886. }
  887. }
  888. if(in_array('other_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  889. if(json_decode($data->other_certification)){
  890. $data->other_certification = json_decode($data->other_certification);
  891. $photo_data = [];
  892. foreach ($data->other_certification as $k => $v) {
  893. if($v->status){
  894. $photo_data[] = [
  895. 'alt' => $v->name,
  896. 'pid' => $v->uid,
  897. 'src' => $v->response->path,
  898. ];
  899. }
  900. }
  901. $photos['other_certification'] = [
  902. 'title' => '其他证明',
  903. 'id' => 1,
  904. 'start' => 0,
  905. 'data' =>$photo_data
  906. ];
  907. }else{
  908. $data->other_certification = [];
  909. }
  910. }
  911. if(in_array('chengnuoshu',$recruit->forms)){
  912. if(json_decode($data->chengnuoshu)){
  913. $data->chengnuoshu = json_decode($data->chengnuoshu);
  914. $photo_data = [];
  915. foreach ($data->chengnuoshu as $k => $v) {
  916. if($v->status){
  917. $photo_data[] = [
  918. 'alt' => $v->name,
  919. 'pid' => $v->uid,
  920. 'src' => $v->response->path,
  921. ];
  922. }
  923. }
  924. $photos['chengnuoshu'] = [
  925. 'title' => '诚信承诺书',
  926. 'id' => 1,
  927. 'start' => 0,
  928. 'data' =>$photo_data
  929. ];
  930. }else{
  931. $data->chengnuoshu = [];
  932. }
  933. }
  934. if(in_array('shixin',$recruit->forms)){
  935. if(json_decode($data->shixin)){
  936. $data->shixin = json_decode($data->shixin);
  937. $photo_data = [];
  938. foreach ($data->shixin as $k => $v) {
  939. if($v->status){
  940. $photo_data[] = [
  941. 'alt' => $v->name,
  942. 'pid' => $v->uid,
  943. 'src' => $v->response->path,
  944. ];
  945. }
  946. }
  947. $photos['shixin'] = [
  948. 'title' => '失信被执行人查询信息页扫描件',
  949. 'id' => 1,
  950. 'start' => 0,
  951. 'data' =>$photo_data
  952. ];
  953. }else{
  954. $data->shixin = [];
  955. }
  956. }
  957. $html = view('admin.recruit.manageajax_userinfo')->with(['appointinfo' => $data,'recruit' => $recruit,'photos'=>$photos])->render();
  958. return response()->json(['code' => 1, 'data' => $html]);
  959. }
  960. /**
  961. * 获得招考场次的岗位
  962. * @param Request $request
  963. * @return \Illuminate\Http\JsonResponse
  964. */
  965. public function getRecruitPost(Request $request)
  966. {
  967. //Permission::check('special_recruit_manager_create');
  968. //Permission::check('special_recruit_manager_edit');
  969. $id = $request->id;
  970. $recruit = Recruit::find($id);
  971. $post = RecruitPost::where('recruit_id', $id)->get();
  972. return response()->json(['post' => $post, 'recruit' => $recruit], '200');
  973. }
  974. /**
  975. * 报名记录审核处理
  976. * @param Request $request
  977. * @return \Illuminate\Http\JsonResponse
  978. */
  979. public function appoint_audit(Request $request)
  980. {
  981. $ids = $request->ids;
  982. if (!is_array($ids)) {
  983. $ids = explode(",", $ids);
  984. }
  985. if (empty($ids)) {
  986. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  987. }
  988. $audit = $request->audit;
  989. $exam_flow_path = $request->exam_flow_path;
  990. $reason = $request->reason;
  991. if(empty($audit)){
  992. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  993. }
  994. if($audit == '3' && empty($exam_flow_path)){
  995. return response()->json(['status' => 0, 'msg' => '请选择审核后的考试流程!'], '200');
  996. }
  997. if($audit != '3' && empty($reason)){
  998. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  999. }
  1000. $message = [];
  1001. switch ($audit){
  1002. case '1':
  1003. //撤回至未审核
  1004. foreach ($ids as $k => $v){
  1005. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1006. $recruit = Recruit::find($appointinfo->recruit_id);
  1007. if(!$recruit->special){
  1008. continue;
  1009. }
  1010. if(!$appointinfo || intval($appointinfo->audit) === 1){
  1011. continue;
  1012. }
  1013. //设置该报名的各个状态
  1014. $appointinfo_data = [
  1015. 'current' => 1,
  1016. 'audit' => 1,
  1017. 'pen_audit' => -1,
  1018. 'computer_audit' => -1,
  1019. 'face_audit' => -1,
  1020. 'reexamine_audit' => -1,
  1021. 'inspect_audit' => -1,
  1022. 'political_audit' => -1,
  1023. 'employ_audit' => -1
  1024. ];
  1025. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1026. //写日志
  1027. $log = [
  1028. 'type' => 2,
  1029. 'step' => 1,
  1030. 'appoint_id' => $v,
  1031. 'uid' => Admin::user()->id,
  1032. 'log' => '撤回至未审核状态,原因是:'.$reason
  1033. ];
  1034. RecruitAppointLog::create($log);
  1035. $message[$v] = '您此次的报名需要重新审核,原因是:'.$reason;
  1036. }
  1037. break;
  1038. case '2':
  1039. //审核未通过
  1040. foreach ($ids as $k => $v){
  1041. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1042. $recruit = Recruit::find($appointinfo->recruit_id);
  1043. if(!$recruit->special){
  1044. continue;
  1045. }
  1046. if(!$appointinfo || intval($appointinfo->audit) === 2){
  1047. continue;
  1048. }
  1049. //设置该报名的各个状态
  1050. $appointinfo_data = [
  1051. 'current' => 1,
  1052. 'audit' => 2,
  1053. 'pen_audit' => -1,
  1054. 'computer_audit' => -1,
  1055. 'face_audit' => -1,
  1056. 'reexamine_audit' => -1,
  1057. 'inspect_audit' => -1,
  1058. 'political_audit' => -1,
  1059. 'employ_audit' => -1
  1060. ];
  1061. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1062. //写日志
  1063. $log = [
  1064. 'type' => 2,
  1065. 'step' => 1,
  1066. 'appoint_id' => $v,
  1067. 'uid' => Admin::user()->id,
  1068. 'log' => '审核未通过,原因是:'.$reason
  1069. ];
  1070. RecruitAppointLog::create($log);
  1071. $message[$v] = '您此次报名审核未通过,原因是:'.$reason;
  1072. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1073. }
  1074. break;
  1075. case '3':
  1076. //审核通过
  1077. foreach ($ids as $k => $v){
  1078. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1079. $recruit = Recruit::find($appointinfo->recruit_id);
  1080. if(!$recruit->special){
  1081. continue;
  1082. }
  1083. if(!$appointinfo || intval($appointinfo->audit) === 3){
  1084. continue;
  1085. }
  1086. $recruit = Recruit::where('id',$appointinfo->recruit_id)->first();
  1087. $step = explode(',',$recruit->step);
  1088. $step_str = [
  1089. 'pen' => '未设置此条报名记录的笔试信息',
  1090. ];
  1091. if(in_array('3',$step)){
  1092. //场次有设置笔试
  1093. if(in_array('pen',$exam_flow_path)){
  1094. $step_str['pen'] = '该场次需要笔试,已设置此条报考需要参与笔试';
  1095. $pen_audit = -1;
  1096. }else{
  1097. $step_str['pen'] = '该场次需要笔试,此条报考可跳过笔试';
  1098. $pen_audit = 3;
  1099. }
  1100. }else{
  1101. $step_str['pen'] = '该场次不需要笔试';
  1102. $pen_audit = 3;
  1103. }
  1104. if(in_array('4',$step)){
  1105. //场次有设置上机
  1106. if(in_array('computer',$exam_flow_path)){
  1107. $step_str['computer'] = '该场次需要上机,已设置此条报考需要参与上机';
  1108. $computer_audit = -1;
  1109. }else{
  1110. $step_str['computer'] = '该场次需要上机,此条报考可跳过上机';
  1111. $computer_audit = 3;
  1112. }
  1113. }else{
  1114. $step_str['computer'] = '该场次不需要上机';
  1115. $computer_audit = 3;
  1116. }
  1117. if(in_array('5',$step)){
  1118. //场次有设置上机
  1119. if(in_array('face',$exam_flow_path)){
  1120. $step_str['face'] = '该场次需要面试,已设置此条报考需要参与面试';
  1121. $face_audit = -1;
  1122. }else{
  1123. $step_str['face'] = '该场次需要面试,此条报考可跳过面试';
  1124. $face_audit = 3;
  1125. }
  1126. }else{
  1127. $step_str['face'] = '该场次不需要面试';
  1128. $face_audit = 3;
  1129. }
  1130. if(in_array('6',$step)){
  1131. //场次有设置复试
  1132. if(in_array('reexamine',$exam_flow_path)){
  1133. $step_str['reexamine'] = '该场次需要复试,已设置此条报考需要参与复试';
  1134. $reexamine_audit = -1;
  1135. }else{
  1136. $step_str['reexamine'] = '该场次需要复试,此条报考可跳过复试';
  1137. $reexamine_audit = 3;
  1138. }
  1139. }else{
  1140. $step_str['reexamine'] = '该场次不需要复试';
  1141. $reexamine_audit = 3;
  1142. }
  1143. //设置该报名的各个状态
  1144. $appointinfo_data = [
  1145. 'current' => 2,//审核成功后进入考试流程
  1146. 'audit' => 3,
  1147. 'pen_audit' => $pen_audit,
  1148. 'computer_audit' => $computer_audit,
  1149. 'face_audit' => $face_audit,
  1150. 'reexamine_audit' => $reexamine_audit,
  1151. 'inspect_audit' => -1,
  1152. 'political_audit' => -1,
  1153. 'employ_audit' => -1
  1154. ];
  1155. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1156. $reason = $reason ?? '符合报考条件';
  1157. //写日志
  1158. $log = [
  1159. 'type' => 2,
  1160. 'step' => 1,
  1161. 'appoint_id' => $v,
  1162. 'uid' => Admin::user()->id,
  1163. 'log' => '审核通过,原因是:' . $reason,
  1164. 'admin_log' => implode(';',$step_str)
  1165. ];
  1166. RecruitAppointLog::create($log);
  1167. $message[$v] = '您此次报名审核已通过,原因是:' . $reason;
  1168. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1169. $this->fetch_word(['recruit_id'=>$appointinfo->recruit_id,'appoint_id'=>$appointinfo->id]);
  1170. }
  1171. break;
  1172. }
  1173. //站内信
  1174. foreach ($ids as $key => $val) {
  1175. if(array_key_exists($val,$message)){
  1176. $user_info = Member::where('id', $appointinfo->uid)->first();
  1177. Pms::write_pmsnotice($user_info->id, $user_info->username, $message[$val]);
  1178. }else{
  1179. continue;
  1180. }
  1181. }
  1182. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1183. }
  1184. }