VerifyApi.php 29 KB

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