VerifyApi.php 33 KB

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