VerifyApi.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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 md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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 md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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["industry_field_old"]) {
  278. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  279. }
  280. if ($params["enterprise_tag"]) {
  281. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  282. }
  283. if ($params["talent_type"]) {
  284. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  285. }
  286. if ($params["import_way"]) {
  287. $where[] = ["ti.import_way", "=", $params["import_way"]];
  288. }
  289. if ($params["highest_degree"]) {
  290. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  291. }
  292. if ($params["study_abroad"]) {
  293. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  294. }
  295. if ($params["source"]) {
  296. $where[] = ["ti.source", "=", $params["source"]];
  297. }
  298. if ($params["talent_arrange"]) {
  299. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  300. }
  301. if ($params["talent_condition"]) {
  302. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  303. }
  304. if ($params["isMatchZhiren"]) {
  305. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  306. }
  307. $process = $params["process"];
  308. if ($process == 4) {
  309. switch ($params["checkState"]) {
  310. case 5:
  311. $_where = [];
  312. $_where[] = ["type", "=", 1];
  313. $_where[] = ["active", "=", 1];
  314. $_where[] = ["step", "=", 3];
  315. $_where[] = ["companyId", "=", session("user")["companyId"]];
  316. $mainIds = \app\common\model\TalentChecklog::where($_where)->group("mainId")->order("createTime desc")->column("mainId");
  317. if ($mainIds) {
  318. $where[] = ["ti.id", "in", $mainIds];
  319. } else {
  320. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  321. $where[] = ["ti.pass_dept_check", "=", 0];
  322. }
  323. break;
  324. default:
  325. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  326. $where[] = ["ti.pass_dept_check", "=", 0];
  327. break;
  328. }
  329. return self::getDeptList($params, $where);
  330. }
  331. if ($process == 5) {
  332. $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 = ''))");
  333. switch ($params["checkState"]) {
  334. case 1:
  335. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  336. break;
  337. case -1:
  338. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_FAIL];
  339. break;
  340. }
  341. $count = 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 md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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)->where($where)->count();
  347. $list = Talent::alias("ti")
  348. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  349. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  350. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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")
  351. //->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)")
  352. ->whereRaw($whereRaw)
  353. ->where($where)
  354. ->limit($offset, $limit)
  355. ->order("ti.createTime " . $order)
  356. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  357. ->select()->toArray();
  358. } else {
  359. switch ($process) {
  360. case 1:
  361. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  362. break;
  363. case 2:
  364. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  365. break;
  366. case 3:
  367. switch ($params["checkState"]) {
  368. case -1://保存未提交
  369. //$where[] = ["ti.checkState", "=", TalentState::SCND_SAVE];
  370. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  371. $where[] = ["ti.delete", "=", 0];
  372. break;
  373. case 1://待审核
  374. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  375. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  376. break;
  377. case 2://驳回
  378. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  379. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  380. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  381. break;
  382. case 3://通过
  383. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  384. break;
  385. case 4://失败
  386. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  387. break;
  388. case 5://重新提交
  389. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  390. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  391. break;
  392. default:
  393. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  394. //$where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  395. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  396. }
  397. break;
  398. case 6:
  399. $where[] = ["ti.checkState", ">=", TalentState::REVERIFY_PASS];
  400. if ($params["checkState"]) {
  401. $where[] = ["ti.checkState", "=", $params["checkState"]];
  402. }
  403. break;
  404. case 7:
  405. $where[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
  406. break;
  407. }
  408. $count = Talent::alias("ti")
  409. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  410. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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")
  411. //->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")
  412. ->where($where)->count();
  413. $list = Talent::alias("ti")
  414. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  415. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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")
  416. //->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")
  417. ->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();
  418. }
  419. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  420. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  421. foreach ($list as &$item) {
  422. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  423. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  424. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  425. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  426. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  427. //$item["lastState"] = $last_log["last_state"];
  428. //$item["realState"] = $last_log["state"];
  429. }unset($item);
  430. return ["total" => $count, "rows" => $list];
  431. }
  432. public static function getExportDatas($process, $params) {
  433. $where[] = [];
  434. //特殊字段处理
  435. $fields = [];
  436. foreach ($params as $param) {
  437. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  438. $fields[] = "ti." . $param;
  439. }
  440. }
  441. $fields[] = "e.name as enterpriseName";
  442. $fields[] = "e.industryFieldNew";
  443. $fields[] = "e.enterpriseTag";
  444. $fields[] = "e.street";
  445. $fields[] = "tc.talentLevelCat";
  446. $fields[] = "tl.description as checkMsg";
  447. $fields[] = "tc.name as talentConditionName";
  448. $fields[] = "tl.description as checkMsg";
  449. if (in_array("card_type", $params)) {
  450. $cardTypes = DictApi::selectByParentCode("card_type");
  451. }
  452. if (in_array("industryFieldNew", $params)) {
  453. $industry_fields = DictApi::selectByParentCode("industry_field");
  454. }
  455. if (in_array("enterpriseTag", $params)) {
  456. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  457. }
  458. if (in_array("street", $params)) {
  459. $streets = DictApi::selectByParentCode("street");
  460. }
  461. if (in_array("nation", $params)) {
  462. $nations = DictApi::selectByParentCode("nation");
  463. }
  464. if (in_array("nationality", $params)) {
  465. $nationalitys = DictApi::selectByParentCode("nationality");
  466. }
  467. if (in_array("politics", $params)) {
  468. $politics = DictApi::selectByParentCode("politics");
  469. }
  470. if (in_array("talent_type", $params)) {
  471. $talentTypes = DictApi::selectByParentCode("talent_type");
  472. }
  473. if (in_array("talent_arrange_category", $params)) {
  474. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  475. }
  476. if (in_array("highest_degree", $params)) {
  477. $highest_degree = DictApi::selectByParentCode("highest_degree");
  478. }
  479. if (in_array("import_way", $params)) {
  480. $import_way = DictApi::selectByParentCode("import_way");
  481. }
  482. if (in_array("source", $params)) {
  483. $source = DictApi::selectByParentCode("source");
  484. }
  485. if (in_array("source_city", $params)) {
  486. $source_city = DictApi::selectByParentCode("source_city");
  487. }
  488. if (in_array("source_county", $params)) {
  489. $source_county = DictApi::selectByParentCode("source_county");
  490. }
  491. if (in_array("talent_arrange", $params)) {
  492. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  493. }
  494. $sex = [1 => "男", 2 => "女"];
  495. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  496. $study_abroad = [1 => "是", 2 => "否"];
  497. $where = [];
  498. $where[] = ["e.type", "=", session("user")["type"]];
  499. switch ($process) {
  500. case 1:
  501. $where = "ti.checkState in (" . TalentState::FST_SUBMIT . "," . TalentState::BASE_VERIFY_FAIL . ")";
  502. break;
  503. case 2:
  504. $where = "ti.checkState in (" . TalentState::BASE_VERIFY_PASS . "," . TalentState::BASE_REVERIFY_FAIL . ")";
  505. break;
  506. case 3:
  507. $where = "ti.checkState in (" . TalentState::SCND_SUBMIT . "," . TalentState::FST_VERIFY_FAIL . ")";
  508. break;
  509. case 4:
  510. $companyId = session("user")["companyId"];
  511. $where = "ti.checkState = " . TalentState::FST_VERIFY_PASS . " and ti.pass_dept_check=0 and find_in_set({$companyId},tc.companyIds)";
  512. break;
  513. case 5:
  514. $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);
  515. break;
  516. case 6:
  517. $where = "ti.checkState >= " . TalentState::REVERIFY_PASS;
  518. break;
  519. case 7:
  520. $where = "ti.checkState = " . TalentState::CERTIFICATED;
  521. break;
  522. }
  523. $list = Talent::alias("ti")
  524. ->field($fields)
  525. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  526. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  527. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) 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")
  528. //->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)")
  529. ->whereRaw($where)
  530. ->select()->toArray();
  531. foreach ($list as &$item) {
  532. $item["card_type"] = $cardTypes[$item["card_type"]];
  533. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  534. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  535. $item["street"] = $streets[$item["street"]];
  536. $item["nation"] = $nations[$item["nation"]];
  537. $item["nationality"] = $nationalitys[$item["nationality"]];
  538. $item["politics"] = $politics[$item["politics"]];
  539. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  540. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  541. $item["sex"] = $sex[$item["sex"]];
  542. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  543. $item["import_way"] = $import_way[$item["import_way"]];
  544. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  545. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  546. $item["source"] = $source[$item["source"]];
  547. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  548. $item["talent_condition"] = $item["talentConditionName"];
  549. if (in_array("source_city", $params)) {
  550. $item["source_city"] = Db::table("un_common_location")->where("code", "=", $item["source_city"])->findOrEmpty()["name"];
  551. }
  552. if (in_array("source_county", $params)) {
  553. $item["source_county"] = Db::table("un_common_location")->where("code", "=", $item["source_county"])->findOrEmpty()["name"];
  554. }
  555. if (in_array("province", $params)) {
  556. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  557. }
  558. if (in_array("city", $params)) {
  559. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  560. }
  561. if (in_array("county", $params)) {
  562. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  563. }
  564. $item["checkState"] = TalentState::getStateName($item["checkState"]);
  565. }unset($item);
  566. return $list;
  567. }
  568. public static function getListByProcess($process) {
  569. switch ($process) {
  570. case 1:
  571. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  572. break;
  573. case 2:
  574. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  575. break;
  576. case 3:
  577. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  578. break;
  579. default:
  580. return null;
  581. }
  582. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  583. }
  584. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  585. $data["id"] = $mainId;
  586. $data["checkState"] = $state;
  587. switch ($state) {
  588. case TalentState::ZX_PASS:
  589. case TalentState::ZX_FAIL:
  590. $data["isPublic"] = 2;
  591. break;
  592. case TalentState::ANNOUNCED:
  593. $data["isPublic"] = 3;
  594. $data["publicBatch"] = $batch;
  595. break;
  596. case TalentState::ANNOUNCED_REVERIFY_PASS:
  597. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  598. $data["isPublic"] = 3;
  599. break;
  600. case TalentState::PUBLISH_PASS:
  601. $data["isPublic"] = 4;
  602. $data["identifyMonth"] = $batch;
  603. $data["certificateGetTime"] = $batch; //时间待定
  604. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years", $batch))); //时间待定
  605. break;
  606. case TalentState::PUBLISH_FAIL:
  607. $data["isPublic"] = 4;
  608. break;
  609. }
  610. if (Talent::update($data)) {
  611. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  612. return true;
  613. }
  614. return false;
  615. }
  616. }