VerifyApi.php 79 KB

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