VerifyApi.php 78 KB

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