TalentInfo.php 8.2 KB

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