VerifyApi.php 34 KB

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