TalentInfo.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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}A-Za-z ]+$/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:new_talent_info|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,4",
  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. "return" => "between:0,2",
  26. "salary_pay_way" => "between:1,2",
  27. "salary_pay_month" => "checkRangeDate:salary_pay_month",
  28. "experience" => "max:1000",
  29. "education" => "max:1000",
  30. "phone" => "mobile",
  31. "email" => "email",
  32. "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",
  33. "study_abroad" => "between:1,2",
  34. "import_way" => "between:1,3",
  35. "cur_entry_time" => "dateFormat:Y-m-d",
  36. "source" => "between:1,5",
  37. "fujian_highcert_pubtime" => "dateFormat:Y-m-d",
  38. "fujian_highcert_exptime" => "dateFormat:Y-m-d",
  39. "quanzhou_highcert_pubtime" => "dateFormat:Y-m-d",
  40. "quanzhou_highcert_exptime" => "dateFormat:Y-m-d",
  41. "talent_arrange" => "between:1,7",
  42. "bank" => "regex:/^[\x{4e00}-\x{9fa5}]+银行$/u",
  43. "bank_number" => "regex:/^\d+$/",
  44. //"bank_branch_name" => "regex:/^[\x{4e00}-\x{9fa5}]+银行[\x{4e00}-\x{9fa5}]+省?[\x{4e00}-\x{9fa5}]+市[\x{4e00}-\x{9fa5}]+$/u",
  45. "bank_account" => "regex:/^\d+$/",
  46. "break_faith" => "between:1,2",
  47. "identifyGetTime" => "dateFormat:Y-m-d"
  48. ];
  49. protected $message = [
  50. //"name.regex" => "姓名允许中文、英文、或者空格,不能含有其它字符",
  51. "card_type.between" => "不存在的证件类型,请在列表中选择",
  52. "card_number.checkUnique" => "证件号码已经存在",
  53. "sex.between" => "性别只能在预设列表中选择",
  54. "politics.between" => "政治面貌只能在预设列表中选择",
  55. "birthday.dateFormat" => "生日必需是有效日期格式[yyyy-MM-dd]",
  56. "talent_type.between" => "不存在的人才类型,请在列表中选择",
  57. "fst_work_time.dateFormat" => "来晋工作时间必需是有效的日期格式[yyyy-MM-dd]",
  58. "pre_import_type.between" => "预引进类型只能在预设列表中选择",
  59. "return.between" => "是否流出晋江满3年后又返回晋江的选项只能在预设列表中选择",
  60. "salary_pay_way.between" => "工资发放渠道只能在预设列表中选择",
  61. "experience.max" => "工作经历不能超过200个字符,请简明扼要的描述您的工作经历",
  62. "education.max" => "教育背景不能超过200个字符,请简明扼要的描述您的教育背景",
  63. "phone.mobile" => "请填写正确的手机号",
  64. "email.email" => "电子邮箱格式错误",
  65. "highest_degree.between" => "最高学历只能在预设列表中选择",
  66. "study_abroad.between" => "留学经历只能选择是与否",
  67. "import_way.between" => "不存在的引进方式,请在列表中选择",
  68. "cur_entry_time.dateFormat" => "本单位入职时间必需是有效的日期格式[yyyy-MM-dd]",
  69. "source.between" => "不存在的申报来源,请在列表中选择",
  70. "fujian_highcert_pubtime.dateFormat" => "福建省高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
  71. "fujian_highcert_exptime.dateFormat" => "福建省高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
  72. "quanzhou_highcert_pubtime.dateFormat" => "泉州高层次人才证书发证日期必需是有效的日期格式[yyyy-MM-dd]",
  73. "quanzhou_highcert_exptime.dateFormat" => "泉州高层次人才证书有效期必需是有效的日期格式[yyyy-MM-dd]",
  74. "talent_arrange" => "不存在的人才层次,请在列表中选择",
  75. "bank.regex" => "开户银行格式应为[XX银行]",
  76. "bank_number.regex" => "银行行号只能是数字",
  77. //"bank_branch_name.regex" => "开户银行网点格式应为[XX银行XX省XX市XX行/处]",
  78. "bank_account.regex" => "银行账号只能是数字",
  79. "break_faith.between" => "是否曾被相关主管部门列为失信个人只能在预设列表中选择",
  80. "identifyGetTime.dateFormat" => "认定条件取得时间必需是有效的日期格式[yyyy-MM-dd]",
  81. ];
  82. protected function checkUnique($value, $rule, $data = [], $field) {
  83. $db = $this->db->name($rule);
  84. $pk = $db->getPk();
  85. $map = [];
  86. $map[] = [$field, "=", $data[$field]];
  87. $map[] = ["delete", "=", 0];
  88. $map[] = ["checkState", "not in", [TalentState::SCND_SAVE, 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]];
  89. if ($data[$pk]) {
  90. $info = $db->where("id", $data[$pk])->field($pk)->find();
  91. $map[] = [$pk, "<>", $data[$pk]];
  92. $map[] = ["apply_year", "=", $info["apply_year"]];
  93. } else {
  94. $batch = \app\common\api\BatchApi::getValidBatch(\app\common\state\ProjectState::TALENT, session("user")["type"])["batch"];
  95. $map[] = ["apply_year", "=", $batch];
  96. }
  97. if ($db->where($map)->field($pk)->find()) {
  98. return false;
  99. }
  100. return true;
  101. }
  102. protected function checkInSelect($value, $rule, $data = []) {
  103. $title = "";
  104. $select = explode(",", $rule);
  105. $type = array_shift($select);
  106. switch ($type) {
  107. case "nation":
  108. $title = "民族";
  109. break;
  110. case "politics":
  111. $title = "政治面貌";
  112. break;
  113. case "nationality":
  114. $title = "国籍/地区";
  115. break;
  116. case "highest_degree":
  117. $title = "最高学历";
  118. break;
  119. }
  120. return in_array($value, $select) ?: "{$title}只能在预设列表中选择";
  121. }
  122. protected function checkCardNumber($value, $rule, $data = []) {
  123. if (!$data["card_type"]) {
  124. return "填写证件号码前请先选择证件类型";
  125. }
  126. if ($data["card_type"] == 1) {
  127. $num = strlen($value);
  128. switch ($num) {
  129. case 15:
  130. case 18:
  131. if (!\app\common\api\IdCardApi::isValid($value)) {
  132. return "身份证号码不合法";
  133. }
  134. break;
  135. default:
  136. return "身份证号码不合法";
  137. break;
  138. }
  139. } else if ($data["card_type"] == 2) {
  140. if (!preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) && !preg_match("/^([0-9]{8}|[0-9]{10})$/", $value)) {
  141. return "通行证号码不合法";
  142. }
  143. } else {
  144. if (!preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value)) {
  145. return "护照号码不合法";
  146. }
  147. }
  148. $db = $this->db->name($rule);
  149. $where = [];
  150. $where[] = ["card_number", "=", $value];
  151. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  152. $talentInfo = $db->where($where)->find();
  153. if ($talentInfo)
  154. return "您已经是在库人才,不需要重复申报";
  155. return true;
  156. }
  157. protected function checkRangeDate($value, $rule, $data = []) {
  158. $title = "";
  159. $format = "[yyyy-MM-dd - yyyy-MM-dd]";
  160. $str = "日期";
  161. switch ($rule) {
  162. case "tax_insurance_month":
  163. $format = "[yyyy-MM - yyyy-MM]";
  164. $str = "月份";
  165. if ($data["talent_type"] == 1) {
  166. $title = "缴交社会保险或个人所得税月份";
  167. }
  168. if ($data["talent_type"] == 2) {
  169. $title = "首次在我市缴交社会保险或个人所得税月份";
  170. }
  171. break;
  172. case "labor_contract_rangetime":
  173. $title = "劳动合同起止时间";
  174. break;
  175. case "salary_pay_month":
  176. $format = "[yyyy-MM - yyyy-MM]";
  177. $str = "月份";
  178. $title = "工资发放月份";
  179. break;
  180. }
  181. $arr = explode(" - ", $value);
  182. $chk1 = strtotime($arr[0]);
  183. $chk2 = strtotime($arr[1]);
  184. if (!$chk1 || !$chk2)
  185. return "{$title}日期范围格式应为{$format}";
  186. if ($chk1 > $chk2)
  187. return "{$title}起始{$str}不能大于结束{$str}";
  188. return true;
  189. }
  190. }