VerifyApi.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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["enterpriseTag"] = $enterprise["enterpriseTag"];
  46. if ($enterprise["street"]) {
  47. $info["street"] = $enterprise["street"];
  48. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  49. }
  50. if ($enterprise["industryFieldNew"]) {
  51. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  52. }
  53. if ($enterprise["enterpriseTag"]) {
  54. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  55. }
  56. if ($info["talent_arrange"]) {
  57. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  58. }
  59. if ($info["import_way"]) {
  60. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  61. }
  62. if ($info["source"]) {
  63. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  64. }
  65. if ($info["source_city"]) {
  66. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  67. }
  68. if ($info["source_county"]) {
  69. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  70. }
  71. if ($info["highest_degree"]) {
  72. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  73. }
  74. if ($info["qz_talent_info"]) {
  75. $qz_talent_info = explode(";", $info["qz_talent_info"]);
  76. list($tmp1, $timeStart) = explode(":", $qz_talent_info[1]);
  77. list($tmp2, $timeEnd) = explode(":", $qz_talent_info[2]);
  78. if (strtotime($timeStart)) {
  79. $tmp_time = date("Y-m-d", strtotime($timeStart));
  80. $qz_talent_info[1] = implode(":", [$tmp1, $tmp_time]);
  81. if ($isAdmin) {
  82. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  83. if ($batch_info) {
  84. $qz_talent_info[1] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $qz_talent_info[1] . "</a>";
  85. }
  86. }
  87. }
  88. if (strtotime($timeEnd)) {
  89. $qz_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($timeEnd))]);
  90. }
  91. $info["qz_talent_info"] = implode(";", $qz_talent_info);
  92. }
  93. if ($info["fj_talent_info"]) {
  94. $fj_talent_info = explode(";", $info["fj_talent_info"]);
  95. list($tmp1, $timeStart) = explode(":", $fj_talent_info[0]);
  96. list($tmp2, $validYear) = explode(":", $fj_talent_info[2]);
  97. $timeStart = str_replace(["."], "-", $timeStart);
  98. if (strtotime($timeStart)) {
  99. $tmp_time = date("Y-m-d", strtotime($timeStart));
  100. $fj_talent_info[0] = implode(":", [$tmp1, $tmp_time]);
  101. if ($isAdmin) {
  102. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  103. if ($batch_info) {
  104. $fj_talent_info[0] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $fj_talent_info[0] . "</a>";
  105. }
  106. }
  107. if (strtotime($validYear)) {
  108. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($validYear))]);
  109. } else {
  110. $validval = intval($validYear);
  111. if ($validYear > 0) {
  112. $timestr = str_replace($validval, "", $validYear);
  113. switch ($timestr) {
  114. case "月":
  115. $timetype = "months";
  116. break;
  117. case "日":
  118. $timetype = "days";
  119. break;
  120. default:
  121. $timetype = "years";
  122. break;
  123. }
  124. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime("+{$validval} {$timetype}", strtotime($timeStart)))]);
  125. }
  126. }
  127. }
  128. $info["fj_talent_info"] = implode(";", $fj_talent_info);
  129. }
  130. if ($info["talent_condition"]) {
  131. $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
  132. $info["talentConditionName"] = $talent_condition["name"];
  133. $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
  134. $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
  135. }
  136. }
  137. return $info;
  138. }
  139. public static function getOne($id) {
  140. return Talent::findOrEmpty($id);
  141. }
  142. public static function getDeptList($params, $where = []) {
  143. $order = $params["order"] ?: "desc";
  144. $offset = $params["offset"] ?: 0;
  145. $limit = $params["limit"] ?: 10;
  146. $companyId = session("user")["companyId"];
  147. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  148. $count = Talent::alias("ti")
  149. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  150. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  151. ->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)")
  152. ->where($where)
  153. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  154. $list = Talent::alias("ti")
  155. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  156. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  157. ->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)")
  158. ->where($where)
  159. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  160. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  161. ->limit($offset, $limit)->order("ti.createTime " . $order)
  162. ->select()->toArray();
  163. foreach ($list as &$item) {
  164. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  165. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  166. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  167. $item["deptCheckState"] = $lastCheckLog["new_state"];
  168. }unset($item);
  169. return ["total" => $count, "rows" => $list];
  170. }
  171. public static function getPublicList($params) {
  172. $order = $params["order"];
  173. $offset = $params["offset"];
  174. $limit = $params["limit"];
  175. $where = [];
  176. $where[] = ["e.type", "=", session("user")["type"]];
  177. if ($params["name"]) {
  178. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  179. }
  180. if ($params["sex"]) {
  181. $where[] = ["ti.sex", "=", $params["sex"]];
  182. }
  183. if ($params["checkState"]) {
  184. $where[] = ["ti.checkState", "=", $params["checkState"]];
  185. }
  186. $type = $params["type"];
  187. switch ($type) {
  188. case 1:
  189. case 2:
  190. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  191. break;
  192. case 3: //公示
  193. case 7: //公示预览
  194. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  195. break;
  196. case 4: //公示通过
  197. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  198. break;
  199. case 5:
  200. case 8: //公布预览
  201. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  202. break;
  203. case 6:
  204. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  205. break;
  206. }
  207. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  208. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  209. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  210. ->where($where)
  211. ->limit($offset, $limit)
  212. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  213. foreach ($list as &$item) {
  214. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  215. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  216. }unset($item);
  217. return ["total" => $count, "rows" => $list];
  218. }
  219. public static function getListByIds($ids) {
  220. $where[] = ["id", "in", $ids];
  221. return Talent::where($where)->select()->toArray();
  222. }
  223. public static function getList($params) {
  224. $where = [];
  225. $order = $params["order"] ?: "desc";
  226. $offset = $params["offset"] ?: 0;
  227. $limit = $params["limit"] ?: 10;
  228. unset($params["order"]);
  229. unset($params["limit"]);
  230. unset($params["offset"]);
  231. $where[] = ["e.type", "=", session("user")["type"]];
  232. if ($params["name"]) {
  233. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  234. }
  235. if ($params["card_number"]) {
  236. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  237. }
  238. if ($params["sex"]) {
  239. $where[] = ["ti.sex", "=", $params["sex"]];
  240. }
  241. if ($params["nation"]) {
  242. $where[] = ["ti.nation", "=", $params["nation"]];
  243. }
  244. if ($params["apply_year"]) {
  245. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  246. }
  247. if ($params["phone"]) {
  248. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  249. }
  250. if ($params["email"]) {
  251. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  252. }
  253. if ($params["nationality"]) {
  254. $where[] = ["ti.nationality", "=", $params["nationality"]];
  255. }
  256. if ($params["province"]) {
  257. $where[] = ["ti.province", "=", $params["province"]];
  258. }
  259. if ($params["politics"]) {
  260. $where[] = ["ti.politics", "=", $params["politics"]];
  261. }
  262. if ($params["enterprise_id"]) {
  263. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  264. }
  265. if ($params["street"]) {
  266. $where[] = ["e.street", "=", $params["street"]];
  267. }
  268. if ($params["industry_field"]) {
  269. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  270. }
  271. if ($params["talent_type"]) {
  272. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  273. }
  274. if ($params["import_way"]) {
  275. $where[] = ["ti.import_way", "=", $params["import_way"]];
  276. }
  277. if ($params["highest_degree"]) {
  278. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  279. }
  280. if ($params["study_abroad"]) {
  281. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  282. }
  283. if ($params["source"]) {
  284. $where[] = ["ti.source", "=", $params["source"]];
  285. }
  286. if ($params["talent_arrange"]) {
  287. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  288. }
  289. $process = $params["process"];
  290. if ($process == 4) {
  291. switch ($params["checkState"]) {
  292. case 5:
  293. $_where = [];
  294. $_where[] = ["type", "=", 1];
  295. $_where[] = ["active", "=", 1];
  296. $_where[] = ["step", "=", 3];
  297. $_where[] = ["companyId", "=", session("user")["companyId"]];
  298. $mainIds = \app\common\model\TalentChecklog::where($_where)->group("mainId")->order("createTime desc")->column("mainId");
  299. if ($mainIds) {
  300. $where[] = ["ti.id", "in", $mainIds];
  301. } else {
  302. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  303. $where[] = ["ti.pass_dept_check", "=", 0];
  304. }
  305. break;
  306. default:
  307. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  308. $where[] = ["ti.pass_dept_check", "=", 0];
  309. break;
  310. }
  311. return self::getDeptList($params, $where);
  312. }
  313. if ($process == 5) {
  314. $whereRaw = sprintf("(ti.checkState in (14,15,16)) or (ti.checkState=12 and ti.pass_dept_check=0) or (ti.checkState=10 and ti.pass_dept_check=1) or (ti.checkState=10 and (tc.companyIds is null or tc.companyIds = ''))");
  315. switch ($params["checkState"]) {
  316. case 1:
  317. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  318. break;
  319. case -1:
  320. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_FAIL];
  321. break;
  322. }
  323. $count = Talent::alias("ti")
  324. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  325. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  326. ->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)")
  327. ->whereRaw($whereRaw)->where($where)->count();
  328. $list = Talent::alias("ti")
  329. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  330. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  331. ->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)")
  332. ->whereRaw($whereRaw)
  333. ->where($where)
  334. ->limit($offset, $limit)
  335. ->order("ti.createTime " . $order)
  336. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  337. ->select()->toArray();
  338. } else {
  339. switch ($process) {
  340. case 1:
  341. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  342. break;
  343. case 2:
  344. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  345. break;
  346. case 3:
  347. switch ($params["checkState"]) {
  348. case 1://待审核
  349. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  350. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  351. break;
  352. case 2://驳回
  353. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  354. $where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  355. $where[] = ["tl.state", "in", [TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  356. break;
  357. default:
  358. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  359. $where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  360. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  361. }
  362. break;
  363. case 6:
  364. $where[] = ["ti.checkState", ">=", TalentState::REVERIFY_PASS];
  365. if ($params["checkState"]) {
  366. $where[] = ["ti.checkState", "=", $params["checkState"]];
  367. }
  368. break;
  369. }
  370. $count = Talent::alias("ti")
  371. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  372. ->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)")
  373. ->where($where)->count();
  374. $list = Talent::alias("ti")
  375. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  376. ->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)")
  377. ->where($where)->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();
  378. }
  379. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  380. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  381. foreach ($list as &$item) {
  382. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  383. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  384. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  385. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  386. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  387. //$item["lastState"] = $last_log["last_state"];
  388. //$item["realState"] = $last_log["state"];
  389. }unset($item);
  390. return ["total" => $count, "rows" => $list];
  391. }
  392. public static function getExportDatas($process, $params) {
  393. $where[] = [];
  394. //特殊字段处理
  395. $fields = [];
  396. foreach ($params as $param) {
  397. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  398. $fields[] = "ti." . $param;
  399. }
  400. }
  401. $fields[] = "e.name as enterpriseName";
  402. $fields[] = "e.industryFieldNew";
  403. $fields[] = "e.enterpriseTag";
  404. $fields[] = "e.street";
  405. $fields[] = "tc.talentLevelCat";
  406. $fields[] = "tl.description as checkMsg";
  407. $fields[] = "tc.name as talentConditionName";
  408. $fields[] = "tl.description as checkMsg";
  409. if (in_array("card_type", $params)) {
  410. $cardTypes = DictApi::selectByParentCode("card_type");
  411. }
  412. if (in_array("industryFieldNew", $params)) {
  413. $industry_fields = DictApi::selectByParentCode("industry_field");
  414. }
  415. if (in_array("enterpriseTag", $params)) {
  416. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  417. }
  418. if (in_array("street", $params)) {
  419. $streets = DictApi::selectByParentCode("street");
  420. }
  421. if (in_array("nation", $params)) {
  422. $nations = DictApi::selectByParentCode("nation");
  423. }
  424. if (in_array("nationality", $params)) {
  425. $nationalitys = DictApi::selectByParentCode("nationality");
  426. }
  427. if (in_array("politics", $params)) {
  428. $politics = DictApi::selectByParentCode("politics");
  429. }
  430. if (in_array("talent_type", $params)) {
  431. $talentTypes = DictApi::selectByParentCode("talent_type");
  432. }
  433. if (in_array("talent_arrange_category", $params)) {
  434. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  435. }
  436. if (in_array("highest_degree", $params)) {
  437. $highest_degree = DictApi::selectByParentCode("highest_degree");
  438. }
  439. if (in_array("import_way", $params)) {
  440. $import_way = DictApi::selectByParentCode("import_way");
  441. }
  442. if (in_array("source", $params)) {
  443. $source = DictApi::selectByParentCode("source");
  444. }
  445. if (in_array("source_city", $params)) {
  446. $source_city = DictApi::selectByParentCode("source_city");
  447. }
  448. if (in_array("source_county", $params)) {
  449. $source_county = DictApi::selectByParentCode("source_county");
  450. }
  451. if (in_array("talent_arrange", $params)) {
  452. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  453. }
  454. $sex = [1 => "男", 2 => "女"];
  455. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  456. $study_abroad = [1 => "是", 2 => "否"];
  457. $where = [];
  458. $where[] = ["e.type", "=", session("user")["type"]];
  459. switch ($process) {
  460. case 1:
  461. $where = "ti.checkState in (" . TalentState::FST_SUBMIT . "," . TalentState::BASE_VERIFY_FAIL . ")";
  462. break;
  463. case 2:
  464. $where = "ti.checkState in (" . TalentState::BASE_VERIFY_PASS . "," . TalentState::BASE_REVERIFY_FAIL . ")";
  465. break;
  466. case 3:
  467. $where = "ti.checkState in (" . TalentState::SCND_SUBMIT . "," . TalentState::FST_VERIFY_FAIL . ")";
  468. break;
  469. case 4:
  470. $companyId = session("user")["companyId"];
  471. $where = "ti.checkState = " . TalentState::FST_VERIFY_PASS . " and ti.pass_dept_check=0 and find_in_set({$companyId},tc.companyIds)";
  472. break;
  473. case 5:
  474. $where = sprintf("(ti.checkState in (%d,%d,%d)) or (ti.checkState=%d and ti.pass_dept_check=0) or (ti.checkState=%d and ti.pass_dept_check=1) or (ti.checkState=%d and (tc.companyIds is null or tc.companyIds = ''))", TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL, TalentState::DEPT_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
  475. break;
  476. case 6:
  477. $where = "ti.checkState >= " . TalentState::REVERIFY_PASS;
  478. break;
  479. }
  480. $list = Talent::alias("ti")
  481. ->field($fields)
  482. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  483. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  484. ->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)")
  485. ->whereRaw($where)
  486. ->select()->toArray();
  487. foreach ($list as &$item) {
  488. $item["card_type"] = $cardTypes[$item["card_type"]];
  489. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  490. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  491. $item["street"] = $streets[$item["street"]];
  492. $item["nation"] = $nations[$item["nation"]];
  493. $item["nationality"] = $nationalitys[$item["nationality"]];
  494. $item["politics"] = $politics[$item["politics"]];
  495. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  496. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  497. $item["sex"] = $sex[$item["sex"]];
  498. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  499. $item["import_way"] = $import_way[$item["import_way"]];
  500. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  501. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  502. $item["source"] = $source[$item["source"]];
  503. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  504. $item["talent_condition"] = $item["talentConditionName"];
  505. if (in_array("source_city", $params)) {
  506. $item["source_city"] = Db::table("un_common_location")->where("code", "=", $item["source_city"])->findOrEmpty()["name"];
  507. }
  508. if (in_array("source_county", $params)) {
  509. $item["source_county"] = Db::table("un_common_location")->where("code", "=", $item["source_county"])->findOrEmpty()["name"];
  510. }
  511. if (in_array("province", $params)) {
  512. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  513. }
  514. if (in_array("city", $params)) {
  515. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  516. }
  517. if (in_array("county", $params)) {
  518. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  519. }
  520. $item["checkState"] = TalentState::getStateName($item["checkState"]);
  521. }unset($item);
  522. return $list;
  523. }
  524. public static function getListByProcess($process) {
  525. switch ($process) {
  526. case 1:
  527. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  528. break;
  529. case 2:
  530. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  531. break;
  532. case 3:
  533. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  534. break;
  535. default:
  536. return null;
  537. }
  538. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  539. }
  540. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  541. $data["id"] = $mainId;
  542. $data["checkState"] = $state;
  543. switch ($state) {
  544. case TalentState::ZX_PASS:
  545. case TalentState::ZX_FAIL:
  546. $data["isPublic"] = 2;
  547. break;
  548. case TalentState::ANNOUNCED:
  549. $data["isPublic"] = 3;
  550. $data["publicBatch"] = $batch;
  551. break;
  552. case TalentState::ANNOUNCED_REVERIFY_PASS:
  553. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  554. $data["isPublic"] = 3;
  555. break;
  556. case TalentState::PUBLISH_PASS:
  557. $data["isPublic"] = 4;
  558. $data["certificateGetTime"] = $batch;
  559. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years", $batch)));
  560. break;
  561. case TalentState::PUBLISH_FAIL:
  562. $data["isPublic"] = 4;
  563. break;
  564. }
  565. if (Talent::update($data)) {
  566. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  567. return true;
  568. }
  569. return false;
  570. }
  571. }