VerifyApi.php 75 KB

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