VerifyApi.php 79 KB

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