VerifyApi.php 69 KB

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