VerifyApi.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. if ($params["name"]) {
  177. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  178. }
  179. if ($params["sex"]) {
  180. $where[] = ["ti.sex", "=", $params["sex"]];
  181. }
  182. if ($params["checkState"]) {
  183. $where[] = ["ti.checkState", "=", $params["checkState"]];
  184. }
  185. $type = $params["type"];
  186. switch ($type) {
  187. case 1:
  188. case 2:
  189. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  190. break;
  191. case 3: //公示
  192. case 7: //公示预览
  193. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  194. break;
  195. case 4: //公示通过
  196. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  197. break;
  198. case 5:
  199. case 8: //公布预览
  200. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  201. break;
  202. case 6:
  203. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  204. break;
  205. }
  206. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  207. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  208. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  209. ->where($where)
  210. ->limit($offset, $limit)
  211. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  212. foreach ($list as &$item) {
  213. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  214. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  215. }unset($item);
  216. return ["total" => $count, "rows" => $list];
  217. }
  218. public static function getListByIds($ids) {
  219. $where[] = ["id", "in", $ids];
  220. return Talent::where($where)->select()->toArray();
  221. }
  222. public static function getList($params) {
  223. $where = [];
  224. $order = $params["order"] ?: "desc";
  225. $offset = $params["offset"] ?: 0;
  226. $limit = $params["limit"] ?: 10;
  227. unset($params["order"]);
  228. unset($params["limit"]);
  229. unset($params["offset"]);
  230. if ($params["name"]) {
  231. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  232. }
  233. if ($params["card_number"]) {
  234. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  235. }
  236. if ($params["sex"]) {
  237. $where[] = ["ti.sex", "=", $params["sex"]];
  238. }
  239. if ($params["nation"]) {
  240. $where[] = ["ti.nation", "=", $params["nation"]];
  241. }
  242. if ($params["apply_year"]) {
  243. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  244. }
  245. if ($params["phone"]) {
  246. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  247. }
  248. if ($params["email"]) {
  249. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  250. }
  251. if ($params["nationality"]) {
  252. $where[] = ["ti.nationality", "=", $params["nationality"]];
  253. }
  254. if ($params["province"]) {
  255. $where[] = ["ti.province", "=", $params["province"]];
  256. }
  257. if ($params["politics"]) {
  258. $where[] = ["ti.politics", "=", $params["politics"]];
  259. }
  260. if ($params["enterprise_id"]) {
  261. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  262. }
  263. if ($params["street"]) {
  264. $where[] = ["e.street", "=", $params["street"]];
  265. }
  266. if ($params["industry_field"]) {
  267. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  268. }
  269. if ($params["talent_type"]) {
  270. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  271. }
  272. if ($params["import_way"]) {
  273. $where[] = ["ti.import_way", "=", $params["import_way"]];
  274. }
  275. if ($params["highest_degree"]) {
  276. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  277. }
  278. if ($params["study_abroad"]) {
  279. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  280. }
  281. if ($params["source"]) {
  282. $where[] = ["ti.source", "=", $params["source"]];
  283. }
  284. if ($params["talent_arrange"]) {
  285. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  286. }
  287. $process = $params["process"];
  288. if ($process == 4) {
  289. switch ($params["checkState"]) {
  290. case 5:
  291. $_where = [];
  292. $_where[] = ["type", "=", 1];
  293. $_where[] = ["active", "=", 1];
  294. $_where[] = ["step", "=", 3];
  295. $_where[] = ["companyId", "=", session("user")["companyId"]];
  296. $mainIds = \app\common\model\TalentChecklog::where($_where)->group("mainId")->order("createTime desc")->column("mainId");
  297. if ($mainIds) {
  298. $where[] = ["ti.id", "in", $mainIds];
  299. } else {
  300. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  301. $where[] = ["ti.pass_dept_check", "=", 0];
  302. }
  303. break;
  304. default:
  305. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  306. $where[] = ["ti.pass_dept_check", "=", 0];
  307. break;
  308. }
  309. return self::getDeptList($params, $where);
  310. }
  311. if ($process == 5) {
  312. $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 = ''))");
  313. switch ($params["checkState"]) {
  314. case 1:
  315. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  316. break;
  317. case -1:
  318. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_FAIL];
  319. break;
  320. }
  321. $count = Talent::alias("ti")
  322. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  323. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  324. ->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)")
  325. ->whereRaw($whereRaw)->where($where)->count();
  326. $list = Talent::alias("ti")
  327. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  328. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  329. ->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)")
  330. ->whereRaw($whereRaw)
  331. ->where($where)
  332. ->limit($offset, $limit)
  333. ->order("ti.createTime " . $order)
  334. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  335. ->select()->toArray();
  336. } else {
  337. switch ($process) {
  338. case 1:
  339. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  340. break;
  341. case 2:
  342. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  343. break;
  344. case 3:
  345. switch ($params["checkState"]) {
  346. case 1://待审核
  347. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  348. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  349. break;
  350. case 2://驳回
  351. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  352. $where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  353. $where[] = ["tl.state", "in", [TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  354. break;
  355. default:
  356. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  357. $where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  358. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  359. }
  360. break;
  361. case 6:
  362. $where[] = ["ti.checkState", ">=", TalentState::REVERIFY_PASS];
  363. if ($params["checkState"]) {
  364. $where[] = ["ti.checkState", "=", $params["checkState"]];
  365. }
  366. break;
  367. }
  368. $count = Talent::alias("ti")
  369. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  370. ->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)")
  371. ->where($where)->count();
  372. $list = Talent::alias("ti")
  373. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  374. ->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)")
  375. ->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();
  376. }
  377. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  378. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  379. foreach ($list as &$item) {
  380. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  381. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  382. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  383. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  384. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  385. //$item["lastState"] = $last_log["last_state"];
  386. //$item["realState"] = $last_log["state"];
  387. }unset($item);
  388. return ["total" => $count, "rows" => $list];
  389. }
  390. public static function getExportDatas($process, $params) {
  391. $where[] = [];
  392. //特殊字段处理
  393. $fields = [];
  394. foreach ($params as $param) {
  395. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  396. $fields[] = "ti." . $param;
  397. }
  398. }
  399. $fields[] = "e.name as enterpriseName";
  400. $fields[] = "e.industryFieldNew";
  401. $fields[] = "e.enterpriseTag";
  402. $fields[] = "e.street";
  403. $fields[] = "tc.talentLevelCat";
  404. $fields[] = "tl.description as checkMsg";
  405. $fields[] = "tc.name as talentConditionName";
  406. $fields[] = "tl.description as checkMsg";
  407. if (in_array("card_type", $params)) {
  408. $cardTypes = DictApi::selectByParentCode("card_type");
  409. }
  410. if (in_array("industryFieldNew", $params)) {
  411. $industry_fields = DictApi::selectByParentCode("industry_field");
  412. }
  413. if (in_array("enterpriseTag", $params)) {
  414. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  415. }
  416. if (in_array("street", $params)) {
  417. $streets = DictApi::selectByParentCode("street");
  418. }
  419. if (in_array("nation", $params)) {
  420. $nations = DictApi::selectByParentCode("nation");
  421. }
  422. if (in_array("nationality", $params)) {
  423. $nationalitys = DictApi::selectByParentCode("nationality");
  424. }
  425. if (in_array("politics", $params)) {
  426. $politics = DictApi::selectByParentCode("politics");
  427. }
  428. if (in_array("talent_type", $params)) {
  429. $talentTypes = DictApi::selectByParentCode("talent_type");
  430. }
  431. if (in_array("talent_arrange_category", $params)) {
  432. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  433. }
  434. if (in_array("highest_degree", $params)) {
  435. $highest_degree = DictApi::selectByParentCode("highest_degree");
  436. }
  437. if (in_array("import_way", $params)) {
  438. $import_way = DictApi::selectByParentCode("import_way");
  439. }
  440. if (in_array("source", $params)) {
  441. $source = DictApi::selectByParentCode("source");
  442. }
  443. if (in_array("source_city", $params)) {
  444. $source_city = DictApi::selectByParentCode("source_city");
  445. }
  446. if (in_array("source_county", $params)) {
  447. $source_county = DictApi::selectByParentCode("source_county");
  448. }
  449. if (in_array("talent_arrange", $params)) {
  450. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  451. }
  452. $sex = [1 => "男", 2 => "女"];
  453. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  454. $study_abroad = [1 => "是", 2 => "否"];
  455. $where = [];
  456. switch ($process) {
  457. case 1:
  458. $where = "ti.checkState in (" . TalentState::FST_SUBMIT . "," . TalentState::BASE_VERIFY_FAIL . ")";
  459. break;
  460. case 2:
  461. $where = "ti.checkState in (" . TalentState::BASE_VERIFY_PASS . "," . TalentState::BASE_REVERIFY_FAIL . ")";
  462. break;
  463. case 3:
  464. $where = "ti.checkState in (" . TalentState::SCND_SUBMIT . "," . TalentState::FST_VERIFY_FAIL . ")";
  465. break;
  466. case 4:
  467. $companyId = session("user")["companyId"];
  468. $where = "ti.checkState = " . TalentState::FST_VERIFY_PASS . " and ti.pass_dept_check=0 and find_in_set({$companyId},tc.companyIds)";
  469. break;
  470. case 5:
  471. $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);
  472. break;
  473. case 6:
  474. $where = "ti.checkState >= " . TalentState::REVERIFY_PASS;
  475. break;
  476. }
  477. $list = Talent::alias("ti")
  478. ->field($fields)
  479. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  480. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  481. ->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)")
  482. ->whereRaw($where)
  483. ->select()->toArray();
  484. foreach ($list as &$item) {
  485. $item["card_type"] = $cardTypes[$item["card_type"]];
  486. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  487. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  488. $item["street"] = $streets[$item["street"]];
  489. $item["nation"] = $nations[$item["nation"]];
  490. $item["nationality"] = $nationalitys[$item["nationality"]];
  491. $item["politics"] = $politics[$item["politics"]];
  492. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  493. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  494. $item["sex"] = $sex[$item["sex"]];
  495. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  496. $item["import_way"] = $import_way[$item["import_way"]];
  497. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  498. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  499. $item["source"] = $source[$item["source"]];
  500. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  501. $item["talent_condition"] = $item["talentConditionName"];
  502. if (in_array("source_city", $params)) {
  503. $item["source_city"] = Db::table("un_common_location")->where("code", "=", $item["source_city"])->findOrEmpty()["name"];
  504. }
  505. if (in_array("source_county", $params)) {
  506. $item["source_county"] = Db::table("un_common_location")->where("code", "=", $item["source_county"])->findOrEmpty()["name"];
  507. }
  508. if (in_array("province", $params)) {
  509. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  510. }
  511. if (in_array("city", $params)) {
  512. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  513. }
  514. if (in_array("county", $params)) {
  515. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  516. }
  517. $item["checkState"] = TalentState::getStateName($item["checkState"]);
  518. }unset($item);
  519. return $list;
  520. }
  521. public static function getListByProcess($process) {
  522. switch ($process) {
  523. case 1:
  524. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  525. break;
  526. case 2:
  527. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  528. break;
  529. case 3:
  530. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  531. break;
  532. default:
  533. return null;
  534. }
  535. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  536. }
  537. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  538. $data["id"] = $mainId;
  539. $data["checkState"] = $state;
  540. switch ($state) {
  541. case TalentState::ZX_PASS:
  542. case TalentState::ZX_FAIL:
  543. $data["isPublic"] = 2;
  544. break;
  545. case TalentState::ANNOUNCED:
  546. $data["isPublic"] = 3;
  547. $data["publicBatch"] = $batch;
  548. break;
  549. case TalentState::ANNOUNCED_REVERIFY_PASS:
  550. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  551. $data["isPublic"] = 3;
  552. break;
  553. case TalentState::PUBLISH_PASS:
  554. $data["isPublic"] = 4;
  555. $data["certificateGetTime"] = $batch;
  556. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years", $batch)));
  557. break;
  558. case TalentState::PUBLISH_FAIL:
  559. $data["isPublic"] = 4;
  560. break;
  561. }
  562. if (Talent::update($data)) {
  563. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  564. return true;
  565. }
  566. return false;
  567. }
  568. }