浏览代码

修改基础信息变更中企业人才名单的读取

sugangqiang 9 月之前
父节点
当前提交
7150a113d8
共有 1 个文件被更改,包括 20 次插入22 次删除
  1. 20 22
      app/enterprise/controller/TalentBasicChange.php

+ 20 - 22
app/enterprise/controller/TalentBasicChange.php

@@ -97,6 +97,16 @@ class TalentBasicChange extends EnterpriseController {
                 $response->msg = "修改成功";
                 return $response;
             } else {
+                $where = [];
+                $where[] = ["checkState", "<>", 3];
+                $where[] = ["oldIdCard", "=", $talentInfo["card_number"]];
+                $exist = TbcModel::where($where)->find();
+                if ($exist) {
+                    $response->code = 500;
+                    $response->msg = "已经存在变更记录,不能重复添加";
+                    return $response;
+                }
+
                 $data["id"] = getStringId();
                 $data["oldName"] = $talentInfo["name"];
                 $data["oldNationality"] = $talentInfo["nationality"];
@@ -141,31 +151,19 @@ class TalentBasicChange extends EnterpriseController {
             $where[] = ["enterprise_id", "=", $this->user["uid"]];
             $where[] = ["id", "not in", $changes];
             $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
-
-            $twiceIdentifyPersons = \app\common\api\VerifyApi::getTwiceIdentifyPersons();
-            if ($twiceIdentifyPersons) {
-                $_whr = $where;
-                $where[] = ["card_number", "not in", $twiceIdentifyPersons];
-                $_whr[] = ["card_number", "in", $twiceIdentifyPersons];
-                $tmpList = \app\enterprise\model\Talent::where($_whr)->field("id,name")->select()->toArray();
-
-                $twiceIdentifyPersonList = [];
-                foreach ($tmpList as $person) {
-                    if (!$twiceIdentifyPersonList[$person["card_number"]]) {
-                        $twiceIdentifyPersonList[$person["card_number"]] = $person;
-                    } else {
-                        if ($person["talent_arrange"] < $twiceIdentifyPersonList[$person["card_number"]]["talent_arrange"]) {
-                            $twiceIdentifyPersonList[$person["card_number"]] = $person;
-                        }
+            $list = \app\enterprise\model\Talent::where($where)->field("id,name,card_number,talent_arrange")->select()->toArray();
+            $checkList = [];
+            foreach ($list as $item) {
+                if ($checkList[$item["card_number"]]) {
+                    if ($item["talent_arrange"] < $checkList[$item["card_number"]]["talent_arrange"]) {
+                        $checkList[$item["card_number"]] = $item;
                     }
+                } else {
+                    $checkList[$item["card_number"]] = $item;
                 }
-                sort($twiceIdentifyPersonList);
-            }
-            $list = \app\enterprise\model\Talent::where($where)->field("id,name")->select()->toArray();
-            if ($twiceIdentifyPersonList) {
-                $list = array_merge($twiceIdentifyPersonList, (array) $list);
             }
-            $assigns["list"] = $list;
+            sort($checkList);
+            $assigns["list"] = $checkList;
         }
         $assigns["type"] = $this->user["type"];
         $assigns["row"] = $info;