VerifyApi.php 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  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} -1 days", 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 getFullDeptList($params, $where = []) {
  147. $order = $params["order"] ?: "desc";
  148. $offset = $params["offset"] ?: 0;
  149. $limit = $params["limit"] ?: 10;
  150. $whereRaw = "";
  151. switch ($params["checkState"]) {
  152. case 1:
  153. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  154. $where[] = ["ti.pass_dept_check", "=", 0];
  155. break;
  156. case 2:
  157. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  158. break;
  159. case 3:
  160. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  161. break;
  162. default:
  163. $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
  164. break;
  165. }
  166. $companyId = session("user")["companyId"];
  167. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  168. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  169. $count = Talent::alias("ti")
  170. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  171. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  172. ->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")
  173. ->where($where)
  174. ->where($whereRaw)->count();
  175. $list = Talent::alias("ti")
  176. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  177. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  178. ->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")
  179. ->where($where)
  180. ->where($whereRaw)
  181. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tc.name as talentConditionName")
  182. ->limit($offset, $limit)->order("ti.createTime " . $order)
  183. ->select()->toArray();
  184. foreach ($list as &$item) {
  185. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  186. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  187. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  188. }unset($item);
  189. return ["total" => $count, "rows" => $list];
  190. }
  191. public static function getDeptList($params, $where = []) {
  192. $order = $params["order"] ?: "desc";
  193. $offset = $params["offset"] ?: 0;
  194. $limit = $params["limit"] ?: 10;
  195. $companyId = session("user")["companyId"];
  196. switch ($params["checkState"]) {
  197. case 1:
  198. //待审核
  199. $where[] = ["tl.active", "=", 0];
  200. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  201. break;
  202. case 2:
  203. //已驳回
  204. $where[] = ["tl.active", "=", 1];
  205. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  206. break;
  207. case 3:
  208. //已通过
  209. $where[] = ["tl.active", "=", 1];
  210. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  211. break;
  212. default:
  213. $where = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  214. break;
  215. }
  216. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  217. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  218. $count = Talent::alias("ti")
  219. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  220. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  221. ->leftJoin("(select mainId,active,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`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  222. ->where($where)
  223. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  224. $list = Talent::alias("ti")
  225. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  226. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  227. ->leftJoin("(select mainId,active,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`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  228. ->where($where)
  229. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  230. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tc.name as talentConditionName")
  231. ->limit($offset, $limit)->order("ti.createTime " . $order)
  232. ->select()->toArray();
  233. foreach ($list as &$item) {
  234. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  235. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  236. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  237. $item["deptCheckState"] = $lastCheckLog["new_state"];
  238. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  239. }unset($item);
  240. return ["total" => $count, "rows" => $list];
  241. }
  242. public static function getPublicList($params) {
  243. $order = $params["order"];
  244. $offset = $params["offset"];
  245. $limit = $params["limit"];
  246. $where = [];
  247. $where[] = ["e.type", "=", session("user")["type"]];
  248. if ($params["name"]) {
  249. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  250. }
  251. if ($params["sex"]) {
  252. $where[] = ["ti.sex", "=", $params["sex"]];
  253. }
  254. if ($params["checkState"]) {
  255. $where[] = ["ti.checkState", "=", $params["checkState"]];
  256. }
  257. $type = $params["type"];
  258. switch ($type) {
  259. case 1:
  260. case 2:
  261. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  262. break;
  263. case 3: //公示
  264. case 7: //公示预览
  265. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  266. break;
  267. case 4: //公示通过
  268. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  269. break;
  270. case 5:
  271. case 8: //公布预览
  272. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  273. break;
  274. case 6:
  275. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  276. break;
  277. }
  278. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  279. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  280. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  281. ->where($where)
  282. ->limit($offset, $limit)
  283. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  284. foreach ($list as &$item) {
  285. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  286. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  287. }unset($item);
  288. return ["total" => $count, "rows" => $list];
  289. }
  290. public static function getListByIds($ids) {
  291. $where[] = ["id", "in", $ids];
  292. return Talent::where($where)->select()->toArray();
  293. }
  294. public static function getList($params) {
  295. $where = [];
  296. $order = $params["order"] ?: "desc";
  297. $offset = $params["offset"] ?: 0;
  298. $limit = $params["limit"] ?: 10;
  299. $where[] = ["e.type", "=", session("user")["type"]];
  300. if ($params["name"]) {
  301. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  302. }
  303. if ($params["card_number"]) {
  304. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  305. }
  306. if ($params["sex"]) {
  307. $where[] = ["ti.sex", "=", $params["sex"]];
  308. }
  309. if ($params["nation"]) {
  310. $where[] = ["ti.nation", "=", $params["nation"]];
  311. }
  312. if ($params["apply_year"]) {
  313. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  314. }
  315. if ($params["phone"]) {
  316. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  317. }
  318. if ($params["email"]) {
  319. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  320. }
  321. if ($params["nationality"]) {
  322. $where[] = ["ti.nationality", "=", $params["nationality"]];
  323. }
  324. if ($params["province"]) {
  325. $where[] = ["ti.province", "=", $params["province"]];
  326. }
  327. if ($params["politics"]) {
  328. $where[] = ["ti.politics", "=", $params["politics"]];
  329. }
  330. if ($params["enterprise_id"]) {
  331. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  332. }
  333. if ($params["street"]) {
  334. $where[] = ["e.street", "=", $params["street"]];
  335. }
  336. if ($params["industry_field"]) {
  337. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  338. }
  339. if ($params["industry_field_old"]) {
  340. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  341. }
  342. if ($params["enterprise_tag"]) {
  343. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  344. }
  345. if ($params["talent_type"]) {
  346. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  347. }
  348. if ($params["import_way"]) {
  349. $where[] = ["ti.import_way", "=", $params["import_way"]];
  350. }
  351. if ($params["highest_degree"]) {
  352. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  353. }
  354. if ($params["study_abroad"]) {
  355. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  356. }
  357. if ($params["source"]) {
  358. $where[] = ["ti.source", "=", $params["source"]];
  359. }
  360. if ($params["talent_arrange"]) {
  361. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  362. }
  363. if ($params["talent_condition"]) {
  364. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  365. }
  366. if ($params["isMatchZhiren"]) {
  367. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  368. }
  369. $process = $params["process"];
  370. if ($process == 4) {
  371. $companyId = session('user')['companyId'];
  372. $company_info = CompanyApi::getOne($companyId);
  373. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  374. return self::getFullDeptList($params, $where);
  375. } else {
  376. return self::getDeptList($params, $where);
  377. }
  378. }
  379. if ($process == 5) {
  380. $whereRaw = sprintf("(tl.state in (14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  381. switch ($params["checkState"]) {
  382. case 1:
  383. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  384. break;
  385. case -1:
  386. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  387. break;
  388. }
  389. $count = Talent::alias("ti")
  390. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  391. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  392. ->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")
  393. //->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)")
  394. ->whereRaw($whereRaw)->where($where)->count();
  395. $list = Talent::alias("ti")
  396. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  397. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  398. ->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")
  399. //->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)")
  400. ->whereRaw($whereRaw)
  401. ->where($where)
  402. ->limit($offset, $limit)
  403. ->order("ti.createTime " . $order)
  404. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  405. ->select()->toArray();
  406. } else {
  407. switch ($process) {
  408. case 1:
  409. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  410. break;
  411. case 2:
  412. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  413. break;
  414. case 3:
  415. switch ($params["checkState"]) {
  416. case -1://保存未提交
  417. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  418. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  419. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  420. $where[] = ["ti.delete", "=", 0];
  421. break;
  422. case 1://待审核
  423. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  424. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  425. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  426. break;
  427. case 2://驳回
  428. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  429. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  430. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  431. break;
  432. case 3://通过
  433. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  434. break;
  435. case 4://失败
  436. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  437. break;
  438. case 5://重新提交
  439. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  440. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  441. break;
  442. default:
  443. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  444. $whereRaw = sprintf("((tl.new_state=%d and ti.`delete`=0) or tl.new_state=%d or tl.state in (%d,%d))", TalentState::SCND_SAVE, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL);
  445. }
  446. break;
  447. case 6:
  448. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  449. if ($params["checkState"]) {
  450. $where[] = ["tl.state", "=", $params["checkState"]];
  451. }
  452. break;
  453. case 7:
  454. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  455. break;
  456. }
  457. $count = Talent::alias("ti")
  458. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  459. ->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")
  460. //->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")
  461. ->where($where)->where($whereRaw)->count();
  462. $list = Talent::alias("ti")
  463. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  464. ->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")
  465. //->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")
  466. ->where($where)->where($whereRaw)->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();
  467. }
  468. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  469. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  470. foreach ($list as &$item) {
  471. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  472. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  473. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  474. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  475. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  476. //$item["lastState"] = $last_log["last_state"];
  477. //$item["realState"] = $last_log["state"];
  478. }unset($item);
  479. return ["total" => $count, "rows" => $list];
  480. }
  481. public static function getExportDatas($process, $params) {
  482. $where[] = [];
  483. //特殊字段处理
  484. $exportFields = $params["export"];
  485. $fields = [];
  486. foreach ($exportFields as $field) {
  487. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  488. $fields[] = "ti." . $field;
  489. }
  490. }
  491. $fields[] = "e.name as enterpriseName";
  492. $fields[] = "e.industryFieldNew";
  493. $fields[] = "e.enterpriseTag";
  494. $fields[] = "e.street";
  495. $fields[] = "tc.talentLevelCat";
  496. $fields[] = "tl.description as checkMsg";
  497. $fields[] = "tc.name as talentConditionName";
  498. $fields[] = "tl.description as checkMsg";
  499. if (in_array("card_type", $exportFields)) {
  500. $cardTypes = DictApi::selectByParentCode("card_type");
  501. }
  502. if (in_array("industryFieldNew", $exportFields)) {
  503. $industry_fields = DictApi::selectByParentCode("industry_field");
  504. }
  505. if (in_array("enterpriseTag", $exportFields)) {
  506. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  507. }
  508. if (in_array("street", $exportFields)) {
  509. $streets = DictApi::selectByParentCode("street");
  510. }
  511. if (in_array("nation", $exportFields)) {
  512. $nations = DictApi::selectByParentCode("nation");
  513. }
  514. if (in_array("nationality", $exportFields)) {
  515. $nationalitys = DictApi::selectByParentCode("nationality");
  516. }
  517. if (in_array("politics", $exportFields)) {
  518. $politics = DictApi::selectByParentCode("politics");
  519. }
  520. if (in_array("talent_type", $exportFields)) {
  521. $talentTypes = DictApi::selectByParentCode("talent_type");
  522. }
  523. if (in_array("talent_arrange_category", $exportFields)) {
  524. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  525. }
  526. if (in_array("highest_degree", $exportFields)) {
  527. $highest_degree = DictApi::selectByParentCode("highest_degree");
  528. }
  529. if (in_array("import_way", $exportFields)) {
  530. $import_way = DictApi::selectByParentCode("import_way");
  531. }
  532. if (in_array("source", $exportFields)) {
  533. $source = DictApi::selectByParentCode("source");
  534. }
  535. if (in_array("source_city", $exportFields)) {
  536. $source_city = DictApi::selectByParentCode("source_city");
  537. }
  538. if (in_array("source_county", $exportFields)) {
  539. $source_county = DictApi::selectByParentCode("source_county");
  540. }
  541. if (in_array("talent_arrange", $exportFields)) {
  542. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  543. }
  544. $sex = [1 => "男", 2 => "女"];
  545. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  546. $study_abroad = [1 => "是", 2 => "否"];
  547. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  548. $return = [1 => "是", 2 => "否"];
  549. $isMatchZhiren = [0 => "否", 1 => "是"];
  550. $where = [];
  551. $where[] = ["e.type", "=", session("user")["type"]];
  552. if ($params["all"] != 1) {
  553. if ($params["name"]) {
  554. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  555. }
  556. if ($params["card_number"]) {
  557. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  558. }
  559. if ($params["sex"]) {
  560. $where[] = ["ti.sex", "=", $params["sex"]];
  561. }
  562. if ($params["nation"]) {
  563. $where[] = ["ti.nation", "=", $params["nation"]];
  564. }
  565. if ($params["apply_year"]) {
  566. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  567. }
  568. if ($params["phone"]) {
  569. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  570. }
  571. if ($params["email"]) {
  572. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  573. }
  574. if ($params["nationality"]) {
  575. $where[] = ["ti.nationality", "=", $params["nationality"]];
  576. }
  577. if ($params["province"]) {
  578. $where[] = ["ti.province", "=", $params["province"]];
  579. }
  580. if ($params["politics"]) {
  581. $where[] = ["ti.politics", "=", $params["politics"]];
  582. }
  583. if ($params["enterprise_id"]) {
  584. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  585. }
  586. if ($params["street"]) {
  587. $where[] = ["e.street", "=", $params["street"]];
  588. }
  589. if ($params["industry_field"]) {
  590. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  591. }
  592. if ($params["industry_field_old"]) {
  593. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  594. }
  595. if ($params["enterprise_tag"]) {
  596. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  597. }
  598. if ($params["talent_type"]) {
  599. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  600. }
  601. if ($params["import_way"]) {
  602. $where[] = ["ti.import_way", "=", $params["import_way"]];
  603. }
  604. if ($params["highest_degree"]) {
  605. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  606. }
  607. if ($params["study_abroad"]) {
  608. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  609. }
  610. if ($params["source"]) {
  611. $where[] = ["ti.source", "=", $params["source"]];
  612. }
  613. if ($params["talent_arrange"]) {
  614. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  615. }
  616. if ($params["talent_condition"]) {
  617. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  618. }
  619. if ($params["isMatchZhiren"]) {
  620. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  621. }
  622. switch ($process) {
  623. case 1:
  624. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  625. break;
  626. case 2:
  627. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  628. break;
  629. case 3:
  630. switch ($params["checkState"]) {
  631. case -1://保存未提交
  632. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  633. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  634. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  635. $where[] = ["ti.delete", "=", 0];
  636. break;
  637. case 1://待审核
  638. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  639. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  640. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  641. break;
  642. case 2://驳回
  643. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  644. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  645. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  646. break;
  647. case 3://通过
  648. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  649. break;
  650. case 4://失败
  651. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  652. break;
  653. case 5://重新提交
  654. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  655. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  656. break;
  657. default:
  658. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  659. //$where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  660. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  661. }
  662. break;
  663. case 4:
  664. $companyId = session('user')['companyId'];
  665. $company_info = CompanyApi::getOne($companyId);
  666. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  667. switch ($params["checkState"]) {
  668. case 1:
  669. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  670. $where[] = ["ti.pass_dept_check", "=", 0];
  671. break;
  672. case 2:
  673. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  674. break;
  675. case 3:
  676. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  677. break;
  678. default:
  679. $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
  680. break;
  681. }
  682. } else {
  683. switch ($params["checkState"]) {
  684. case 1:
  685. //待审核
  686. $where[] = ["tl.active", "=", 0];
  687. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  688. break;
  689. case 2:
  690. //已驳回
  691. $where[] = ["tl.active", "=", 1];
  692. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  693. break;
  694. case 3:
  695. //已通过
  696. $where[] = ["tl.active", "=", 1];
  697. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  698. break;
  699. default:
  700. $where = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  701. break;
  702. }
  703. }
  704. break;
  705. case 5:
  706. $whereRaw = sprintf("(tl.state in (14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  707. switch ($params["checkState"]) {
  708. case 1:
  709. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  710. break;
  711. case -1:
  712. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  713. break;
  714. }
  715. break;
  716. case 6:
  717. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  718. if ($params["checkState"]) {
  719. $where[] = ["tl.state", "=", $params["checkState"]];
  720. }
  721. break;
  722. case 7:
  723. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  724. break;
  725. }
  726. } else {
  727. $whereRaw = "tl.state is not null";
  728. $where[] = ["ti.delete", "=", 0];
  729. }
  730. $fields[] = "ti.pass_dept_check";
  731. $fields[] = "tl.state";
  732. $fields[] = "tl.new_state";
  733. $fields[] = "tl.last_state";
  734. $fields[] = "tc.companyIds";
  735. if ($process == 4) {
  736. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  737. $list = Talent::alias("ti")
  738. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  739. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  740. ->leftJoin("(select mainId,description,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")
  741. ->where($where)
  742. ->where($whereRaw)
  743. ->field($fields)
  744. ->select()->toArray();
  745. } else {
  746. $fields[] = "tl.active";
  747. $fields[] = "tl.new_state as deptCheckState";
  748. $list = Talent::alias("ti")
  749. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  750. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  751. ->leftJoin("(select mainId,active,description,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`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  752. ->where($where)
  753. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  754. ->field($fields)
  755. ->select()->toArray();
  756. }
  757. } else if ($process == 5) {
  758. $list = Talent::alias("ti")
  759. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  760. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  761. ->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")
  762. //->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)")
  763. ->whereRaw($whereRaw)
  764. ->where($where)
  765. ->field($fields)
  766. ->select()->toArray();
  767. } else {
  768. $list = Talent::alias("ti")
  769. ->field($fields)
  770. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  771. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  772. ->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")
  773. //->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)")
  774. ->where($where)
  775. ->where($whereRaw)
  776. ->select()->toArray();
  777. }
  778. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  779. foreach ($list as &$item) {
  780. $item["card_type"] = $cardTypes[$item["card_type"]];
  781. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  782. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  783. $item["street"] = $streets[$item["street"]];
  784. $item["nation"] = $nations[$item["nation"]];
  785. $item["nationality"] = $nationalitys[$item["nationality"]];
  786. $item["politics"] = $politics[$item["politics"]];
  787. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  788. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  789. $item["sex"] = $sex[$item["sex"]];
  790. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  791. $item["import_way"] = $import_way[$item["import_way"]];
  792. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  793. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  794. $item["return"] = $return[$item["return"]];
  795. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  796. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  797. $item["source"] = $source[$item["source"]];
  798. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  799. $item["talent_condition"] = $item["talentConditionName"];
  800. if (in_array("source_city", $exportFields)) {
  801. $item["source_city"] = $un_common_location[$item["source_city"]];
  802. }
  803. if (in_array("source_county", $exportFields)) {
  804. $item["source_county"] = $un_common_location[$item["source_county"]];
  805. }
  806. if (in_array("province", $exportFields)) {
  807. $item["province"] = $un_common_location[$item["province"]];
  808. }
  809. if (in_array("city", $exportFields)) {
  810. $item["city"] = $un_common_location[$item["city"]];
  811. }
  812. if (in_array("county", $exportFields)) {
  813. $item["county"] = $un_common_location[$item["county"]];
  814. }
  815. if ($item["state"] == TalentState::SCND_SUBMIT) {
  816. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  817. $item["checkState"] = "待初审(重新提交)";
  818. } else {
  819. $item["checkState"] = "待初审(首次提交)";
  820. }
  821. } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
  822. if ($item["deptCheckState"]) {
  823. if ($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) {
  824. $item["checkState"] = "待部门审核";
  825. }
  826. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  827. $item["checkState"] = "部门审核通过";
  828. }
  829. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  830. $item["checkState"] = "部门审核驳回";
  831. }
  832. } else {
  833. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  834. $item["checkState"] = "待复核(初审通过)";
  835. }
  836. if ($item["pass_dept_check"] == 0) {
  837. $item["checkState"] = "待部门并审";
  838. }
  839. }
  840. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  841. $item["checkState"] = "待初审(部门并审驳回)";
  842. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  843. $item["checkState"] = "待复核(部门并审通过)";
  844. } else {
  845. $item["checkState"] = TalentState::getStateName($item["state"]);
  846. }
  847. }unset($item);
  848. return $list;
  849. }
  850. public static function getListByProcess($process) {
  851. switch ($process) {
  852. case 1:
  853. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  854. break;
  855. case 2:
  856. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  857. break;
  858. case 3:
  859. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  860. break;
  861. default:
  862. return null;
  863. }
  864. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  865. }
  866. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  867. $data["id"] = $mainId;
  868. $data["checkState"] = $state;
  869. switch ($state) {
  870. case TalentState::ZX_PASS:
  871. case TalentState::ZX_FAIL:
  872. $data["isPublic"] = 2;
  873. break;
  874. case TalentState::ANNOUNCED:
  875. $data["isPublic"] = 3;
  876. $data["publicBatch"] = $batch;
  877. break;
  878. case TalentState::ANNOUNCED_REVERIFY_PASS:
  879. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  880. $data["isPublic"] = 3;
  881. break;
  882. case TalentState::PUBLISH_PASS:
  883. $data["isPublic"] = 4;
  884. $data["identifyMonth"] = $batch;
  885. $data["certificateGetTime"] = $batch; //时间待定
  886. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  887. break;
  888. case TalentState::PUBLISH_FAIL:
  889. $data["isPublic"] = 4;
  890. break;
  891. }
  892. if (Talent::update($data)) {
  893. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  894. return true;
  895. }
  896. return false;
  897. }
  898. }