VerifyApi.php 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  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, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  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. if ($user["type"] == 2) {
  817. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  818. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  819. $where[] = ["ti.delete", "=", 0];
  820. } else {
  821. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  822. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  823. $where[] = ["ti.delete", "=", 0];
  824. }
  825. }
  826. break;
  827. case 4:
  828. $companyId = session('user')['companyId'];
  829. $company_info = CompanyApi::getOne($companyId);
  830. if (self::chkUserInSuperDeptUsers()) {
  831. switch ($params["checkState"]) {
  832. case 1:
  833. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  834. $where[] = ["ti.pass_dept_check", "=", 0];
  835. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  836. break;
  837. case 2:
  838. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  839. $where[] = ["ti.pass_dept_check", "=", 0];
  840. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  841. break;
  842. case 3:
  843. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  844. break;
  845. case 4:
  846. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  847. break;
  848. default:
  849. $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);
  850. break;
  851. }
  852. } else {
  853. switch ($params["checkState"]) {
  854. case 1://待部门并审(首次提交)
  855. //$where[] = ["tl.active", "=", 0];
  856. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  857. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  858. $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);
  859. break;
  860. case 2://待部门并审(重新提交)
  861. //$where[] = ["tl.active", "=", 0];
  862. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  863. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  864. $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);
  865. break;
  866. case 3://部门并审通过
  867. $where[] = ["tl.active", "=", 1];
  868. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  869. break;
  870. case 4://部门并审驳回
  871. $where[] = ["tl.active", "=", 1];
  872. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  873. break;
  874. default:
  875. $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);
  876. break;
  877. }
  878. }
  879. break;
  880. case 5:
  881. $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 = ''))");
  882. switch ($params["checkState"]) {
  883. case 1://待复审(首次提交)
  884. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  885. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  886. break;
  887. case 2://待复审(重新提交)
  888. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  889. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  890. break;
  891. case 3://复审通过
  892. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  893. break;
  894. case 4://复审驳回
  895. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  896. break;
  897. case 5://复审不通过
  898. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  899. break;
  900. }
  901. break;
  902. case 6:
  903. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  904. if ($params["checkState"]) {
  905. $where[] = ["tl.state", "=", $params["checkState"]];
  906. }
  907. break;
  908. case 7:
  909. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  910. break;
  911. }
  912. } else {
  913. $whereRaw = "tl.state is not null";
  914. $where[] = ["ti.delete", "=", 0];
  915. }
  916. $fields[] = "ti.id";
  917. $fields[] = "ti.pass_dept_check";
  918. $fields[] = "tl.state";
  919. $fields[] = "tl.new_state";
  920. $fields[] = "tl.last_state";
  921. $fields[] = "tc.companyIds";
  922. if ($process == 4) {
  923. $fields[] = "tl2.resubmit";
  924. if (self::chkUserInSuperDeptUsers()) {
  925. $fields[] = "tl3.deptVerifyJsonData";
  926. $list = Talent::alias("ti")
  927. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  928. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  929. ->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")
  930. ->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")
  931. ->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`")
  932. ->where($where)
  933. ->where($whereRaw)
  934. ->field($fields)
  935. ->select()->toArray();
  936. } else {
  937. $fields[] = "tl.active";
  938. $fields[] = "if(tl.new_state,tl.new_state,10) as deptCheckState";
  939. $fields[] = "tl.createTime as first_dept_check_time";
  940. $list = Talent::alias("ti")
  941. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  942. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  943. ->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")
  944. ->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")
  945. ->where($where)
  946. ->where($whereRaw)
  947. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  948. ->field($fields)
  949. ->select()->toArray();
  950. }
  951. } else if ($process == 5) {
  952. $fields[] = "tl2.resubmit";
  953. $list = Talent::alias("ti")
  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("(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")
  958. ->where($whereRaw)
  959. ->where($where)
  960. ->field($fields)
  961. ->select()->toArray();
  962. } else {
  963. $list = Talent::alias("ti")
  964. ->field($fields)
  965. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  966. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  967. ->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")
  968. //->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)")
  969. ->where($where)
  970. ->where($whereRaw)
  971. ->select()->toArray();
  972. }
  973. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  974. foreach ($list as &$item) {
  975. $item["card_type"] = $cardTypes[$item["card_type"]];
  976. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  977. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  978. $item["street"] = $streets[$item["street"]];
  979. $item["nation"] = $nations[$item["nation"]];
  980. $item["nationality"] = $nationalitys[$item["nationality"]];
  981. $item["politics"] = $politics[$item["politics"]];
  982. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  983. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  984. $item["sex"] = $sex[$item["sex"]];
  985. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  986. $item["import_way"] = $import_way[$item["import_way"]];
  987. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  988. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  989. $item["return"] = $return[$item["return"]];
  990. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  991. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  992. $item["source"] = $source[$item["source"]];
  993. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  994. $item["talent_condition"] = $item["checkState"] == TalentState::CERTIFICATED && !$item["talent_condition"] ? "积分认定" : $item["talentConditionName"];
  995. if (in_array("source_city", $exportFields)) {
  996. $item["source_city"] = $un_common_location[$item["source_city"]];
  997. }
  998. if (in_array("source_county", $exportFields)) {
  999. $item["source_county"] = $un_common_location[$item["source_county"]];
  1000. }
  1001. if (in_array("province", $exportFields)) {
  1002. $item["province"] = $un_common_location[$item["province"]];
  1003. }
  1004. if (in_array("city", $exportFields)) {
  1005. $item["city"] = $un_common_location[$item["city"]];
  1006. }
  1007. if (in_array("county", $exportFields)) {
  1008. $item["county"] = $un_common_location[$item["county"]];
  1009. }
  1010. if ($item["state"] == TalentState::SCND_SUBMIT) {
  1011. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  1012. $item["checkState"] = "待初审(重新提交)";
  1013. } else {
  1014. $item["checkState"] = "待初审(首次提交)";
  1015. }
  1016. } else if ($item["state"] == TalentState::FST_VERIFY_PASS || (!$item["state"] && $item["deptCheckState"])) {
  1017. if ($item["deptCheckState"]) {
  1018. if (($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) || !$item["active"]) {
  1019. if ($item["resubmit"]) {
  1020. $item["checkState"] = "待部门并审(重新提交)";
  1021. } else {
  1022. $item["checkState"] = "待部门并审(首次提交)";
  1023. }
  1024. }
  1025. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  1026. $item["checkState"] = "部门并审通过";
  1027. }
  1028. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  1029. $item["checkState"] = "部门并审驳回";
  1030. }
  1031. } else {
  1032. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  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. if ($item["pass_dept_check"] == 0) {
  1044. if ($process == 3) {
  1045. $item["checkState"] = "初审通过(待部门并审)";
  1046. } else {
  1047. if ($item["resubmit"]) {
  1048. $item["checkState"] = "待部门并审(重新提交)";
  1049. } else {
  1050. $item["checkState"] = "待部门并审(首次提交)";
  1051. }
  1052. }
  1053. }
  1054. }
  1055. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  1056. if ($process == 3) {
  1057. $item["checkState"] = "待初审(部门并审驳回)";
  1058. } else {
  1059. $item["checkState"] = "部门并审驳回";
  1060. }
  1061. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  1062. if ($process == 3) {
  1063. $item["checkState"] = "待复审(部门并审通过)";
  1064. } else if ($process == 4) {
  1065. $item["checkState"] = "部门并审通过";
  1066. } else {
  1067. if ($item["resubmit"]) {
  1068. $item["checkState"] = "待复审(重新提交)";
  1069. } else {
  1070. $item["checkState"] = "待复审(首次提交)";
  1071. }
  1072. }
  1073. } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
  1074. if ($process == 3) {
  1075. $item["checkState"] = "待初审(复审驳回)";
  1076. } else {
  1077. $item["checkState"] = "复审驳回";
  1078. }
  1079. } else {
  1080. $item["checkState"] = TalentState::getStateName($item["state"]);
  1081. }
  1082. if ($process == 4) {
  1083. if (self::chkUserInSuperDeptUsers()) {
  1084. $companys = array_filter(explode(",", $item["companyIds"]));
  1085. $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
  1086. $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
  1087. $verifyDepts = [];
  1088. $item["deptReject"] = 0;
  1089. $item["deptPass"] = 0;
  1090. $item["deptWait"] = 0;
  1091. $deptDescriptions = [];
  1092. foreach ($companys as $k => $companyId) {
  1093. $company = getCacheById("Company", $companyId);
  1094. //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  1095. $i = 0;
  1096. while ($log = $deptChecklogs[$i]) {
  1097. if ($log["companyId"] == $companyId) {
  1098. break;
  1099. } else {
  1100. $log = null;
  1101. }
  1102. $i++;
  1103. }
  1104. $item["first_dept_check_time"] = date("Y-m-d H:i:s", $log["createTime"]);
  1105. $verifyDepts[$k] = $company["name"];
  1106. if ($log["active"] == 1) {
  1107. if ($log["new_state"] == 9) {
  1108. $verifyDepts[$k] .= "(审核驳回)";
  1109. $item["deptReject"] ++;
  1110. }
  1111. if ($log["new_state"] == 12) {
  1112. $verifyDepts[$k] .= "(审核通过)";
  1113. $item["deptPass"] ++;
  1114. }
  1115. $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
  1116. } else {
  1117. if (!$log && in_array($item["state"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT])) {
  1118. unset($verifyDepts[$k]);
  1119. continue;
  1120. }
  1121. $verifyDepts[$k] .= "(待审核)";
  1122. $item["deptWait"] ++;
  1123. }
  1124. }
  1125. $item["verifyDepts"] = implode(chr(10), $verifyDepts);
  1126. $item["deptDescription"] = implode(chr(10), $deptDescriptions);
  1127. } else {
  1128. $item["checkMsg"] = $item["active"] == 1 ? $item["checkMsg"] : "等待部门审核";
  1129. }
  1130. }
  1131. }unset($item);
  1132. return $list;
  1133. }
  1134. public static function getListByProcess($params) {
  1135. $process = $params["process"];
  1136. $type = session("user")["type"];
  1137. $where[] = ["e.type", "=", $type];
  1138. if ($params["name"]) {
  1139. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  1140. }
  1141. if ($params["card_number"]) {
  1142. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  1143. }
  1144. if ($params["sex"]) {
  1145. $where[] = ["ti.sex", "=", $params["sex"]];
  1146. }
  1147. if ($params["nation"]) {
  1148. $where[] = ["ti.nation", "=", $params["nation"]];
  1149. }
  1150. if ($params["apply_year"]) {
  1151. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  1152. }
  1153. if ($params["phone"]) {
  1154. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  1155. }
  1156. if ($params["email"]) {
  1157. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  1158. }
  1159. if ($params["nationality"]) {
  1160. $where[] = ["ti.nationality", "=", $params["nationality"]];
  1161. }
  1162. if ($params["province"]) {
  1163. $where[] = ["ti.province", "=", $params["province"]];
  1164. }
  1165. if ($params["politics"]) {
  1166. $where[] = ["ti.politics", "=", $params["politics"]];
  1167. }
  1168. if ($params["enterprise_id"]) {
  1169. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  1170. }
  1171. if ($params["medicalCommunityId"]) {
  1172. $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
  1173. }
  1174. if ($params["isGeneral"]) {
  1175. $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
  1176. }
  1177. if ($params["street"]) {
  1178. $where[] = ["e.street", "=", $params["street"]];
  1179. }
  1180. if ($params["industry_field"]) {
  1181. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  1182. }
  1183. if ($params["industry_field_old"]) {
  1184. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  1185. }
  1186. if ($params["enterprise_tag"]) {
  1187. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  1188. }
  1189. if ($params["talent_type"]) {
  1190. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  1191. }
  1192. if ($params["import_way"]) {
  1193. $where[] = ["ti.import_way", "=", $params["import_way"]];
  1194. }
  1195. if ($params["highest_degree"]) {
  1196. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  1197. }
  1198. if ($params["study_abroad"]) {
  1199. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  1200. }
  1201. if ($params["source"]) {
  1202. $where[] = ["ti.source", "=", $params["source"]];
  1203. }
  1204. if ($params["talent_arrange"]) {
  1205. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  1206. }
  1207. if ($params["talent_condition"]) {
  1208. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  1209. }
  1210. if ($params["isMatchZhiren"]) {
  1211. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  1212. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  1213. }
  1214. if ($params["active"]) {
  1215. $where[] = ["ti.active", "=", $params["active"]];
  1216. }
  1217. if ($params["breakFaith"]) {
  1218. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  1219. }
  1220. switch ($process) {
  1221. case 1:
  1222. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  1223. break;
  1224. case 2:
  1225. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  1226. break;
  1227. case 3:
  1228. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  1229. break;
  1230. default:
  1231. return null;
  1232. }
  1233. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  1234. }
  1235. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  1236. $data["id"] = $mainId;
  1237. $data["checkState"] = $state;
  1238. switch ($state) {
  1239. case TalentState::ZX_PASS:
  1240. case TalentState::ZX_FAIL:
  1241. $data["isPublic"] = 2;
  1242. break;
  1243. case TalentState::ANNOUNCED:
  1244. $data["isPublic"] = 3;
  1245. $data["publicBatch"] = $batch;
  1246. break;
  1247. case TalentState::ANNOUNCED_REVERIFY_PASS:
  1248. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  1249. $data["isPublic"] = 3;
  1250. break;
  1251. case TalentState::PUBLISH_PASS:
  1252. $data["isPublic"] = 4;
  1253. $data["identifyMonth"] = $batch;
  1254. $data["certificateGetTime"] = $batch; //时间待定
  1255. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  1256. break;
  1257. case TalentState::PUBLISH_FAIL:
  1258. $data["isPublic"] = 4;
  1259. break;
  1260. }
  1261. if (Talent::update($data)) {
  1262. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  1263. return true;
  1264. }
  1265. return false;
  1266. }
  1267. public static function setEffect($mainId, $effect, $log) {
  1268. $data["id"] = $mainId;
  1269. $data["isEffect"] = $effect;
  1270. if (Talent::update($data)) {
  1271. $user = session("user");
  1272. $log["id"] = getStringId();
  1273. $log["type"] = \app\common\state\ProjectState::TALENT;
  1274. $log["mainId"] = $mainId;
  1275. if ($user) {
  1276. $log["companyId"] = $user["companyId"];
  1277. }
  1278. $log["active"] = $log["active"] ?: 0;
  1279. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  1280. $log["createTime"] = date("Y-m-d H:i:s");
  1281. if ($effect == 1) {
  1282. $log["step"] = 65;
  1283. } else {
  1284. $log["step"] = 60;
  1285. }
  1286. \app\common\model\TalentLog::create($log);
  1287. return true;
  1288. }
  1289. return false;
  1290. }
  1291. private static function getSuperPrivsForDeptVerify() {
  1292. $config = getJsonConfig("../sys_config.json", "super_privs_for_dept_verify");
  1293. return $config;
  1294. }
  1295. public static function chkUserInSuperDeptUsers() {
  1296. $config = self::getSuperPrivsForDeptVerify();
  1297. $companyId = session("user")["companyId"];
  1298. $company = getCacheById("Company", $companyId);
  1299. $account = session("user")["account"];
  1300. return in_array($company["code"], $config["companys"]) || in_array($account, $config["users"]);
  1301. }
  1302. }