SpecialController.php 49 KB

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