浏览代码

修改子女择校兼容旧库人才

sugangqiang 1 年之前
父节点
当前提交
8cb662e2c0
共有 3 个文件被更改,包括 160 次插入65 次删除
  1. 15 5
      app/common/controller/Auth.php
  2. 134 58
      app/person/controller/Education.php
  3. 11 2
      app/person/controller/UserInfo.php

+ 15 - 5
app/common/controller/Auth.php

@@ -15,6 +15,7 @@ use think\facade\Request;
 use app\common\api\UploadApi;
 use app\enterprise\model\Talent;
 use app\common\api\TalentState;
+use think\facade\Db;
 
 class Auth extends BaseController {
 
@@ -675,18 +676,27 @@ class Auth extends BaseController {
                             ->field("ti.*,e.type as enterpriseType")
                             ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
                             ->where('ti.checkState', TalentState::CERTIFICATED)->find();
-            if (!$info) {
+            $oldWhere = [];
+            $oldWhere[] = ["idCard", "=", $data['idCard']];
+            $oldWhere[] = ["checkState", "=", \app\common\state\MainState::PASS];
+            $oldWhere[] = ["isPublic", "=", 6];
+            $oldWhere[] = ["isEffect", "=", 1];
+            $oldInfo = Db::table("un_talent_info")->where($oldWhere)->find();
+
+            if (!$info && !$oldInfo) {
                 throw new ValidateException("人才库中不存在该证件号码,注册失败");
             }
-
-            if (!strtotime($info["certificateExpireTime"]) || strtotime($info["certificateExpireTime"]) < time()) {
+            $certificateExpireTime = $info ? $info["certificateExpireTime"] : $oldInfo["qzgccrcActiveTime"];
+            $phone = $info ? $info["phone"] : $oldInfo["phone"];
+            $type = $info ? $info["enterpriseType"] : $oldInfo["type"];
+            if (!strtotime($certificateExpireTime) || strtotime($certificateExpireTime) < time()) {
                 throw new ValidateException("人才库中该证件号码所属人才的人才证书已过期,注册失败");
             }
-            if ($info["phone"] != $data["phone"]) {
+            if ($phone != $data["phone"]) {
                 throw new ValidateException("手机号码必须与人才库中一致,可联系企业经办人修改人才库手机号码");
             }
             $data["id"] = getStringId();
-            $data["type"] = $info["enterpriseType"];
+            $data["type"] = $type;
             $data["createTime"] = date("Y-m-d H:i:s");
             $data["updateTime"] = date("Y-m-d H:i:s");
             $data["password"] = md5($data["password"]);

+ 134 - 58
app/person/controller/Education.php

@@ -44,31 +44,65 @@ class Education extends PersonController {
             $where[] = ["card_number", "=", $this->user["idCard"]];
             $where[] = ["isEffect", "=", 1];
             $talentInfo = \app\enterprise\model\Talent::where($where)->find();
-            $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
-            $info["personId"] = $this->user["uid"];
-            $info["type"] = $this->user["type"];
-            $info["talentId"] = $talentInfo["id"];
-            $info["pName"] = $talentInfo["name"];
-            $info["pSex"] = $talentInfo["sex"];
-            $info["pIdcard"] = $talentInfo["card_number"];
-            $info["talentArrange"] = $talentInfo["talent_arrange"];
-            $info["identifyCondition"] = $talentCondition["name"];
-            $info["certificateStartTime"] = $talentInfo["certificateGetTime"];
-            $info["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
-            $info["certificateNo"] = $talentInfo["certificateNo"];
-            $area = [];
-            if ($talentInfo["province"]) {
-                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
-            }
-            if ($talentInfo["city"]) {
-                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
-            }
-            if ($talentInfo["county"]) {
-                $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
+            if ($talentInfo) {
+                $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
+                $info["personId"] = $this->user["uid"];
+                $info["type"] = $this->user["type"];
+                $info["talentId"] = $talentInfo["id"];
+                $info["pName"] = $talentInfo["name"];
+                $info["pSex"] = $talentInfo["sex"];
+                $info["pIdcard"] = $talentInfo["card_number"];
+                $info["talentArrange"] = $talentInfo["talent_arrange"];
+                $info["identifyCondition"] = $talentCondition["name"];
+                $info["certificateStartTime"] = $talentInfo["certificateGetTime"];
+                $info["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
+                $info["certificateNo"] = $talentInfo["certificateNo"];
+                $area = [];
+                if ($talentInfo["province"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
+                }
+                if ($talentInfo["city"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
+                }
+                if ($talentInfo["county"]) {
+                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
+                }
+                $info["nativePlace"] = implode("", $area);
+                $info["certificateNo"] = $talentInfo["certificateNo"];
+                $info["phone"] = $talentInfo["phone"];
+            } else {
+                $oldWhere = [];
+                $oldWhere[] = ["idCard", "=", $this->user["idCard"]];
+                $oldWhere[] = ["checkState", "=", MainState::PASS];
+                $oldWhere[] = ["isPublic", "=", 6];
+                $oldWhere[] = ["isEffect", "=", 1];
+                $oldTalentInfo = Db::table("un_talent_info")->where($oldWhere)->find();
+
+                $info["personId"] = $this->user["uid"];
+                $info["type"] = $this->user["type"];
+                $info["talentId"] = $oldTalentInfo["id"];
+                $info["pName"] = $oldTalentInfo["name"];
+                $info["pSex"] = $oldTalentInfo["sex"];
+                $info["pIdcard"] = $oldTalentInfo["idCard"];
+                $info["talentArrange"] = $oldTalentInfo["talentArrange"];
+                $info["identifyCondition"] = $oldTalentInfo["identifyConditionName"];
+                $info["certificateStartTime"] = $oldTalentInfo["certificateStartTime"];
+                $info["qzgccrcActiveTime"] = $oldTalentInfo["qzgccrcActiveTime"];
+                $info["certificateNo"] = $oldTalentInfo["certificateNO"];
+                $area = [];
+                if ($oldTalentInfo["provinceName"]) {
+                    $area[] = $oldTalentInfo["provinceName"];
+                }
+                if ($oldTalentInfo["cityName"]) {
+                    $area[] = $oldTalentInfo["cityName"];
+                }
+                if ($oldTalentInfo["countyName"]) {
+                    $area[] = $oldTalentInfo["countyName"];
+                }
+                $info["nativePlace"] = implode("", $area);
+                $info["certificateNo"] = $oldTalentInfo["certificateNO"];
+                $info["phone"] = $oldTalentInfo["phone"];
             }
-            $info["nativePlace"] = implode("", $area);
-            $info["certificateNo"] = $talentInfo["certificateNo"];
-            $info["phone"] = $talentInfo["phone"];
         }
         if ($request->isPost()) {
             return $this->save($info, $request);
@@ -111,38 +145,72 @@ class Education extends PersonController {
                 $response->msg = "修改成功";
             } else {
                 $talentInfo = \app\enterprise\api\TalentApi::getOne($info["talentId"]);
-                if (!$talentInfo || $talentInfo["checkState"] != \app\common\api\TalentState::CERTIFICATED) {
-                    throw new ValidateException("未查询到有效的人才数据(根据证件号码匹配),无法申报");
-                }
-                if (!strtotime($talentInfo["certificateExpireTime"]) || strtotime($talentInfo["certificateExpireTime"]) < time()) {
-                    throw new ValidateException("您的人才证书已过期,请进行人才层次变更后再申报");
-                }
-                if ($this->user["type"] == 1 && $talentInfo["talent_arrange"] > 5) {
-                    throw new ValidateException("子女择校政策只针对第一至五层次人才!");
-                }
-
                 $area = [];
-                if ($talentInfo["province"]) {
-                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
-                }
-                if ($talentInfo["city"]) {
-                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
-                }
-                if ($talentInfo["county"]) {
-                    $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
-                }
+                if ($talentInfo) {
+                    if (!$talentInfo || $talentInfo["checkState"] != \app\common\api\TalentState::CERTIFICATED || $talentInfo["isEffect"] != 1) {
+                        throw new ValidateException("未查询到有效的人才数据(根据证件号码匹配),无法申报");
+                    }
+                    if (!strtotime($talentInfo["certificateExpireTime"]) || strtotime($talentInfo["certificateExpireTime"]) < time()) {
+                        throw new ValidateException("您的人才证书已过期,请进行人才层次变更后再申报");
+                    }
+                    if ($this->user["type"] == 1 && $talentInfo["talent_arrange"] > 5) {
+                        throw new ValidateException("子女择校政策只针对第一至五层次人才!");
+                    }
 
-                $data["id"] = getStringId();
-                $data["personId"] = $this->user["uid"];
-                $data["pName"] = $talentInfo["name"];
-                $data["pSex"] = $talentInfo["sex"];
-                $data["pIdcard"] = $talentInfo["card_number"];
-                $data["talentArrange"] = $talentInfo["talent_arrange"];
-                $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
-                $data["identifyCondition"] = $talentCondition["name"];
-                $data["certificateNo"] = $talentInfo["certificateNo"];
-                $data["certificateStartTime"] = $talentInfo["certificateGetTime"];
-                $data["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
+                    if ($talentInfo["province"]) {
+                        $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["province"])->findOrEmpty()["name"];
+                    }
+                    if ($talentInfo["city"]) {
+                        $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["city"])->findOrEmpty()["name"];
+                    }
+                    if ($talentInfo["county"]) {
+                        $area[] = Db::table("un_common_location")->where("code", "=", $talentInfo["county"])->findOrEmpty()["name"];
+                    }
+
+                    $data["id"] = getStringId();
+                    $data["personId"] = $this->user["uid"];
+                    $data["pName"] = $talentInfo["name"];
+                    $data["pSex"] = $talentInfo["sex"];
+                    $data["pIdcard"] = $talentInfo["card_number"];
+                    $data["talentArrange"] = $talentInfo["talent_arrange"];
+                    $talentCondition = \app\common\api\TalentConditionApi::getOne($talentInfo["talent_condition"]);
+                    $data["identifyCondition"] = $talentCondition["name"];
+                    $data["certificateNo"] = $talentInfo["certificateNo"];
+                    $data["certificateStartTime"] = $talentInfo["certificateGetTime"];
+                    $data["qzgccrcActiveTime"] = $talentInfo["certificateExpireTime"];
+                } else {
+                    $oldTalentInfo = Db::table("un_talent_info")->where("id", $info["talentId"])->find();
+                    if (!$oldTalentInfo || $oldTalentInfo["checkState"] != MainState::PASS || $oldTalentInfo["isEffect"] != 1 || $oldTalentInfo["isPublic"] != 6) {
+                        throw new ValidateException("未查询到有效的人才数据(根据证件号码匹配),无法申报");
+                    }
+                    if (!strtotime($oldTalentInfo["qzgccrcActiveTime"]) || strtotime($oldTalentInfo["qzgccrcActiveTime"]) < time()) {
+                        throw new ValidateException("您的人才证书已过期,请进行人才层次变更后再申报");
+                    }
+                    if ($this->user["type"] == 1 && $oldTalentInfo["talentArrange"] > 5) {
+                        throw new ValidateException("子女择校政策只针对第一至五层次人才!");
+                    }
+
+                    if ($oldTalentInfo["provinceName"]) {
+                        $area[] = $oldTalentInfo["provinceName"];
+                    }
+                    if ($oldTalentInfo["cityName"]) {
+                        $area[] = $oldTalentInfo["cityName"];
+                    }
+                    if ($oldTalentInfo["countyName"]) {
+                        $area[] = $oldTalentInfo["countyName"];
+                    }
+
+                    $data["id"] = getStringId();
+                    $data["personId"] = $this->user["uid"];
+                    $data["pName"] = $oldTalentInfo["name"];
+                    $data["pSex"] = $oldTalentInfo["sex"];
+                    $data["pIdcard"] = $oldTalentInfo["idCard"];
+                    $data["talentArrange"] = $oldTalentInfo["talentArrange"];
+                    $data["identifyCondition"] = $oldTalentInfo["identifyConditionName"];
+                    $data["certificateNo"] = $oldTalentInfo["certificateNO"];
+                    $data["certificateStartTime"] = $oldTalentInfo["certificateStartTime"];
+                    $data["qzgccrcActiveTime"] = $oldTalentInfo["qzgccrcActiveTime"];
+                }
                 $data["nativePlace"] = implode("", $area);
                 $data["checkState"] = -2;
                 $data["createTime"] = date("Y-m-d H:i:s");
@@ -310,16 +378,24 @@ class Education extends PersonController {
         $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
         $where[] = ["isEffect", "=", 1];
         $list = \app\enterprise\model\Talent::where($where)->select()->toArray();
-        if (!$list || count($list) == 0) {
+
+        $whereOld = [];
+        $whereOld[] = ["idCard", "=", $this->user["idCard"]];
+        $whereOld[] = ["isPublic", "=", 6];
+        $whereOld[] = ["checkState", "=", MainState::PASS];
+        $whereOld[] = ["isEffect", "=", 1];
+        $oldList = Db::table("un_talent_info")->where($whereOld)->select()->toArray();
+        if (!$list && !$oldList) {
             $response->msg = "未查询到有效的人才数据(根据证件号码匹配),无法申报";
             return json($response);
         }
-        if (count($list) > 1) {
+        $count = $list ? count($list) : count($oldList);
+        $expireTime = $list ? $list[0]["certificateExpireTime"] : $oldList[0]["qzgccrcActiveTime"];
+        if ($count > 1) {
             $response->msg = "根据证件号码查询到多条在库数据,无法申报,可联系相关单位取消重复人才资格";
             return json($response);
         }
-        $info = $list[0];
-        if ($this->user["type"] == 1 && (!strtotime($info["certificateExpireTime"]) || strtotime($info["certificateExpireTime"]) < time())) {
+        if ($this->user["type"] == 1 && (!strtotime($expireTime) || strtotime($expireTime) < time())) {
             $response->msg = "您的人才证书已过期,请进行人才层次变更后再申报";
             return json($response);
         }

+ 11 - 2
app/person/controller/UserInfo.php

@@ -5,6 +5,7 @@ namespace app\person\controller;
 use app\person\common\PersonController;
 use app\common\model\Person as PersonModel;
 use app\common\api\UserApi;
+use think\facade\Db;
 
 /**
  * Description of UserInfo
@@ -139,12 +140,20 @@ class UserInfo extends PersonController {
             $where[] = ["card_number", "=", $userInfo["idCard"]];
             $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
             $talentInfo = \app\enterprise\model\Talent::where($where)->order("createTime desc")->find();
+
+            $oldWhere = [];
+            $oldWhere[] = ["idCard", "=", $userInfo['idCard']];
+            $oldWhere[] = ["checkState", "=", \app\common\state\MainState::PASS];
+            $oldWhere[] = ["isPublic", "=", 6];
+            $oldWhere[] = ["isEffect", "=", 1];
+            $oldTalentInfo = Db::table("un_talent_info")->where($oldWhere)->find();
             //查询该证件号码和手机号是否在库
-            if (!$talentInfo) {
+            $phone = $talentInfo ? $talentInfo["phone"] : $oldTalentInfo["phone"];
+            if (!$talentInfo && !$oldTalentInfo) {
                 $response_object->msg = "人才库中不存在该证件号码,修改失败!";
                 return json($response_object);
             }
-            if ($talentInfo["phone"] != $params["newPhone"]) {
+            if ($phone != $params["newPhone"]) {
                 $response_object->msg = "手机号码必须与人才库中一致,可联系企业经办人修改人才库手机号码后再行修改";
                 return json($response_object);
             }