VerifyApi.php 63 KB

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