TalentInfo.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\enterprise\validate;
  3. use think\Validate;
  4. /**
  5. * Description of TalentInfo
  6. * 先不用。分两步等下通不过
  7. * @author sgq
  8. */
  9. class TalentInfo extends Validate {
  10. protected $rule = [
  11. "name" => "regex:/^[\x{4e00}-\x{9fa5}]+$/u",
  12. "nation" => "checkInSelect:nation,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57",
  13. "card_type" => "between:1,3",
  14. "card_number" => "checkCardNumber|unique:new_talent_info",
  15. "sex" => "between:1,2",
  16. "politics" => "checkInSelect:politics,01,02,03,04,05,06,07,08,09,10,11,12,13,14",
  17. "birthday" => "dateFormat:Y-m-d",
  18. "nationality" => "checkInSelect:nationality,cn,cn_hk,cn_mc,cn_tw,us,en,jp,co,nl,sg,other",
  19. "talent_type" => "between:1,3",
  20. "tax_insurance_month" => "checkRangeDate:tax_insurance_month",
  21. "labor_contract_rangetime" => "checkRangeDate:labor_contract_rangetime",
  22. "fst_work_time" => "dateFormat:Y-m-d",
  23. "pre_import_type" => "between:1,2",
  24. "experience" => "max:200",
  25. "education" => "max:200",
  26. "phone" => "mobile|unique:new_talent_info",
  27. "email" => "email|unique:new_talent_info",
  28. "highest_degree" => "checkInSelect:highest_degree,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21",
  29. "study_abroad" => "between:1,2",
  30. "import_way" => "between:1,3",
  31. "cur_entry_time" => "dateFormat:Y-m-d",
  32. "source" => "between:1,5",
  33. "fujian_highcert_pubtime" => "dateFormat:Y-m-d",
  34. "fujian_highcert_exptime" => "dateFormat:Y-m-d",
  35. "quanzhou_highcert_pubtime" => "dateFormat:Y-m-d",
  36. "quanzhou_highcert_exptime" => "dateFormat:Y-m-d",
  37. "talent_arrange" => "between:1,7",
  38. "bank" => "regex:/^[\x{4e00}-\x{9fa5}]+银行$/u",
  39. "bank_number" => "regex:/^\d+$/",
  40. "bank_branch_name" => "regex:/^[\x{4e00}-\x{9fa5}]+银行[\x{4e00}-\x{9fa5}]+省?[\x{4e00}-\x{9fa5}]+市[\x{4e00}-\x{9fa5}]+$/u",
  41. "bank_account" => "regex:/^\d+$/",
  42. ];
  43. protected $message = [
  44. "name.regex" => "姓名只能是中文",
  45. "card_type.between" => "不存在的证件类型,请在列表中选择",
  46. "card_number.unique" => "身份证已经存在",
  47. "sex.between" => "性别只能在预设列表中选择",
  48. "politics.between" => "政治面貌只能在预设列表中选择",
  49. "birthday.dateFormat" => "生日必需是有效日期格式[yyyy-MM-dd]",
  50. "talent_type.between" => "不存在的人才类型,请在列表中选择",
  51. "fst_work_time.dateFormat" => "来晋工作时间必需是有效的日期格式[yyyy-MM-dd]",
  52. "pre_import_type.between" => "预引进类型只能在预设列表中选择",
  53. "experience.max" => "工作经历不能超过200个字符,请简明扼要的描述您的工作经历",
  54. "education.max" => "教育背景不能超过200个字符,请简明扼要的描述您的教育背景",
  55. "phone.mobile" => "请填写正确的手机号",
  56. "phone.unique" => "手机号已经存在",
  57. "email.email" => "电子邮箱格式错误",
  58. "email.unique" => "电子邮箱已经存在",
  59. "highest_degree.between" => "最高学历只能在预设列表中选择",
  60. "study_abroad.between" => "留学经历只能选择是与否",
  61. "import_way.between" => "不存在的引进方式,请在列表中选择",
  62. "cur_entry_time.dateFormat" => "本单位入职时间必需是有效的日期格式[yyyy-MM-dd]",
  63. "source.between" => "不存在的申报来源,请在列表中选择",
  64. "fujian_highcert_pubtime.dateFormat" => "福建省高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
  65. "fujian_highcert_exptime.dateFormat" => "福建省高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
  66. "quanzhou_highcert_pubtime.dateFormat" => "泉州高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
  67. "quanzhou_highcert_exptime.dateFormat" => "泉州高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
  68. "talent_arrange" => "不存在的人才层次,请在列表中选择",
  69. "bank.regex" => "开户银行格式应为[XX银行]",
  70. "bank_number.regex" => "银行行号只能是数字",
  71. "bank_branch_name.regex" => "开户银行网点格式应为[XX银行XX省XX市XX行/处]",
  72. "bank_account.regex" => "银行账号只能是数字",
  73. ];
  74. protected function checkInSelect($value, $rule, $data = []) {
  75. $title = "";
  76. $select = explode(",", $rule);
  77. $type = array_shift($select);
  78. switch ($type) {
  79. case "nation":
  80. $title = "民族";
  81. break;
  82. case "politics":
  83. $title = "政治面貌";
  84. break;
  85. case "nationality":
  86. $title = "国籍/地区";
  87. break;
  88. case "highest_degree":
  89. $title = "最高学历";
  90. break;
  91. }
  92. return in_array($value, $select) ?: "{$title}只能在预设列表中选择";
  93. }
  94. protected function checkCardNumber($value, $rule, $data = []) {
  95. if (!$data["card_type"]) {
  96. return "填写证件号码前请先选择证件类型";
  97. }
  98. if ($data["card_type"] == 1) {
  99. $num = strlen($value);
  100. switch ($num) {
  101. case 15:
  102. case 18:
  103. return \app\common\api\IdCardApi::isValid($value) ?: "身份证号码不合法";
  104. break;
  105. default:
  106. //return \app\common\api\IdCardApi::isValidExceptMainland($value) ?: "身份证号码不合法";
  107. break;
  108. }
  109. }
  110. return "身份证号码不合法";
  111. }
  112. protected function checkRangeDate($value, $rule, $data = []) {
  113. $title = "";
  114. $format = "[yyyy-MM-dd - yyyy-MM-dd]";
  115. $str = "日期";
  116. switch ($rule) {
  117. case "tax_insurance_month":
  118. $format = "[yyyy-MM - yyyy-MM]";
  119. $str = "月份";
  120. if ($data["talent_type"] == 1) {
  121. $title = "缴交社会保险或个人所得税月份";
  122. }
  123. if ($data["talent_type"] == 2) {
  124. $title = "首次在我市缴交社会保险或个人所得税月份";
  125. }
  126. break;
  127. case "labor_contract_rangetime":
  128. $title = "劳动合同起止时间";
  129. break;
  130. }
  131. $arr = explode(" - ", $value);
  132. $chk1 = strtotime($arr[0]);
  133. $chk2 = strtotime($arr[1]);
  134. if (!$chk1 || !$chk2)
  135. return "{$title}日期范围格式应为{$format}";
  136. if ($chk1 > $chk2)
  137. return "{$title}起始{$str}不能大于结束{$str}";
  138. return true;
  139. }
  140. }