VerifyApi.php 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. <?php
  2. namespace app\common\api;
  3. use app\admin\model\Notice as NoticeModel;
  4. use app\enterprise\model\Talent;
  5. use app\common\api\DictApi;
  6. use app\admin\model\Enterprise;
  7. use think\facade\Db;
  8. use app\common\model\TalentCondition;
  9. /**
  10. * Description of VerifyApi
  11. *
  12. * @author sgq
  13. */
  14. class VerifyApi {
  15. public static function getTalentInfoById($id, $isAdmin = false) {//添加admin只为区别导入数据管理端的显示差异
  16. $info = self::getOne($id);
  17. if ($info) {
  18. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  19. $info["enterpriseName"] = $enterprise["name"];
  20. $info["enterpriseAddress"] = $enterprise["address"];
  21. $info["enterpriseId"] = $enterprise["id"];
  22. $info["enterpriseType"] = $enterprise["type"];
  23. $info["enterpriseEphone"] = $enterprise["ephone"];
  24. $info["enterpriseTag"] = $enterprise["enterpriseTag"];
  25. $info["enterpriseBankCard"] = $enterprise["bankCard"];
  26. $info["enterpriseBankNetwork"] = $enterprise["bankNetwork"];
  27. $info["enterpriseBank"] = $enterprise["bank"];
  28. $info["isGeneral"] = $enterprise["isGeneral"];
  29. $info["medicalCommunityName"] = \app\common\api\Nhc::getMedicalCommunityMap()[$enterprise["medicalCommunityId"]];
  30. if ($info["talent_type"]) {
  31. if ($enterprise["type"] == \app\common\state\CommonConst::ENTERPRISE_WJ) {
  32. $info["talentTypeName"] = DictApi::selectByParentCode("wj_talent_type")[$info["talent_type"]];
  33. } else {
  34. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  35. }
  36. }
  37. if ($info["nationality"]) {
  38. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  39. }
  40. if ($info["nation"]) {
  41. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  42. }
  43. if ($info["politics"]) {
  44. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  45. }
  46. if ($info["province"]) {
  47. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  48. }
  49. if ($info["city"]) {
  50. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  51. }
  52. if ($info["county"]) {
  53. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  54. }
  55. if ($enterprise["street"]) {
  56. $info["street"] = $enterprise["street"];
  57. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  58. }
  59. if ($enterprise["industryFieldNew"]) {
  60. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  61. }
  62. if ($enterprise["enterpriseTag"]) {
  63. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  64. }
  65. if ($info["talent_arrange"]) {
  66. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  67. }
  68. if ($info["import_way"]) {
  69. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  70. }
  71. if ($info["source"]) {
  72. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  73. }
  74. if ($info["source_city"]) {
  75. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  76. }
  77. if ($info["source_county"]) {
  78. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  79. }
  80. if ($info["highest_degree"]) {
  81. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  82. }
  83. if ($info["labor_contract_rangetime"]) {
  84. list($startTime, $endTime) = explode(" - ", $info["labor_contract_rangetime"]);
  85. $info["startTime"] = $startTime;
  86. $info["endTime"] = $endTime;
  87. }
  88. if ($info["qz_talent_info"]) {
  89. $qz_talent_info = explode(";", $info["qz_talent_info"]);
  90. list($tmp1, $timeStart) = explode(":", $qz_talent_info[1]);
  91. list($tmp2, $timeEnd) = explode(":", $qz_talent_info[2]);
  92. if (strtotime($timeStart)) {
  93. $tmp_time = date("Y-m-d", strtotime($timeStart));
  94. $qz_talent_info[1] = implode(":", [$tmp1, $tmp_time]);
  95. if ($isAdmin) {
  96. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  97. if ($batch_info) {
  98. $qz_talent_info[1] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $qz_talent_info[1] . "</a>";
  99. }
  100. }
  101. }
  102. if (strtotime($timeEnd)) {
  103. $qz_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($timeEnd))]);
  104. }
  105. $info["qz_talent_info"] = implode(";", $qz_talent_info);
  106. }
  107. if ($info["fj_talent_info"]) {
  108. $fj_talent_info = explode(";", $info["fj_talent_info"]);
  109. list($tmp1, $timeStart) = explode(":", $fj_talent_info[0]);
  110. list($tmp2, $validYear) = explode(":", $fj_talent_info[2]);
  111. $timeStart = str_replace(["."], "-", $timeStart);
  112. if (strtotime($timeStart)) {
  113. $tmp_time = date("Y-m-d", strtotime($timeStart));
  114. $fj_talent_info[0] = implode(":", [$tmp1, $tmp_time]);
  115. if ($isAdmin) {
  116. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  117. if ($batch_info) {
  118. $fj_talent_info[0] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $fj_talent_info[0] . "</a>";
  119. }
  120. }
  121. if (strtotime($validYear)) {
  122. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($validYear))]);
  123. } else {
  124. $validval = intval($validYear);
  125. if ($validYear > 0) {
  126. $timestr = str_replace($validval, "", $validYear);
  127. switch ($timestr) {
  128. case "月":
  129. $timetype = "months";
  130. break;
  131. case "日":
  132. $timetype = "days";
  133. break;
  134. default:
  135. $timetype = "years";
  136. break;
  137. }
  138. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime("+{$validval} {$timetype} -1 days", strtotime($timeStart)))]);
  139. }
  140. }
  141. }
  142. $info["fj_talent_info"] = implode(";", $fj_talent_info);
  143. }
  144. if ($info["talent_condition"]) {
  145. $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
  146. $info["talentConditionName"] = $talent_condition["name"];
  147. $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
  148. $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
  149. }
  150. }
  151. return $info;
  152. }
  153. public static function getOne($id) {
  154. return Talent::findOrEmpty($id)->toArray();
  155. }
  156. /**
  157. * 获得新的需要重审的部门集合(如果$oriReCheckCompanyIds为空,返回认定条件审核部门集合$talentConditionCompanyIds)
  158. * @param type $oriReCheckCompanyIds 原来的需要再审核的部门id集合
  159. * @param type $talentConditionCompanyIds 认定条件中的审核部门id集合
  160. * @param type $passedCompanyIds 已经通过审核的部门id集合
  161. * @return type
  162. */
  163. public static function getNewReCheckCompanyIds($oriReCheckCompanyIds, $talentConditionCompanyIds, $passedCompanyIds) {
  164. if ($oriReCheckCompanyIds) {
  165. //$removeReCheckCompanyIds:获得再审核部门中已经被移除的集合(修改认定条件审核部门后,已经不再在列表中的部门Id集合)
  166. $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $talentConditionCompanyIds);
  167. //$reCheckCompanyIds:获得再审核部门中仍需审核的部门集合
  168. $reCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
  169. //$notInReCheckCompanyIds:不在重审列表里面的审核部门集合(这里面存在新增的审核部门)
  170. $notInReCheckCompanyIds = array_diff($talentConditionCompanyIds, $reCheckCompanyIds);
  171. //$needReCheckCompanyIds:找出不在重审列表里面并且没有在已审核通过的列表中的部门Id集合
  172. $needReCheckCompanyIds = array_diff($notInReCheckCompanyIds, $passedCompanyIds);
  173. //合并新的需要重审的部门集合
  174. $newReCheckCompanyIds = array_unique(array_merge($reCheckCompanyIds, $needReCheckCompanyIds));
  175. return $newReCheckCompanyIds;
  176. }
  177. return $talentConditionCompanyIds;
  178. }
  179. public static function getFullDeptList($params, $where = []) {
  180. $order = $params["order"] ?: "desc";
  181. $offset = $params["offset"] ?: 0;
  182. $limit = $params["limit"] ?: 10;
  183. $whereRaw = "";
  184. if ($params["company_id"]) {
  185. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  186. }
  187. switch ($params["checkState"]) {
  188. case 1://待部门并审(首次提交)
  189. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  190. $where[] = ["ti.pass_dept_check", "=", 0];
  191. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  192. break;
  193. case 2://待部门并审(重新提交)
  194. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  195. $where[] = ["ti.pass_dept_check", "=", 0];
  196. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  197. break;
  198. case 3://部门并审通过
  199. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  200. break;
  201. case 4://部门并审驳回
  202. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  203. break;
  204. default:
  205. $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);
  206. break;
  207. }
  208. $companyId = session("user")["companyId"];
  209. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  210. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  211. $count = Talent::alias("ti")
  212. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  213. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  214. ->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")
  215. ->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")
  216. ->where($where)
  217. ->where($whereRaw)->count();
  218. $list = Talent::alias("ti")
  219. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  220. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  221. ->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")
  222. ->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")
  223. ->where($where)
  224. ->where($whereRaw)
  225. ->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")
  226. ->limit($offset, $limit)->order("ti.createTime " . $order)
  227. ->select()->toArray();
  228. foreach ($list as &$item) {
  229. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  230. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  231. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  232. $companys = array_filter(explode(",", $item["companyIds"]));
  233. $verifyDepts = [];
  234. foreach ($companys as $k => $companyId) {
  235. $company = getCacheById("Company", $companyId);
  236. $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  237. if (!$log && in_array($item["realState"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT]))
  238. continue;
  239. $verifyDepts[$k]["id"] = $companyId;
  240. $verifyDepts[$k]["shortName"] = $company["shortName"];
  241. $verifyDepts[$k]["name"] = $company["name"];
  242. $verifyDepts[$k]["code"] = $company["code"];
  243. $verifyDepts[$k]["checkState"] = $log["new_state"];
  244. $verifyDepts[$k]["active"] = $log["active"];
  245. }
  246. $item["verifyDepts"] = $verifyDepts;
  247. }unset($item);
  248. return ["total" => $count, "rows" => $list];
  249. }
  250. public static function getDeptList($params, $where = []) {
  251. $order = $params["order"] ?: "desc";
  252. $offset = $params["offset"] ?: 0;
  253. $limit = $params["limit"] ?: 10;
  254. $companyId = session("user")["companyId"];
  255. $whereRaw = "";
  256. switch ($params["checkState"]) {
  257. case 1://待部门并审(首次提交)
  258. //$where[] = ["tl.active", "=", 0];
  259. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  260. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  261. $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);
  262. break;
  263. case 2://待部门并审(重新提交)
  264. //$where[] = ["tl.active", "=", 0];
  265. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  266. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  267. $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);
  268. break;
  269. case 3://部门并审通过
  270. $where[] = ["tl.active", "=", 1];
  271. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  272. break;
  273. case 4://部门并审驳回
  274. $where[] = ["tl.active", "=", 1];
  275. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  276. break;
  277. default:
  278. $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);
  279. break;
  280. }
  281. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  282. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  283. $count = Talent::alias("ti")
  284. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  285. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  286. ->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")
  287. ->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")
  288. ->where($where)
  289. ->where($whereRaw)
  290. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  291. $list = Talent::alias("ti")
  292. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  293. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  294. ->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")
  295. ->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")
  296. ->where($where)
  297. ->where($whereRaw)
  298. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  299. ->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")
  300. ->limit($offset, $limit)->order("ti.createTime " . $order)
  301. ->select()->toArray();
  302. $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
  303. foreach ($list as &$item) {
  304. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  305. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  306. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  307. $item["deptCheckState"] = $lastCheckLog["new_state"] ?: TalentState::FST_VERIFY_PASS;
  308. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  309. $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
  310. }unset($item);
  311. return ["total" => $count, "rows" => $list];
  312. }
  313. public static function getPublicList($params) {
  314. $order = $params["order"];
  315. $offset = $params["offset"];
  316. $limit = $params["limit"];
  317. $where = [];
  318. $where[] = ["e.type", "=", session("user")["type"]];
  319. if ($params["name"]) {
  320. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  321. }
  322. if ($params["sex"]) {
  323. $where[] = ["ti.sex", "=", $params["sex"]];
  324. }
  325. if ($params["checkState"]) {
  326. $where[] = ["ti.checkState", "=", $params["checkState"]];
  327. }
  328. $type = $params["type"];
  329. switch ($type) {
  330. case 1:
  331. case 2:
  332. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  333. break;
  334. case 3: //公示
  335. case 7: //公示预览
  336. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  337. break;
  338. case 4: //公示通过
  339. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  340. break;
  341. case 5:
  342. case 8: //公布预览
  343. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  344. break;
  345. case 6:
  346. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  347. break;
  348. }
  349. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  350. //$count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  351. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  352. ->where($where)
  353. //->limit($offset, $limit)
  354. ->order("ti.createTime " . $order)
  355. ->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  356. foreach ($list as &$item) {
  357. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  358. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  359. }unset($item);
  360. return $list;
  361. }
  362. public static function getListByIds($ids) {
  363. $where[] = ["id", "in", $ids];
  364. return Talent::where($where)->select()->toArray();
  365. }
  366. public static function getList($params) {
  367. $where = [];
  368. $order = $params["order"] ?: "desc";
  369. $offset = $params["offset"] ?: 0;
  370. $limit = $params["limit"] ?: 10;
  371. $type = session("user")["type"];
  372. $where[] = ["e.type", "=", $type];
  373. if ($params["name"]) {
  374. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  375. }
  376. if ($params["card_number"]) {
  377. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  378. }
  379. if ($params["sex"]) {
  380. $where[] = ["ti.sex", "=", $params["sex"]];
  381. }
  382. if ($params["nation"]) {
  383. $where[] = ["ti.nation", "=", $params["nation"]];
  384. }
  385. if ($params["apply_year"]) {
  386. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  387. }
  388. if ($params["phone"]) {
  389. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  390. }
  391. if ($params["email"]) {
  392. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  393. }
  394. if ($params["nationality"]) {
  395. $where[] = ["ti.nationality", "=", $params["nationality"]];
  396. }
  397. if ($params["province"]) {
  398. $where[] = ["ti.province", "=", $params["province"]];
  399. }
  400. if ($params["politics"]) {
  401. $where[] = ["ti.politics", "=", $params["politics"]];
  402. }
  403. if ($params["enterprise_id"]) {
  404. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  405. }
  406. if ($params["medicalCommunityId"]) {
  407. $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
  408. }
  409. if ($params["isGeneral"]) {
  410. $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
  411. }
  412. if ($params["street"]) {
  413. $where[] = ["e.street", "=", $params["street"]];
  414. }
  415. if ($params["industry_field"]) {
  416. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  417. }
  418. if ($params["industry_field_old"]) {
  419. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  420. }
  421. if ($params["enterprise_tag"]) {
  422. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  423. }
  424. if ($params["talent_type"]) {
  425. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  426. }
  427. if ($params["import_way"]) {
  428. $where[] = ["ti.import_way", "=", $params["import_way"]];
  429. }
  430. if ($params["highest_degree"]) {
  431. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  432. }
  433. if ($params["study_abroad"]) {
  434. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  435. }
  436. if ($params["source"]) {
  437. $where[] = ["ti.source", "=", $params["source"]];
  438. }
  439. if ($params["talent_arrange"]) {
  440. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  441. }
  442. if ($params["talent_condition"]) {
  443. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  444. }
  445. if ($params["isMatchZhiren"]) {
  446. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  447. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  448. }
  449. if ($params["active"]) {
  450. $where[] = ["ti.active", "=", $params["active"]];
  451. }
  452. if ($params["breakFaith"]) {
  453. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  454. }
  455. $process = $params["process"];
  456. if ($process == 4) {
  457. if (self::chkUserInSuperDeptUsers()) {
  458. return self::getFullDeptList($params, $where);
  459. } else {
  460. return self::getDeptList($params, $where);
  461. }
  462. }
  463. if ($process == 5) {
  464. $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 = ''))");
  465. switch ($params["checkState"]) {
  466. case 1://待复审(首次提交)
  467. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  468. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  469. break;
  470. case 2://待复审(重新提交)
  471. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  472. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  473. break;
  474. case 3://复审通过
  475. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  476. break;
  477. case 4://复审驳回
  478. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  479. break;
  480. case 5://复审不通过
  481. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  482. break;
  483. default:
  484. if ($type == 2) {
  485. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  486. }
  487. break;
  488. }
  489. $count = Talent::alias("ti")
  490. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  491. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  492. ->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")
  493. ->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")
  494. ->whereRaw($whereRaw)->where($where)->count();
  495. $list = Talent::alias("ti")
  496. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  497. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  498. ->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")
  499. ->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")
  500. ->whereRaw($whereRaw)
  501. ->where($where)
  502. ->limit($offset, $limit)
  503. ->order("ti.createTime " . $order)
  504. ->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")
  505. ->select()->toArray();
  506. } else {
  507. switch ($process) {
  508. case 1:
  509. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  510. break;
  511. case 2:
  512. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  513. break;
  514. case 3:
  515. switch ($params["checkState"]) {
  516. case 1://保存未提交
  517. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  518. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  519. $where[] = ["ti.delete", "=", 0];
  520. break;
  521. case 2://初审驳回
  522. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  523. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  524. $where[] = ["ti.delete", "=", 0];
  525. break;
  526. case 3://待初审(首次提交)
  527. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  528. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  529. $where[] = ["ti.delete", "=", 0];
  530. break;
  531. case 4://待初审(重新提交)
  532. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  533. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  534. $where[] = ["ti.delete", "=", 0];
  535. break;
  536. case 5://待初审(部门并审驳回)
  537. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  538. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  539. $where[] = ["ti.delete", "=", 0];
  540. break;
  541. case 6://待初审(复审驳回)
  542. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  543. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  544. $where[] = ["ti.delete", "=", 0];
  545. break;
  546. case 7://初审通过(待部门并审)
  547. $where[] = ["ti.pass_dept_check", "=", 0];
  548. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  549. $where[] = ["ti.delete", "=", 0];
  550. break;
  551. case 8://初审通过(待复审)
  552. $where[] = ["ti.pass_dept_check", "=", 1];
  553. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  554. $where[] = ["ti.delete", "=", 0];
  555. break;
  556. case 9://初审不通过
  557. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  558. $where[] = ["ti.delete", "=", 0];
  559. break;
  560. default:
  561. //$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);
  562. if ($type == 2) {
  563. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  564. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  565. $where[] = ["ti.delete", "=", 0];
  566. } else {
  567. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  568. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  569. $where[] = ["ti.delete", "=", 0];
  570. }
  571. }
  572. break;
  573. case 6:
  574. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  575. $where[] = ["tl.state", "not in", [TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL]];
  576. if ($params["checkState"]) {
  577. $where[] = ["tl.state", "=", $params["checkState"]];
  578. }
  579. break;
  580. case 7:
  581. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  582. break;
  583. }
  584. $count = Talent::alias("ti")
  585. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  586. ->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")
  587. //->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")
  588. ->where($where)->where($whereRaw)->count();
  589. $list = Talent::alias("ti")
  590. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  591. ->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")
  592. //->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")
  593. ->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();
  594. }
  595. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  596. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  597. $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
  598. foreach ($list as &$item) {
  599. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  600. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  601. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  602. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  603. $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
  604. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  605. //$item["lastState"] = $last_log["last_state"];
  606. //$item["realState"] = $last_log["state"];
  607. }unset($item);
  608. return ["total" => $count, "rows" => $list];
  609. }
  610. public static function getExportDatas($process, $params) {
  611. $where[] = [];
  612. //特殊字段处理
  613. $exportFields = $params["export"];
  614. $fields = [];
  615. foreach ($exportFields as $field) {
  616. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg", "breakFaithName", "activeName"])) {
  617. $fields[] = "ti." . $field;
  618. }
  619. }
  620. $fields[] = "e.name as enterpriseName";
  621. $fields[] = "e.industryFieldNew";
  622. $fields[] = "e.enterpriseTag";
  623. $fields[] = "e.street";
  624. $fields[] = "tc.talentLevelCat";
  625. $fields[] = "tl.description as checkMsg";
  626. $fields[] = "tc.name as talentConditionName";
  627. $fields[] = "tl.description as checkMsg";
  628. $fields[] = "if(ti.break_faith=1,'是','否') as breakFaithName";
  629. $fields[] = "if(ti.active=2,'离职','在职') as activeName";
  630. if (in_array("card_type", $exportFields)) {
  631. $cardTypes = DictApi::selectByParentCode("card_type");
  632. }
  633. if (in_array("industryFieldNew", $exportFields)) {
  634. $industry_fields = DictApi::selectByParentCode("industry_field");
  635. }
  636. if (in_array("enterpriseTag", $exportFields)) {
  637. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  638. }
  639. if (in_array("street", $exportFields)) {
  640. $streets = DictApi::selectByParentCode("street");
  641. }
  642. if (in_array("nation", $exportFields)) {
  643. $nations = DictApi::selectByParentCode("nation");
  644. }
  645. if (in_array("nationality", $exportFields)) {
  646. $nationalitys = DictApi::selectByParentCode("nationality");
  647. }
  648. if (in_array("politics", $exportFields)) {
  649. $politics = DictApi::selectByParentCode("politics");
  650. }
  651. if (in_array("talent_type", $exportFields)) {
  652. $talentTypes = DictApi::selectByParentCode("talent_type");
  653. }
  654. if (in_array("talent_arrange_category", $exportFields)) {
  655. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  656. }
  657. if (in_array("highest_degree", $exportFields)) {
  658. $highest_degree = DictApi::selectByParentCode("highest_degree");
  659. }
  660. if (in_array("import_way", $exportFields)) {
  661. $import_way = DictApi::selectByParentCode("import_way");
  662. }
  663. if (in_array("source", $exportFields)) {
  664. $source = DictApi::selectByParentCode("source");
  665. }
  666. if (in_array("source_city", $exportFields)) {
  667. $source_city = DictApi::selectByParentCode("source_city");
  668. }
  669. if (in_array("source_county", $exportFields)) {
  670. $source_county = DictApi::selectByParentCode("source_county");
  671. }
  672. if (in_array("talent_arrange", $exportFields)) {
  673. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  674. }
  675. $sex = [1 => "男", 2 => "女"];
  676. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  677. $study_abroad = [1 => "是", 2 => "否"];
  678. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  679. $return = [1 => "是", 2 => "否"];
  680. $isMatchZhiren = [0 => "否", 1 => "是"];
  681. $where = [];
  682. $whereRaw = "";
  683. $user = session("user");
  684. if ($user["usertype"] == 1) {
  685. $where[] = ["e.type", "=", $user["type"]];
  686. } else if ($user["usertype"] == 2) {
  687. $where[] = ["e.id", "=", $user["uid"]];
  688. } else {
  689. }
  690. if ($params["all"] != 1) {
  691. if ($params["name"]) {
  692. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  693. }
  694. if ($params["card_number"]) {
  695. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  696. }
  697. if ($params["sex"]) {
  698. $where[] = ["ti.sex", "=", $params["sex"]];
  699. }
  700. if ($params["nation"]) {
  701. $where[] = ["ti.nation", "=", $params["nation"]];
  702. }
  703. if ($params["apply_year"]) {
  704. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  705. }
  706. if ($params["phone"]) {
  707. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  708. }
  709. if ($params["email"]) {
  710. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  711. }
  712. if ($params["nationality"]) {
  713. $where[] = ["ti.nationality", "=", $params["nationality"]];
  714. }
  715. if ($params["province"]) {
  716. $where[] = ["ti.province", "=", $params["province"]];
  717. }
  718. if ($params["politics"]) {
  719. $where[] = ["ti.politics", "=", $params["politics"]];
  720. }
  721. if ($params["enterprise_id"]) {
  722. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  723. }
  724. if ($params["street"]) {
  725. $where[] = ["e.street", "=", $params["street"]];
  726. }
  727. if ($params["industry_field"]) {
  728. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  729. }
  730. if ($params["industry_field_old"]) {
  731. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  732. }
  733. if ($params["enterprise_tag"]) {
  734. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  735. }
  736. if ($params["talent_type"]) {
  737. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  738. }
  739. if ($params["import_way"]) {
  740. $where[] = ["ti.import_way", "=", $params["import_way"]];
  741. }
  742. if ($params["highest_degree"]) {
  743. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  744. }
  745. if ($params["study_abroad"]) {
  746. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  747. }
  748. if ($params["source"]) {
  749. $where[] = ["ti.source", "=", $params["source"]];
  750. }
  751. if ($params["talent_arrange"]) {
  752. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  753. }
  754. if ($params["talent_condition"]) {
  755. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  756. }
  757. if ($params["isMatchZhiren"]) {
  758. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  759. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  760. }
  761. if ($params["active"]) {
  762. $where[] = ["ti.active", "=", $params["active"]];
  763. }
  764. if ($params["breakFaith"]) {
  765. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  766. }
  767. if ($params["company_id"]) {
  768. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  769. }
  770. switch ($process) {
  771. case 1:
  772. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  773. break;
  774. case 2:
  775. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  776. break;
  777. case 3:
  778. switch ($params["checkState"]) {
  779. case 1://保存未提交
  780. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  781. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  782. $where[] = ["ti.delete", "=", 0];
  783. break;
  784. case 2://初审驳回
  785. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  786. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  787. break;
  788. case 3://待初审(首次提交)
  789. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  790. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  791. break;
  792. case 4://待初审(重新提交)
  793. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  794. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  795. break;
  796. case 5://待初审(部门并审驳回)
  797. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  798. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  799. break;
  800. case 6://待初审(复审驳回)
  801. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  802. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  803. break;
  804. case 7://初审通过(待部门并审)
  805. $where[] = ["ti.pass_dept_check", "=", 0];
  806. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  807. break;
  808. case 8://初审通过(待复审)
  809. $where[] = ["ti.pass_dept_check", "=", 1];
  810. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  811. break;
  812. case 9://初审不通过
  813. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  814. break;
  815. default:
  816. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  817. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  818. $where[] = ["ti.delete", "=", 0];
  819. }
  820. break;
  821. case 4:
  822. $companyId = session('user')['companyId'];
  823. $company_info = CompanyApi::getOne($companyId);
  824. if (self::chkUserInSuperDeptUsers()) {
  825. switch ($params["checkState"]) {
  826. case 1:
  827. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  828. $where[] = ["ti.pass_dept_check", "=", 0];
  829. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  830. break;
  831. case 2:
  832. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  833. $where[] = ["ti.pass_dept_check", "=", 0];
  834. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  835. break;
  836. case 3:
  837. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  838. break;
  839. case 4:
  840. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  841. break;
  842. default:
  843. $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);
  844. break;
  845. }
  846. } else {
  847. switch ($params["checkState"]) {
  848. case 1://待部门并审(首次提交)
  849. //$where[] = ["tl.active", "=", 0];
  850. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  851. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  852. $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);
  853. break;
  854. case 2://待部门并审(重新提交)
  855. //$where[] = ["tl.active", "=", 0];
  856. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  857. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  858. $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);
  859. break;
  860. case 3://部门并审通过
  861. $where[] = ["tl.active", "=", 1];
  862. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  863. break;
  864. case 4://部门并审驳回
  865. $where[] = ["tl.active", "=", 1];
  866. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  867. break;
  868. default:
  869. $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);
  870. break;
  871. }
  872. }
  873. break;
  874. case 5:
  875. $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 = ''))");
  876. switch ($params["checkState"]) {
  877. case 1://待复审(首次提交)
  878. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  879. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  880. break;
  881. case 2://待复审(重新提交)
  882. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  883. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  884. break;
  885. case 3://复审通过
  886. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  887. break;
  888. case 4://复审驳回
  889. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  890. break;
  891. case 5://复审不通过
  892. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  893. break;
  894. }
  895. break;
  896. case 6:
  897. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  898. if ($params["checkState"]) {
  899. $where[] = ["tl.state", "=", $params["checkState"]];
  900. }
  901. break;
  902. case 7:
  903. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  904. break;
  905. }
  906. } else {
  907. $whereRaw = "tl.state is not null";
  908. $where[] = ["ti.delete", "=", 0];
  909. }
  910. $fields[] = "ti.id";
  911. $fields[] = "ti.pass_dept_check";
  912. $fields[] = "tl.state";
  913. $fields[] = "tl.new_state";
  914. $fields[] = "tl.last_state";
  915. $fields[] = "tc.companyIds";
  916. if ($process == 4) {
  917. $fields[] = "tl2.resubmit";
  918. if (self::chkUserInSuperDeptUsers()) {
  919. $fields[] = "tl3.deptVerifyJsonData";
  920. $list = Talent::alias("ti")
  921. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  922. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  923. ->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")
  924. ->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")
  925. ->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`")
  926. ->where($where)
  927. ->where($whereRaw)
  928. ->field($fields)
  929. ->select()->toArray();
  930. } else {
  931. $fields[] = "tl.active";
  932. $fields[] = "if(tl.new_state,tl.new_state,10) as deptCheckState";
  933. $fields[] = "tl.createTime as first_dept_check_time";
  934. $list = Talent::alias("ti")
  935. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  936. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  937. ->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")
  938. ->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")
  939. ->where($where)
  940. ->where($whereRaw)
  941. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  942. ->field($fields)
  943. ->select()->toArray();
  944. }
  945. } else if ($process == 5) {
  946. $fields[] = "tl2.resubmit";
  947. $list = Talent::alias("ti")
  948. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  949. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  950. ->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")
  951. ->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")
  952. ->where($whereRaw)
  953. ->where($where)
  954. ->field($fields)
  955. ->select()->toArray();
  956. } else {
  957. $list = Talent::alias("ti")
  958. ->field($fields)
  959. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  960. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  961. ->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")
  962. //->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)")
  963. ->where($where)
  964. ->where($whereRaw)
  965. ->select()->toArray();
  966. }
  967. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  968. foreach ($list as &$item) {
  969. $item["card_type"] = $cardTypes[$item["card_type"]];
  970. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  971. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  972. $item["street"] = $streets[$item["street"]];
  973. $item["nation"] = $nations[$item["nation"]];
  974. $item["nationality"] = $nationalitys[$item["nationality"]];
  975. $item["politics"] = $politics[$item["politics"]];
  976. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  977. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  978. $item["sex"] = $sex[$item["sex"]];
  979. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  980. $item["import_way"] = $import_way[$item["import_way"]];
  981. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  982. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  983. $item["return"] = $return[$item["return"]];
  984. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  985. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  986. $item["source"] = $source[$item["source"]];
  987. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  988. $item["talent_condition"] = $item["checkState"] == TalentState::CERTIFICATED && !$item["talent_condition"] ? "积分认定" : $item["talentConditionName"];
  989. if (in_array("source_city", $exportFields)) {
  990. $item["source_city"] = $un_common_location[$item["source_city"]];
  991. }
  992. if (in_array("source_county", $exportFields)) {
  993. $item["source_county"] = $un_common_location[$item["source_county"]];
  994. }
  995. if (in_array("province", $exportFields)) {
  996. $item["province"] = $un_common_location[$item["province"]];
  997. }
  998. if (in_array("city", $exportFields)) {
  999. $item["city"] = $un_common_location[$item["city"]];
  1000. }
  1001. if (in_array("county", $exportFields)) {
  1002. $item["county"] = $un_common_location[$item["county"]];
  1003. }
  1004. if ($item["state"] == TalentState::SCND_SUBMIT) {
  1005. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  1006. $item["checkState"] = "待初审(重新提交)";
  1007. } else {
  1008. $item["checkState"] = "待初审(首次提交)";
  1009. }
  1010. } else if ($item["state"] == TalentState::FST_VERIFY_PASS || (!$item["state"] && $item["deptCheckState"])) {
  1011. if ($item["deptCheckState"]) {
  1012. if (($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) || !$item["active"]) {
  1013. if ($item["resubmit"]) {
  1014. $item["checkState"] = "待部门并审(重新提交)";
  1015. } else {
  1016. $item["checkState"] = "待部门并审(首次提交)";
  1017. }
  1018. }
  1019. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  1020. $item["checkState"] = "部门并审通过";
  1021. }
  1022. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  1023. $item["checkState"] = "部门并审驳回";
  1024. }
  1025. } else {
  1026. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  1027. if ($process == 3) {
  1028. $item["checkState"] = "初审通过(待复审)";
  1029. } else {
  1030. if ($item["resubmit"]) {
  1031. $item["checkState"] = "待复审(重新提交)";
  1032. } else {
  1033. $item["checkState"] = "待复审(首次提交)";
  1034. }
  1035. }
  1036. }
  1037. if ($item["pass_dept_check"] == 0) {
  1038. if ($process == 3) {
  1039. $item["checkState"] = "初审通过(待部门并审)";
  1040. } else {
  1041. if ($item["resubmit"]) {
  1042. $item["checkState"] = "待部门并审(重新提交)";
  1043. } else {
  1044. $item["checkState"] = "待部门并审(首次提交)";
  1045. }
  1046. }
  1047. }
  1048. }
  1049. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  1050. if ($process == 3) {
  1051. $item["checkState"] = "待初审(部门并审驳回)";
  1052. } else {
  1053. $item["checkState"] = "部门并审驳回";
  1054. }
  1055. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  1056. if ($process == 3) {
  1057. $item["checkState"] = "待复审(部门并审通过)";
  1058. } else if ($process == 4) {
  1059. $item["checkState"] = "部门并审通过";
  1060. } else {
  1061. if ($item["resubmit"]) {
  1062. $item["checkState"] = "待复审(重新提交)";
  1063. } else {
  1064. $item["checkState"] = "待复审(首次提交)";
  1065. }
  1066. }
  1067. } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
  1068. if ($process == 3) {
  1069. $item["checkState"] = "待初审(复审驳回)";
  1070. } else {
  1071. $item["checkState"] = "复审驳回";
  1072. }
  1073. } else {
  1074. $item["checkState"] = TalentState::getStateName($item["state"]);
  1075. }
  1076. if ($process == 4) {
  1077. if (self::chkUserInSuperDeptUsers()) {
  1078. $companys = array_filter(explode(",", $item["companyIds"]));
  1079. $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
  1080. $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
  1081. $verifyDepts = [];
  1082. $item["deptReject"] = 0;
  1083. $item["deptPass"] = 0;
  1084. $item["deptWait"] = 0;
  1085. $deptDescriptions = [];
  1086. foreach ($companys as $k => $companyId) {
  1087. $company = getCacheById("Company", $companyId);
  1088. //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  1089. $i = 0;
  1090. while ($log = $deptChecklogs[$i]) {
  1091. if ($log["companyId"] == $companyId) {
  1092. break;
  1093. } else {
  1094. $log = null;
  1095. }
  1096. $i++;
  1097. }
  1098. $item["first_dept_check_time"] = date("Y-m-d H:i:s", $log["createTime"]);
  1099. $verifyDepts[$k] = $company["name"];
  1100. if ($log["active"] == 1) {
  1101. if ($log["new_state"] == 9) {
  1102. $verifyDepts[$k] .= "(审核驳回)";
  1103. $item["deptReject"] ++;
  1104. }
  1105. if ($log["new_state"] == 12) {
  1106. $verifyDepts[$k] .= "(审核通过)";
  1107. $item["deptPass"] ++;
  1108. }
  1109. $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
  1110. } else {
  1111. if (!$log && in_array($item["state"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT])) {
  1112. unset($verifyDepts[$k]);
  1113. continue;
  1114. }
  1115. $verifyDepts[$k] .= "(待审核)";
  1116. $item["deptWait"] ++;
  1117. }
  1118. }
  1119. $item["verifyDepts"] = implode(chr(10), $verifyDepts);
  1120. $item["deptDescription"] = implode(chr(10), $deptDescriptions);
  1121. } else {
  1122. $item["checkMsg"] = $item["active"] == 1 ? $item["checkMsg"] : "等待部门审核";
  1123. }
  1124. }
  1125. }unset($item);
  1126. return $list;
  1127. }
  1128. public static function getListByProcess($params) {
  1129. $process = $params["process"];
  1130. $type = session("user")["type"];
  1131. $where[] = ["e.type", "=", $type];
  1132. if ($params["name"]) {
  1133. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  1134. }
  1135. if ($params["card_number"]) {
  1136. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  1137. }
  1138. if ($params["sex"]) {
  1139. $where[] = ["ti.sex", "=", $params["sex"]];
  1140. }
  1141. if ($params["nation"]) {
  1142. $where[] = ["ti.nation", "=", $params["nation"]];
  1143. }
  1144. if ($params["apply_year"]) {
  1145. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  1146. }
  1147. if ($params["phone"]) {
  1148. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  1149. }
  1150. if ($params["email"]) {
  1151. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  1152. }
  1153. if ($params["nationality"]) {
  1154. $where[] = ["ti.nationality", "=", $params["nationality"]];
  1155. }
  1156. if ($params["province"]) {
  1157. $where[] = ["ti.province", "=", $params["province"]];
  1158. }
  1159. if ($params["politics"]) {
  1160. $where[] = ["ti.politics", "=", $params["politics"]];
  1161. }
  1162. if ($params["enterprise_id"]) {
  1163. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  1164. }
  1165. if ($params["medicalCommunityId"]) {
  1166. $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
  1167. }
  1168. if ($params["isGeneral"]) {
  1169. $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
  1170. }
  1171. if ($params["street"]) {
  1172. $where[] = ["e.street", "=", $params["street"]];
  1173. }
  1174. if ($params["industry_field"]) {
  1175. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  1176. }
  1177. if ($params["industry_field_old"]) {
  1178. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  1179. }
  1180. if ($params["enterprise_tag"]) {
  1181. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  1182. }
  1183. if ($params["talent_type"]) {
  1184. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  1185. }
  1186. if ($params["import_way"]) {
  1187. $where[] = ["ti.import_way", "=", $params["import_way"]];
  1188. }
  1189. if ($params["highest_degree"]) {
  1190. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  1191. }
  1192. if ($params["study_abroad"]) {
  1193. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  1194. }
  1195. if ($params["source"]) {
  1196. $where[] = ["ti.source", "=", $params["source"]];
  1197. }
  1198. if ($params["talent_arrange"]) {
  1199. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  1200. }
  1201. if ($params["talent_condition"]) {
  1202. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  1203. }
  1204. if ($params["isMatchZhiren"]) {
  1205. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  1206. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  1207. }
  1208. if ($params["active"]) {
  1209. $where[] = ["ti.active", "=", $params["active"]];
  1210. }
  1211. if ($params["breakFaith"]) {
  1212. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  1213. }
  1214. switch ($process) {
  1215. case 1:
  1216. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  1217. break;
  1218. case 2:
  1219. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  1220. break;
  1221. case 3:
  1222. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  1223. break;
  1224. default:
  1225. return null;
  1226. }
  1227. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  1228. }
  1229. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  1230. $data["id"] = $mainId;
  1231. $data["checkState"] = $state;
  1232. switch ($state) {
  1233. case TalentState::ZX_PASS:
  1234. case TalentState::ZX_FAIL:
  1235. $data["isPublic"] = 2;
  1236. break;
  1237. case TalentState::ANNOUNCED:
  1238. $data["isPublic"] = 3;
  1239. $data["publicBatch"] = $batch;
  1240. break;
  1241. case TalentState::ANNOUNCED_REVERIFY_PASS:
  1242. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  1243. $data["isPublic"] = 3;
  1244. break;
  1245. case TalentState::PUBLISH_PASS:
  1246. $data["isPublic"] = 4;
  1247. $data["identifyMonth"] = $batch;
  1248. $data["certificateGetTime"] = $batch; //时间待定
  1249. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  1250. break;
  1251. case TalentState::PUBLISH_FAIL:
  1252. $data["isPublic"] = 4;
  1253. break;
  1254. }
  1255. if (Talent::update($data)) {
  1256. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  1257. return true;
  1258. }
  1259. return false;
  1260. }
  1261. public static function setEffect($mainId, $effect, $log) {
  1262. $data["id"] = $mainId;
  1263. $data["isEffect"] = $effect;
  1264. if (Talent::update($data)) {
  1265. $user = session("user");
  1266. $log["id"] = getStringId();
  1267. $log["type"] = \app\common\state\ProjectState::TALENT;
  1268. $log["mainId"] = $mainId;
  1269. if ($user) {
  1270. $log["companyId"] = $user["companyId"];
  1271. }
  1272. $log["active"] = $log["active"] ?: 0;
  1273. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  1274. $log["createTime"] = date("Y-m-d H:i:s");
  1275. if ($effect == 1) {
  1276. $log["step"] = 65;
  1277. } else {
  1278. $log["step"] = 60;
  1279. }
  1280. \app\common\model\TalentLog::create($log);
  1281. return true;
  1282. }
  1283. return false;
  1284. }
  1285. private static function getSuperPrivsForDeptVerify() {
  1286. $config = getJsonConfig("../sys_config.json", "super_privs_for_dept_verify");
  1287. return $config;
  1288. }
  1289. public static function chkUserInSuperDeptUsers() {
  1290. $config = self::getSuperPrivsForDeptVerify();
  1291. $companyId = session("user")["companyId"];
  1292. $company = getCacheById("Company", $companyId);
  1293. $account = session("user")["account"];
  1294. return in_array($company["code"], $config["companys"]) || in_array($account, $config["users"]);
  1295. }
  1296. }