Recruit.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Encore\Admin\Traits\ModelTree;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. class Recruit extends Model
  7. {
  8. use SoftDeletes;
  9. protected $table = 'recruit';
  10. protected $guarded = [];
  11. //当前步骤
  12. public static $currentText = ['已结束','报名','审核','笔试','上机','面试','复试','体检','政审','公示'];
  13. //步骤和流程的处理
  14. public static function parse_index(Recruit $value)
  15. {
  16. //步骤处理
  17. $current = $value->current;
  18. $value->current_text = self::$currentText[$current];
  19. switch ($current){
  20. case '0':
  21. $value->current_time = "时间:" . date('m.d',strtotime($value->updated_at));
  22. break;
  23. case '1':
  24. if(empty($value->apply_start)){
  25. $value->current_time = '待定';
  26. }else if(empty($value->apply_end)){
  27. $value->current_time = date('m.d',strtotime($value->apply_start)) . '-' . '待定';
  28. }else{
  29. $value->current_time = date('m.d',strtotime($value->apply_start)) . '-' . date('m.d',strtotime($value->apply_end));
  30. }
  31. break;
  32. case '2':
  33. if(empty($value->audit_start)){
  34. $value->current_time = '待定';
  35. }else if(empty($value->audit_end)){
  36. $value->current_time = date('m.d',strtotime($value->audit_start)) . '-' . '待定';
  37. }else{
  38. $value->current_time = date('m.d',strtotime($value->audit_start)) . '-' . date('m.d',strtotime($value->audit_end));
  39. }
  40. break;
  41. case '3':
  42. if(empty($value->preliminary_start)){
  43. $value->current_time = '待定';
  44. }else if(empty($value->preliminary_end)){
  45. $value->current_time = date('m.d',strtotime($value->preliminary_start)) . '-' . '待定';
  46. }else{
  47. $value->current_time = date('m.d',strtotime($value->preliminary_start)) . '-' . date('m.d',strtotime($value->preliminary_end));
  48. }
  49. break;
  50. case '4':
  51. if(empty($value->computer_start)){
  52. $value->current_time = '待定';
  53. }else if(empty($value->computer_end)){
  54. $value->current_time = date('m.d',strtotime($value->computer_start)) . '-' . '待定';
  55. }else{
  56. $value->current_time = date('m.d',strtotime($value->computer_start)) . '-' . date('m.d',strtotime($value->computer_end));
  57. }
  58. break;
  59. case '5':
  60. if(empty($value->interview_start)){
  61. $value->current_time = '待定';
  62. }else if(empty($value->interview_end)){
  63. $value->current_time = date('m.d',strtotime($value->interview_start)) . '-' . '待定';
  64. }else{
  65. $value->current_time = date('m.d',strtotime($value->interview_start)) . '-' . date('m.d',strtotime($value->interview_end));
  66. }
  67. break;
  68. case '6':
  69. if(empty($value->reexamine_start)){
  70. $value->current_time = '待定';
  71. }else if(empty($value->reexamine_end)){
  72. $value->current_time = date('m.d',strtotime($value->reexamine_start)) . '-' . '待定';
  73. }else{
  74. $value->current_time = date('m.d',strtotime($value->reexamine_start)) . '-' . date('m.d',strtotime($value->reexamine_end));
  75. }
  76. break;
  77. case '7':
  78. if(empty($value->health_start)){
  79. $value->current_time = '待定';
  80. }else if(empty($value->health_end)){
  81. $value->current_time = date('m.d',strtotime($value->health_start)) . '-' . '待定';
  82. }else{
  83. $value->current_time = date('m.d',strtotime($value->health_start)) . '-' . date('m.d',strtotime($value->health_end));
  84. }
  85. break;
  86. case '8':
  87. if(empty($value->political_start)){
  88. $value->current_time = '待定';
  89. }else if(empty($value->political_end)){
  90. $value->current_time = date('m.d',strtotime($value->political_start)) . '-' . '待定';
  91. }else{
  92. $value->current_time = date('m.d',strtotime($value->political_start)) . '-' . date('m.d',strtotime($value->political_end));
  93. }
  94. break;
  95. case '9':
  96. if(empty($value->publicity_start)){
  97. $value->current_time = '待定';
  98. }else if(empty($value->publicity_end)){
  99. $value->current_time = date('m.d',strtotime($value->publicity_start)) . '-' . '待定';
  100. }else{
  101. $value->current_time = date('m.d',strtotime($value->publicity_start)) . '-' . date('m.d',strtotime($value->publicity_end));
  102. }
  103. break;
  104. }
  105. //流程处理
  106. $step_arr = explode(',',$value->step);
  107. $step_text = '';
  108. foreach ($step_arr as $k => $v) {
  109. if ((count($step_arr) - 1 ) == $k) {
  110. $step_text .= self::$currentText[$v];
  111. } else {
  112. $step_text .= self::$currentText[$v] . '->';
  113. }
  114. }
  115. $value->step_text = $step_text;
  116. return $value;
  117. }
  118. public static function parse_info(Recruit $value)
  119. {
  120. $step = explode(',',$value->step);
  121. $steps = [];
  122. foreach ($step as $v){
  123. switch ($v){
  124. case '0':
  125. $item['step_id'] = 10;
  126. $item['name'] = '已结束';
  127. $item['time'] = "时间:" . date('m.d',strtotime($value->updated_at));
  128. break;
  129. case '1':
  130. $item['step_id'] = 1;
  131. $item['name'] = '报名';
  132. if(empty($value->apply_start)){
  133. $time = '待定';
  134. }else if(empty($value->apply_end)){
  135. $time = date('m.d',strtotime($value->apply_start)) . '-' . '待定';
  136. }else{
  137. if ($value->apply_start == $value->apply_end) {
  138. $time = date('m.d',strtotime($value->apply_start));
  139. } else {
  140. $time = date('m.d',strtotime($value->apply_start)) . '-' . date('m.d',strtotime($value->apply_end));
  141. }
  142. }
  143. $item['time'] = $time;
  144. break;
  145. case '2':
  146. $item['step_id'] = 2;
  147. $item['name'] = '审核';
  148. if(empty($value->audit_start)){
  149. $time = '待定';
  150. }else if(empty($value->audit_end)){
  151. $time = date('m.d',strtotime($value->audit_start)) . '-' . '待定';
  152. }else{
  153. if ($value->audit_start == $value->audit_end) {
  154. $time = date('m.d',strtotime($value->audit_start));
  155. } else {
  156. $time = date('m.d',strtotime($value->audit_start)) . '-' . date('m.d',strtotime($value->audit_end));
  157. }
  158. }
  159. $item['time'] = $time;
  160. break;
  161. case '3':
  162. $item['step_id'] = 3;
  163. $item['name'] = '笔试';
  164. if(empty($value->preliminary_start)){
  165. $time = '待定';
  166. }else if(empty($value->preliminary_end)){
  167. $time = date('m.d',strtotime($value->preliminary_start)) . '-' . '待定';
  168. }else{
  169. $value->preliminary_start = date('m.d',strtotime($value->preliminary_start));
  170. $value->preliminary_end = date('m.d',strtotime($value->preliminary_end));
  171. if ($value->preliminary_start == $value->preliminary_end) {
  172. $time = $value->preliminary_start;
  173. } else {
  174. $time = $value->preliminary_start . '-' . $value->preliminary_end;
  175. }
  176. }
  177. $item['time'] = $time;
  178. break;
  179. case '4':
  180. $item['step_id'] = 4;
  181. $item['name'] = '上机';
  182. if(empty($value->computer_start)){
  183. $time = '待定';
  184. }else if(empty($value->computer_end)){
  185. $time = date('m.d',strtotime($value->computer_start)) . '-' . '待定';
  186. }else{
  187. if ($value->computer_start == $value->computer_end) {
  188. $time = date('m.d',strtotime($value->computer_start));
  189. } else {
  190. $time = date('m.d',strtotime($value->computer_start)) . '-' . date('m.d',strtotime($value->computer_end));
  191. }
  192. }
  193. $item['time'] = $time;
  194. break;
  195. case '5':
  196. $item['step_id'] = 5;
  197. $item['name'] = '面试';
  198. if(empty($value->interview_start)){
  199. $time = '待定';
  200. }else if(empty($value->interview_end)){
  201. $time = date('m.d',strtotime($value->interview_start)) . '-' . '待定';
  202. }else{
  203. if ($value->interview_start == $value->interview_end) {
  204. $time = date('m.d',strtotime($value->interview_start));
  205. } else {
  206. $time = date('m.d',strtotime($value->interview_start)) . '-' . date('m.d',strtotime($value->interview_end));
  207. }
  208. }
  209. $item['time'] = $time;
  210. break;
  211. case '6':
  212. $item['step_id'] = 6;
  213. $item['name'] = '复试';
  214. if(empty($value->reexamine_start)){
  215. $time = '待定';
  216. }else if(empty($value->reexamine_end)){
  217. $time = date('m.d',strtotime($value->reexamine_start)) . '-' . '待定';
  218. }else{
  219. if ($value->reexamine_start == $value->reexamine_end) {
  220. $time = date('m.d',strtotime($value->reexamine_start));
  221. } else {
  222. $time = date('m.d',strtotime($value->reexamine_start)) . '-' . date('m.d',strtotime($value->reexamine_end));
  223. }
  224. }
  225. $item['time'] = $time;
  226. break;
  227. case '7':
  228. $item['step_id'] = 7;
  229. $item['name'] = '体检';
  230. if(empty($value->health_start)){
  231. $time = '待定';
  232. }else if(empty($value->health_end)){
  233. $time = date('m.d',strtotime($value->health_start)) . '-' . '待定';
  234. }else{
  235. if ($value->health_start == $value->health_end) {
  236. $time = date('m.d',strtotime($value->health_start));
  237. } else {
  238. $time = date('m.d',strtotime($value->health_start)) . '-' . date('m.d',strtotime($value->health_end));
  239. }
  240. }
  241. $item['time'] = $time;
  242. break;
  243. case '8':
  244. $item['step_id'] = 8;
  245. $item['name'] = '政审';
  246. if(empty($value->political_start)){
  247. $time = '待定';
  248. }else if(empty($value->political_end)){
  249. $time = date('m.d',strtotime($value->political_start)) . '-' . '待定';
  250. }else{
  251. if ($value->political_start == $value->political_end) {
  252. $time = date('m.d',strtotime($value->political_start));
  253. } else {
  254. $time = date('m.d',strtotime($value->political_start)) . '-' . date('m.d',strtotime($value->political_end));
  255. }
  256. }
  257. $item['time'] = $time;
  258. break;
  259. case '9':
  260. $item['step_id'] = 9;
  261. $item['name'] = '公示';
  262. if(empty($value->publicity_start)){
  263. $time = '待定';
  264. }else if(empty($value->publicity_end)){
  265. $time = date('m.d',strtotime($value->publicity_start)) . '-' . '待定';
  266. }else{
  267. if ($value->publicity_start == $value->publicity_end) {
  268. $time = date('m.d',strtotime($value->publicity_start));
  269. } else {
  270. $time = date('m.d',strtotime($value->publicity_start)) . '-' . date('m.d',strtotime($value->publicity_end));
  271. }
  272. }
  273. $item['time'] = $time;
  274. break;
  275. }
  276. array_push($steps,$item);
  277. }
  278. $value->steps = $steps;
  279. if($value->current == '0'){
  280. $value->current = '10';
  281. }
  282. $value->introduction = htmlspecialchars_decode($value->introduction, ENT_QUOTES);
  283. $time = time();
  284. // 报名中
  285. if (strtotime($value->audit_start) < $time && strtotime($value->audit_end) > $time) {
  286. $value->isApply = 1;
  287. } else {
  288. $value->isApply = 0;
  289. }
  290. return $value;
  291. }
  292. }