12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328 |
- <?php
- namespace app\common\api;
- use app\admin\model\Notice as NoticeModel;
- use app\enterprise\model\Talent;
- use app\common\api\DictApi;
- use app\admin\model\Enterprise;
- use think\facade\Db;
- use app\common\model\TalentCondition;
- /**
- * Description of VerifyApi
- *
- * @author sgq
- */
- class VerifyApi {
- public static function getTalentInfoById($id, $isAdmin = false) {//添加admin只为区别导入数据管理端的显示差异
- $info = self::getOne($id);
- if ($info) {
- $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
- $info["enterpriseName"] = $enterprise["name"];
- $info["enterpriseAddress"] = $enterprise["address"];
- $info["enterpriseId"] = $enterprise["id"];
- $info["enterpriseType"] = $enterprise["type"];
- $info["enterpriseEphone"] = $enterprise["ephone"];
- $info["enterpriseTag"] = $enterprise["enterpriseTag"];
- $info["enterpriseBankCard"] = $enterprise["bankCard"];
- $info["enterpriseBankNetwork"] = $enterprise["bankNetwork"];
- $info["enterpriseBank"] = $enterprise["bank"];
- $info["isGeneral"] = $enterprise["isGeneral"];
- $info["medicalCommunityName"] = \app\common\api\Nhc::getMedicalCommunityMap()[$enterprise["medicalCommunityId"]];
- if ($info["talent_type"]) {
- if ($enterprise["type"] == \app\common\state\CommonConst::ENTERPRISE_WJ) {
- $info["talentTypeName"] = DictApi::selectByParentCode("wj_talent_type")[$info["talent_type"]];
- } else {
- $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
- }
- }
- if ($info["nationality"]) {
- $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
- }
- if ($info["nation"]) {
- $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
- }
- if ($info["politics"]) {
- $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
- }
- if ($info["province"]) {
- $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
- }
- if ($info["city"]) {
- $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
- }
- if ($info["county"]) {
- $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
- }
- if ($enterprise["street"]) {
- $info["street"] = $enterprise["street"];
- $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
- }
- if ($enterprise["industryFieldNew"]) {
- $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
- }
- if ($enterprise["enterpriseTag"]) {
- $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
- }
- if ($info["talent_arrange"]) {
- $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
- }
- if ($info["import_way"]) {
- $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
- }
- if ($info["source"]) {
- $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
- }
- if ($info["source_city"]) {
- $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
- }
- if ($info["source_county"]) {
- $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
- }
- if ($info["highest_degree"]) {
- $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
- }
- if ($info["labor_contract_rangetime"]) {
- list($startTime, $endTime) = explode(" - ", $info["labor_contract_rangetime"]);
- $info["startTime"] = $startTime;
- $info["endTime"] = $endTime;
- }
- if ($info["qz_talent_info"]) {
- $qz_talent_info = explode(";", $info["qz_talent_info"]);
- list($tmp1, $timeStart) = explode(":", $qz_talent_info[1]);
- list($tmp2, $timeEnd) = explode(":", $qz_talent_info[2]);
- if (strtotime($timeStart)) {
- $tmp_time = date("Y-m-d", strtotime($timeStart));
- $qz_talent_info[1] = implode(":", [$tmp1, $tmp_time]);
- if ($isAdmin) {
- $batch_info = NoticeModel::where('batch', $tmp_time)->find();
- if ($batch_info) {
- $qz_talent_info[1] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $qz_talent_info[1] . "</a>";
- }
- }
- }
- if (strtotime($timeEnd)) {
- $qz_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($timeEnd))]);
- }
- $info["qz_talent_info"] = implode(";", $qz_talent_info);
- }
- if ($info["fj_talent_info"]) {
- $fj_talent_info = explode(";", $info["fj_talent_info"]);
- list($tmp1, $timeStart) = explode(":", $fj_talent_info[0]);
- list($tmp2, $validYear) = explode(":", $fj_talent_info[2]);
- $timeStart = str_replace(["."], "-", $timeStart);
- if (strtotime($timeStart)) {
- $tmp_time = date("Y-m-d", strtotime($timeStart));
- $fj_talent_info[0] = implode(":", [$tmp1, $tmp_time]);
- if ($isAdmin) {
- $batch_info = NoticeModel::where('batch', $tmp_time)->find();
- if ($batch_info) {
- $fj_talent_info[0] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $fj_talent_info[0] . "</a>";
- }
- }
- if (strtotime($validYear)) {
- $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($validYear))]);
- } else {
- $validval = intval($validYear);
- if ($validYear > 0) {
- $timestr = str_replace($validval, "", $validYear);
- switch ($timestr) {
- case "月":
- $timetype = "months";
- break;
- case "日":
- $timetype = "days";
- break;
- default:
- $timetype = "years";
- break;
- }
- $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime("+{$validval} {$timetype} -1 days", strtotime($timeStart)))]);
- }
- }
- }
- $info["fj_talent_info"] = implode(";", $fj_talent_info);
- }
- if ($info["talent_condition"]) {
- $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
- $info["talentConditionName"] = $talent_condition["name"];
- $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
- $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
- }
- }
- return $info;
- }
- public static function getOne($id) {
- return Talent::findOrEmpty($id)->toArray();
- }
- /**
- * 获得新的需要重审的部门集合(如果$oriReCheckCompanyIds为空,返回认定条件审核部门集合$talentConditionCompanyIds)
- * @param type $oriReCheckCompanyIds 原来的需要再审核的部门id集合
- * @param type $talentConditionCompanyIds 认定条件中的审核部门id集合
- * @param type $passedCompanyIds 已经通过审核的部门id集合
- * @return type
- */
- public static function getNewReCheckCompanyIds($oriReCheckCompanyIds, $talentConditionCompanyIds, $passedCompanyIds) {
- if ($oriReCheckCompanyIds) {
- //$removeReCheckCompanyIds:获得再审核部门中已经被移除的集合(修改认定条件审核部门后,已经不再在列表中的部门Id集合)
- $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $talentConditionCompanyIds);
- //$reCheckCompanyIds:获得再审核部门中仍需审核的部门集合
- $reCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
- //$notInReCheckCompanyIds:不在重审列表里面的审核部门集合(这里面存在新增的审核部门)
- $notInReCheckCompanyIds = array_diff($talentConditionCompanyIds, $reCheckCompanyIds);
- //$needReCheckCompanyIds:找出不在重审列表里面并且没有在已审核通过的列表中的部门Id集合
- $needReCheckCompanyIds = array_diff($notInReCheckCompanyIds, $passedCompanyIds);
- //合并新的需要重审的部门集合
- $newReCheckCompanyIds = array_unique(array_merge($reCheckCompanyIds, $needReCheckCompanyIds));
- return $newReCheckCompanyIds;
- }
- return $talentConditionCompanyIds;
- }
- public static function getFullDeptList($params, $where = []) {
- $order = $params["order"] ?: "desc";
- $offset = $params["offset"] ?: 0;
- $limit = $params["limit"] ?: 10;
- $whereRaw = "";
- if ($params["company_id"]) {
- $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
- }
- switch ($params["checkState"]) {
- case 1://待部门并审(首次提交)
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- break;
- case 2://待部门并审(重新提交)
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- break;
- case 3://部门并审通过
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
- break;
- case 4://部门并审驳回
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
- break;
- default:
- $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
- break;
- }
- $companyId = session("user")["companyId"];
- $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $count = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->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")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->where($where)
- ->where($whereRaw)->count();
- $list = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->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")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->where($where)
- ->where($whereRaw)
- ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tc.name as talentConditionName,tc.companyIds,tl2.resubmit")
- ->limit($offset, $limit)->order("ti.createTime " . $order)
- ->select()->toArray();
- foreach ($list as &$item) {
- $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
- $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
- $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
- $companys = array_filter(explode(",", $item["companyIds"]));
- $verifyDepts = [];
- foreach ($companys as $k => $companyId) {
- $company = getCacheById("Company", $companyId);
- $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
- if (!$log && in_array($item["realState"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT]))
- continue;
- $verifyDepts[$k]["id"] = $companyId;
- $verifyDepts[$k]["shortName"] = $company["shortName"];
- $verifyDepts[$k]["name"] = $company["name"];
- $verifyDepts[$k]["code"] = $company["code"];
- $verifyDepts[$k]["checkState"] = $log["new_state"];
- $verifyDepts[$k]["active"] = $log["active"];
- }
- $item["verifyDepts"] = $verifyDepts;
- }unset($item);
- return ["total" => $count, "rows" => $list];
- }
- public static function getDeptList($params, $where = []) {
- $order = $params["order"] ?: "desc";
- $offset = $params["offset"] ?: 0;
- $limit = $params["limit"] ?: 10;
- $companyId = session("user")["companyId"];
- $whereRaw = "";
- switch ($params["checkState"]) {
- case 1://待部门并审(首次提交)
- //$where[] = ["tl.active", "=", 0];
- //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
- break;
- case 2://待部门并审(重新提交)
- //$where[] = ["tl.active", "=", 0];
- //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
- break;
- case 3://部门并审通过
- $where[] = ["tl.active", "=", 1];
- $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
- break;
- case 4://部门并审驳回
- $where[] = ["tl.active", "=", 1];
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- break;
- default:
- $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
- break;
- }
- $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $count = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("(select mainId,active,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->where($where)
- ->where($whereRaw)
- ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
- $list = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("(select mainId,active,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->where($where)
- ->where($whereRaw)
- ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
- ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',tl.new_state as 'newState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId,tc.name as talentConditionName,tl2.resubmit,tl.active as deptActive")
- ->limit($offset, $limit)->order("ti.createTime " . $order)
- ->select()->toArray();
- $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
- foreach ($list as &$item) {
- $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
- $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
- $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
- $item["deptCheckState"] = $lastCheckLog["new_state"] ?: TalentState::FST_VERIFY_PASS;
- $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
- $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
- }unset($item);
- return ["total" => $count, "rows" => $list];
- }
- public static function getPublicList($params) {
- $order = $params["order"];
- $offset = $params["offset"];
- $limit = $params["limit"];
- $where = [];
- $where[] = ["e.type", "=", session("user")["type"]];
- if ($params["name"]) {
- $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
- }
- if ($params["sex"]) {
- $where[] = ["ti.sex", "=", $params["sex"]];
- }
- if ($params["checkState"]) {
- $where[] = ["ti.checkState", "=", $params["checkState"]];
- }
- $type = $params["type"];
- switch ($type) {
- case 1:
- case 2:
- $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
- break;
- case 3: //公示
- case 7: //公示预览
- $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
- break;
- case 4: //公示通过
- $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
- break;
- case 5:
- case 8: //公布预览
- $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
- break;
- case 6:
- $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
- break;
- }
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- //$count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
- $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->where($where)
- //->limit($offset, $limit)
- ->order("ti.createTime " . $order)
- ->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
- foreach ($list as &$item) {
- $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
- $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
- }unset($item);
- return $list;
- }
- public static function getListByIds($ids) {
- $where[] = ["id", "in", $ids];
- return Talent::where($where)->select()->toArray();
- }
- public static function getList($params) {
- $where = [];
- $order = $params["order"] ?: "desc";
- $offset = $params["offset"] ?: 0;
- $limit = $params["limit"] ?: 10;
- $type = session("user")["type"];
- $where[] = ["e.type", "=", $type];
- if ($params["name"]) {
- $where[] = ["ti.name", "like", "%{$params["name"]}%"];
- }
- if ($params["card_number"]) {
- $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
- }
- if ($params["sex"]) {
- $where[] = ["ti.sex", "=", $params["sex"]];
- }
- if ($params["nation"]) {
- $where[] = ["ti.nation", "=", $params["nation"]];
- }
- if ($params["apply_year"]) {
- $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
- }
- if ($params["phone"]) {
- $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
- }
- if ($params["email"]) {
- $where[] = ["ti.email", "like", "%{$params["email"]}%"];
- }
- if ($params["nationality"]) {
- $where[] = ["ti.nationality", "=", $params["nationality"]];
- }
- if ($params["province"]) {
- $where[] = ["ti.province", "=", $params["province"]];
- }
- if ($params["politics"]) {
- $where[] = ["ti.politics", "=", $params["politics"]];
- }
- if ($params["enterprise_id"]) {
- $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
- }
- if ($params["medicalCommunityId"]) {
- $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
- }
- if ($params["isGeneral"]) {
- $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
- }
- if ($params["street"]) {
- $where[] = ["e.street", "=", $params["street"]];
- }
- if ($params["industry_field"]) {
- $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
- }
- if ($params["industry_field_old"]) {
- $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
- }
- if ($params["enterprise_tag"]) {
- $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
- }
- if ($params["talent_type"]) {
- $where[] = ["ti.talent_type", "=", $params["talent_type"]];
- }
- if ($params["import_way"]) {
- $where[] = ["ti.import_way", "=", $params["import_way"]];
- }
- if ($params["highest_degree"]) {
- $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
- }
- if ($params["study_abroad"]) {
- $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
- }
- if ($params["source"]) {
- $where[] = ["ti.source", "=", $params["source"]];
- }
- if ($params["talent_arrange"]) {
- $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
- }
- if ($params["talent_condition"]) {
- $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
- }
- if ($params["isMatchZhiren"]) {
- $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
- $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
- }
- if ($params["active"]) {
- $where[] = ["ti.active", "=", $params["active"]];
- }
- if ($params["breakFaith"]) {
- $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
- }
- $process = $params["process"];
- if ($process == 4) {
- if (self::chkUserInSuperDeptUsers()) {
- return self::getFullDeptList($params, $where);
- } else {
- return self::getDeptList($params, $where);
- }
- }
- if ($process == 5) {
- $whereRaw = sprintf("(tl.state in (-14,14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
- switch ($params["checkState"]) {
- case 1://待复审(首次提交)
- $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- break;
- case 2://待复审(重新提交)
- $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- break;
- case 3://复审通过
- $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
- break;
- case 4://复审驳回
- $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
- break;
- case 5://复审不通过
- $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
- break;
- default:
- if ($type == 2) {
- $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- }
- break;
- }
- $count = Talent::alias("ti")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->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")
- ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
- ->whereRaw($whereRaw)->where($where)->count();
- $list = Talent::alias("ti")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->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")
- ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
- ->whereRaw($whereRaw)
- ->where($where)
- ->limit($offset, $limit)
- ->order("ti.createTime " . $order)
- ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId,tl2.resubmit")
- ->select()->toArray();
- } else {
- switch ($process) {
- case 1:
- $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
- break;
- case 2:
- $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
- break;
- case 3:
- switch ($params["checkState"]) {
- case 1://保存未提交
- $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
- $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 2://初审驳回
- $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 3://待初审(首次提交)
- $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
- $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 4://待初审(重新提交)
- $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
- $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 5://待初审(部门并审驳回)
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 6://待初审(复审驳回)
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 7://初审通过(待部门并审)
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 8://初审通过(待复审)
- $where[] = ["ti.pass_dept_check", "=", 1];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 9://初审不通过
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
- $where[] = ["ti.delete", "=", 0];
- break;
- default:
- //$whereRaw = sprintf("((tl.new_state=%d and ti.`delete`=0) or tl.new_state=%d or tl.state in (%d,%d) or tl.state>%d)", TalentState::SCND_SAVE, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL, TalentState::FST_VERIFY_REJECT);
- if ($type == 2) {
- $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT,
- TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
- $where[] = ["ti.delete", "=", 0];
- } else {
- $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
- TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
- $where[] = ["ti.delete", "=", 0];
- }
- }
- break;
- case 6:
- $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
- $where[] = ["tl.state", "not in", [TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL]];
- if ($params["checkState"]) {
- $where[] = ["tl.state", "=", $params["checkState"]];
- }
- break;
- case 7:
- $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
- break;
- }
- $count = Talent::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")
- //->leftJoin("(select mainId,last_state,new_state,state,createTime,row_number() over (partition by mainId order by createTime desc) as rowIndex from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null) tl", "tl.mainId=ti.id and tl.rowIndex=1")
- ->where($where)->where($whereRaw)->count();
- $list = Talent::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")
- //->leftJoin("(select mainId,last_state,new_state,state,createTime,row_number() over (partition by mainId order by createTime desc) as rowIndex from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null) tl", "tl.mainId=ti.id and tl.rowIndex=1")
- ->where($where)->where($whereRaw)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId")->select()->toArray();
- }
- $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
- foreach ($list as &$item) {
- $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
- $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
- $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
- $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
- $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
- //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
- //$item["lastState"] = $last_log["last_state"];
- //$item["realState"] = $last_log["state"];
- }unset($item);
- return ["total" => $count, "rows" => $list];
- }
- public static function getExportDatas($process, $params) {
- $where[] = [];
- //特殊字段处理
- $exportFields = $params["export"];
- $fields = [];
- foreach ($exportFields as $field) {
- if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg", "breakFaithName", "activeName"])) {
- $fields[] = "ti." . $field;
- }
- }
- $fields[] = "e.name as enterpriseName";
- $fields[] = "e.industryFieldNew";
- $fields[] = "e.enterpriseTag";
- $fields[] = "e.street";
- $fields[] = "tc.talentLevelCat";
- $fields[] = "tl.description as checkMsg";
- $fields[] = "tc.name as talentConditionName";
- $fields[] = "tl.description as checkMsg";
- $fields[] = "if(ti.break_faith=1,'是','否') as breakFaithName";
- $fields[] = "if(ti.active=2,'离职','在职') as activeName";
- if (in_array("card_type", $exportFields)) {
- $cardTypes = DictApi::selectByParentCode("card_type");
- }
- if (in_array("industryFieldNew", $exportFields)) {
- $industry_fields = DictApi::selectByParentCode("industry_field");
- }
- if (in_array("enterpriseTag", $exportFields)) {
- $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
- }
- if (in_array("street", $exportFields)) {
- $streets = DictApi::selectByParentCode("street");
- }
- if (in_array("nation", $exportFields)) {
- $nations = DictApi::selectByParentCode("nation");
- }
- if (in_array("nationality", $exportFields)) {
- $nationalitys = DictApi::selectByParentCode("nationality");
- }
- if (in_array("politics", $exportFields)) {
- $politics = DictApi::selectByParentCode("politics");
- }
- if (in_array("talent_type", $exportFields)) {
- $talentTypes = DictApi::selectByParentCode("talent_type");
- }
- if (in_array("talent_arrange_category", $exportFields)) {
- $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
- }
- if (in_array("highest_degree", $exportFields)) {
- $highest_degree = DictApi::selectByParentCode("highest_degree");
- }
- if (in_array("import_way", $exportFields)) {
- $import_way = DictApi::selectByParentCode("import_way");
- }
- if (in_array("source", $exportFields)) {
- $source = DictApi::selectByParentCode("source");
- }
- if (in_array("source_city", $exportFields)) {
- $source_city = DictApi::selectByParentCode("source_city");
- }
- if (in_array("source_county", $exportFields)) {
- $source_county = DictApi::selectByParentCode("source_county");
- }
- if (in_array("talent_arrange", $exportFields)) {
- $talent_arrange = DictApi::selectByParentCode("talent_arrange");
- }
- $sex = [1 => "男", 2 => "女"];
- $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
- $study_abroad = [1 => "是", 2 => "否"];
- $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
- $return = [1 => "是", 2 => "否"];
- $isMatchZhiren = [0 => "否", 1 => "是"];
- $where = [];
- $whereRaw = "";
- $user = session("user");
- if ($user["usertype"] == 1) {
- $where[] = ["e.type", "=", $user["type"]];
- } else if ($user["usertype"] == 2) {
- $where[] = ["e.id", "=", $user["uid"]];
- } else {
-
- }
- if ($params["all"] != 1) {
- if ($params["name"]) {
- $where[] = ["ti.name", "like", "%{$params["name"]}%"];
- }
- if ($params["card_number"]) {
- $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
- }
- if ($params["sex"]) {
- $where[] = ["ti.sex", "=", $params["sex"]];
- }
- if ($params["nation"]) {
- $where[] = ["ti.nation", "=", $params["nation"]];
- }
- if ($params["apply_year"]) {
- $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
- }
- if ($params["phone"]) {
- $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
- }
- if ($params["email"]) {
- $where[] = ["ti.email", "like", "%{$params["email"]}%"];
- }
- if ($params["nationality"]) {
- $where[] = ["ti.nationality", "=", $params["nationality"]];
- }
- if ($params["province"]) {
- $where[] = ["ti.province", "=", $params["province"]];
- }
- if ($params["politics"]) {
- $where[] = ["ti.politics", "=", $params["politics"]];
- }
- if ($params["enterprise_id"]) {
- $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
- }
- if ($params["street"]) {
- $where[] = ["e.street", "=", $params["street"]];
- }
- if ($params["industry_field"]) {
- $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
- }
- if ($params["industry_field_old"]) {
- $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
- }
- if ($params["enterprise_tag"]) {
- $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
- }
- if ($params["talent_type"]) {
- $where[] = ["ti.talent_type", "=", $params["talent_type"]];
- }
- if ($params["import_way"]) {
- $where[] = ["ti.import_way", "=", $params["import_way"]];
- }
- if ($params["highest_degree"]) {
- $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
- }
- if ($params["study_abroad"]) {
- $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
- }
- if ($params["source"]) {
- $where[] = ["ti.source", "=", $params["source"]];
- }
- if ($params["talent_arrange"]) {
- $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
- }
- if ($params["talent_condition"]) {
- $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
- }
- if ($params["isMatchZhiren"]) {
- $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
- $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
- }
- if ($params["active"]) {
- $where[] = ["ti.active", "=", $params["active"]];
- }
- if ($params["breakFaith"]) {
- $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
- }
- if ($params["company_id"]) {
- $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
- }
- switch ($process) {
- case 1:
- $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
- break;
- case 2:
- $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
- break;
- case 3:
- switch ($params["checkState"]) {
- case 1://保存未提交
- $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
- $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
- $where[] = ["ti.delete", "=", 0];
- break;
- case 2://初审驳回
- $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
- break;
- case 3://待初审(首次提交)
- $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
- $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
- break;
- case 4://待初审(重新提交)
- $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
- $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
- break;
- case 5://待初审(部门并审驳回)
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
- break;
- case 6://待初审(复审驳回)
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
- break;
- case 7://初审通过(待部门并审)
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- break;
- case 8://初审通过(待复审)
- $where[] = ["ti.pass_dept_check", "=", 1];
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- break;
- case 9://初审不通过
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
- break;
- default:
- if ($user["type"] == 2) {
- $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT,
- TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
- $where[] = ["ti.delete", "=", 0];
- } else {
- $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
- TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
- $where[] = ["ti.delete", "=", 0];
- }
- }
- break;
- case 4:
- $companyId = session('user')['companyId'];
- $company_info = CompanyApi::getOne($companyId);
- if (self::chkUserInSuperDeptUsers()) {
- switch ($params["checkState"]) {
- case 1:
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- break;
- case 2:
- $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- $where[] = ["ti.pass_dept_check", "=", 0];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- break;
- case 3:
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
- break;
- case 4:
- $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
- break;
- default:
- $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
- break;
- }
- } else {
- switch ($params["checkState"]) {
- case 1://待部门并审(首次提交)
- //$where[] = ["tl.active", "=", 0];
- //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
- break;
- case 2://待部门并审(重新提交)
- //$where[] = ["tl.active", "=", 0];
- //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
- //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
- break;
- case 3://部门并审通过
- $where[] = ["tl.active", "=", 1];
- $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
- break;
- case 4://部门并审驳回
- $where[] = ["tl.active", "=", 1];
- $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
- break;
- default:
- $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
- break;
- }
- }
- break;
- case 5:
- $whereRaw = sprintf("(tl.state in (-14,14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
- switch ($params["checkState"]) {
- case 1://待复审(首次提交)
- $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
- break;
- case 2://待复审(重新提交)
- $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
- break;
- case 3://复审通过
- $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
- break;
- case 4://复审驳回
- $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
- break;
- case 5://复审不通过
- $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
- break;
- }
- break;
- case 6:
- $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
- if ($params["checkState"]) {
- $where[] = ["tl.state", "=", $params["checkState"]];
- }
- break;
- case 7:
- $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
- break;
- }
- } else {
- $whereRaw = "tl.state is not null";
- $where[] = ["ti.delete", "=", 0];
- }
- $fields[] = "ti.id";
- $fields[] = "ti.pass_dept_check";
- $fields[] = "tl.state";
- $fields[] = "tl.new_state";
- $fields[] = "tl.last_state";
- $fields[] = "tc.companyIds";
- if ($process == 4) {
- $fields[] = "tl2.resubmit";
- if (self::chkUserInSuperDeptUsers()) {
- $fields[] = "tl3.deptVerifyJsonData";
- $list = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("(select mainId,description,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")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->leftJoin("(select mainId,JSON_ARRAYAGG(JSON_OBJECT('companyId',companyId,'active',`active`,'description',`description`,'new_state',`new_state`,'createTime',unix_timestamp(`createTime`))) as deptVerifyJsonData from new_talent_checklog where `step`=3 and `type`=1 group by mainId) as tl3", "tl3.mainId=ti.`id`")
- ->where($where)
- ->where($whereRaw)
- ->field($fields)
- ->select()->toArray();
- } else {
- $fields[] = "tl.active";
- $fields[] = "if(tl.new_state,tl.new_state,10) as deptCheckState";
- $fields[] = "tl.createTime as first_dept_check_time";
- $list = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("(select mainId,active,description,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
- ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
- ->where($where)
- ->where($whereRaw)
- ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
- ->field($fields)
- ->select()->toArray();
- }
- } else if ($process == 5) {
- $fields[] = "tl2.resubmit";
- $list = Talent::alias("ti")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("(select description,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")
- ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
- ->where($whereRaw)
- ->where($where)
- ->field($fields)
- ->select()->toArray();
- } else {
- $list = Talent::alias("ti")
- ->field($fields)
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("(select description,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")
- //->leftJoin("new_talent_checklog tl", "tl.mainId=ti.id and tl.id=(select id from new_talent_checklog where mainId=ti.id and `step` is null and active=1 and typeFileId is null order by createTime desc limit 1)")
- ->where($where)
- ->where($whereRaw)
- ->select()->toArray();
- }
- $un_common_location = Db::table("un_common_location")->column('name', 'code');
- foreach ($list as &$item) {
- $item["card_type"] = $cardTypes[$item["card_type"]];
- $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
- $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
- $item["street"] = $streets[$item["street"]];
- $item["nation"] = $nations[$item["nation"]];
- $item["nationality"] = $nationalitys[$item["nationality"]];
- $item["politics"] = $politics[$item["politics"]];
- $item["talent_type"] = $talentTypes[$item["talent_type"]];
- $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
- $item["sex"] = $sex[$item["sex"]];
- $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
- $item["import_way"] = $import_way[$item["import_way"]];
- $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
- $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
- $item["return"] = $return[$item["return"]];
- $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
- $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
- $item["source"] = $source[$item["source"]];
- $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
- $item["talent_condition"] = $item["checkState"] == TalentState::CERTIFICATED && !$item["talent_condition"] ? "积分认定" : $item["talentConditionName"];
- if (in_array("source_city", $exportFields)) {
- $item["source_city"] = $un_common_location[$item["source_city"]];
- }
- if (in_array("source_county", $exportFields)) {
- $item["source_county"] = $un_common_location[$item["source_county"]];
- }
- if (in_array("province", $exportFields)) {
- $item["province"] = $un_common_location[$item["province"]];
- }
- if (in_array("city", $exportFields)) {
- $item["city"] = $un_common_location[$item["city"]];
- }
- if (in_array("county", $exportFields)) {
- $item["county"] = $un_common_location[$item["county"]];
- }
- if ($item["state"] == TalentState::SCND_SUBMIT) {
- if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
- $item["checkState"] = "待初审(重新提交)";
- } else {
- $item["checkState"] = "待初审(首次提交)";
- }
- } else if ($item["state"] == TalentState::FST_VERIFY_PASS || (!$item["state"] && $item["deptCheckState"])) {
- if ($item["deptCheckState"]) {
- if (($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) || !$item["active"]) {
- if ($item["resubmit"]) {
- $item["checkState"] = "待部门并审(重新提交)";
- } else {
- $item["checkState"] = "待部门并审(首次提交)";
- }
- }
- if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
- $item["checkState"] = "部门并审通过";
- }
- if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
- $item["checkState"] = "部门并审驳回";
- }
- } else {
- if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
- if ($process == 3) {
- $item["checkState"] = "初审通过(待复审)";
- } else {
- if ($item["resubmit"]) {
- $item["checkState"] = "待复审(重新提交)";
- } else {
- $item["checkState"] = "待复审(首次提交)";
- }
- }
- }
- if ($item["pass_dept_check"] == 0) {
- if ($process == 3) {
- $item["checkState"] = "初审通过(待部门并审)";
- } else {
- if ($item["resubmit"]) {
- $item["checkState"] = "待部门并审(重新提交)";
- } else {
- $item["checkState"] = "待部门并审(首次提交)";
- }
- }
- }
- }
- } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
- if ($process == 3) {
- $item["checkState"] = "待初审(部门并审驳回)";
- } else {
- $item["checkState"] = "部门并审驳回";
- }
- } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
- if ($process == 3) {
- $item["checkState"] = "待复审(部门并审通过)";
- } else if ($process == 4) {
- $item["checkState"] = "部门并审通过";
- } else {
- if ($item["resubmit"]) {
- $item["checkState"] = "待复审(重新提交)";
- } else {
- $item["checkState"] = "待复审(首次提交)";
- }
- }
- } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
- if ($process == 3) {
- $item["checkState"] = "待初审(复审驳回)";
- } else {
- $item["checkState"] = "复审驳回";
- }
- } else {
- $item["checkState"] = TalentState::getStateName($item["state"]);
- }
- if ($process == 4) {
- if (self::chkUserInSuperDeptUsers()) {
- $companys = array_filter(explode(",", $item["companyIds"]));
- $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
- $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
- $verifyDepts = [];
- $item["deptReject"] = 0;
- $item["deptPass"] = 0;
- $item["deptWait"] = 0;
- $deptDescriptions = [];
- foreach ($companys as $k => $companyId) {
- $company = getCacheById("Company", $companyId);
- //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
- $i = 0;
- while ($log = $deptChecklogs[$i]) {
- if ($log["companyId"] == $companyId) {
- break;
- } else {
- $log = null;
- }
- $i++;
- }
- $item["first_dept_check_time"] = date("Y-m-d H:i:s", $log["createTime"]);
- $verifyDepts[$k] = $company["name"];
- if ($log["active"] == 1) {
- if ($log["new_state"] == 9) {
- $verifyDepts[$k] .= "(审核驳回)";
- $item["deptReject"] ++;
- }
- if ($log["new_state"] == 12) {
- $verifyDepts[$k] .= "(审核通过)";
- $item["deptPass"] ++;
- }
- $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
- } else {
- if (!$log && in_array($item["state"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT])) {
- unset($verifyDepts[$k]);
- continue;
- }
- $verifyDepts[$k] .= "(待审核)";
- $item["deptWait"] ++;
- }
- }
- $item["verifyDepts"] = implode(chr(10), $verifyDepts);
- $item["deptDescription"] = implode(chr(10), $deptDescriptions);
- } else {
- $item["checkMsg"] = $item["active"] == 1 ? $item["checkMsg"] : "等待部门审核";
- }
- }
- }unset($item);
- return $list;
- }
- public static function getListByProcess($params) {
- $process = $params["process"];
- $type = session("user")["type"];
- $where[] = ["e.type", "=", $type];
- if ($params["name"]) {
- $where[] = ["ti.name", "like", "%{$params["name"]}%"];
- }
- if ($params["card_number"]) {
- $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
- }
- if ($params["sex"]) {
- $where[] = ["ti.sex", "=", $params["sex"]];
- }
- if ($params["nation"]) {
- $where[] = ["ti.nation", "=", $params["nation"]];
- }
- if ($params["apply_year"]) {
- $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
- }
- if ($params["phone"]) {
- $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
- }
- if ($params["email"]) {
- $where[] = ["ti.email", "like", "%{$params["email"]}%"];
- }
- if ($params["nationality"]) {
- $where[] = ["ti.nationality", "=", $params["nationality"]];
- }
- if ($params["province"]) {
- $where[] = ["ti.province", "=", $params["province"]];
- }
- if ($params["politics"]) {
- $where[] = ["ti.politics", "=", $params["politics"]];
- }
- if ($params["enterprise_id"]) {
- $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
- }
- if ($params["medicalCommunityId"]) {
- $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
- }
- if ($params["isGeneral"]) {
- $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
- }
- if ($params["street"]) {
- $where[] = ["e.street", "=", $params["street"]];
- }
- if ($params["industry_field"]) {
- $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
- }
- if ($params["industry_field_old"]) {
- $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
- }
- if ($params["enterprise_tag"]) {
- $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
- }
- if ($params["talent_type"]) {
- $where[] = ["ti.talent_type", "=", $params["talent_type"]];
- }
- if ($params["import_way"]) {
- $where[] = ["ti.import_way", "=", $params["import_way"]];
- }
- if ($params["highest_degree"]) {
- $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
- }
- if ($params["study_abroad"]) {
- $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
- }
- if ($params["source"]) {
- $where[] = ["ti.source", "=", $params["source"]];
- }
- if ($params["talent_arrange"]) {
- $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
- }
- if ($params["talent_condition"]) {
- $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
- }
- if ($params["isMatchZhiren"]) {
- $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
- $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
- }
- if ($params["active"]) {
- $where[] = ["ti.active", "=", $params["active"]];
- }
- if ($params["breakFaith"]) {
- $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
- }
- switch ($process) {
- case 1:
- $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
- break;
- case 2:
- $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
- break;
- case 3:
- $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
- break;
- default:
- return null;
- }
- return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
- }
- public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
- $data["id"] = $mainId;
- $data["checkState"] = $state;
- switch ($state) {
- case TalentState::ZX_PASS:
- case TalentState::ZX_FAIL:
- $data["isPublic"] = 2;
- break;
- case TalentState::ANNOUNCED:
- $data["isPublic"] = 3;
- $data["publicBatch"] = $batch;
- break;
- case TalentState::ANNOUNCED_REVERIFY_PASS:
- case TalentState::ANNOUNCED_REVERIFY_FAIL:
- $data["isPublic"] = 3;
- break;
- case TalentState::PUBLISH_PASS:
- $data["isPublic"] = 4;
- $data["identifyMonth"] = $batch;
- $data["certificateGetTime"] = $batch; //时间待定
- $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
- break;
- case TalentState::PUBLISH_FAIL:
- $data["isPublic"] = 4;
- break;
- }
- if (Talent::update($data)) {
- TalentLogApi::write($type, $mainId, $state, $msg, 1);
- return true;
- }
- return false;
- }
- public static function setEffect($mainId, $effect, $log) {
- $data["id"] = $mainId;
- $data["isEffect"] = $effect;
- if (Talent::update($data)) {
- $user = session("user");
- $log["id"] = getStringId();
- $log["type"] = \app\common\state\ProjectState::TALENT;
- $log["mainId"] = $mainId;
- if ($user) {
- $log["companyId"] = $user["companyId"];
- }
- $log["active"] = $log["active"] ?: 0;
- $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
- $log["createTime"] = date("Y-m-d H:i:s");
- if ($effect == 1) {
- $log["step"] = 65;
- } else {
- $log["step"] = 60;
- }
- \app\common\model\TalentLog::create($log);
- return true;
- }
- return false;
- }
- private static function getSuperPrivsForDeptVerify() {
- $config = getJsonConfig("../sys_config.json", "super_privs_for_dept_verify");
- return $config;
- }
- public static function chkUserInSuperDeptUsers() {
- $config = self::getSuperPrivsForDeptVerify();
- $companyId = session("user")["companyId"];
- $company = getCacheById("Company", $companyId);
- $account = session("user")["account"];
- return in_array($company["code"], $config["companys"]) || in_array($account, $config["users"]);
- }
- }
|