VerifyApi.php 33 KB

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