VerifyApi.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  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. *
  148. * @param type $oriReCheckCompanyIds 原来的需要再审核的部门id集合
  149. * @param type $TalentConditionCompanyIds 认定条件中的审核部门id集合
  150. * @param type $passedCompanyIds 已经通过审核的部门id集合
  151. * @return type
  152. */
  153. public static function getReCheckCompanyIds($oriReCheckCompanyIds, $TalentConditionCompanyIds, $passedCompanyIds) {
  154. if (!$oriReCheckCompanyIds || !$TalentConditionCompanyIds)
  155. return null;
  156. $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $TalentConditionCompanyIds);
  157. $remainReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
  158. }
  159. public static function getFullDeptList($params, $where = []) {
  160. $order = $params["order"] ?: "desc";
  161. $offset = $params["offset"] ?: 0;
  162. $limit = $params["limit"] ?: 10;
  163. $whereRaw = "";
  164. if ($params["company_id"]) {
  165. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  166. }
  167. switch ($params["checkState"]) {
  168. case 1://待部门并审(首次提交)
  169. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  170. $where[] = ["ti.pass_dept_check", "=", 0];
  171. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  172. break;
  173. case 2://待部门并审(重新提交)
  174. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  175. $where[] = ["ti.pass_dept_check", "=", 0];
  176. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  177. break;
  178. case 3://部门并审通过
  179. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  180. break;
  181. case 4://部门并审驳回
  182. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  183. break;
  184. default:
  185. $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);
  186. break;
  187. }
  188. $companyId = session("user")["companyId"];
  189. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  190. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  191. $count = Talent::alias("ti")
  192. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  193. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  194. ->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")
  195. ->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")
  196. ->where($where)
  197. ->where($whereRaw)->count();
  198. $list = Talent::alias("ti")
  199. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  200. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  201. ->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")
  202. ->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")
  203. ->where($where)
  204. ->where($whereRaw)
  205. ->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")
  206. ->limit($offset, $limit)->order("ti.createTime " . $order)
  207. ->select()->toArray();
  208. foreach ($list as &$item) {
  209. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  210. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  211. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  212. $companys = array_filter(explode(",", $item["companyIds"]));
  213. $verifyDepts = [];
  214. foreach ($companys as $k => $companyId) {
  215. $company = getCacheById("Company", $companyId);
  216. $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  217. $verifyDepts[$k]["id"] = $companyId;
  218. $verifyDepts[$k]["shortName"] = $company["shortName"];
  219. $verifyDepts[$k]["name"] = $company["name"];
  220. $verifyDepts[$k]["code"] = $company["code"];
  221. $verifyDepts[$k]["checkState"] = $log["new_state"];
  222. $verifyDepts[$k]["active"] = $log["active"];
  223. }
  224. $item["verifyDepts"] = $verifyDepts;
  225. }unset($item);
  226. return ["total" => $count, "rows" => $list];
  227. }
  228. public static function getDeptList($params, $where = []) {
  229. $order = $params["order"] ?: "desc";
  230. $offset = $params["offset"] ?: 0;
  231. $limit = $params["limit"] ?: 10;
  232. $companyId = session("user")["companyId"];
  233. $whereRaw = "";
  234. switch ($params["checkState"]) {
  235. case 1://待部门并审(首次提交)
  236. $where[] = ["tl.active", "=", 0];
  237. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  238. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  239. //$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);
  240. break;
  241. case 2://待部门并审(重新提交)
  242. $where[] = ["tl.active", "=", 0];
  243. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  244. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  245. //$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);
  246. break;
  247. case 3://部门并审通过
  248. $where[] = ["tl.active", "=", 1];
  249. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  250. break;
  251. case 4://部门并审驳回
  252. $where[] = ["tl.active", "=", 1];
  253. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  254. break;
  255. default:
  256. $whereRaw = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  257. break;
  258. }
  259. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  260. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  261. $count = Talent::alias("ti")
  262. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  263. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  264. ->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")
  265. ->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")
  266. ->where($where)
  267. ->where($whereRaw)
  268. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  269. $list = Talent::alias("ti")
  270. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  271. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  272. ->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")
  273. ->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")
  274. ->where($where)
  275. ->where($whereRaw)
  276. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  277. ->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")
  278. ->limit($offset, $limit)->order("ti.createTime " . $order)
  279. ->select()->toArray();
  280. foreach ($list as &$item) {
  281. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  282. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  283. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  284. $item["deptCheckState"] = $lastCheckLog["new_state"];
  285. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  286. }unset($item);
  287. return ["total" => $count, "rows" => $list];
  288. }
  289. public static function getPublicList($params) {
  290. $order = $params["order"];
  291. $offset = $params["offset"];
  292. $limit = $params["limit"];
  293. $where = [];
  294. $where[] = ["e.type", "=", session("user")["type"]];
  295. if ($params["name"]) {
  296. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  297. }
  298. if ($params["sex"]) {
  299. $where[] = ["ti.sex", "=", $params["sex"]];
  300. }
  301. if ($params["checkState"]) {
  302. $where[] = ["ti.checkState", "=", $params["checkState"]];
  303. }
  304. $type = $params["type"];
  305. switch ($type) {
  306. case 1:
  307. case 2:
  308. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  309. break;
  310. case 3: //公示
  311. case 7: //公示预览
  312. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  313. break;
  314. case 4: //公示通过
  315. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  316. break;
  317. case 5:
  318. case 8: //公布预览
  319. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  320. break;
  321. case 6:
  322. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  323. break;
  324. }
  325. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  326. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  327. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  328. ->where($where)
  329. ->limit($offset, $limit)
  330. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  331. foreach ($list as &$item) {
  332. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  333. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  334. }unset($item);
  335. return ["total" => $count, "rows" => $list];
  336. }
  337. public static function getListByIds($ids) {
  338. $where[] = ["id", "in", $ids];
  339. return Talent::where($where)->select()->toArray();
  340. }
  341. public static function getList($params) {
  342. $where = [];
  343. $order = $params["order"] ?: "desc";
  344. $offset = $params["offset"] ?: 0;
  345. $limit = $params["limit"] ?: 10;
  346. $where[] = ["e.type", "=", session("user")["type"]];
  347. if ($params["name"]) {
  348. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  349. }
  350. if ($params["card_number"]) {
  351. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  352. }
  353. if ($params["sex"]) {
  354. $where[] = ["ti.sex", "=", $params["sex"]];
  355. }
  356. if ($params["nation"]) {
  357. $where[] = ["ti.nation", "=", $params["nation"]];
  358. }
  359. if ($params["apply_year"]) {
  360. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  361. }
  362. if ($params["phone"]) {
  363. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  364. }
  365. if ($params["email"]) {
  366. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  367. }
  368. if ($params["nationality"]) {
  369. $where[] = ["ti.nationality", "=", $params["nationality"]];
  370. }
  371. if ($params["province"]) {
  372. $where[] = ["ti.province", "=", $params["province"]];
  373. }
  374. if ($params["politics"]) {
  375. $where[] = ["ti.politics", "=", $params["politics"]];
  376. }
  377. if ($params["enterprise_id"]) {
  378. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  379. }
  380. if ($params["street"]) {
  381. $where[] = ["e.street", "=", $params["street"]];
  382. }
  383. if ($params["industry_field"]) {
  384. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  385. }
  386. if ($params["industry_field_old"]) {
  387. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  388. }
  389. if ($params["enterprise_tag"]) {
  390. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  391. }
  392. if ($params["talent_type"]) {
  393. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  394. }
  395. if ($params["import_way"]) {
  396. $where[] = ["ti.import_way", "=", $params["import_way"]];
  397. }
  398. if ($params["highest_degree"]) {
  399. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  400. }
  401. if ($params["study_abroad"]) {
  402. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  403. }
  404. if ($params["source"]) {
  405. $where[] = ["ti.source", "=", $params["source"]];
  406. }
  407. if ($params["talent_arrange"]) {
  408. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  409. }
  410. if ($params["talent_condition"]) {
  411. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  412. }
  413. if ($params["isMatchZhiren"]) {
  414. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  415. }
  416. $process = $params["process"];
  417. if ($process == 4) {
  418. if (self::chkUserInSuperDeptUsers()) {
  419. return self::getFullDeptList($params, $where);
  420. } else {
  421. return self::getDeptList($params, $where);
  422. }
  423. }
  424. if ($process == 5) {
  425. $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 = ''))");
  426. switch ($params["checkState"]) {
  427. case 1://待复审(首次提交)
  428. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  429. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  430. break;
  431. case 2://待复审(重新提交)
  432. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  433. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  434. break;
  435. case 3://复审通过
  436. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  437. break;
  438. case 4://复审驳回
  439. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  440. break;
  441. case 5://复审不通过
  442. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  443. break;
  444. }
  445. $count = Talent::alias("ti")
  446. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  447. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  448. ->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")
  449. ->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")
  450. ->whereRaw($whereRaw)->where($where)->count();
  451. $list = Talent::alias("ti")
  452. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  453. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  454. ->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")
  455. ->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")
  456. ->whereRaw($whereRaw)
  457. ->where($where)
  458. ->limit($offset, $limit)
  459. ->order("ti.createTime " . $order)
  460. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tl2.resubmit")
  461. ->select()->toArray();
  462. } else {
  463. switch ($process) {
  464. case 1:
  465. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  466. break;
  467. case 2:
  468. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  469. break;
  470. case 3:
  471. switch ($params["checkState"]) {
  472. case 1://保存未提交
  473. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  474. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  475. $where[] = ["ti.delete", "=", 0];
  476. break;
  477. case 2://初审驳回
  478. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  479. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  480. break;
  481. case 3://待初审(首次提交)
  482. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  483. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  484. break;
  485. case 4://待初审(重新提交)
  486. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  487. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  488. break;
  489. case 5://待初审(部门并审驳回)
  490. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  491. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  492. break;
  493. case 6://待初审(复审驳回)
  494. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  495. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  496. break;
  497. case 7://初审通过(待部门并审)
  498. $where[] = ["ti.pass_dept_check", "=", 0];
  499. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  500. break;
  501. case 8://初审通过(待复审)
  502. $where[] = ["ti.pass_dept_check", "=", 1];
  503. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  504. break;
  505. case 9://初审不通过
  506. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  507. break;
  508. default:
  509. //$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);
  510. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  511. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  512. $where[] = ["ti.delete", "=", 0];
  513. }
  514. break;
  515. case 6:
  516. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  517. $where[] = ["tl.state", "not in", [TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL]];
  518. if ($params["checkState"]) {
  519. $where[] = ["tl.state", "=", $params["checkState"]];
  520. }
  521. break;
  522. case 7:
  523. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  524. break;
  525. }
  526. $count = Talent::alias("ti")
  527. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  528. ->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")
  529. //->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")
  530. ->where($where)->where($whereRaw)->count();
  531. $list = Talent::alias("ti")
  532. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  533. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  534. //->leftJoin("(select 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")
  535. ->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();
  536. }
  537. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  538. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  539. foreach ($list as &$item) {
  540. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  541. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  542. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  543. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  544. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  545. //$item["lastState"] = $last_log["last_state"];
  546. //$item["realState"] = $last_log["state"];
  547. }unset($item);
  548. return ["total" => $count, "rows" => $list];
  549. }
  550. public static function getExportDatas($process, $params) {
  551. $where[] = [];
  552. //特殊字段处理
  553. $exportFields = $params["export"];
  554. $fields = [];
  555. foreach ($exportFields as $field) {
  556. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  557. $fields[] = "ti." . $field;
  558. }
  559. }
  560. $fields[] = "e.name as enterpriseName";
  561. $fields[] = "e.industryFieldNew";
  562. $fields[] = "e.enterpriseTag";
  563. $fields[] = "e.street";
  564. $fields[] = "tc.talentLevelCat";
  565. $fields[] = "tl.description as checkMsg";
  566. $fields[] = "tc.name as talentConditionName";
  567. $fields[] = "tl.description as checkMsg";
  568. if (in_array("card_type", $exportFields)) {
  569. $cardTypes = DictApi::selectByParentCode("card_type");
  570. }
  571. if (in_array("industryFieldNew", $exportFields)) {
  572. $industry_fields = DictApi::selectByParentCode("industry_field");
  573. }
  574. if (in_array("enterpriseTag", $exportFields)) {
  575. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  576. }
  577. if (in_array("street", $exportFields)) {
  578. $streets = DictApi::selectByParentCode("street");
  579. }
  580. if (in_array("nation", $exportFields)) {
  581. $nations = DictApi::selectByParentCode("nation");
  582. }
  583. if (in_array("nationality", $exportFields)) {
  584. $nationalitys = DictApi::selectByParentCode("nationality");
  585. }
  586. if (in_array("politics", $exportFields)) {
  587. $politics = DictApi::selectByParentCode("politics");
  588. }
  589. if (in_array("talent_type", $exportFields)) {
  590. $talentTypes = DictApi::selectByParentCode("talent_type");
  591. }
  592. if (in_array("talent_arrange_category", $exportFields)) {
  593. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  594. }
  595. if (in_array("highest_degree", $exportFields)) {
  596. $highest_degree = DictApi::selectByParentCode("highest_degree");
  597. }
  598. if (in_array("import_way", $exportFields)) {
  599. $import_way = DictApi::selectByParentCode("import_way");
  600. }
  601. if (in_array("source", $exportFields)) {
  602. $source = DictApi::selectByParentCode("source");
  603. }
  604. if (in_array("source_city", $exportFields)) {
  605. $source_city = DictApi::selectByParentCode("source_city");
  606. }
  607. if (in_array("source_county", $exportFields)) {
  608. $source_county = DictApi::selectByParentCode("source_county");
  609. }
  610. if (in_array("talent_arrange", $exportFields)) {
  611. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  612. }
  613. $sex = [1 => "男", 2 => "女"];
  614. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  615. $study_abroad = [1 => "是", 2 => "否"];
  616. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  617. $return = [1 => "是", 2 => "否"];
  618. $isMatchZhiren = [0 => "否", 1 => "是"];
  619. $where = [];
  620. $whereRaw = "";
  621. $where[] = ["e.type", "=", session("user")["type"]];
  622. if ($params["all"] != 1) {
  623. if ($params["name"]) {
  624. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  625. }
  626. if ($params["card_number"]) {
  627. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  628. }
  629. if ($params["sex"]) {
  630. $where[] = ["ti.sex", "=", $params["sex"]];
  631. }
  632. if ($params["nation"]) {
  633. $where[] = ["ti.nation", "=", $params["nation"]];
  634. }
  635. if ($params["apply_year"]) {
  636. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  637. }
  638. if ($params["phone"]) {
  639. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  640. }
  641. if ($params["email"]) {
  642. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  643. }
  644. if ($params["nationality"]) {
  645. $where[] = ["ti.nationality", "=", $params["nationality"]];
  646. }
  647. if ($params["province"]) {
  648. $where[] = ["ti.province", "=", $params["province"]];
  649. }
  650. if ($params["politics"]) {
  651. $where[] = ["ti.politics", "=", $params["politics"]];
  652. }
  653. if ($params["enterprise_id"]) {
  654. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  655. }
  656. if ($params["street"]) {
  657. $where[] = ["e.street", "=", $params["street"]];
  658. }
  659. if ($params["industry_field"]) {
  660. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  661. }
  662. if ($params["industry_field_old"]) {
  663. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  664. }
  665. if ($params["enterprise_tag"]) {
  666. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  667. }
  668. if ($params["talent_type"]) {
  669. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  670. }
  671. if ($params["import_way"]) {
  672. $where[] = ["ti.import_way", "=", $params["import_way"]];
  673. }
  674. if ($params["highest_degree"]) {
  675. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  676. }
  677. if ($params["study_abroad"]) {
  678. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  679. }
  680. if ($params["source"]) {
  681. $where[] = ["ti.source", "=", $params["source"]];
  682. }
  683. if ($params["talent_arrange"]) {
  684. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  685. }
  686. if ($params["talent_condition"]) {
  687. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  688. }
  689. if ($params["isMatchZhiren"]) {
  690. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  691. }
  692. switch ($process) {
  693. case 1:
  694. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  695. break;
  696. case 2:
  697. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  698. break;
  699. case 3:
  700. switch ($params["checkState"]) {
  701. case 1://保存未提交
  702. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  703. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  704. $where[] = ["ti.delete", "=", 0];
  705. break;
  706. case 2://初审驳回
  707. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  708. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  709. break;
  710. case 3://待初审(首次提交)
  711. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  712. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  713. break;
  714. case 4://待初审(重新提交)
  715. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  716. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  717. break;
  718. case 5://待初审(部门并审驳回)
  719. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  720. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  721. break;
  722. case 6://待初审(复审驳回)
  723. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  724. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  725. break;
  726. case 7://初审通过(待部门并审)
  727. $where[] = ["ti.pass_dept_check", "=", 0];
  728. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  729. break;
  730. case 8://初审通过(待复审)
  731. $where[] = ["ti.pass_dept_check", "=", 1];
  732. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  733. break;
  734. case 9://初审不通过
  735. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  736. break;
  737. default:
  738. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  739. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  740. $where[] = ["ti.delete", "=", 0];
  741. }
  742. break;
  743. case 4:
  744. $companyId = session('user')['companyId'];
  745. $company_info = CompanyApi::getOne($companyId);
  746. if (self::chkUserInSuperDeptUsers()) {
  747. switch ($params["checkState"]) {
  748. case 1:
  749. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  750. $where[] = ["ti.pass_dept_check", "=", 0];
  751. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  752. break;
  753. case 2:
  754. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  755. $where[] = ["ti.pass_dept_check", "=", 0];
  756. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  757. break;
  758. case 3:
  759. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  760. break;
  761. case 4:
  762. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  763. break;
  764. default:
  765. $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);
  766. break;
  767. }
  768. } else {
  769. switch ($params["checkState"]) {
  770. case 1://待部门并审(首次提交)
  771. $where[] = ["tl.active", "=", 0];
  772. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  773. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  774. break;
  775. case 2://待部门并审(重新提交)
  776. $where[] = ["tl.active", "=", 0];
  777. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  778. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  779. break;
  780. case 3://部门并审通过
  781. $where[] = ["tl.active", "=", 1];
  782. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  783. break;
  784. case 4://部门并审驳回
  785. $where[] = ["tl.active", "=", 1];
  786. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  787. break;
  788. default:
  789. $whereRaw = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  790. break;
  791. }
  792. }
  793. break;
  794. case 5:
  795. $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 = ''))");
  796. switch ($params["checkState"]) {
  797. case 1://待复审(首次提交)
  798. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  799. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  800. break;
  801. case 2://待复审(重新提交)
  802. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  803. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  804. break;
  805. case 3://复审通过
  806. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  807. break;
  808. case 4://复审驳回
  809. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  810. break;
  811. case 5://复审不通过
  812. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  813. break;
  814. }
  815. break;
  816. case 6:
  817. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  818. if ($params["checkState"]) {
  819. $where[] = ["tl.state", "=", $params["checkState"]];
  820. }
  821. break;
  822. case 7:
  823. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  824. break;
  825. }
  826. } else {
  827. $whereRaw = "tl.state is not null";
  828. $where[] = ["ti.delete", "=", 0];
  829. }
  830. $fields[] = "ti.id";
  831. $fields[] = "ti.pass_dept_check";
  832. $fields[] = "tl.state";
  833. $fields[] = "tl.new_state";
  834. $fields[] = "tl.last_state";
  835. $fields[] = "tc.companyIds";
  836. if ($process == 4) {
  837. $fields[] = "tl2.resubmit";
  838. if (self::chkUserInSuperDeptUsers()) {
  839. $fields[] = "tl3.deptVerifyJsonData";
  840. $list = Talent::alias("ti")
  841. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  842. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  843. ->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")
  844. ->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")
  845. ->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`")
  846. ->where($where)
  847. ->where($whereRaw)
  848. ->field($fields)
  849. ->select()->toArray();
  850. } else {
  851. $fields[] = "tl.active";
  852. $fields[] = "tl.new_state as deptCheckState";
  853. $fields[] = "tl.createTime as first_dept_check_time";
  854. $list = Talent::alias("ti")
  855. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  856. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  857. ->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")
  858. ->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")
  859. ->where($where)
  860. ->where($whereRaw)
  861. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  862. ->field($fields)
  863. ->select()->toArray();
  864. }
  865. } else if ($process == 5) {
  866. $fields[] = "tl2.resubmit";
  867. $list = Talent::alias("ti")
  868. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  869. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  870. ->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")
  871. ->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")
  872. ->where($whereRaw)
  873. ->where($where)
  874. ->field($fields)
  875. ->select()->toArray();
  876. } else {
  877. $list = Talent::alias("ti")
  878. ->field($fields)
  879. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  880. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  881. ->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")
  882. //->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)")
  883. ->where($where)
  884. ->where($whereRaw)
  885. ->select()->toArray();
  886. }
  887. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  888. foreach ($list as &$item) {
  889. $item["card_type"] = $cardTypes[$item["card_type"]];
  890. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  891. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  892. $item["street"] = $streets[$item["street"]];
  893. $item["nation"] = $nations[$item["nation"]];
  894. $item["nationality"] = $nationalitys[$item["nationality"]];
  895. $item["politics"] = $politics[$item["politics"]];
  896. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  897. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  898. $item["sex"] = $sex[$item["sex"]];
  899. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  900. $item["import_way"] = $import_way[$item["import_way"]];
  901. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  902. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  903. $item["return"] = $return[$item["return"]];
  904. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  905. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  906. $item["source"] = $source[$item["source"]];
  907. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  908. $item["talent_condition"] = $item["talentConditionName"];
  909. if (in_array("source_city", $exportFields)) {
  910. $item["source_city"] = $un_common_location[$item["source_city"]];
  911. }
  912. if (in_array("source_county", $exportFields)) {
  913. $item["source_county"] = $un_common_location[$item["source_county"]];
  914. }
  915. if (in_array("province", $exportFields)) {
  916. $item["province"] = $un_common_location[$item["province"]];
  917. }
  918. if (in_array("city", $exportFields)) {
  919. $item["city"] = $un_common_location[$item["city"]];
  920. }
  921. if (in_array("county", $exportFields)) {
  922. $item["county"] = $un_common_location[$item["county"]];
  923. }
  924. if ($item["state"] == TalentState::SCND_SUBMIT) {
  925. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  926. $item["checkState"] = "待初审(重新提交)";
  927. } else {
  928. $item["checkState"] = "待初审(首次提交)";
  929. }
  930. } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
  931. if ($item["deptCheckState"]) {
  932. if ($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) {
  933. if ($item["resubmit"]) {
  934. $item["checkState"] = "待部门并审(重新提交)";
  935. } else {
  936. $item["checkState"] = "待部门并审(首次提交)";
  937. }
  938. }
  939. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  940. $item["checkState"] = "部门并审通过";
  941. }
  942. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  943. $item["checkState"] = "部门并审驳回";
  944. }
  945. } else {
  946. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  947. if ($process == 3) {
  948. $item["checkState"] = "初审通过(待复审)";
  949. } else {
  950. if ($item["resubmit"]) {
  951. $item["checkState"] = "待复审(重新提交)";
  952. } else {
  953. $item["checkState"] = "待复审(首次提交)";
  954. }
  955. }
  956. }
  957. if ($item["pass_dept_check"] == 0) {
  958. if ($process == 3) {
  959. $item["checkState"] = "初审通过(待部门并审)";
  960. } else {
  961. if ($item["resubmit"]) {
  962. $item["checkState"] = "待部门并审(重新提交)";
  963. } else {
  964. $item["checkState"] = "待部门并审(首次提交)";
  965. }
  966. }
  967. }
  968. }
  969. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  970. if ($process == 3) {
  971. $item["checkState"] = "待初审(部门并审驳回)";
  972. } else {
  973. $item["checkState"] = "部门并审驳回";
  974. }
  975. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  976. if ($process == 3) {
  977. $item["checkState"] = "待复审(部门并审通过)";
  978. } else if ($process == 4) {
  979. $item["checkState"] = "部门并审通过";
  980. } else {
  981. if ($item["resubmit"]) {
  982. $item["checkState"] = "待复审(重新提交)";
  983. } else {
  984. $item["checkState"] = "待复审(首次提交)";
  985. }
  986. }
  987. } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
  988. if ($process == 3) {
  989. $item["checkState"] = "待初审(复审驳回)";
  990. } else {
  991. $item["checkState"] = "复审驳回";
  992. }
  993. } else {
  994. $item["checkState"] = TalentState::getStateName($item["state"]);
  995. }
  996. if ($process == 4) {
  997. if (self::chkUserInSuperDeptUsers()) {
  998. $companys = array_filter(explode(",", $item["companyIds"]));
  999. $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
  1000. $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
  1001. $verifyDepts = [];
  1002. $item["deptReject"] = 0;
  1003. $item["deptPass"] = 0;
  1004. $item["deptWait"] = 0;
  1005. $deptDescriptions = [];
  1006. foreach ($companys as $k => $companyId) {
  1007. $company = getCacheById("Company", $companyId);
  1008. //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  1009. $i = 0;
  1010. while ($log = $deptChecklogs[$i]) {
  1011. if ($log["companyId"] == $companyId) {
  1012. break;
  1013. }
  1014. $i++;
  1015. }
  1016. $item["first_dept_check_time"] = date("Y-m-d H:i:s", $log["createTime"]);
  1017. $verifyDepts[$k] = $company["name"];
  1018. if ($log["active"] == 1) {
  1019. if ($log["new_state"] == 9) {
  1020. $verifyDepts[$k] .= "(审核驳回)";
  1021. $item["deptReject"]++;
  1022. }
  1023. if ($log["new_state"] == 12) {
  1024. $verifyDepts[$k] .= "(审核通过)";
  1025. $item["deptPass"]++;
  1026. }
  1027. $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
  1028. } else {
  1029. $verifyDepts[$k] .= "(待审核)";
  1030. $item["deptWait"]++;
  1031. }
  1032. }
  1033. $item["verifyDepts"] = implode(chr(10), $verifyDepts);
  1034. $item["deptDescription"] = implode(chr(10), $deptDescriptions);
  1035. } else {
  1036. $item["checkMsg"] = $item["active"] == 1 ? $item["checkMsg"] : "等待部门审核";
  1037. }
  1038. }
  1039. }unset($item);
  1040. return $list;
  1041. }
  1042. public static function getListByProcess($process) {
  1043. switch ($process) {
  1044. case 1:
  1045. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  1046. break;
  1047. case 2:
  1048. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  1049. break;
  1050. case 3:
  1051. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  1052. break;
  1053. default:
  1054. return null;
  1055. }
  1056. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  1057. }
  1058. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  1059. $data["id"] = $mainId;
  1060. $data["checkState"] = $state;
  1061. switch ($state) {
  1062. case TalentState::ZX_PASS:
  1063. case TalentState::ZX_FAIL:
  1064. $data["isPublic"] = 2;
  1065. break;
  1066. case TalentState::ANNOUNCED:
  1067. $data["isPublic"] = 3;
  1068. $data["publicBatch"] = $batch;
  1069. break;
  1070. case TalentState::ANNOUNCED_REVERIFY_PASS:
  1071. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  1072. $data["isPublic"] = 3;
  1073. break;
  1074. case TalentState::PUBLISH_PASS:
  1075. $data["isPublic"] = 4;
  1076. $data["identifyMonth"] = $batch;
  1077. $data["certificateGetTime"] = $batch; //时间待定
  1078. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  1079. break;
  1080. case TalentState::PUBLISH_FAIL:
  1081. $data["isPublic"] = 4;
  1082. break;
  1083. }
  1084. if (Talent::update($data)) {
  1085. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  1086. return true;
  1087. }
  1088. return false;
  1089. }
  1090. private static function getSuperPrivsForDeptVerify() {
  1091. $config = getJsonConfig("../sys_config.json", "super_privs_for_dept_verify");
  1092. return $config;
  1093. }
  1094. public static function chkUserInSuperDeptUsers() {
  1095. $config = self::getSuperPrivsForDeptVerify();
  1096. $companyId = session("user")["companyId"];
  1097. $company = getCacheById("Company", $companyId);
  1098. $account = session("user")["account"];
  1099. return in_array($company["code"], $config["companys"]) || in_array($account, $config["users"]);
  1100. }
  1101. }