| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 | 
							- <?php
 
- namespace app\enterprise\api;
 
- use app\enterprise\model\Talent;
 
- use app\common\api\DictApi;
 
- use app\common\api\TalentConditionApi;
 
- use app\common\api\TalentLogApi;
 
- use app\common\api\TalentState;
 
- use app\enterprise\model\TalentTypeChange;
 
- use think\facade\Db;
 
- /**
 
-  * Description of TalentApi
 
-  *
 
-  * @author sgq
 
-  */
 
- class TalentApi {
 
-     /**
 
-      * 判断是否可以编辑
 
-      * @param type $id
 
-      * @return boolean
 
-      */
 
-     public static function checkIsEditable($id) {
 
-         $info = Talent::findOrEmpty($id)->toArray();
 
-         if ($info["delete"] == 1 || !in_array($info["checkState"], [0, TalentState::FST_SAVE, TalentState::BASE_REVERIFY_PASS, TalentState::SCND_SAVE]))
 
-             return false;
 
-         return true;
 
-     }
 
-     static public function chkIsOwner($id, $uid) {
 
-         $info = self::getOne($id);
 
-         if ($info["enterprise_id"] != $uid)
 
-             return null;
 
-         return $info;
 
-     }
 
-     public static function getOne($id) {
 
-         $one = Talent::findOrEmpty($id);
 
-         return $one;
 
-     }
 
-     public static function getList($request, $step = 0) {
 
-         $order = trim($request->param("order")) ?: "desc";
 
-         $offset = trim($request->param("offset")) ?: 0;
 
-         $limit = trim($request->param("limit")) ?: 10;
 
-         $name = trim($request->param("name"));
 
-         $idCard = trim($request->param("card_number"));
 
-         $sex = trim($request->param("sex"));
 
-         $nation = trim($request->param("nation"));
 
-         $nationality = trim($request->param("nationality"));
 
-         $talentArrange = trim($request->param("talent_arrange"));
 
-         $checkState = trim($request->param("checkState"));
 
-         $type = session("user")["type"];
 
-         $where = [];
 
-         $where[] = ["delete", "=", 0];
 
-         if (session("user")["usertype"] == 2) {
 
-             $where[] = ["enterprise_id", "=", session("user")["uid"]];
 
-         }
 
-         //$where[] = ["isImport", "=", $request->param("import") ?: 0];
 
-         if ($step) {
 
-             switch ($step) {
 
-                 case 1:
 
-                     $where[] = ["checkState", "in", [TalentState::FST_SAVE, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
 
-                     switch ($checkState) {
 
-                         case -1:
 
-                             $where[] = ["checkState", "in", [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL]];
 
-                             break;
 
-                         case 1:
 
-                             $where[] = ["checkState", "=", TalentState::FST_SAVE];
 
-                             break;
 
-                         case 2:
 
-                             $where[] = ["checkState", "in", [TalentState::BASE_REJECT, TalentState::BASE_REVERIFY_REJECT]];
 
-                             break;
 
-                         case 3:
 
-                             $where[] = ["checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS]];
 
-                             break;
 
-                     }
 
-                     break;
 
-                 case 2:
 
-                     $where[] = ["checkState", "not in", [TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL, TalentState::BASE_VERIFY_FAIL]];
 
-                     switch ($checkState) {
 
-                         case -1:
 
-                             $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
 
-                             break;
 
-                         case 1:
 
-                             $where[] = ["checkState", "in", [TalentState::SCND_SAVE, TalentState::FST_SAVE]];
 
-                             break;
 
-                         case 2:
 
-                             $where[] = ["checkState", "in", [TalentState::BASE_REJECT, TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
 
-                             break;
 
-                         case 3:
 
-                             $where[] = ["checkState", "in", [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,
 
-                                     TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];
 
-                             break;
 
-                         case 4:
 
-                             $where[] = ["checkState", "=", TalentState::CERTIFICATED];
 
-                             break;
 
-                     }
 
-                     break;
 
-                 case 3:
 
-                     $where[] = ["checkState", "=", TalentState::CERTIFICATED];
 
-                     break;
 
-             }
 
-             if ($name) {
 
-                 $where[] = ["name", "like", "%" . $name . "%"];
 
-             }
 
-             if ($idCard) {
 
-                 $where[] = ["card_number", "like", "%" . $idCard . "%"];
 
-             }
 
-             if ($sex) {
 
-                 $where[] = ["sex", "=", $sex];
 
-             }
 
-             if ($nation) {
 
-                 $where[] = ["nation", "=", $nation];
 
-             }
 
-             if ($nationality) {
 
-                 $where[] = ["nationality", "=", $nationality];
 
-             }
 
-             if ($talentArrange) {
 
-                 $where[] = ["talent_arrange", "=", $talentArrange];
 
-             }
 
-             $count = Talent::where($where)->count();
 
-             $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
 
-             $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
 
-             $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
 
-             $industries = DictApi::selectByParentCode("industry_field"); //产业
 
-             $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
 
-             foreach ($list as $key => $item) {
 
-                 $condition = TalentConditionApi::getOne($item["talent_condition"]);
 
-                 $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
 
-                 $list[$key]["identifyConditionText"] = $condition["name"];
 
-                 if (!$item["isMatchZhiren"]) {
 
-                     $list[$key]["companyIds"] = $condition["companyIds"];
 
-                 }
 
-                 $list[$key]["type"] = $enterprise["type"];
 
-                 $list[$key]["enterpriseName"] = $enterprise["name"];
 
-                 $list[$key]["industryName"] = $industries[$enterprise["industryFieldNew"]];
 
-                 $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
 
-                 $last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["active", "=", 1]);
 
-                 $list[$key]["real_state"] = $last_log["state"];
 
-                 $list[$key]["last_state"] = $last_log["last_state"];
 
-             }
 
-             return ["total" => $count, "rows" => $list];
 
-         }
 
-     }
 
-     public static function getTypeChangeList($request) {
 
-         $order = trim($request->param("order")) ?: "desc";
 
-         $offset = trim($request->param("offset")) ?: 0;
 
-         $limit = trim($request->param("limit")) ?: 10;
 
-         $talentName = trim($request->param("talentName"));
 
-         $oldTalentArrange = trim($request->param("oldTalentArrange"));
 
-         $newTalentArrange = trim($request->param("newTalentArrange"));
 
-         $checkState = trim($request->param("checkState"));
 
-         $oldIdentifyCondition = trim($request->param("oldIdentifyCondition"));
 
-         $newIdentifyCondition = trim($request->param("newIdentifyCondition"));
 
-         $where = [];
 
-         $where[] = ["enterpriseId", "=", session("user")["uid"]];
 
-         $where[] = ["delete", "=", 0];
 
-         //$whereRaw = "length(talentId) <> 19";
 
-         if ($talentName) {
 
-             $where[] = ["talentName", "like", "%" . $talentName . "%"];
 
-         }
 
-         if ($oldTalentArrange) {
 
-             $where[] = ["oldTalentArrange", "=", $oldTalentArrange];
 
-         }
 
-         if ($newTalentArrange) {
 
-             $where[] = ["newTalentArrange", "=", $newTalentArrange];
 
-         }
 
-         if ($checkState) {
 
-             $where[] = ["checkState", "=", $checkState];
 
-         }
 
-         if ($oldIdentifyCondition) {
 
-             $where[] = ["oldIdentifyCondition", "=", $oldIdentifyCondition];
 
-         }
 
-         if ($newIdentifyCondition) {
 
-             $where[] = ["newIdentifyCondition", "=", $newIdentifyCondition];
 
-         }
 
-         $count = TalentTypeChange::where($where)->count();
 
-         $list = TalentTypeChange::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
 
-         $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
 
-         foreach ($list as $k => $v) {
 
-             if (strlen($v["oldIdentifyCondition"]) == 19) {
 
-                 $condition = Db::table("un_identify_condition")->find($v["oldIdentifyCondition"]);
 
-                 $list[$k]["oldIdentifyCondition"] = $condition["name"];
 
-             } else if ($v["oldIdentifyCondition"]) {
 
-                 $condition = TalentConditionApi::getOne($v["oldIdentifyCondition"]);
 
-                 $list[$k]["oldIdentifyCondition"] = $condition["name"];
 
-             }
 
-             if (strlen($v["newIdentifyCondition"]) == 19) {
 
-                 $condition = Db::table("un_identify_condition")->find($v["newIdentifyCondition"]);
 
-                 $list[$k]["newIdentifyCondition"] = $condition["name"];
 
-             } else if ($v["newIdentifyCondition"]) {
 
-                 $condition = TalentConditionApi::getOne($v["newIdentifyCondition"]);
 
-                 $list[$k]["newIdentifyCondition"] = $condition["name"];
 
-             }
 
-             $list[$k]["oldTalentArrangeName"] = array_key_exists($v["oldTalentArrange"], $talentArangeList) ? $talentArangeList[$v["oldTalentArrange"]] : "";
 
-             $list[$k]["newTalentArrangeName"] = array_key_exists($v["newTalentArrange"], $talentArangeList) ? $talentArangeList[$v["newTalentArrange"]] : "";
 
-         }
 
-         return ["total" => $count, "rows" => $list];
 
-     }
 
-     public static function getHospitalExamineList($request) {
 
-         $user = session("user");
 
-         if ($user["isGeneral"] == 1) {
 
-             $order = trim($request->param("order")) ?: "desc";
 
-             $offset = trim($request->param("offset")) ?: 0;
 
-             $limit = trim($request->param("limit")) ?: 10;
 
-             $name = trim($request->param("name"));
 
-             $idCard = trim($request->param("card_number"));
 
-             $sex = trim($request->param("sex"));
 
-             $nation = trim($request->param("nation"));
 
-             $talentArrange = trim($request->param("talent_arrange"));
 
-             $checkState = trim($request->param("checkState"));
 
-             $where = [];
 
-             $where[] = ["ti.delete", "=", 0];
 
-             $where[] = ["e.type", "=", $user["type"]];
 
-             $where[] = ["e.isGeneral", "=", 2];
 
-             $where[] = ["e.medicalCommunityId", "=", $user["medicalCommunityId"]];
 
-             $where[] = ["ti.first_submit_time", "EXP", \think\facade\Db::raw("is not null")];
 
-             if ($name) {
 
-                 $where[] = ["ti.name", "like", "%" . $name . "%"];
 
-             }
 
-             if ($idCard) {
 
-                 $where[] = ["ti.card_number", "like", "%" . $idCard . "%"];
 
-             }
 
-             if ($sex) {
 
-                 $where[] = ["ti.sex", "=", $sex];
 
-             }
 
-             if ($nation) {
 
-                 $where[] = ["ti.nation", "=", $nation];
 
-             }
 
-             if ($talentArrange) {
 
-                 $where[] = ["ti.talent_arrange", "=", $talentArrange];
 
-             }
 
-             $whereRaw = sprintf("tl.state in (%s,%s) or tl.state >= %s", TalentState::FST_SUBMIT, TalentState::BASE_REJECT, TalentState::SCND_SUBMIT);
 
-             switch ($checkState) {
 
-                 case 1:
 
-                     $where[] = ["tl.state", "=", TalentState::FST_SUBMIT];
 
-                     break;
 
-                 case 2:
 
-                     $where[] = ["tl.state", "=", TalentState::BASE_REJECT];
 
-                     break;
 
-                 case 3:
 
-                     $where[] = ["tl.state", ">=", TalentState::SCND_SUBMIT];
 
-                     break;
 
-             }
 
-             $count = Talent::where($where)->whereRaw($whereRaw)->alias("ti")
 
-                     ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
 
-                     ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
 
-                     ->count();
 
-             $list = Talent::where($where)->whereRaw($whereRaw)->alias("ti")
 
-                             ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
 
-                             ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
 
-                             ->field("ti.*,e.name as enterpriseName,e.type")
 
-                             ->limit($offset, $limit)->order("ti.createTime " . $order)->select()->toArray();
 
-             $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
 
-             foreach ($list as $key => $item) {
 
-                 $condition = TalentConditionApi::getOne($item["talent_condition"]);
 
-                 $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
 
-                 $list[$key]["talentConditionName"] = $condition["name"];
 
-                 $last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["active", "=", 1]);
 
-                 $list[$key]["real_state"] = $last_log["state"];
 
-                 $list[$key]["last_state"] = $last_log["last_state"];
 
-             }
 
-             return ["total" => $count, "rows" => $list];
 
-         }
 
-         return [];
 
-     }
 
- }
 
 
  |