sugangqiang 2 年之前
父節點
當前提交
8789f75f2e
共有 1 個文件被更改,包括 38 次插入4 次删除
  1. 38 4
      app/common/api/EnterpriseApi.php

+ 38 - 4
app/common/api/EnterpriseApi.php

@@ -30,18 +30,35 @@ class EnterpriseApi {
                 $whr[] = ["companyId", "=", $companyId];
                 $whr[] = ["delete", "=", 0];
                 $list = \app\common\model\EnterpriseVerifyMgr::where($whr)->select()->toArray();
-                $talentType = [];
-                $uniCodes = [];
+                $talentType = []; //查找单位对应标签
+                $uniCodes = []; //查找单位对应例外
                 foreach ($list as $k => $v) {
                     array_push($talentType, $v['enterpriseTag']);
                     $codes = explode(",", $v["uniCode"]);
                     $uniCodes = array_merge($uniCodes, (array) $codes);
                 }
+
+                $_whr[] = ["uniCode", "<>", ""];
+                $_whr[] = ["delete", "=", 0];
+                $_whr[] = ["companyId", "<>", $companyId];
+                $_list = \app\common\model\EnterpriseVerifyMgr::where($_whr)->select()->toArray();
+                $expUniCodes = []; //排除其它单位的例外
+                foreach ($_list as $_v) {
+                    $codes = explode(",", $_v["uniCode"]);
+                    $expUniCodes = array_merge($expUniCodes, (array) $codes);
+                }
                 if ($talentType && $uniCodes) {
-                    $whereRaw = sprintf('enterpriseTag in ("%s") or idCard in ("%s")', implode('","', $talentType), implode('","', $uniCodes));
+                    if ($expUniCodes) {
+                        $whereRaw = sprintf('(enterpriseTag in ("%s") and idCard not in ("%s")) or idCard in ("%s")', implode('","', $talentType), implode('","', $expUniCodes), implode('","', $uniCodes));
+                    } else {
+                        $whereRaw = sprintf('enterpriseTag in ("%s") or idCard in ("%s")', implode('","', $talentType), implode('","', $uniCodes));
+                    }
                 }
                 if ($talentType && !$uniCodes) {
                     $where[] = ["enterpriseTag", "in", $talentType];
+                    if ($expUniCodes) {
+                        $where[] = ["idCard", "not in", $expUniCodes];
+                    }
                 }
                 if (!$talentType && $uniCodes) {
                     $where[] = ["idCard", "in", $uniCodes];
@@ -142,11 +159,28 @@ class EnterpriseApi {
                     $codes = explode(",", $v["uniCode"]);
                     $uniCodes = array_merge($uniCodes, (array) $codes);
                 }
+
+                $_whr[] = ["uniCode", "<>", ""];
+                $_whr[] = ["delete", "=", 0];
+                $_whr[] = ["companyId", "<>", $companyId];
+                $_list = \app\common\model\EnterpriseVerifyMgr::where($_whr)->select()->toArray();
+                $expUniCodes = []; //排除其它单位的例外
+                foreach ($_list as $_v) {
+                    $codes = explode(",", $_v["uniCode"]);
+                    $expUniCodes = array_merge($expUniCodes, (array) $codes);
+                }
                 if ($talentType && $uniCodes) {
-                    $whereRaw = sprintf('newEnterpriseTag in ("%s") or newIdCard in ("%s")', implode('","', $talentType), implode('","', $uniCodes));
+                    if ($expUniCodes) {
+                        $whereRaw = sprintf('(newEnterpriseTag in ("%s") and newIdCard not in ("%s")) or newIdCard in ("%s")', implode('","', $talentType), implode('","', $expUniCodes), implode('","', $uniCodes));
+                    } else {
+                        $whereRaw = sprintf('newEnterpriseTag in ("%s") or newIdCard in ("%s")', implode('","', $talentType), implode('","', $uniCodes));
+                    }
                 }
                 if ($talentType && !$uniCodes) {
                     $where[] = ["newEnterpriseTag", "in", $talentType];
+                    if ($expUniCodes) {
+                        $where[] = ["newIdCard", "not in", $expUniCodes];
+                    }
                 }
                 if (!$talentType && $uniCodes) {
                     $where[] = ["newIdCard", "in", $uniCodes];