VerifyApi.php 30 KB

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