浏览代码

同一个身份证如果已经是在库人才,不能再申报

sugangqiang 1 年之前
父节点
当前提交
de24aaa731
共有 1 个文件被更改,包括 17 次插入10 次删除
  1. 17 10
      app/enterprise/validate/TalentInfo.php

+ 17 - 10
app/enterprise/validate/TalentInfo.php

@@ -16,7 +16,7 @@ class TalentInfo extends Validate {
         //"name" => "regex:/^[\x{4e00}-\x{9fa5}A-Za-z ]+$/u",
         //"name" => "regex:/^[\x{4e00}-\x{9fa5}A-Za-z ]+$/u",
         "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",
         "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",
         "card_type" => "between:1,3",
         "card_type" => "between:1,3",
-        "card_number" => "checkCardNumber|checkUnique:new_talent_info",
+        "card_number" => "checkCardNumber:new_talent_info|checkUnique:new_talent_info",
         "sex" => "between:1,2",
         "sex" => "between:1,2",
         "politics" => "checkInSelect:politics,01,02,03,04,05,06,07,08,09,10,11,12,13,14",
         "politics" => "checkInSelect:politics,01,02,03,04,05,06,07,08,09,10,11,12,13,14",
         "birthday" => "dateFormat:Y-m-d",
         "birthday" => "dateFormat:Y-m-d",
@@ -135,24 +135,31 @@ class TalentInfo extends Validate {
             switch ($num) {
             switch ($num) {
                 case 15:
                 case 15:
                 case 18:
                 case 18:
-                    return \app\common\api\IdCardApi::isValid($value) ?: "身份证号码不合法";
+                    if (!\app\common\api\IdCardApi::isValid($value)) {
+                        return "身份证号码不合法";
+                    }
                     break;
                     break;
                 default:
                 default:
-                    //return \app\common\api\IdCardApi::isValidExceptMainland($value) ?: "身份证号码不合法";
+                    return "身份证号码不合法";
                     break;
                     break;
             }
             }
-            return "身份证号码不合法";
         } else if ($data["card_type"] == 2) {
         } else if ($data["card_type"] == 2) {
-            if (preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) || preg_match("/^([0-9]{8}|[0-9]{10})$/", $value)) {
-                return true;
+            if (!preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) && !preg_match("/^([0-9]{8}|[0-9]{10})$/", $value)) {
+                return "通行证号码不合法";
             }
             }
-            return "通行证号码不合法";
         } else {
         } else {
-            if (preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value)) {
-                return true;
+            if (!preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value)) {
+                return "护照号码不合法";
             }
             }
-            return "护照号码不合法";
         }
         }
+        $db = $this->db->name($rule);
+        $where = [];
+        $where[] = ["card_number", "=", $value];
+        $where[] = ["checkState", "=", TalentState::CERTIFICATED];
+        $talentInfo = $db->where($where)->find();
+        if ($talentInfo)
+            return "您已经是在库人才,不需要重复申报";
+        return true;
     }
     }
 
 
     protected function checkRangeDate($value, $rule, $data = []) {
     protected function checkRangeDate($value, $rule, $data = []) {