VerifyApi.php 78 KB

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